<?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 Re: Bapi Usage in RFC Function Modules in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824825#M660903</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;function zvp_bapi_goodsmvt_create.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;"Local Interface:&lt;/P&gt;&lt;P&gt;*"  IMPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(PSTNGDATE) TYPE  BUDAT&lt;/P&gt;&lt;P&gt;*"     VALUE(DOCDATE) TYPE  BUDAT&lt;/P&gt;&lt;P&gt;*"     VALUE(GM_CODE) TYPE  GM_CODE&lt;/P&gt;&lt;P&gt;*"     VALUE(REF_DOC_NO) TYPE  XBLNR&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_HEADER) LIKE  BAPI2017_GM_HEAD_01 STRUCTURE&lt;/P&gt;&lt;P&gt;*"        BAPI2017_GM_HEAD_01&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_CODE) TYPE  BAPI2017_GM_CODE&lt;/P&gt;&lt;P&gt;*"     VALUE(TESTRUN) LIKE  BAPI2017_GM_GEN-TESTRUN DEFAULT SPACE&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_REF_EWM) LIKE  /SPE/BAPI2017_GM_REF_EWM STRUCTURE&lt;/P&gt;&lt;P&gt;*"        /SPE/BAPI2017_GM_REF_EWM OPTIONAL&lt;/P&gt;&lt;P&gt;*"  EXPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_HEADRET) LIKE  BAPI2017_GM_HEAD_RET STRUCTURE&lt;/P&gt;&lt;P&gt;*"        BAPI2017_GM_HEAD_RET&lt;/P&gt;&lt;P&gt;*"     VALUE(MATERIALDOCUMENT) TYPE  BAPI2017_GM_HEAD_RET-MAT_DOC&lt;/P&gt;&lt;P&gt;*"     VALUE(MATDOCUMENTYEAR) TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR&lt;/P&gt;&lt;P&gt;*"  TABLES&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_ITEM STRUCTURE  BAPI2017_GM_ITEM_CREATE&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_SERIALNUMBER STRUCTURE  BAPI2017_GM_SERIALNUMBER&lt;/P&gt;&lt;P&gt;*"       OPTIONAL&lt;/P&gt;&lt;P&gt;*"      RETURN STRUCTURE  BAPIRET2&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_SERV_PART_DATA STRUCTURE&lt;/P&gt;&lt;P&gt;*"        /SPE/BAPI2017_SERVICEPART_DATA OPTIONAL&lt;/P&gt;&lt;P&gt;*"      EXTENSIONIN STRUCTURE  BAPIPAREX OPTIONAL&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_ITEM_CWM STRUCTURE  /CWM/BAPI2017_GM_ITEM_CREATE&lt;/P&gt;&lt;P&gt;*"       OPTIONAL&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  goodsmvt_header-pstng_date = pstngdate.&lt;/P&gt;&lt;P&gt;  goodsmvt_header-doc_date   = docdate.&lt;/P&gt;&lt;P&gt;  "APPEND goodsmvt_header.&lt;/P&gt;&lt;P&gt;  goodsmvt_header-ref_doc_no = ref_doc_no.&lt;/P&gt;&lt;P&gt;    goodsmvt_code-gm_code    = gm_code.&lt;/P&gt;&lt;P&gt;  "APPEND goodsmvt_code.&lt;/P&gt;&lt;P&gt;  call function 'BAPI_GOODSMVT_CREATE'&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;      goodsmvt_header         = goodsmvt_header&lt;/P&gt;&lt;P&gt;      goodsmvt_code           = goodsmvt_code&lt;/P&gt;&lt;P&gt;      testrun                 = testrun&lt;/P&gt;&lt;P&gt;      goodsmvt_ref_ewm        = goodsmvt_ref_ewm&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;      goodsmvt_headret        = goodsmvt_headret&lt;/P&gt;&lt;P&gt;      materialdocument        = materialdocument&lt;/P&gt;&lt;P&gt;      matdocumentyear         = matdocumentyear&lt;/P&gt;&lt;P&gt;    tables&lt;/P&gt;&lt;P&gt;      goodsmvt_item           = goodsmvt_item&lt;/P&gt;&lt;P&gt;      goodsmvt_serialnumber   = goodsmvt_serialnumber&lt;/P&gt;&lt;P&gt;      return                  = return&lt;/P&gt;&lt;P&gt;      goodsmvt_serv_part_data = goodsmvt_serv_part_data&lt;/P&gt;&lt;P&gt;      extensionin             = extensionin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if not return-type = 'E' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    update zvp_vendespatch set   vdflag = 'X'&lt;/P&gt;&lt;P&gt;                           where ebeln = goodsmvt_item-po_number&lt;/P&gt;&lt;P&gt;                           and xblnr = goodsmvt_header-ref_doc_no.&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      return-type     = 'I'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Record updated Succesfully'.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;      clear return.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      return-type     = 'E'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Record not updated '.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if return-type = 'E'.&lt;/P&gt;&lt;P&gt;      return-type     = 'I'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Document not posted'.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endfunction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi i have called this function module to update the z table, have a look  at this ,&lt;/P&gt;&lt;P&gt; i think u ll get some idea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2007 08:51:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-09-20T08:51:09Z</dc:date>
    <item>
      <title>Bapi Usage in RFC Function Modules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824824#M660902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hie there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone sent me sample code for the usage of a BAPI in a Function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want ot develop an RFC whereby i pass an Account number to it and get the BP addressess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The structures which i intend to use for this functionality is&lt;/P&gt;&lt;P&gt;1. Tablble say T_XXXX  (this contains the Accnt Number )&lt;/P&gt;&lt;P&gt;2. from this Account number i intend to  intend to pass it into a BAPI say BAPI_BCA_XXXXXX1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Import&lt;/P&gt;&lt;P&gt;  Accnt Number&lt;/P&gt;&lt;P&gt;Export&lt;/P&gt;&lt;P&gt; Accnt number&lt;/P&gt;&lt;P&gt;  BP Number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from this result of this Bapi i intend to use the result above&lt;/P&gt;&lt;P&gt;i.e BP # &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in another BApi BAPI _ADRESS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Import&lt;/P&gt;&lt;P&gt;BP #&lt;/P&gt;&lt;P&gt;Export&lt;/P&gt;&lt;P&gt;AddressData.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This structure ADDRESSDATA is the overall structure which should come out from the RFC Function Module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample code for similar scenarios will be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points rewarded&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:39:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824824#M660902</guid>
      <dc:creator>former_member746838</dc:creator>
      <dc:date>2007-09-20T08:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi Usage in RFC Function Modules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824825#M660903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;function zvp_bapi_goodsmvt_create.&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;"Local Interface:&lt;/P&gt;&lt;P&gt;*"  IMPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(PSTNGDATE) TYPE  BUDAT&lt;/P&gt;&lt;P&gt;*"     VALUE(DOCDATE) TYPE  BUDAT&lt;/P&gt;&lt;P&gt;*"     VALUE(GM_CODE) TYPE  GM_CODE&lt;/P&gt;&lt;P&gt;*"     VALUE(REF_DOC_NO) TYPE  XBLNR&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_HEADER) LIKE  BAPI2017_GM_HEAD_01 STRUCTURE&lt;/P&gt;&lt;P&gt;*"        BAPI2017_GM_HEAD_01&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_CODE) TYPE  BAPI2017_GM_CODE&lt;/P&gt;&lt;P&gt;*"     VALUE(TESTRUN) LIKE  BAPI2017_GM_GEN-TESTRUN DEFAULT SPACE&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_REF_EWM) LIKE  /SPE/BAPI2017_GM_REF_EWM STRUCTURE&lt;/P&gt;&lt;P&gt;*"        /SPE/BAPI2017_GM_REF_EWM OPTIONAL&lt;/P&gt;&lt;P&gt;*"  EXPORTING&lt;/P&gt;&lt;P&gt;*"     VALUE(GOODSMVT_HEADRET) LIKE  BAPI2017_GM_HEAD_RET STRUCTURE&lt;/P&gt;&lt;P&gt;*"        BAPI2017_GM_HEAD_RET&lt;/P&gt;&lt;P&gt;*"     VALUE(MATERIALDOCUMENT) TYPE  BAPI2017_GM_HEAD_RET-MAT_DOC&lt;/P&gt;&lt;P&gt;*"     VALUE(MATDOCUMENTYEAR) TYPE  BAPI2017_GM_HEAD_RET-DOC_YEAR&lt;/P&gt;&lt;P&gt;*"  TABLES&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_ITEM STRUCTURE  BAPI2017_GM_ITEM_CREATE&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_SERIALNUMBER STRUCTURE  BAPI2017_GM_SERIALNUMBER&lt;/P&gt;&lt;P&gt;*"       OPTIONAL&lt;/P&gt;&lt;P&gt;*"      RETURN STRUCTURE  BAPIRET2&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_SERV_PART_DATA STRUCTURE&lt;/P&gt;&lt;P&gt;*"        /SPE/BAPI2017_SERVICEPART_DATA OPTIONAL&lt;/P&gt;&lt;P&gt;*"      EXTENSIONIN STRUCTURE  BAPIPAREX OPTIONAL&lt;/P&gt;&lt;P&gt;*"      GOODSMVT_ITEM_CWM STRUCTURE  /CWM/BAPI2017_GM_ITEM_CREATE&lt;/P&gt;&lt;P&gt;*"       OPTIONAL&lt;/P&gt;&lt;P&gt;*"----&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  goodsmvt_header-pstng_date = pstngdate.&lt;/P&gt;&lt;P&gt;  goodsmvt_header-doc_date   = docdate.&lt;/P&gt;&lt;P&gt;  "APPEND goodsmvt_header.&lt;/P&gt;&lt;P&gt;  goodsmvt_header-ref_doc_no = ref_doc_no.&lt;/P&gt;&lt;P&gt;    goodsmvt_code-gm_code    = gm_code.&lt;/P&gt;&lt;P&gt;  "APPEND goodsmvt_code.&lt;/P&gt;&lt;P&gt;  call function 'BAPI_GOODSMVT_CREATE'&lt;/P&gt;&lt;P&gt;    exporting&lt;/P&gt;&lt;P&gt;      goodsmvt_header         = goodsmvt_header&lt;/P&gt;&lt;P&gt;      goodsmvt_code           = goodsmvt_code&lt;/P&gt;&lt;P&gt;      testrun                 = testrun&lt;/P&gt;&lt;P&gt;      goodsmvt_ref_ewm        = goodsmvt_ref_ewm&lt;/P&gt;&lt;P&gt;    importing&lt;/P&gt;&lt;P&gt;      goodsmvt_headret        = goodsmvt_headret&lt;/P&gt;&lt;P&gt;      materialdocument        = materialdocument&lt;/P&gt;&lt;P&gt;      matdocumentyear         = matdocumentyear&lt;/P&gt;&lt;P&gt;    tables&lt;/P&gt;&lt;P&gt;      goodsmvt_item           = goodsmvt_item&lt;/P&gt;&lt;P&gt;      goodsmvt_serialnumber   = goodsmvt_serialnumber&lt;/P&gt;&lt;P&gt;      return                  = return&lt;/P&gt;&lt;P&gt;      goodsmvt_serv_part_data = goodsmvt_serv_part_data&lt;/P&gt;&lt;P&gt;      extensionin             = extensionin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  commit work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  if not return-type = 'E' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    update zvp_vendespatch set   vdflag = 'X'&lt;/P&gt;&lt;P&gt;                           where ebeln = goodsmvt_item-po_number&lt;/P&gt;&lt;P&gt;                           and xblnr = goodsmvt_header-ref_doc_no.&lt;/P&gt;&lt;P&gt;    if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      return-type     = 'I'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Record updated Succesfully'.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;      clear return.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      return-type     = 'E'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Record not updated '.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  else.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if return-type = 'E'.&lt;/P&gt;&lt;P&gt;      return-type     = 'I'.&lt;/P&gt;&lt;P&gt;      return-message  = 'Document not posted'.&lt;/P&gt;&lt;P&gt;      append return.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;endfunction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hi i have called this function module to update the z table, have a look  at this ,&lt;/P&gt;&lt;P&gt; i think u ll get some idea&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:51:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824825#M660903</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T08:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi Usage in RFC Function Modules</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824826#M660904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;See this steps and do accordingly&lt;/P&gt;&lt;P&gt;RFC (Remote Function Call) is similar to the general SAP fun module: except that in the attributes you click the radio button: RFC enabled;&lt;/P&gt;&lt;P&gt;and you will be passing an Import parameter DESTINATION to it.&lt;/P&gt;&lt;P&gt;Other code and usage will be similar to any fun module;&lt;/P&gt;&lt;P&gt;Have a look at any fun module in SE37 to understand better about the different components of Fun modules;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer this link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/22/042518488911d189490000e829fbbd/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/22/042518488911d189490000e829fbbd/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BAPI&lt;/P&gt;&lt;P&gt;BAPI Step by step Guidance &lt;/P&gt;&lt;P&gt;BAPI stands for Business Application Programming Interface. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are 5 different steps in BAPI. &lt;/P&gt;&lt;P&gt;- Create BAPI Structure &lt;/P&gt;&lt;P&gt;- Create BAPI Function Module or API Method. &lt;/P&gt;&lt;P&gt;- Create BAPI object &lt;/P&gt;&lt;P&gt;- Release BAPI Function Module. &lt;/P&gt;&lt;P&gt;- Release BAPI object. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step1.&lt;/P&gt;&lt;P&gt;Creating BAPI Structure: &lt;/P&gt;&lt;P&gt;- Go to &amp;lt;SE11&amp;gt;. &lt;/P&gt;&lt;P&gt;- Select Data Type &amp;amp; Enter a name. &lt;/P&gt;&lt;P&gt;- Click on Create. &lt;/P&gt;&lt;P&gt;- Note: Always BAPI should be in a development class with request number (Not Local Object). &lt;/P&gt;&lt;P&gt;- Select Structure &amp;amp; hit ENTER. &lt;/P&gt;&lt;P&gt;- Enter the fields from your database. Make sure that the first field is the Primary Key Field. &lt;/P&gt;&lt;P&gt;- Then SAVE &amp;amp; ACTIVATE. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 2. &lt;/P&gt;&lt;P&gt;Creating BAPI module: &lt;/P&gt;&lt;P&gt;- Enter TR.CODE &amp;lt;SE37&amp;gt;. &lt;/P&gt;&lt;P&gt;- Before entering any thing, from the present screen that you are in, select the menu &lt;/P&gt;&lt;P&gt;Goto -&amp;gt; Function Groups -&amp;gt; Create Group. &lt;/P&gt;&lt;P&gt;Enter a name (Note: This name Must start with ZBAPI) &lt;/P&gt;&lt;P&gt;Let this screen be as it is and open another window and there, enter TR.CODE &amp;lt;SE80). &lt;/P&gt;&lt;P&gt;Click on the Third ICON that says Inactive Objects. &lt;/P&gt;&lt;P&gt;Select the group that you just created and click on Activate. &lt;/P&gt;&lt;P&gt;Notice that the group you created will disappear from the list of inactive objects. &lt;/P&gt;&lt;P&gt;- Go back to &amp;gt;&amp;lt;SE37&amp;gt; screen and enter a name and hit &amp;lt;ENTER&amp;gt;. Then enter the group name that you just created and activated. &lt;/P&gt;&lt;P&gt;NOTE: When you release a function module the respective group will be attached to that particular application. It cannot be used for any other application. NEVER include an already existing group that is attached to another module. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now click on the first Tab that says [ATTRIBUTES] and select the radio button that says remote-enabled module since we will be accessing this from any external system. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then click on the second tab that says [IMPORT]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enter a PARAMETER NAME, TYPE and the structure you created in the first step. Also select the check box &amp;#145;Pa&amp;#146;. All remotely enabled functional modules MUST be Pa enabled, where Pa means &amp;#145;Passed by Value&amp;#146; and if you don&amp;#146;t select &amp;#145;Pa&amp;#146;, then that means it will be passed by reference.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then click on tab that says [EXPORT]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enter the following as is in the first three fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RETURN TYPE BAPIRETURN (These 3 field values are always same) &lt;/P&gt;&lt;P&gt;Here also select &amp;#145;Pa&amp;#146; meaning Pass by value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: BAPIRETURN contains structure with message fields. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then SAVE and ACTIVATE. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Step 3. &lt;/P&gt;&lt;P&gt;Creating BAPI object: &lt;/P&gt;&lt;P&gt;- Enter Tr.Code &amp;lt;SWO1&amp;gt; (Note. It is letter &amp;#145;O&amp;#146; and not Zero). &lt;/P&gt;&lt;P&gt;- Enter a name and then click on create. Enter details. &lt;/P&gt;&lt;P&gt;NOTE: Make sure that that Object Type and Program name are SAME. &lt;/P&gt;&lt;P&gt;- Enter Application &amp;#145;M&amp;#146;, if you are using standard table Mara. If you are using your own database then select &amp;#145;Z&amp;#146; at the bottom. &lt;/P&gt;&lt;P&gt;- Then hit &amp;lt;ENTER&amp;gt;. &lt;/P&gt;&lt;P&gt;- Now we have to add &amp;#145;Methods&amp;#146;. High light METHODS and then select the following from the menu: &lt;/P&gt;&lt;P&gt;Goto Utilities -&amp;gt; API Methods -&amp;gt; Add Methods. &lt;/P&gt;&lt;P&gt;- Enter function Module name and hit &amp;lt;ENTER&amp;gt;. &lt;/P&gt;&lt;P&gt;- Select the second FORWARD ARROW button (&amp;gt;)to go to next step. &lt;/P&gt;&lt;P&gt;- Check if every thing looks ok and again click on FORWARD ARROW button (&amp;gt;). &lt;/P&gt;&lt;P&gt;- Then select &amp;#145;YES&amp;#146; and click on &amp;lt;SAVE&amp;gt;. &lt;/P&gt;&lt;P&gt;- Now on a different screen goto TR.CODE &amp;lt;SE37&amp;gt;. Enter Function Module name and select from the top menu Function Module -&amp;gt; Release -&amp;gt; Release. &lt;/P&gt;&lt;P&gt;- Goback to TR.CODE &amp;lt;SWO1&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here select the menu combination shown below in the same order. &lt;/P&gt;&lt;P&gt;- Edit -&amp;gt; Change Release Status -&amp;gt; Object Type Component -&amp;gt; To Implemented. &lt;/P&gt;&lt;P&gt;- Edit -&amp;gt; Change Release Status -&amp;gt; Object Type Component -&amp;gt; To Released. &lt;/P&gt;&lt;P&gt;- Edit -&amp;gt; Change Release Status -&amp;gt; Object Type -&amp;gt; To Implemented. &lt;/P&gt;&lt;P&gt;- Edit -&amp;gt; Change Release Status -&amp;gt; Object Type -&amp;gt; To Released. &lt;/P&gt;&lt;P&gt;- Then click on &amp;lt;SAVE&amp;gt;. &lt;/P&gt;&lt;P&gt;- Then click on Generate Button (4th button from left hand side looks like spinning wheel). &lt;/P&gt;&lt;P&gt;- Then Click on the button that says &amp;#145;PROGRAM&amp;#146; to see the source code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check if this is present in work flow goto TR.CODE &amp;lt;BAPI&amp;gt;. &lt;/P&gt;&lt;P&gt;Here it shows business object repository. &lt;/P&gt;&lt;P&gt;- First click on the middle button and then select &amp;#147;ALL&amp;#148; and hit ENTER. &lt;/P&gt;&lt;P&gt;- Goto tab [ALPHABETICAL] and look for the object that you created. This shows that the BAPI object has been created successfully. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code&lt;/P&gt;&lt;P&gt;Check this example of creating a sales order and for creating delivery...and PGI&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************SALES ORDER INPUT CREATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_auart TYPE auart OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_spart TYPE vtweg OBLIGATORY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_sold TYPE kunnr OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_ship TYPE kunnr OBLIGATORY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*ITEM&lt;/P&gt;&lt;P&gt;PARAMETERS: p_matnr TYPE matnr OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_plant TYPE werks_d OBLIGATORY.&lt;/P&gt;&lt;P&gt;PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;DATA DECLARATIONS.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DATA: v_vbeln LIKE vbak-vbeln.&lt;/P&gt;&lt;P&gt;DATA: header LIKE bapisdhead1.&lt;/P&gt;&lt;P&gt;DATA: headerx LIKE bapisdhead1x.&lt;/P&gt;&lt;P&gt;DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx&lt;/P&gt;&lt;P&gt;WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl&lt;/P&gt;&lt;P&gt;WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;HEADER DATA&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;header-doc_type = p_auart.&lt;/P&gt;&lt;P&gt;headerx-doc_type = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;header-sales_org = p_vkorg.&lt;/P&gt;&lt;P&gt;headerx-sales_org = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;header-distr_chan = p_vtweg.&lt;/P&gt;&lt;P&gt;headerx-distr_chan = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;header-division = p_spart.&lt;/P&gt;&lt;P&gt;headerx-division = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;headerx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;PARTNER DATA&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;partner-partn_role = 'AG'.&lt;/P&gt;&lt;P&gt;partner-partn_numb = p_sold.&lt;/P&gt;&lt;P&gt;APPEND partner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;partner-partn_role = 'WE'.&lt;/P&gt;&lt;P&gt;partner-partn_numb = p_ship.&lt;/P&gt;&lt;P&gt;APPEND partner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;ITEM DATA&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;itemx-updateflag = 'I'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-itm_number = '000010'.&lt;/P&gt;&lt;P&gt;itemx-itm_number = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-material = p_matnr.&lt;/P&gt;&lt;P&gt;itemx-material = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-plant = p_plant.&lt;/P&gt;&lt;P&gt;itemx-plant = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-target_qty = p_menge.&lt;/P&gt;&lt;P&gt;itemx-target_qty = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-target_qu = 'EA'.&lt;/P&gt;&lt;P&gt;itemx-target_qu = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item-item_categ = p_itcat.&lt;/P&gt;&lt;P&gt;itemx-item_categ = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND item.&lt;/P&gt;&lt;P&gt;APPEND itemx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill schedule lines&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;lt_schedules_in-itm_number = '000010'.&lt;/P&gt;&lt;P&gt;lt_schedules_in-sched_line = '0001'.&lt;/P&gt;&lt;P&gt;lt_schedules_in-req_qty = p_menge.&lt;/P&gt;&lt;P&gt;APPEND lt_schedules_in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill schedule line flags&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;lt_schedules_inx-itm_number = '000010'.&lt;/P&gt;&lt;P&gt;lt_schedules_inx-sched_line = '0001'.&lt;/P&gt;&lt;P&gt;lt_schedules_inx-updateflag = 'X'.&lt;/P&gt;&lt;P&gt;lt_schedules_inx-req_qty = 'X'.&lt;/P&gt;&lt;P&gt;APPEND lt_schedules_inx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Call the BAPI&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;sales_header_in = header&lt;/P&gt;&lt;P&gt;sales_header_inx = headerx&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;salesdocument_ex = v_vbeln&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;return = return&lt;/P&gt;&lt;P&gt;sales_items_in = item&lt;/P&gt;&lt;P&gt;sales_items_inx = itemx&lt;/P&gt;&lt;P&gt;sales_schedules_in = lt_schedules_in&lt;/P&gt;&lt;P&gt;sales_schedules_inx = lt_schedules_inx&lt;/P&gt;&lt;P&gt;sales_partners = partner.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Check the return table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT return WHERE type = 'E' OR type = 'A'.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE: / 'Error in creating document'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK AND WAIT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE: / 'Document ', v_vbeln, ' created'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************DELIVERY CREATION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF t_vbap OCCURS 0,&lt;/P&gt;&lt;P&gt;vbeln LIKE vbap-vbeln,&lt;/P&gt;&lt;P&gt;posnr LIKE vbap-posnr,&lt;/P&gt;&lt;P&gt;zmeng LIKE vbap-kwmeng,&lt;/P&gt;&lt;P&gt;matnr LIKE vbap-matnr,&lt;/P&gt;&lt;P&gt;werks LIKE vbap-werks,&lt;/P&gt;&lt;P&gt;END OF t_vbap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: t_request TYPE STANDARD TABLE OF bapideliciousrequest&lt;/P&gt;&lt;P&gt;WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: t_created TYPE STANDARD TABLE OF bapideliciouscreateditems&lt;/P&gt;&lt;P&gt;WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT vbeln posnr zmeng matnr werks&lt;/P&gt;&lt;P&gt;INTO TABLE t_vbap&lt;/P&gt;&lt;P&gt;FROM vbap&lt;/P&gt;&lt;P&gt;WHERE vbeln = v_vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_vbap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_request-document_numb = t_vbap-vbeln.&lt;/P&gt;&lt;P&gt;t_request-document_item = t_vbap-posnr.&lt;/P&gt;&lt;P&gt;t_request-quantity_sales_uom = t_vbap-zmeng.&lt;/P&gt;&lt;P&gt;t_request-quantity_base__uom = t_vbap-zmeng.&lt;/P&gt;&lt;P&gt;t_request-id = 1.&lt;/P&gt;&lt;P&gt;t_request-document_type = 'A'.&lt;/P&gt;&lt;P&gt;t_request-delivery_date = sy-datum.&lt;/P&gt;&lt;P&gt;t_request-material = t_vbap-matnr.&lt;/P&gt;&lt;P&gt;t_request-plant = t_vbap-werks.&lt;/P&gt;&lt;P&gt;t_request-date = sy-datum.&lt;/P&gt;&lt;P&gt;t_request-goods_issue_date = sy-datum.&lt;/P&gt;&lt;P&gt;t_request-goods_issue_time = sy-uzeit.&lt;/P&gt;&lt;P&gt;APPEND t_request.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;request = t_request&lt;/P&gt;&lt;P&gt;createditems = t_created&lt;/P&gt;&lt;P&gt;return = t_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE t_return WITH KEY type = 'E'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;MESSAGE e208(00) WITH 'Delivery creation error'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;************Post goods issue.&lt;/P&gt;&lt;P&gt;READ TABLE t_created INDEX 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: vbkok_wa TYPE vbkok.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vbkok_wa-vbeln_vl = t_created-document_numb.&lt;/P&gt;&lt;P&gt;vbkok_wa-wabuc = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: v_error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'WS_DELIVERY_UPDATE'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;vbkok_wa = vbkok_wa&lt;/P&gt;&lt;P&gt;delivery = t_created-document_numb&lt;/P&gt;&lt;P&gt;IMPORTING&lt;/P&gt;&lt;P&gt;ef_error_in_goods_issue_0 = v_error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COMMIT WORK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2007 08:55:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-usage-in-rfc-function-modules/m-p/2824826#M660904</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-20T08:55:46Z</dc:date>
    </item>
  </channel>
</rss>

