Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI Extension Structures

Former Member
0 Likes
11,089

Hi All,

Can any body tell me how to find the BAPI Extension structures for a BAPI. for example BAPI_TE_MEPOHEADER and BAPI_TE_MEPOITEM in case of BAPI_PO_CREATE1. Also i found the statement in the SCN thread i.e BAPIPAREX+30 =  BAPI_TE_MARA in a sample code.what does it mean. I would like to know how to Use Extensionin and Extensionout parameters with example.

Thanks in advance

Mallikarjun Reddy G

5 REPLIES 5
Read only

Former Member
0 Likes
5,303

Custom fields may be passed using EXTENSIONIN and EXTENSIONOUT parameters of the BAPI function module. This example in SAP Library shows how to fill EXTENSIONIN when there are few custom fields, as SAP says in its example: "take care that you have 960 bytes in pieces of 240 byte. Luckily we have less than 240 byte so we need only one move".

So that to work all the time, you may call the following routine to ease the initialization of EXTENSIONIN parameter:

DATA ls_extensionin TYPE bapiparex.

DATA lt_extensionin TYPE TABLE OF bapiparex.

DATA ls_extensioninx TYPE bapiparex.

DATA lt_extensioninx TYPE TABLE OF bapiparex.

DATA ls_bapi_te_mara TYPE bapi_te_mara.

DATA ls_bapi_te_marax TYPE bapi_te_marax.

ls_extensionin-structure = 'BAPI_TE_MARA'.

ls_bapi_te_mara-material = lv_matnr.

ls_bapi_te_mara-zzfld01  = lv_zzfld01.

ls_bapi_te_mara-zzfld02  = lv_zzfld02.

PERFORM transfer_to_extensionin USING ls_bapi_te_mara CHANGING ls_extensionin.

APPEND ls_extensionin TO lt_extensionin.

ls_extensioninx-structure = 'BAPI_TE_MARAX'.

ls_bapi_te_marax-material = lv_matnr.

ls_bapi_te_marax-zzfld01  = 'X'.

ls_bapi_te_marax-zzfld02  = 'X'.

PERFORM transfer_to_extensionin USING ls_bapi_te_marax CHANGING lt_extensioninx.

APPEND ls_extensioninx TO lt_extensioninx.

Read only

Former Member
0 Likes
5,303

REPORT REPORT_TRAVELAGENCY .

************************************************************************

* *

* Example to show how to fill the EXTENSION_IN Structure in a BAPI *

* which uses table extension as possibility for a customer to extend *

* SAP functionality without modification. *

* *

* In this example we use the BAPI *

* BAPI_TRAVELAGENCY_CREATE *

* *

************************************************************************

data x_agencynumber type bapisadeta-agencynum.

data x_agencydata_in type bapisadtin.

data x_cus_data_in type travelag.

data begin of x_extensionin occurs 0.

include structure bapiparex.

data end of x_extensionin.

data begin of x_return occurs 0.

include structure bapiret2.

data end of x_return.

data x_bapi_te_sa type bapi_te_sa.

* only for this example we hardcode the data, normally you would

* write an own transaction to fill this fields.

x_agencydata_in-name = 'Galactic Travel Agency'.

x_agencydata_in-street = 'Lunatic'.

x_agencydata_in-postbox = '123456'.

x_agencydata_in-postcode = '984735'.

x_agencydata_in-city = 'Luna 1'.

x_agencydata_in-country = 'Moon'.

x_agencydata_in-region = 'Moon'.

x_agencydata_in-telephone = '30457584375374957'.

x_agencydata_in-url = 'http://lunatic.com'.

x_agencydata_in-langu = 'E'.

x_cus_data_in-planetype = 'Space Shuttle'.

x_cus_data_in-company = 'Moon Shuttle Service'.

x_cus_data_in-seatsmax = 24.

* now fill the key of the extension parameter

move 'BAPI_TE_SA' to x_extensionin-structure.

* now normally you fill the object key into the BAPI_TE_SA structure

* but in this case the create will give internal the key for the new

* travel agency, so here only a clear

clear x_bapi_te_sa-agencynum.

