<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Why we are using flags for bapi_po_create1 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928806#M1964464</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;In this sample code why they are using flags .i cannot understand them.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;amp;---------------------------------------------------------------------
*&amp;amp; Report ZBAPI_CREATE_PO *
*&amp;amp; *&amp;amp;---------------------------------------------------------------------REPORT ZBAPI_CREATE_PO .&amp;amp;---------------------------------------------------------------------
*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.
*&amp;amp;---------------------------------------------------------------------
**START-OF-SELECTION.
*&amp;amp;---------------------------------------------------------------------
**DATA POPULATION
*&amp;amp;---------------------------------------------------------------------
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 .&amp;amp;---------------------------------------------------------------------
*POPULATE HEADER FLAG.&amp;amp;---------------------------------------------------------------------
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.&amp;amp;---------------------------------------------------------------------
*POPULATE ITEM DATA.&amp;amp;---------------------------------------------------------------------
ITEM-PO_ITEM = item_num.
ITEM-MATERIAL = material.
ITEM-PLANT = plant.
ITEM-QUANTITY = quantity.APPEND ITEM.&amp;amp;---------------------------------------------------------------------
*POPULATE ITEM FLAG TABLE&amp;amp;---------------------------------------------------------------------
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.&amp;amp;---------------------------------------------------------------------
*BAPI CALL&amp;amp;---------------------------------------------------------------------CALLFUNCTION'BAPI_PO_CREATE1'EXPORTING
POHEADER =HEADER
POHEADERX = HEADERX

POADDRVENDOR = 
TESTRUN =IMPORTING
EXPPURCHASEORDER = V_EXPPURCHASEORDER

EXPHEADER = 
EXPPOEXPIMPHEADER =TABLESRETURN=RETURN
POITEM = ITEM
POITEMX = ITEMX.&amp;amp;---------------------------------------------------------------------
*Confirm the document creation by calling database COMMIT&amp;amp;---------------------------------------------------------------------CALLFUNCTION'BAPI_TRANSACTION_COMMIT'EXPORTINGWAIT='X'IMPORTINGRETURN=.end-of-selection.
****&amp;amp;---------------------------------------------------------------------*
****Output the messages returned from BAPI call
****&amp;amp;---------------------------------------------------------------------*
*LOOP AT RETURN.WRITE/ v_EXPPURCHASEORDER.
*ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 12 May 2019 13:33:30 GMT</pubDate>
    <dc:creator>DKanna</dc:creator>
    <dc:date>2019-05-12T13:33:30Z</dc:date>
    <item>
      <title>Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928806#M1964464</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;In this sample code why they are using flags .i cannot understand them.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;amp;---------------------------------------------------------------------
*&amp;amp; Report ZBAPI_CREATE_PO *
*&amp;amp; *&amp;amp;---------------------------------------------------------------------REPORT ZBAPI_CREATE_PO .&amp;amp;---------------------------------------------------------------------
*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.
*&amp;amp;---------------------------------------------------------------------
**START-OF-SELECTION.
*&amp;amp;---------------------------------------------------------------------
**DATA POPULATION
*&amp;amp;---------------------------------------------------------------------
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 .&amp;amp;---------------------------------------------------------------------
*POPULATE HEADER FLAG.&amp;amp;---------------------------------------------------------------------
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.&amp;amp;---------------------------------------------------------------------
*POPULATE ITEM DATA.&amp;amp;---------------------------------------------------------------------
ITEM-PO_ITEM = item_num.
ITEM-MATERIAL = material.
ITEM-PLANT = plant.
ITEM-QUANTITY = quantity.APPEND ITEM.&amp;amp;---------------------------------------------------------------------
*POPULATE ITEM FLAG TABLE&amp;amp;---------------------------------------------------------------------
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.&amp;amp;---------------------------------------------------------------------
*BAPI CALL&amp;amp;---------------------------------------------------------------------CALLFUNCTION'BAPI_PO_CREATE1'EXPORTING
POHEADER =HEADER
POHEADERX = HEADERX

POADDRVENDOR = 
TESTRUN =IMPORTING
EXPPURCHASEORDER = V_EXPPURCHASEORDER

EXPHEADER = 
EXPPOEXPIMPHEADER =TABLESRETURN=RETURN
POITEM = ITEM
POITEMX = ITEMX.&amp;amp;---------------------------------------------------------------------
*Confirm the document creation by calling database COMMIT&amp;amp;---------------------------------------------------------------------CALLFUNCTION'BAPI_TRANSACTION_COMMIT'EXPORTINGWAIT='X'IMPORTINGRETURN=.end-of-selection.
****&amp;amp;---------------------------------------------------------------------*
****Output the messages returned from BAPI call
****&amp;amp;---------------------------------------------------------------------*
*LOOP AT RETURN.WRITE/ v_EXPPURCHASEORDER.
*ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 May 2019 13:33:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928806#M1964464</guid>
      <dc:creator>DKanna</dc:creator>
      <dc:date>2019-05-12T13:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928807#M1964465</link>
      <description>&lt;P&gt;For "Change" BAPIs, X flags are used to distinguish those two cases:&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;clear object field (set the X flag)&lt;/LI&gt;&lt;LI&gt;do not change object field (do not set the X flag)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For "Create" BAPIs, X flags are used to distinguish those two cases (that's a guess):&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;value " " for object field (set the X flag)&lt;/LI&gt;&lt;LI&gt;keep default value proposed by SAP (do not set the X flag)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;(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)&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 13:59:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928807#M1964465</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-05-12T13:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928808#M1964466</link>
      <description>&lt;P&gt;...c_x = 'X'.&lt;/P&gt;&lt;P&gt;Not exactly the best constant definition I've seen. Could be worse I suppose, like &lt;/P&gt;&lt;P&gt;...c_x = 'Y'...&lt;/P&gt;</description>
      <pubDate>Sun, 12 May 2019 15:23:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928808#M1964466</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-05-12T15:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928809#M1964467</link>
      <description>&lt;P&gt;Did you try to read data element BAPIUPDATE documentaiton?&lt;/P&gt;</description>
      <pubDate>Mon, 13 May 2019 09:21:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928809#M1964467</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2019-05-13T09:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928810#M1964468</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you need to change the value  you should pass the X value . Ex: &lt;/P&gt;&lt;P&gt;If you need to update the company code &lt;/P&gt;&lt;P&gt;POHEADER-COMP_CODE = '1000'.&lt;/P&gt;&lt;P&gt;POHEADERX-COMP_CODE = 'X'.&lt;/P&gt;&lt;P&gt;If your not pass the parameter like 'X' , PO will not update the relevant field. &lt;/P&gt;&lt;P&gt;your C_X should be constant like &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CONSTANTS : C_X TYPE C VALUE 'X'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 May 2019 17:48:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928810#M1964468</guid>
      <dc:creator>Nawanandana</dc:creator>
      <dc:date>2019-05-13T17:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why we are using flags for bapi_po_create1</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928811#M1964469</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this bapi is well documented within SAP. Just go to se37, display and click Function Module Documentation button.&lt;/P&gt;&lt;P&gt;Kind regards, Rob Dielemans&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 10:26:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/why-we-are-using-flags-for-bapi-po-create1/m-p/11928811#M1964469</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-05-14T10:26:00Z</dc:date>
    </item>
  </channel>
</rss>

