Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Skipping a single invoice list creation in a background job

Former Member
0 Kudos

Hi Team,

I have a requirement, where in i need to validate the invoices based on amount, before an Invoice list is created.


If i am giving 10 invoices in the selection screen out of which 4 invoice lists will be created based on splits. If any set of Invoices fails the validation, that invoice list has to be skipped for Invoice list creation and rest should get processed.i.e 3 invoice lists should get created and one should be skipped with a message in log.

Description in detail:

Inv1

Inv2

Inv3

Total amount is greater than 100$, InvoiceList should be created

Inv4

Inv5

Total amount is less than 100$, InvoiceList should not be created

Inv6

Inv7

Total amount is greater than 100$, InvoiceList should be created

Inv8

Inv9

Inv10

Total amount is greater than 100$, InvoiceList should be created

Note: I have tried this by raising Warning message, but it is not stopping the IL creation. When i use Error message, whole job is being abended. Pointers are highly appreciated and helpful.

Could you please suggest how to achieve this ?

Thank you,

Viswanath A

9 REPLIES 9

Former Member
0 Kudos

hi Viswanath

I think when you give a warning message, if you are in a loop to process invoice, you can use 'CONTINUE' key word to avoid process the create IL logic.

if in a FORM, need the 'EXIT' key word.

whatever, don`t run the logic of create IL, don`t use Error message.

regards,

Archer

0 Kudos

Hi Dengyong,

Thanks for your reply.

Currently I am writing code inside an user exit - "USEREXIT_NUMBER_RANGE".
It is not making any difference if we use CONTINUE or EXIT. Is there any way to modify the XVBRK, XVBRL, XKOMFK structures and stop the Invoice list creation?

Regards,

Viswa

nabheetscn
Active Contributor
0 Kudos

Can you please paste the sample code

0 Kudos

Hi Nabheet,

Currently I am validating the total amount in the user exit - "USEREXIT_NUMBER_RANGE". If the validation is OK, I need toproceed further. If validation fails, I need to stop the current invoice list creation.

**  Get the sum of invoices - Amount and taxes

       LOOP AT LT_VBRK ASSIGNING <LS_VBRK>

                       WHERE KUNRG    = LS_VBRK-KUNRG

                         AND FKDAT_RL = LS_VBRK-FKDAT_RL.

         LV_AMT_SUM   = LV_AMT_SUM      +

                        <LS_VBRK>-NETWR +

                        <LS_VBRK>-MWSBK.

       ENDLOOP.



**  Check if minimum value requirement is met

       IF LV_AMT_SUM LT LS_TABLE-MIN_VAL.

IF SY-BATCH = 'X'.

** Throw a message and skip the current invoice list creation

ENDIF.

     ELSE.

**   Do Nothing

     ENDIF.

Is this correct place to do this validation? Please suggest.

0 Kudos

Hi Viswanath

Can you please tell me which tcode you are using which is creating the invoice in background job?

May be you will have to find a suitable exit..? which tcode is it?

Nabheet

0 Kudos

Hi Nabheet,

Thank you, I am using Tcode-VF24 to create invoice list in background job. The Tcode inturn calls RV_INVOICE_LIST_CREATE function module.

Note: The validation has to be performed after all Standard and client specific splits happen.

Regards,

Viswa

0 Kudos

Hi Viswa

Does the SAP standard call this function module once or in loop for each invoice?

I am asking this because if it is getting called for every invoice then can do as mentioned below else we will have to thing of other way

You have an internal table XVBFS at the beginning of this function module call i can see

 

ENHANCEMENT-POINT RV_INVOICE_LIST_CREATE_01 SPOTS ES_SAPLV60A.

You can implement this and fill XVBFS table for the same.

Nabheet

0 Kudos

Hi Nabheet,

This will not be called for each invoice once. The whole set of invoices will be passed to this FM. After standard code splits the invoices based on Payer, Billing date etc, Invoices will be divided in to groups. Each group has to be checked for this validation and then proceed for invoice list creation. If any of the group fails the validation, we need to stop invoice list creation for that and proceed for next groups.

Regards,

Viswa

0 Kudos

Hi Viswa

Unfortunately i can not execute my tcode to tell you the exact place where you shall have your enhancement. But i had a detailed look at the code and i can see various enhancement options available. I would have preferred an implcit/explicit enhancement in function module RV_INVOICE_LIST_DOCUMENT_ADD. Only thing is you will need to find the place in debugging at which points the groups are made.

Nabheet