* but the other fields we have, so fill

move-corresponding x_cus_data_in to x_bapi_te_sa.

* fill the fields in the data part of x_extension in, take care that

* you have 960 bytes in pieces of 240 byte. Luckily we have less than

* 240 byte so we need only one move.

move x_bapi_te_sa to x_extensionin-valuepart1.

append x_extensionin.

CALL FUNCTION 'BAPI_TRAVELAGENCY_CREATE'

EXPORTING

AGENCYDATA_IN = x_agencydata_in

IMPORTING

AGENCYNUMBER = x_agencynumber

TABLES

EXTENSIONIN = x_extensionin

RETURN = x_return.

.

*

write : / 'Return messages in handling the bapi.'.

loop at x_return.

write : / 'return..:', x_return.

endloop.

write : / 'The new travel agency has the number...:', x_agencynumber.

Read only

Former Member
0 Likes
5,303

Another example with Sales Order BAPI.

data: lv_salesdocument like  bapivbeln-vbeln,
    ls_order_header_in    
type bapisdhd1 ,
       ls_order_header_inx   
type bapisdhd1x,
       lt_return       
type table of bapiret2   with header line,
       lt_items_in     
type table of bapisditm  with header line,
       lt_items_inx    
type table of bapisditmx with header line,
       lt_partners     
type table of bapiparnr  with header line,
       lt_schedules_in 
type table of bapischdl  with header line,
       lt_schedules_inx
type table of bapischdlx with header line,
       lt_order_conditions_in
type table of bapicond with header line,
       lt_order_conditions_inx
type table of bapicondx with header line,
       lt_extensionin 
type table of bapiparex with header line,
       lwa_extensionin 
type   bapiparex ,
       lt_bape_vbap
type table of bape_vbap with header line,
       lwa_bape_vbap
type bape_vbap,
       lt_bape_vbapx
type table of bape_vbapx with header line,
       lwa_bape_vbapx
type bape_vbapx.              

               ls_order_header_in-doc_type   = 'Z001'.
        ls_order_header_in-sales_org  =
'1000'.
        ls_order_header_in-distr_chan =
'20'.
        ls_order_header_in-division   =
'01'.
        ls_order_header_in-sales_off  =
'0010'.
        ls_order_header_in-purch_no_c =
'10000001'.
        ls_order_header_inx-updateflag =
'I'.
        ls_order_header_inx-doc_type   =
'X'.
        ls_order_header_inx-sales_org  =
'X'.
        ls_order_header_inx-distr_chan =
'X'.
        ls_order_header_inx-division   =
'X'.
        ls_order_header_inx-sales_off  =
'X'.
       ls_order_header_inx-purch_no_c =
'X'.

                lt_partners-partn_role = 'AG'.
         lt_partners-partn_numb =
'0000004000'.
       
append lt_partners. 

                lt_items_in-itm_number  = '000010'.
         lt_items_in-material    =
'000000000300000040'.
         lt_items_in-sales_unit  =
'ST'.
      
append lt_items_in.

                lt_items_inx-itm_number  = '000010'.
         lt_items_inx-material    =
'X'.
         lt_items_inx-sales_unit  =
'X'.
       
append lt_items_inx.

               lt_schedules_in-itm_number  = '000010'.
       lt_schedules_in-sched_line  =
'0001'.
       lt_schedules_in-req_qty     =
1000.
       lt_schedules_in-req_date    = sy-datum.
      
append lt_schedules_in.

      lt_schedules_inx-itm_number  =
'000010'.
      lt_schedules_inx-sched_line  =
'0001'.
      lt_schedules_inx-req_qty     =
'X'.
      lt_schedules_inx-req_date     =
'X'.
     
append lt_schedules_inx.

     lwa_bape_vbap-vbeln = space.
     lwa_bape_vbap-posnr =
'000010'.
     lwa_bape_vbap-zztuketf =
0.
     lwa_bape_vbap-zztukets =
0.
     lwa_bape_vbap-zzklt1 =
'45GRAM'.
     lwa_bape_vbap-zzsyf1 =
16.
     lwa_bape_vbap-zzklt2 =
