<?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 Bapi in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989748#M706097</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;   Can anybody give me step by step guide as how to use bapis that are already existing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;abaper&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Nov 2007 16:09:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-11-01T16:09:52Z</dc:date>
    <item>
      <title>Bapi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989748#M706097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;   Can anybody give me step by step guide as how to use bapis that are already existing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;abaper&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 16:09:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989748#M706097</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-01T16:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989749#M706098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to understand how BAPIs work you need to know how the corresponding transaction works and which are its mandatory input values. For example, BAPI_USER_CREATE1 corresponds to transaction SU01 (Create SAP user). To create a user in dialog you need to provide at least&lt;/P&gt;&lt;P&gt;- last name&lt;/P&gt;&lt;P&gt;- password&lt;/P&gt;&lt;P&gt;- user type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The same mandatory input needs to be fed to the BAPI's interface. Therefore, I like to describe BAPI's as &amp;lt;i&amp;gt;"dialog without dialog"&amp;lt;/i&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In contrast to normal (RFC-enabled) function modules BAPIs never raise any exceptions. Instead, they collect the messages and return them, usually as TABLES parameter (e.g. RETURN of type BAPIRET2).&lt;/P&gt;&lt;P&gt;Most BAPIs do not execute a commit work. Thus, if the returned messages do not indicate any problem you have to commit work yourself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example of a remotely called BAPI:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  CALL FUNCTION 'BAPI_USER_CREATE1'  destination '&amp;lt;rfc destination&amp;gt;'
     EXPORTING
       ...
     IMPORTING
       ...
     TABLES
       return = lt_return
     EXCEPTIONS
       system_failure            = 1 MESSAGE ld_rfc_msg
       communication_failure = 2 MESSAGE ld_rfc_msg.
" Note: when the BAPI is called via RFC add the default exceptions for RFC-calls

  IF ( syst-subrc NE 0 ).
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'  
          destination '&amp;lt;rfc destination&amp;gt;'.

  ELSE.
    LOOP AT lt_return TRANSPORTING NO FIELDS
                   WHERE ( type CA 'AEX' ).  " abort, error, dump message
      EXIT.
    ENDLOOP.
    IF ( syst-subrc = 0 ).
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'  
          destination '&amp;lt;rfc destination&amp;gt;'.
    ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  
          destination '&amp;lt;rfc destination&amp;gt;'
        EXPORTING
          wait = 'X'.   " 'X' = synchronous, ' ' = asynchronous
    ENDIF.

  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note that when you call BAPIs remotely you have to do data conversion (external -&amp;gt; internal) yourself. For example, if you use BAPI_MATERIAL_SAVEDATA then you have to convert an external material number (e.g. '12345678') into the internal format with leading zeros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2007 19:54:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989749#M706098</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-11-01T19:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Bapi</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989750#M706099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abap,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go to the below link for BAPI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm"&amp;gt;Bapi_help_link&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to use a standard Bapi is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Go to SE37 give the BAPI name and see its documentation.&lt;/P&gt;&lt;P&gt;2. Assert which parameters are mandatory&lt;/P&gt;&lt;P&gt;3. Execute the bapi and give test data&lt;/P&gt;&lt;P&gt;4. It should create a record with your test data&lt;/P&gt;&lt;P&gt;5. Then send the same data in the same order programatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am giving the code below for your reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZBAPI_CREATE_PO                                             *
*&amp;amp;                                                                     *
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Program demonstrates the BAPI call to create Purchase Order         *
*&amp;amp; Minimum required parameters are used are as per the current         *
*&amp;amp; system configuration                                                *
*&amp;amp;---------------------------------------------------------------------*
REPORT  ZBAPI_CREATE_PO                         .
*&amp;amp;---------------------------------------------------------------------*
*DATA DECLARATION
CONSTANTS : C_X VALUE 'X'.

*Structures to hold PO header data
DATA : HEADER LIKE  BAPIMEPOHEADER   ,
       HEADERX LIKE  BAPIMEPOHEADERX .

*Internal Tables to hold PO ITEM DATA
DATA : ITEM   LIKE BAPIMEPOITEM  OCCURS 0 WITH HEADER LINE,
       ITEMX  LIKE BAPIMEPOITEMX OCCURS 0 WITH HEADER LINE,

*Internal table to hold messages from BAPI call
       RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
data : w_header(40) value 'PO Header'.

data : ws_langu like sy-langu.

*text-001 = 'PO Header' - define as text element
selection-screen begin of block b1 with frame title text-001.
parameters : company like header-comp_code  default '2700'      ,
             doctyp  like HEADER-DOC_TYPE   default 'NB'        ,
             cdate   like HEADER-CREAT_DATE default sy-datum    ,
             vendor  like HEADER-VENDOR     default '0010000023',
             pur_org like HEADER-PURCH_ORG  default '2700'      ,
             pur_grp like HEADER-PUR_GROUP  default '001'       .

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text-002.
parameters : item_num like ITEM-PO_ITEM  default '00001',
             material like ITEM-MATERIAL default 'CRANE'   ,
             plant    like ITEM-PLANT    default '2700' ,
             quantity like ITEM-QUANTITY default 100.

selection-screen end of block b2.



*&amp;amp;---------------------------------------------------------------------*
START-OF-SELECTION.
*&amp;amp;---------------------------------------------------------------------*
*DATA POPULATION
*&amp;amp;---------------------------------------------------------------------*
ws_langu = sy-langu.   "Language variable

*POPULATE HEADER DATA FOR PO
HEADER-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;---------------------------------------------------------------------*
CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING
    POHEADER                     = HEADER
    POHEADERX                    = HEADERX
*   POADDRVENDOR                 =
*   TESTRUN                      =
* IMPORTING
*   EXPPURCHASEORDER             =
*   EXPHEADER                    =
*   EXPPOEXPIMPHEADER            =
 TABLES
   RETURN                       = RETURN
   POITEM                       = ITEM
   POITEMX                      = ITEMX.

*&amp;amp;---------------------------------------------------------------------*
*Confirm the document creation by calling database COMMIT
*&amp;amp;---------------------------------------------------------------------*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 EXPORTING
   WAIT          = 'X'
* IMPORTING
*   RETURN        =
          .

end-of-selection.
*&amp;amp;---------------------------------------------------------------------*
*Output the messages returned from BAPI call
*&amp;amp;---------------------------------------------------------------------*
LOOP AT RETURN.
 WRITE / RETURN-MESSAGE.
ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if useful,&lt;/P&gt;&lt;P&gt;Aleem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2007 03:43:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi/m-p/2989750#M706099</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-02T03:43:56Z</dc:date>
    </item>
  </channel>
</rss>

