SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

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

ABAP batch input recorder for mass change of SAP invoices

When Transaction Recorder screen is displayed, press New Recording button new batch input recording

SAP Batch Input New recording

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.

SAP billing document display output messages

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.

create batch input recording for ABAP programmer

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.

SAP invoice number to redetermine output messages

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.

SAP VF02 transaction to change billing document

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.

change batch input recordings using transaction recorder

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.

create ABAP program from batch input recording

Highligh the batch input recording on the list.
Then follow the menu options: Edit > Create program

create ABAP program for batch input

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

ABAP program properties created for batch input recording

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.

ABAP program source codes to create missing billing outputs for SAP invoices

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.

report Z_RECREATE_OUTPUT_BILLINGDOCS no standard page heading line-size 255.

include bdcrecx1.


perform open_group.

perform bdc_dynpro using 'SAPMV60A' '0101'.
perform bdc_field using 'BDC_CURSOR' 'VBRK-VBELN'.
perform bdc_field using 'BDC_OKCODE' '/00'.
perform bdc_field using 'VBRK-VBELN' '0074500008'.
perform bdc_dynpro using 'SAPMV60A' '0104'.
perform bdc_field using 'BDC_CURSOR' 'VBRK-FKART'.
perform bdc_field using 'BDC_OKCODE' '=SICH'.
perform bdc_transaction using 'VF02'.

perform close_group.

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.

report Z_RECREATE_OUTPUT_BILLINGDOCS no standard page heading line-size 255.

include BDCRECX1.

*** Batch Input to Update billing documents using VF02
*** in order to trigger output determination procedure
*** for creation of output messages missing due to a problem
data LV_TEST type CHAR1.
data LV_VBELN type VBELN.

selection-screen begin of block SBLK2 with frame title TEXT-001.
 SO_VBELN for LV_VBELN no intervals, " can be defined as obligatory
 SO_TEST for LV_TEST no intervals default 'X'.
selection-screen end of block SBLK2.


perform OPEN_GROUP.

if SO_TEST is initial. " do not run accidentally, clear Test
 loop at SO_VBELN. " you can also check if it is initial or not
  perform BDC_DYNPRO using 'SAPMV60A' '0101'.
  perform BDC_FIELD using 'BDC_CURSOR' 'VBRK-VBELN'.
  perform BDC_FIELD using 'BDC_OKCODE' '/00'.
  perform BDC_DYNPRO using 'SAPMV60A' '0104'.
  perform BDC_FIELD using 'BDC_CURSOR' 'VBRK-FKART'.
  perform BDC_FIELD using 'BDC_OKCODE' '=SICH'.
  perform BDC_TRANSACTION using 'VF02'.

perform CLOSE_GROUP.

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.

create output messages by mass update of billing documents

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.


Install SAP Free
CRM Companies List
Web Based CRM Software

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.