'49GRAM'.
     lwa_bape_vbap-zzsyf2 =
0.
     lwa_bape_vbap-zzklt3 =
'52GRAM'.
     lwa_bape_vbap-zzsyf3 =
0.
     lwa_bape_vbap-zz45g = space.
     lwa_bape_vbap-zz49g = space.
     lwa_bape_vbap-zzsbs =
8.
     lwa_bape_vbap-zztss =
8.
     lwa_bape_vbap-zzrss =
16.

     lwa_bape_vbapx-vbeln = space.
     lwa_bape_vbapx-posnr =
wa_outtab-posnr.
     lwa_bape_vbapx-zztuketf = space.
     lwa_bape_vbapx-zztukets = space.
     lwa_bape_vbapx-zzklt1 =
'X'.
     lwa_bape_vbapx-zzsyf1 =
'X'.
     lwa_bape_vbapx-zzklt2 =
'X'.
     lwa_bape_vbapx-zzsyf2 =
'X'.
     lwa_bape_vbapx-zzklt3 =
'X'.
     lwa_bape_vbapx-zzsyf3 =
'X'.
     lwa_bape_vbapx-zz45g =
'X'.
     lwa_bape_vbapx-zz49g =
'X'.
     lwa_bape_vbapx-zzsbs =
'X'.
     lwa_bape_vbapx-zztss =
'X'.
     lwa_bape_vbapx-zzrss =
'X'.

     
move 'BAPE_VBAP' to lwa_extensionin-structure.

   
call method cl_abap_container_utilities=>fill_container_c
   
exporting
      im_value = lwa_bape_vbap 
   
importing
      ex_container = lwa_extensionin-valuepart1.

     
append lwa_extensionin to lt_extensionin.

     
clear lwa_extensionin.
     
clear lt_extensionin.

     
move 'BAPE_VBAPX' to lwa_extensionin-structure.
     
move lwa_bape_vbapx to lwa_extensionin-valuepart1.
     
append lwa_extensionin to lt_extensionin.
     
clear lt_extensionin. 

  call function 'BAPI_SALESORDER_CREATEFROMDAT2'
 
exporting*    salesdocumentin               = lv_salesdocument
    order_header_in               = ls_order_header_in
    order_header_inx              = ls_order_header_inx*   SENDER                        =*   BINARY_RELATIONSHIPTYPE       =*   INT_NUMBER_ASSIGNMENT         =*   BEHAVE_WHEN_ERROR             =*   LOGIC_SWITCH                  =*   TESTRUN                       =*   CONVERT                       = ' '
importing
   salesdocument                  = lv_salesdocument
 
tables
  
return                         = lt_return
   order_items_in                 = lt_items_in
   order_items_inx                = lt_items_inx
    order_partners                = lt_partners
   order_schedules_in            = lt_schedules_in
   order_schedules_inx           = lt_schedules_inx
   order_conditions_in           = lt_order_conditions_in
   order_conditions_inx          = lt_order_conditions_inx

*   ORDER_CFGS_REF                =

*   ORDER_CFGS_INST               =

*   ORDER_CFGS_PART_OF            =

*   ORDER_CFGS_VALUE              =

*   ORDER_CFGS_BLOB               =

*   ORDER_CFGS_VK                 =

*   ORDER_CFGS_REFINST            =

*   ORDER_CCARD                   =

*   ORDER_TEXT                    =

*   ORDER_KEYS                    =
   extensionin                    = lt_extensionin

*   PARTNERADDRESSES              =

          .

    call function 'BAPI_TRANSACTION_COMMIT'
  
exporting
    
wait          = 'X'.

Read only

Former Member
Read only

ThangaPrakash
Active Contributor
0 Likes
5,303

Hello Malikarjun,

To find the BAPI extension structures of a BAPI use below step.

1) Find the package of the BAPI in which it is stored.

2) Goto SE11 and give BAPI_TE_* in the data type and press F4.

3) Click on structures

4) You will get a huge list of structures. click on new selection

5) In the pop up provide the package name from step 1 and press OK.

6) Now you will get a list of structures related to that BAPI in step1.

Regards,

Thanga