Explicit PO Number: This post will explain how to create a SAP PO ( Purchasing Order) with Explicit PO Number.
Further information on purchase order BAPIs is available in SAP Note 197958. If you test the BAPIs BAPIPOCREATE1 or BAPIPOCHANGE in the Function Builder (transaction code SE37), no database updates will be carried out. If you need this function, take a look at Note 420646. The BAPI BAPIPOGETDETAIL serves to read the details of a purchase. I've found two functions, BAPIPOCREATE and BAPIPOCREATE1. Since the CREATE1 has a more recent modification date, I assumed this would be the best one to use. As an example, I'm creating a rather simple purchase without a material. BAPIPOCHANGE is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions specific to the object. 1899549-BAPIPOCREATE1: Net price is not taken from input data in POITEM-NETPRICE Symptom When creating a purchase order by BAPIPOCREATE1, net price is not taken from input data in POITEM-NETPRICE. What is BAPIPOCREATE1 BAPIPOCREATE1 is the function module that is allowed you to create purchase orders, this BAPI use the technology behind the enjoy purchase order transaction ( ME21N). In this article i would share you the solution when you cannot input net price ( net price always 0 ) when using BAPIPOCREATE1 to create.
The first part will cover SAP PO Number Customizing and the second part will explain how to create explicit PO Number.
Customizing for Explicit PO Number
In order to allow External number to SAP PO ( Purchase Order ), customizing for PO Number range should be set to External.
So Define a SAP PO document Type then assign a number range for external numbers.
Create External Number Range for Purchasing Document
Launch the SAP Tcode OMH6 : Number Ranges for Purch. Documents
Check also, the following SAP Tcodes for Number Ranges
- OMH6 Number Ranges for Purch. Documents
- OMH7 Number Ranges for Purch. Requisition
- OMH8 Number Ranges for Service Package
- OMH9 Number Ranges for Entry Sheet
Assign External Number Range to Purchasing Document Type
To assign External Number Range to Purchasing Document Type, Navigate through SPRO to
Purchasing > Define Document Types
Set the following information
- Type for Document Types
- Item Number Interval
- No Range Internal
- No Range External
- …
Create SAP PO Explicit PO Number using BAPI
Once the Customizing for External Number Range for PO is done, you can move to ABAP report/Code.
In order to create a SAP Purchasing document with an External PO number use the standard BAPI BAPI_PO_CREATE1 (Create Purchase Order).
Check also List of Important SAP SD Tables (Sales and Distribution).
The main input parameters for PO Number are
- POHEADER : Header Data- type BAPIMEPOHEADER
- POHEADERX: Header Data (Change Parameter)- type BAPIMEPOHEADERX
Use field the POHEADER-PO_NUMBER (EBELN CHAR 10 0 Purchasing Document Number) for the External PO Number for the Purchase Document you want to create.
Set POHEADERX-PO_NUMBER = ‘X’
Call the BAPI BAPI_PO_CREATE1 will all the SAP Purchasing Order Details.
2 4 6 8 10 12 14 16 | DATA:LS_POHEADERTYPEBAPIMEPOHEADER. ' Set External PO ls_poheaderx-po_number=abap_true.' 'X' ' Call SAP PO Creation BAPI EXPORTING POHEADERX=LS_POHEADERX... |
Check more information about Purchasing Document and Most Useful SAP EDI Transactions (SAP Idocs Tcodes) & SAP EDI Tables
*&---------------------------------------------------------------------**& REPORT ZAN_PR2POBAPI1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZAN_PR2POBAPI1.
TYPE-POOLS : SLIS.
TABLES ZLOGHEAD.
DATA:BEGIN OF ITAB_PRLIST OCCURS 0,
BANFN LIKE EBAN-BANFN,
BNFPO LIKE EBAN-BNFPO,
MATNR LIKE EBAN-MATNR,
FLIEF LIKE EBAN-FLIEF, 'FVENDOR
MENGE LIKE EBAN-MENGE,
BSMNG LIKE EBAN-BSMNG, 'OQTY'
INFNR LIKE EBAN-INFNR,
FRGZU LIKE EBAN-FRGZU, 'RELEASE STATUS
BADAT LIKE EBAN-BADAT, 'REQUEST DATE
WERKS LIKE EBAN-WERKS,
NETPR LIKE EINE-NETPR,
LIFNR LIKE EINA-LIFNR,
BSART LIKE EBAN-BSART,
APLFZ LIKE EINE-APLFZ,
END OF ITAB_PRLIST.
TYPES: BEGIN OF STR_PREVPR,
KEY1 TYPE ZLOGHEAD-KEY1 ,
KEY2 TYPE ZLOGHEAD-KEY2,
MATNR TYPE ZLOGHEAD-DATA1,
END OF STR_PREVPR.
DATA: ITAB_PREVPR TYPE TABLE OF STR_PREVPR WITH HEADER LINE.
DATA: WAPREVPR TYPE STR_PREVPR.
DATA:ITAB_PRLIST1 LIKE ITAB_PRLIST OCCURS 0,
WA TYPE ZLOGHEAD,
IT_LOGHEAD TYPE TABLE OF ZLOGHEAD WITH HEADER LINE.
DATA: BEGIN OF IT_DISLOGHEAD OCCURS 0,
PO LIKE BAPIMEPOHEADER-PO_NUMBER,
VENDOR LIKE BAPIMEPOHEADER-VENDOR,
MSGTYPE LIKE BAPIRET2-TYPE,
MSG LIKE BAPIRET2-MESSAGE_V1,
EXPAND LIKE BAPIRET2-TYPE,
END OF IT_DISLOGHEAD .
DATA: BEGIN OF IT_DISLOGDETAIL OCCURS 0,
PO LIKE BAPIMEPOHEADER-PO_NUMBER,
VENDOR LIKE BAPIMEPOHEADER-VENDOR,
LINE LIKE BAPIMEPOITEM-PO_ITEM,
MATERIAL LIKE BAPIMEPOITEM-MATERIAL,
MSGTYPE LIKE BAPIRET2-TYPE,
MSG LIKE BAPIRET2-MESSAGE_V1,
END OF IT_DISLOGDETAIL.
DATA: VLINES TYPE I,
VLINECOUNT TYPE I,
VFIRST TYPE C,
VMATNR LIKE EBAN-MATNR,
VPREVMATNR LIKE EBAN-MATNR,
VNETPR LIKE EINE-NETPR,
VAPLFZ LIKE EINE-APLFZ,
VPORG LIKE EBAN-EKORG VALUE 'BP01',
VPGRP LIKE EBAN-EKGRP VALUE '001',
VCCODE LIKE EKKO-BUKRS VALUE 'BP01',
'VVENDOR LIKE EBAN-LIFNR,
VTEXT(50) TYPE C,
V_PER TYPE P,
VINFNR LIKE EINA-INFNR,
vvendor LIKE bapimepoheader-vendor,
VBANFN LIKE ZLOGHEAD-KEY1,
VBNFPO LIKE ZLOGHEAD-KEY2,
VPREVBANFN LIKE ZLOGHEAD-KEY1,
VPREVBNFPO LIKE ZLOGHEAD-KEY2,
V_TXT(50),
VRUNBAPI TYPE C.
DATA: A1 LIKE EBAN-BANFN,
A2 LIKE EBAN-BNFPO.
DATA: PONUM TYPE BAPIMEPOHEADER-PO_NUMBER.
* DECLARATION RELATED TO PO BAPI
DATA: LPOHEADER TYPE BAPIMEPOHEADER,
LPOHEADERX TYPE BAPIMEPOHEADERX.
DATA:T_POITEM TYPE STANDARD TABLE OF BAPIMEPOITEM WITH HEADER LINE,
T_POITEMX TYPE STANDARD TABLE OF BAPIMEPOITEMX WITH HEADER LINE,
T_RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_KEYINFO TYPE TABLE OF SLIS_KEYINFO_ALV WITH HEADER LINE.
DO.
CLEAR IT_LOGHEAD[]. ' CLEAR INTERNAL TABLES HOLDING MESSAGES
PERFORM READ_LOG.
PERFORM COLLECT_DATA.
PERFORM BAPIDATA_FILL.
PERFORM DISPLAY_LOG_LIST.
EXIT.
ENDDO.
FORM READ_LOG.
SELECT * FROM ZLOGHEAD INTO TABLE IT_LOGHEAD.
ENDFORM.
FORM COLLECT_DATA.
DESCRIBE TABLE IT_LOGHEAD LINES VLINES.
READ TABLE IT_LOGHEAD INDEX VLINES.
IF IT_LOGHEAD[] IS NOT INITIAL.
SELECT BANFN BNFPO MATNR FLIEF MENGE BSMNG INFNR FRGZU BADAT WERKS
BSART
FROM EBAN
INTO CORRESPONDING FIELDS OF TABLE ITAB_PRLIST
WHERE BANFN > IT_LOGHEAD-KEY1 AND
LOEKZ <> 'X'.
SELECT KEY1 KEY2 FROM ZLOGHEAD
INTO CORRESPONDING FIELDS OF TABLE ITAB_PREVPR
WHERE PROCESSNAME = 'PR2POBAPI' AND
PROCESSED = '.
LOOP AT ITAB_PREVPR.
READ TABLE ITAB_PRLIST WITH KEY BANFN = ITAB_PREVPR-KEY1
BNFPO = ITAB_PREVPR-KEY2.
IF SY-SUBRC <> 0.
SELECT BANFN BNFPO MATNR FLIEF MENGE BSMNG INFNR FRGZU
BADAT WERKS BSART
FROM EBAN
APPENDING CORRESPONDING FIELDS OF
TABLE ITAB_PRLIST1
WHERE BANFN = ITAB_PREVPR-KEY1 AND
BNFPO = ITAB_PREVPR-KEY2 AND
LOEKZ <> 'X'.
ENDIF.
ENDLOOP.
ELSE.
SELECT A~BANFN A~BNFPO A~MATNR A~FLIEF A~MENGE B~BSMNG A~INFNR
A~FRGZU A~BADAT A~WERKS A~BSART
FROM EBAN AS A
INNER JOIN EBAN AS B ON A~BANFN = B~BANFN AND A~BNFPO =
B~BNFPO
INTO CORRESPONDING FIELDS OF TABLE ITAB_PRLIST
WHERE ( A~BADAT = SY-DATUM AND
( A~EBELN = ' OR ( A~EBELN <> ' AND A~MENGE >
B~BSMNG ) ) AND
A~LOEKZ <> 'X' AND
A~BANFN <> '0010000091' ).
ENDIF.
IF ITAB_PRLIST1 IS NOT INITIAL.
APPEND LINES OF ITAB_PRLIST1 TO ITAB_PRLIST.
ENDIF.
LOOP AT ITAB_PRLIST.
VNETPR = 0.
VAPLFZ = '.
VINFNR = '.
IF ITAB_PRLIST-FLIEF = '.
SELECT LIFNR INFNR FROM EINA INTO (VVENDOR , VINFNR)
WHERE MATNR = ITAB_PRLIST-MATNR.
ENDSELECT.
IF SY-SUBRC = 0.
ITAB_PRLIST-LIFNR = VVENDOR.
ITAB_PRLIST-INFNR = VINFNR.
MODIFY ITAB_PRLIST FROM ITAB_PRLIST.
ENDIF.
ENDIF.
IF ITAB_PRLIST-INFNR <> '.
SELECT NETPR APLFZ FROM EINE INTO (VNETPR , VAPLFZ)
WHERE
INFNR = ITAB_PRLIST-INFNR AND
EKORG = VPORG AND
ESOKZ = '0' AND
WERKS = ITAB_PRLIST-WERKS.
ENDSELECT.
IF SY-SUBRC = 0.
ITAB_PRLIST-NETPR = VNETPR.
ITAB_PRLIST-APLFZ = VAPLFZ.
MODIFY ITAB_PRLIST FROM ITAB_PRLIST.
ENDIF.
ENDIF.
ENDLOOP.
LOOP AT ITAB_PRLIST.
IF ITAB_PRLIST-BADAT <> SY-DATUM or
itab_prlist-banfn <= '0010000212'.
DELETE ITAB_PRLIST.
ENDIF.
ENDLOOP.
ITAB_PRLIST-MATNR = 'ZZZZZZZZZZZZZZZZZZ'.
APPEND ITAB_PRLIST.
SORT ITAB_PRLIST BY MATNR BANFN BNFPO.
ENDFORM.
FORM BAPIDATA_FILL.
* DETERMINE THE NUMBER OF RECORDS IN THE INTERNAL TABLE
DESCRIBE TABLE ITAB_PRLIST LINES VLINES.
IF VLINES = 1.
EXIT.
ENDIF.
VLINECOUNT = 0.
VFIRST = 'X'.
VMATNR = '.
VPREVMATNR = '.
VPREVBANFN = '.
VPREVBNFPO = 0.
VRUNBAPI = '.
PERFORM DISPLAY_PROGRESS_TIMER.
CLEAR ITAB_PREVPR[].
LOOP AT ITAB_PRLIST.
IF VMATNR <> ITAB_PRLIST-MATNR.
IF VFIRST <> 'X'.
VRUNBAPI = 'X'.
ENDIF.
VMATNR = ITAB_PRLIST-MATNR.
VLINECOUNT = 10.
ENDIF.
IF VRUNBAPI = 'X'.
VMATNR = ITAB_PRLIST-MATNR.
VRUNBAPI = '.
PERFORM BAPI_LOAD.
READ TABLE T_RETURN INDEX 1.
DESCRIBE TABLE T_RETURN.
IF T_RETURN-TYPE = 'S'.
PERFORM DATACOMMIT.
CONCATENATE 'PO CREATED SUCCESSFULLY:' PONUM INTO VTEXT.
LOOP AT ITAB_PREVPR WHERE MATNR = VPREVMATNR.
UPDATE ZLOGHEAD SET MSGTYPE = 'S'
PROCESSED = 'X'
MSGTEXT = VTEXT
WHERE CREATEDATE = SY-DATUM AND
KEY1 = ITAB_PREVPR-KEY1 AND
KEY2 = ITAB_PREVPR-KEY2.
DELETE ITAB_PREVPR.
ENDLOOP.
'ADD RECORDS TO DIS LOGS
IT_DISLOGHEAD-PO = PONUM.
IT_DISLOGHEAD-VENDOR = VVENDOR.
IT_DISLOGHEAD-MSGTYPE = 'S'.
IT_DISLOGHEAD-MSG = VTEXT.
APPEND IT_DISLOGHEAD.
LOOP AT IT_DISLOGDETAIL .
IF IT_DISLOGDETAIL-PO = '.
IT_DISLOGDETAIL-PO = PONUM.
ENDIF.
ENDLOOP.
LOOP AT T_RETURN.
IT_DISLOGDETAIL-PO = PONUM.
IT_DISLOGDETAIL-VENDOR = VVENDOR.
IT_DISLOGDETAIL-LINE = '.
IT_DISLOGDETAIL-MATERIAL = '.
IT_DISLOGDETAIL-MSGTYPE = 'S'.
IT_DISLOGDETAIL-MSG = T_RETURN-MESSAGE(50).
APPEND IT_DISLOGDETAIL.
ENDLOOP.
REFRESH T_RETURN.
ELSE. 'BAPI FAILED
'ADD RECORDS TO DIS LOGS
IT_DISLOGHEAD-PO = '*****'.
IT_DISLOGHEAD-VENDOR = VVENDOR.
IT_DISLOGHEAD-MSGTYPE = 'E'.
IT_DISLOGHEAD-MSG = 'PO CREATION FAILED'.
APPEND IT_DISLOGHEAD.
LOOP AT T_RETURN.
IT_DISLOGDETAIL-PO = '*****'.
IT_DISLOGDETAIL-VENDOR = VVENDOR.
IT_DISLOGDETAIL-LINE = '.
IT_DISLOGDETAIL-MATERIAL = '.
IT_DISLOGDETAIL-MSGTYPE = 'E'.
IT_DISLOGDETAIL-MSG = T_RETURN-MESSAGE(50).
APPEND IT_DISLOGDETAIL.
ENDLOOP.
REFRESH T_RETURN.
ENDIF.
CLEAR T_RETURN[].
CLEAR T_POITEM[].
CLEAR T_POITEMX[].
CLEAR LPOHEADER.
CLEAR LPOHEADERX.
ENDIF.
IF ITAB_PRLIST-MATNR <> 'ZZZZZZZZZZZZZZZZZZ'.
LPOHEADER-COMP_CODE = VCCODE.
LPOHEADER-DOC_TYPE = ITAB_PRLIST-BSART.
LPOHEADER-CREAT_DATE = SY-DATUM.
LPOHEADER-VENDOR = ITAB_PRLIST-FLIEF.
LPOHEADER-PURCH_ORG = VPORG.
LPOHEADER-PUR_GROUP = VPGRP.
IF LPOHEADER-VENDOR = '.
LPOHEADER-VENDOR = ITAB_PRLIST-LIFNR.
ENDIF.
LPOHEADERX-COMP_CODE = 'X'.
LPOHEADERX-DOC_TYPE = 'X'.
LPOHEADERX-CREAT_DATE = 'X'.
LPOHEADERX-VENDOR = 'X'.
LPOHEADERX-PURCH_ORG = 'X'.
LPOHEADERX-PUR_GROUP = 'X'.
T_POITEM-PO_ITEM = VLINECOUNT.
T_POITEM-PREQ_NO = ITAB_PRLIST-BANFN.
T_POITEM-PREQ_ITEM = ITAB_PRLIST-BNFPO.
T_POITEM-PO_PRICE = 2.
T_POITEM-NET_PRICE = ITAB_PRLIST-NETPR.
T_POITEM-QUANTITY = ITAB_PRLIST-MENGE - ITAB_PRLIST-BSMNG.
T_POITEM-PLAN_DEL = ITAB_PRLIST-APLFZ.
APPEND T_POITEM.
T_POITEMX-PO_ITEM = VLINECOUNT.
T_POITEMX-PREQ_NO = ITAB_PRLIST-BANFN.
T_POITEMX-PREQ_ITEM = ITAB_PRLIST-BNFPO.
T_POITEMX-PO_PRICE = 'X'.
T_POITEMX-NET_PRICE = 'X'.
T_POITEMX-QUANTITY = 'X'.
T_POITEMX-PLAN_DEL = 'X'.
APPEND T_POITEMX.
SELECT KEY1 KEY2 FROM ZLOGHEAD
INTO (VBANFN , VBNFPO)
WHERE PROCESSNAME = 'PR2POBAPI' AND
PROCESSED = ' ' AND
KEY1 = ITAB_PRLIST-BANFN AND
KEY2 = ITAB_PRLIST-BNFPO.
ENDSELECT.
IF SY-SUBRC <> 0.
WA-MANDT = SY-MANDT.
WA-PROCESSNAME = 'PR2POBAPI'.
Bapi Po Create1 Manual Price In India
WA-KEY1 = ITAB_PRLIST-BANFN.
WA-KEY2 = ITAB_PRLIST-BNFPO.
WA-PROCESSED = ' '.
WA-MSGTYPE = 'E'.
WA-DATA1 = ITAB_PRLIST-MATNR.
WA-CREATEDATE = SY-DATUM.
WA-CREATETIME = SY-UZEIT.
WA-MSGTEXT = 'PO CREATION FAILED'.
INSERT ZLOGHEAD FROM WA.
ENDIF.
WAPREVPR-KEY1 = ITAB_PRLIST-BANFN.
WAPREVPR-KEY2 = ITAB_PRLIST-BNFPO.
WAPREVPR-MATNR = ITAB_PRLIST-MATNR.
APPEND WAPREVPR TO ITAB_PREVPR.
VLINECOUNT = VLINECOUNT + 10.
VVENDOR = ITAB_PRLIST-LIFNR.
VPREVMATNR = ITAB_PRLIST-MATNR.
VFIRST = '.
ENDIF.
ENDLOOP.
ENDFORM.
FORM BAPI_LOAD.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = LPOHEADER
POHEADERX = LPOHEADERX
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
IMPORTING
EXPPURCHASEORDER = PONUM
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
RETURN = T_RETURN
POITEM = T_POITEM
POITEMX = T_POITEMX
* POADDRDELIVERY =
* POSCHEDULE =
* POSCHEDULEX =
* POACCOUNT =
* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS =
* POCOMPONENTSX =
* POSHIPPING =
* POSHIPPINGX =
* POSHIPPINGEXP =
.
ENDFORM. 'BAPI_LOAD
*&---------------------------------------------------------------------*
*& FORM DATACOMMIT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
FORM DATACOMMIT.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = '2'
* IMPORTING
* RETURN =
.
WAIT UP TO 2 SECONDS.
* WRITE: 'GENERATED PO:', PONUM.
* LOOP AT T_RETURN.
* WRITE:/ T_RETURN-MESSAGE, T_RETURN-MESSAGE_V1.
* ENDLOOP.
ENDFORM. 'DATACOMMIT
FORM DISPLAY_PROGRESS_TIMER .
V_PER = SY-TABIX / VLINES * 100.
WRITE V_PER TO V_TXT.
CONDENSE V_TXT.
CONCATENATE V_TXT '% OF PO RECORDS CREATED...'
INTO V_TXT SEPARATED BY
SPACE.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = V_PER
TEXT = V_TXT.
ENDFORM. ' DISPLAY_PROGRESS_TIMER
FORM DISPLAY_LOG_LIST.
* CREATE FIELDCATALOG FOR ALV
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'IT_DISLOGHEAD'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = IT_FIELDCAT
'I_INCLNAME = SY-REPID
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
Bapi Po Create1 Manual Priced
OTHERS = 3.IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF IT_DISLOGDETAIL IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'IT_DISLOGDETAIL'
I_INCLNAME = SY-REPID
I_CLIENT_NEVER_DISPLAY = 'X'
CHANGING
Bapi Po Create1 Manual Price
CT_FIELDCAT = IT_FIELDCAT[]'I_INCLNAME = SY-REPID
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
IT_KEYINFO-HEADER01 = 'PO'.
IT_KEYINFO-ITEM01 = 'PO'.
IT_KEYINFO-ITEM02 = 'LINE'.
APPEND IT_KEYINFO.
WA_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
WA_LAYOUT-DEF_STATUS = ' '.
'SORT IT_LOGDETAIL BY PLANT MATERIAL MSG.
'DELETE ADJACENT DUPLICATES FROM IT_LOGDETAIL COMPARING
'PLANT MATERIAL MSG.
* CALL FUNCTION TO DISPLAY ALV LOG
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT[]
IS_LAYOUT = WA_LAYOUT
I_DEFAULT = ' '
I_SAVE = 'A'
I_TABNAME_HEADER = 'IT_DISLOGHEAD'
I_TABNAME_ITEM = 'IT_DISLOGDETAIL'
IS_KEYINFO = IT_KEYINFO
I_BYPASSING_BUFFER = 'X'
' I_SUPPRESS_EMPTY_DATA = abap_true
TABLES
T_OUTTAB_HEADER = IT_DISLOGHEAD
T_OUTTAB_ITEM = IT_DISLOGDETAIL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. 'DISPLAY_LOG_LIST