2019 May 12 2:33 PM
Hi all,
In this sample code why they are using flags .i cannot understand them.
&---------------------------------------------------------------------
*& Report ZBAPI_CREATE_PO *
*& *&---------------------------------------------------------------------REPORT ZBAPI_CREATE_PO .&---------------------------------------------------------------------
*DATA DECLARATIONCONSTANTS: C_X VALUE'X'.
*Structures to hold PO header dataDATA:HEADERLIKE BAPIMEPOHEADER ,
HEADERX LIKE BAPIMEPOHEADERX .
*Internal Tables to hold PO ITEM DATADATA: ITEM LIKE BAPIMEPOITEM OCCURS0WITHHEADERLINE,
ITEMX LIKE BAPIMEPOITEMX OCCURS0WITHHEADERLINE,
**Internal table to hold messages from BAPI callRETURNLIKE BAPIRET2 OCCURS0WITHHEADERLINE.data: w_header(40)value'PO Header'.data: ws_langu likesy-langu.data: V_EXPPURCHASEORDER like BAPIMEPOHEADER-PO_NUMBER.
*text-001 = 'PO Header' - define as text elementselection-screenbeginofblock b1 withframetitletext-001.parameters: company likeheader-comp_code default'1000',
doctyp likeHEADER-DOC_TYPE default'NB',
cdate likeHEADER-CREAT_DATE defaultsy-datum ,
vendor likeHEADER-VENDOR default'RAJ',
pur_org likeHEADER-PURCH_ORG default'0001',
pur_grp likeHEADER-PUR_GROUP default'001'.selection-screenendofblock b1.selection-screenbeginofblock b2 withframetitletext-002.parameters: item_num like ITEM-PO_ITEM default'00020',
material like ITEM-MATERIAL default'M-127',
plant like ITEM-PLANT default'0001',
quantity like ITEM-QUANTITY default200.selection-screenendofblock b2.
*&---------------------------------------------------------------------
**START-OF-SELECTION.
*&---------------------------------------------------------------------
**DATA POPULATION
*&---------------------------------------------------------------------
ws_langu =sy-langu."Language variable
*POPULATE HEADER DATA FOR POHEADER-COMP_CODE = company .HEADER-DOC_TYPE = doctyp .HEADER-CREAT_DATE = cdate .HEADER-VENDOR = vendor .HEADER-LANGU = ws_langu .HEADER-PURCH_ORG = pur_org .HEADER-PUR_GROUP = pur_grp .&---------------------------------------------------------------------
*POPULATE HEADER FLAG.&---------------------------------------------------------------------
HEADERX-comp_code = c_x.
HEADERX-doc_type = c_x.
HEADERX-creat_date = c_x.
HEADERX-vendor = c_x.
HEADERX-langu = c_x.
HEADERX-purch_org = c_x.
HEADERX-pur_group = c_x.
*HEADERX-doc_date = c_x.&---------------------------------------------------------------------
*POPULATE ITEM DATA.&---------------------------------------------------------------------
ITEM-PO_ITEM = item_num.
ITEM-MATERIAL = material.
ITEM-PLANT = plant.
ITEM-QUANTITY = quantity.APPEND ITEM.&---------------------------------------------------------------------
*POPULATE ITEM FLAG TABLE&---------------------------------------------------------------------
ITEMX-PO_ITEM = item_num.
ITEMX-MATERIAL = C_X.
ITEMX-PLANT = C_X .
*ITEMX-STGE_LOC = C_X .
ITEMX-QUANTITY = C_X .
*ITEMX-TAX_CODE = C_X .
*ITEMX-ITEM_CAT = C_X .
*ITEMX-ACCTASSCAT = C_X .APPEND ITEMX.&---------------------------------------------------------------------
*BAPI CALL&---------------------------------------------------------------------CALLFUNCTION'BAPI_PO_CREATE1'EXPORTING
POHEADER =HEADER
POHEADERX = HEADERX
POADDRVENDOR =
TESTRUN =IMPORTING
EXPPURCHASEORDER = V_EXPPURCHASEORDER
EXPHEADER =
EXPPOEXPIMPHEADER =TABLESRETURN=RETURN
POITEM = ITEM
POITEMX = ITEMX.&---------------------------------------------------------------------
*Confirm the document creation by calling database COMMIT&---------------------------------------------------------------------CALLFUNCTION'BAPI_TRANSACTION_COMMIT'EXPORTINGWAIT='X'IMPORTINGRETURN=.end-of-selection.
****&---------------------------------------------------------------------*
****Output the messages returned from BAPI call
****&---------------------------------------------------------------------*
*LOOP AT RETURN.WRITE/ v_EXPPURCHASEORDER.
*ENDLOOP.
2019 May 12 2:59 PM
For "Change" BAPIs, X flags are used to distinguish those two cases:
For "Create" BAPIs, X flags are used to distinguish those two cases (that's a guess):
(note: some fields may be required like key fields, not have a default value proposed by SAP, in that case it may not be needed to set the X flag explicitly ; expl: BAPI_SALESORDER_CREATEFROMDAT2, ORDER_HEADER_INX, even if DOC_TYPE, SALES_ORG... are not set, the corresponding fields in ORDER_HEADER_IN are considered)
For "Change" BAPIs, X flags are used to distinguish those two cases:
For "Create" BAPIs, X flags are used to distinguish those two cases (that's a guess):
(note: some fields may be required like key fields, not have a default value proposed by SAP, in that case it may not be needed to set the X flag explicitly ; expl: BAPI_SALESORDER_CREATEFROMDAT2, ORDER_HEADER_INX, even if DOC_TYPE, SALES_ORG... are not set, the corresponding fields in ORDER_HEADER_IN are considered)
2019 May 12 2:59 PM
For "Change" BAPIs, X flags are used to distinguish those two cases:
For "Create" BAPIs, X flags are used to distinguish those two cases (that's a guess):
(note: some fields may be required like key fields, not have a default value proposed by SAP, in that case it may not be needed to set the X flag explicitly ; expl: BAPI_SALESORDER_CREATEFROMDAT2, ORDER_HEADER_INX, even if DOC_TYPE, SALES_ORG... are not set, the corresponding fields in ORDER_HEADER_IN are considered)
2019 May 12 4:23 PM
...c_x = 'X'.
Not exactly the best constant definition I've seen. Could be worse I suppose, like
...c_x = 'Y'...
2019 May 13 10:21 AM
2019 May 13 6:48 PM
Hi,
If you need to change the value you should pass the X value . Ex:
If you need to update the company code
POHEADER-COMP_CODE = '1000'.
POHEADERX-COMP_CODE = 'X'.
If your not pass the parameter like 'X' , PO will not update the relevant field.
your C_X should be constant like
CONSTANTS : C_X TYPE C VALUE 'X'.
2019 May 14 11:26 AM
Hi,
this bapi is well documented within SAP. Just go to se37, display and click Function Module Documentation button.
Kind regards, Rob Dielemans
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |