Trigger Output Re-Determination for Billing Documents
This SAP tutorial shows how to trigger output re-determination for billing documents. For example, using ABAP source codes shared in this tutorial developers can create missing outputs for invoices. I'll share how to create batch input for VF02 transaction to update billing document without any change on any field. But VF02 change billing document transaction will run output determination procedure ending with missing output messages.
Recently I had to create output messages for billing documents in a mass numbers. If the total number of invoices that I had to re-generate outputs could be expressed of a few invoices, I would solve it by updating billing document using VF02 without any change of its figures. Updating invoice with VF02 SAP transaction trigger output determination procedure and results with creation of output messages if missing for that document. This is fast and practical if the invoice number is an amount that can be managable.
I had to re-trigger output determination procedure for hundreds of billing documents so I actually require a massive update of invoices which will generate output documents automatically.
I chosed to use SAP Batch Input functions to update an invoice using its VBELN number on VF02 transaction and convert the batch input to an ABAP program to customize it further.
In this ABAP tutorial I will demonstrate how I create batch input using VF02 transaction as a first step.
Tutorial will continue with conversion of batch input to an ABAP program automatically by services provided by SAP.
Then we will modify the ABAP program by adding select options for VBELN number and parameterize the application to reuse it in other scenarios.
Create Batch Input using VF02 Change Billing Document Transaction
In order to create a batch input solution, developers need to run Batch Input Recorder.
To run recorder follow the menu option on SAP menu: System > Services > Batch Input > Recorder
Or use SAP transaction SHDB
When Transaction Recorder screen is displayed, press New Recording button
I'm going to test SAP batch input procedure using billing document number 0074500008. When I looked at the defined output messages for the related invoice with SAP transaction code VF03, you can see that there is not any outputs created yet.
Within Batch Input Recorder, first give a name to your recording. Here I used ZBillOutputD because I'm going to use this batch input recording for billing document output redetermination process. In the Transaction code input text area, enter SAP transaction VF02. This VF02 tcode is used to update any billing document.
Press "Start recording" button to start batch input recording
VF02 transaction will be executed automatically. Provide the sample billing document number you want to create new output messages missing in the output list currently for that invoice.
Press Enter to get into invoice details screen.
When you enter the VF02 change screen, directly press Save icon.
We are not required to make any changes on any fields of the billing document. The output determination procedure is already executed for the existing billing document and missing output messages are created when invoice is saved.
Recording for batch input will continue. As you see below, there is VBRK-VBELN field name entry with our sample invoice number in the field value column. Later we will enable the batch input program to read vbrk-vbeln value dynamically using a set of billing documents.
Create ABAP Program using Batch Input to Update Billing Documents
After the batch input recorder recording is saved, you can use F3 to navigate back to Transaction Recording: Recording Overview screen. Or developers can use the name they give to the recording to filter.
Filter the recently created batch input recording.
Highligh the batch input recording on the list.
Then follow the menu options: Edit > Create program
Type a valid name for your ABAP program like I did as Z_ReCreate_Output_BillingDocs (short for re-create output messages for billing documents). Then press Enter to continue
In the following screen, enter details for your executable ABAP program. Press Source Code button and save the object either as a local object or place it into a package. Then the ABAP source codes of the batch input program will be displayed as follows in change mode.
Please give your attention to following ABAP code line where billing document number is passed to the VF02 SAP transaction:
perform bdc_field using 'VBRK-VBELN' '0074500008'.
Now place a breakpoint at like "perform open_group." and execute ABAP program using F8.
Choose "Call transaction" option. Select "N Background processing" as "Processing Mode"
When the ABAP program finishes running, it will report that using CALL_TRANSACTION VF02 the related billing document has been saved.
Mass Update of Billing Documents for Output Determination Procedure
Since we want to run this ABAP report for mass update of billing documents to generate missing output messages and the number of billing documents is huge, we have to execute this invoice update task in a loop where we define the billing document numbers.
There are two methods we can choose.
First method that I prefer to use is that: We will find the related VBELN numbers for billing documents in another SAP tools like SE11 or /TFTO/SE16XXL transactions and enter the list of all selected billing document numbers in a VBELN select option.
Second method is to execute a SELECT statement by code in the ABAP report and store values in an internal table. Then we can loop in this internal table to provide VBELN numbers for VF02 billing document change transaction.
Unfortunately this second method is also limited in reusability. So I prefer the first method.
Here is the ABAP program I developed to run VF02 for each billing document that I want to generate output messages by triggering the output determination procedure once more.
I got a list of billing document numbers that I need to create outputs by triggering the output determination procedure. So when I execute the above ABAP report by providing the list as an input to so_vbeln select option, I will be able to generate output messages for given invoices.
ABAP developers can create this program on their development systems by following the steps illustrated in this ABAP tutorial. Before running this ABAP program in production systems, I suggest developers to test it on development or at least test systems to understand the execution behavior of the program.
One last note, since if there is already an output message for the related billing document in any status (successfully processed, incorrectly processed or in not processed status), updating the billing document with SAP VF02 transaction will not create those output messages again. If you need to delete NAST entries for a billing document to remove the output messages from SAP system, ABAP developers can run standart ABAP report RSCLNAST first, and then recreate output messages using method shown in this SAP tutorial.