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

Process Billing Document Output by ABAP Code

ABAP programmer can use sample code shared in this tutorial to process billing document output messages individually by ABAP code instead of VF31 SAP transaction. SAP user can add the output message using VF02 transaction Header Outputs screen too. But in case SAP user fail to add new invoice output message and process it successfully, ABAP developers can use following codes in order to create and process outputs for selected billing document.

Here is ABAP program code which takes the billing document or invoice number and the output message type as input values from the user. I used a basic ABAP Selection Screen code for this task where the SAP user can provide the invoice number and the output type.

process invoice output using ABAP code

As seen in below ABAP code, the program is formed of a few seperate blocks.

First comes the selection screen block, then an ABAP Select command on NAST database table which returns the output message data in a local structure value. This SELECT statement requires an existing output with status either processed or ready for process. It is enough to add manually the specific invoice output using VF02 and leave it unprocessed by setting its dispatch time to 3 (highlight output then press Further data button).

An other code block changes and updates the message status field values for the new process which will take soon.
Update is done by calling ABAP function module RV_MESSAGE_UPDATE_SINGLE

The last ABAP code block process the target output record using ABAP function module WFMC_MESSAGES_PROCESS

TABLES: vbrk, nast.
DATA: lt_msg0 TYPE TABLE OF msg0,
  ls_msg0 TYPE msg0, " Output Control: Basic Data
  lt_naliv2 TYPE TABLE OF naliv2. " Display output from deliveries

SELECTION-SCREEN BEGIN OF BLOCK 100 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
 so_vbeln FOR vbrk-vbeln NO INTERVALS OBLIGATORY NO-EXTENSION,
 so_kschl FOR nast-kschl NO INTERVALS OBLIGATORY NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK 100.

CHECK ( so_vbeln IS NOT INITIAL ) AND ( so_kschl IS NOT INITIAL ) .

SELECT SINGLE * INTO @DATA(ls_nast)
 FROM nast WHERE objky = @so_vbeln-low AND
  kschl = @so_kschl-low.
CHECK sy-subrc = 0.

ls_nast-erdat = sy-datum. " current date
ls_nast-eruhr = sy-uzeit. " current time
ls_nast-anzal = '01'. " number of messages
ls_nast-vstat = '0'. " processing status

*** Update an individual NAST record
CALL FUNCTION 'RV_MESSAGE_UPDATE_SINGLE'
 EXPORTING
  msg_nast = ls_nast.

MOVE-CORRESPONDING ls_nast TO ls_msg0.
APPEND ls_msg0 TO lt_msg0.

*** Process Output Messages
CALL FUNCTION 'WFMC_MESSAGES_PROCESS'
 EXPORTING
  pi_display_id = 'NALIV2'
  pi_no_dialog = 'X'
* PI_NO_COMMIT = ' '
* PI_NO_ENQUEUE = ' '
* PI_VERMO = 0
* PI_USE_GRID_CONTROL = ' '
* PI_BE_QUIET = ' '
 TABLES
  tx_messages = lt_msg0
  tx_display = lt_naliv2.
Code

After ABAP programmer executes above ABAP report to process a specific billing document (invoice) number and for a specific output message, if it runs successfully a green output record will be displayed on VF03 (Goto > Header > Output) Outputs screen.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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