0% found this document useful (0 votes)
2 views19 pages

Quick_guide_BAPI_Doc_1731900995

The document provides a comprehensive guide on executing important BAPIs in various business processes, including sales order creation, change, delivery creation, and picking updates. It details the necessary data structures, constants, and function calls required for each process, ensuring proper handling of order and delivery management. Additionally, it includes examples of header and item changes, as well as transaction commit procedures to ensure data integrity.

Uploaded by

bharatx774
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
2 views19 pages

Quick_guide_BAPI_Doc_1731900995

The document provides a comprehensive guide on executing important BAPIs in various business processes, including sales order creation, change, delivery creation, and picking updates. It details the necessary data structures, constants, and function calls required for each process, ensuring proper handling of order and delivery management. Additionally, it includes examples of header and item changes, as well as transaction commit procedures to ensure data integrity.

Uploaded by

bharatx774
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 19

Guide for Important BAPI’s to be executed in Business Processes

1. Sales order creation >>

DATA: lt_partners TYPE STANDARD TABLE OF BAPIPARNR,


lt_items TYPE STANDARD TABLE OF BAPISDITM,
lt_schedule TYPE STANDARD TABLE OF BAPISCHL,
lt_return TYPE STANDARD TABLE OF BAPIRET2,
lt_extension TYPE STANDARD TABLE OF BAPIPAREX,
lr_header_bapi_ext TYPE REF TO bape_sdsalesdoc,
lr_item_bapi_ext TYPE REF TO bape_sdsalesdocitem,
lv_so_no TYPE vbeln_va.

CONSTANTS:
lc_ag TYPE parvw VALUE 'AG',
lc_we TYPE parvw VALUE 'WE',
lc_key TYPE sdsalesdoc_key VALUE '0000000000000000’.

*&---------------------Sales Header--------------------------------

DATA(ls_bapi_header) = VALUE bapisdhd1( doc_type = VBAK-LFART


sales_org = VBAK-VKORG
Dist_chan = VBAK-VTWEG
Division = VBAK-SPART
Purch_no_c = VBKD-BSTKD
).

*&---------------------Sales Items--------------------------------

lt_items = VALUE #( ( itm_number = VBAP-POSNR


material = VBAP-MATNR
plant = VBAP-WERKS
store_loc = VBAP-LGORT
target_qty = VBAP-ZMENG
target_qu = VBAP- ZIEME ) ).

*&---------------------Sales Partners --------------------------------

lt_partners = VALUE #( ( partn_role = lc_ag "SP( Sold to Party)


partn_numb = VBPA-KUNNR )
( partn_role = lc_we "SH( Sold to Party )
partn_numb = VBPA-KUNAG )
).
*&---------------------Sales Schedule line----------------------------

lt_schedule = VALUE #( ( itm_number = VBEP-POSNR


sched_line = VBEP-ETENR " 0001
req_qty = VBEP-WMENG ) ).

*&------------------- Header Extension --------------------------------


Guide for Important BAPI’s to be executed in Business Processes

CREATE DATA lr_header_bapi_ext.


lr_header_bapi_ext->key = lc_key.
lr_header_bapi_ext->data = VALUE # (z_cfl_field1 = lv_cfl_field1
z_cfl_field2 = lv_cfl_field2
z_cfl_field3 = lv_cfl_field3
).

lr_header_bapi_ext->datax = VALUE # (z_cfl_field1 = abap_true


z_cfl_field2 = abap_true
z_cfl_field3 = abap_true).

*&-map the custom fields of header data to the EXTENSIONIN


CLEAR: lo_bapi_mapping.
lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance().
lo_bapi_mapping->map_to_bapiparex_single(
EXPORTING
ir_source_structure = lr_header_bapi_ext
CHANGING ct_bapiparex = lt_extension).

*&--------------------- Item Extension --------------------------------

CREATE DATA lr_item_bapi_ext.


lr_item_bapi_ext->key = |0000000000{ VBAP-POSNR }|.
lr_item_bapi_ext->data-z_cfl_field_item1 = lv_cfl_field_item1.
lr_item_bapi_ext->data-z_cfl_field_item2 = lv_cfl_field_item2.
lr_item_bapi_ext->datax-z_cfl_field_item1 = abap_true.
lr_item_bapi_ext->datax-z_cfl_field_item2 = abap_true.

CLEAR lr_item_bapi_ext.
lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance( ).
lo_bapi_mapping->map_to_bapiparex_multi(
EXPORTING ir_source_table = lr_item_bapi_ext
CHANGING ct_bapiparex = lt_extension ).

*&----------------------BAPI CALL ------------------------------------

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'


EXPORTING
order_header_in = ls_bapi_header
IMPORTING
salesdocument = lv_so_no
TABLES
return = lt_return
order_items_in = lt_items
order_partners = lt_partners
order_schedules_in = lt_schedule
extensionin = lt_extension.

IF NOT line_exists( lt_return[ type = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

2. Sales order change >>

DATA: lc_upd_flg TYPE updkz_d VALUE 'U',


lt_head_ext TYPE TABLE OF bapiparex.

*&---------------------Header Change ----------------------------------

*&-------------------------------------------
*&-Remove Delivery Block from Sales Order
*&-------------------------------------------
DATA(ls_header) = VALUE bapisdh1( dlv_block = space ).
DATA(ls_header_x) = VALUE bapisdh1x( updateflag = lc_upd_flg
dlv_block = abap_true
).
*&----------------------BAPI CALL ------------------------------------

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'


EXPORTING
salesdocument = VBAK-VBELN
order_header_in = ls_header
order_header_inx = ls_header_x
TABLES
extensionin = lt_extension " Passing ext. same way as in create
return = lt_return.

IF NOT line_exists( lt_return[ type = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

3. Delivery Creation >>


Mostly Delivery creation are kept auto from config.
DATA : lt_sales_order TYPE tt_bapidlvreftosalesorder,
lv_delivery TYPE vbeln_vl,
lt_return TYPE bapiret2_t.

*&--------------------- Header --------------------------------

lt_return_sales_order[] = VALUE #( BASE lt_return_sales_order


( ref_doc = VBAK-VBELN ) ).

*&--------------------- BAPI CALL --------------------------------

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'


EXPORTING
ship_point = VBAP-VSTEL
IMPORTING
delivery = lv_delivery
TABLES
sales_order_items = lt_sales_order
return = lt_return.
IF NOT line_exists( lt_return[ type = if_xo_const_message=>error ] ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

4. Delivery Change >>


DATA: ls_vbkok TYPE vbkok,
lt_vbpok TYPE STANDARD TABLE OF vbpok,
lt_prot TYPE STANDARD TABLE OF prott.

*&-----------------------Header Change --------------------------------

ls_vbkok = VALUE #( vbeln_vl = LIKP-VBELN


vbtyp_vl = ‘J’
packing_refresh = abap_true ).

*&-----------------------Item Change ----------------------------------

*&-----------------------------------
*&-Changing delivery quantity to be 0
*&-----------------------------------
lt_vbpok = VALUE #( BASE lt_vbpok
(
vbeln_vl = LIKP-VBELN
posnr_vl = LIPS-POSNR
matnr = LIPS-MATNR
lfimg = 0
lianp = abap_true
umvkz = 1
umvkn = 1
z_cfl_field1 = lv_custom_field1
)
).

*&--------------------- Item Extension --------------------------------

CALL FUNCTION 'WS_DELIVERY_UPDATE'


EXPORTING
vbkok_wa = ls_vbkok
delivery = LIKP-VBELN
nicht_sperren = abap_true
if_no_remote_chg = abap_true
if_error_messages_send_0 = space
TABLES
vbpok_tab = lt_vbpok
prot = lt_prot
EXCEPTIONS
error_message = 1
OTHERS = 2.

IF NOT line_exists( lt_prot[ msgty = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

------------OR--------------
DATA: ls_header_Data TYPE bapiobdlvhdrchg,
ls_header_Control TYPE bapiobdlvhdrctrlchg,
lt_item_control TYPE STANDARD TABLE OF bapiobdlvitemctrlchg,
lt_item_data TYPE STANDARD TABLE OF bapiobdlvitemchg,
lt_return TYPE STANDARD TABLE OF bapiret2.

*&-----------------------Header Change --------------------------------

ls_header_data = VALUE #( deliv_numb = LIKP-VBELN ) .


ls_header_control = VALUE #( deliv_numb = LIKP-VBELN ).

*&-----------------------Item Change ----------------------------------

lt_item_data = VALUE #( ( deliv_numb = LIKP-VBELN


deliv_item = LIPS-VBELN
dlv_qty = LIPS-LFIMG
dlv_qty_imunit = LIPS-LFIMG
fact_unit_nom = 1
fact_unit_denom = 1
conv_fact = 1

) ).

lt_item_control = VALUE #( (
deliv_numb = p_delv
deliv_item = LIPS-POSNR
chg_delqty = abap_true ) ).

*&-----------------------BAPI_CALL ----------------------------------

CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'


EXPORTING
header_data = ls_header_data
header_control = ls_header_control
delivery = LIKP-VBELN
TABLES
item_data = lt_item_data
item_control = lt_item_control
return = lt_return.

IF NOT line_exists( lt_return[ type = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

5. Delivery PGI >>

DATA: lv_delivery LIKE likp-vbeln,


ls_vbkok TYPE vbkok,
lt_prott TYPE tab_prott.

*&-----------------------Header Change -------------------------------

ls_vbkok-vbeln_vl = LIKP-VBELN.
ls_vbkok-wabuc = abap_true.

*&-----------------------BAPI CALL ----------------------------------

CALL FUNCTION 'WS_DELIVERY_UPDATE'


EXPORTING
vbkok_wa = ls_vbkok
synchron = abap_true
no_messages_update = space
update_picking = abap_true
commit = space
delivery = LIKP-vbeln
nicht_sperren = abap_true
TABLES
prot = lt_prott
EXCEPTIONS
OTHERS = 0.

IF NOT line_exists( lt_prott[ msgty = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

6. Delivery Picking Update >>

DATA: ls_vbkok TYPE vbkok,


lt_vbpok TYPE STANDARD TABLE OF vbpok,
lt_prot TYPE TABLE OF prott.

*&-----------------------Header Change --------------------------------

ls_vbkok = VALUE #( vbeln_vl = LIKP-VBELN vbeln = LIKP-VBELN ).

*&-----------------------Item Change ----------------------------------

lt_vbpok = VALUE #( ( vbeln_vl = LIKP-VBELN


posnr_vl = LIPS-POSNR
vbeln = LIKP-VBELN
posnn = LIKP-POSNR
pikmg = LIPS-LFIMG
) ).

*&-----------------------BAPI CALL ----------------------------------

CALL FUNCTION 'SD_DELIVERY_UPDATE_PICKING'


EXPORTING
vbkok_wa = ls_vbkok
TABLES
vbpok_tab = lt_vbpok
prot = lt_prot.

IF NOT line_exists( lt_prot[ msgty = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.

------------OR--------------
CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
EXPORTING
vbkok_wa = ls_vbkok
synchron = abap_true
delivery = p_delv
update_picking = abap_true
if_database_update_1 = '1'
nicht_sperren_1 = '1'
TABLES
vbpok_tab = lt_vbpok
prot = lt_prot.
IF NOT line_exists( lt_prot[ msgty = if_xo_const_message=>error ] ).
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

7. PO create >>

DATA : lt_po_item TYPE bapimepoitem_tp,


lt_po_itemx TYPE bapimepoitemx_tp,
lv_po TYPE ebeln,
ls_ex_po_hdr TYPE bapimepoheader,
ls_ex_po_trade TYPE bapieikp,
lt_return TYPE bapiret2_t,
lt_extension TYPE STANDARD TABLE OF bapiparex,
lo_bapi_mapping TYPE REF TO if_cfd_bapi_mapping,
lo_header_bapi_ext TYPE REF TO mmpur_po_bapi_header_ext.

*&----------------------Header Change ---------------------------------

DATA(ls_po_hdr) = VALUE bapimepoheader( comp_code = EKKO-BUKRS


doc_date = sy-datum
doc_type = EKKO-BSART
langu = sy-langu
purch_org = EKKO-EKORG
pur_group = EKKO-EKGRP
vendor = EKKO-LIFNR
).
DATA(ls_po_hdrx) = VALUE bapimepoheaderx( comp_code = abap_true
doc_date = abap_true
doc_type = abap_true
langu = abap_true
purch_org = abap_true
pur_group = abap_true
vendor = abap_true ).
*&----------------------Extension ------------------------------------

CREATE DATA lo_header_bapi_ext.


lo_header_bapi_ext->key = EKKO-EBELN.
lo_header_bapi_ext->data = VALUE #( z_cfl_fld1 = lv_field_cfl1).
lo_header_bapi_ext->datax = VALUE #( z_cfl_fld1 = abap_true ).

"map the custom fields of header data to the EXTENSIONIN


lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance( ).
TRY.
lo_bapi_mapping->map_to_bapiparex_single(
EXPORTING
ir_source_structure = lo_header_bapi_ext
CHANGING ct_bapiparex = lt_extension ).
CATCH cx_cfd_bapi_mapping.
ENDTRY.
Guide for Important BAPI’s to be executed in Business Processes

*&----------------------Item Change ----------------------------------


lt_po_item[] = VALUE #( BASE lt_po_item
( po_item = EKPO-POSNR
material = EKPO-MATNR
plant = EKPO~WERKS
stge_loc = EKPO-LGORT
quantity = EKPO-MENGE
po_unit = EKPO-MEINS
orderpr_un = EKPO~MEINS ) ).

lt_po_itemx[] = VALUE #( BASE lt_po_itemx


( po_item = EKPO-POSNR
po_itemx = abap_true
material = abap_true
plant = abap_true
stge_loc = abap_true
quantity = abap_true
po_unit = abap_true
orderpr_un = abap_true) ).

CALL FUNCTION 'BAPI_PO_CREATE1'


EXPORTING
poheader = ls_po_hdr
poheaderx = ls_po_hdrx
IMPORTING
exppurchaseorder = lv_po
expheader = ls_ex_po_hdr
exppoexpimpheader = ls_ex_po_trade
TABLES
return = lt_return
poitem = lt_po_item
poitemx = lt_po_itemx
extensionin = lt_extension.
IF lv_po IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

8. PO change>>

DATA: lt_return TYPE STANDARD TABLE OF bapiret2,


lo_bapi_mapping TYPE REF TO if_cfd_bapi_mapping,
lt_poitem TYPE TABLE OF bapimepoitem,
lt_poitemx TYPE TABLE OF bapimepoitemx,
ls_po_header TYPE bapimepoheader,
ls_po_headerx TYPE bapimepoheaderx,
lt_bapiextension TYPE bapiparex_t,
lr_hd_bapi_ext_po TYPE REF TO mmpur_po_bapi_header_ext.

CONSTANTS: lc_key TYPE sdsalesdoc_key VALUE '0000000000000000',

*&-----------------------Header Change --------------------------------

ls_po_header = VALUE #( po_number = EKKO-EBELN


vper_start = EKKO- KDATB
vper_end = EKKO- KDATE ).

ls_po_headerx = VALUE #( po_number = abap_true


vper_start = abap_true
vper_end = abap_true ).

*&-----------------------Item Change --------------------------------

lt_poitem = VALUE #( BASE lt_poitem


( po_item = EKPO-EBELP
delete_ind = space ) ).

lt_poitemx = VALUE #( BASE lt_poitemx


( po_item = EKPO-EBELP
po_itemx = abap_true
delete_ind = abap_true ) ).

*&-----------------------Extension --------------------------------

CREATE DATA lr_hd_bapi_ext_po.


lr_hd_bapi_ext_po->key = lc_key(10).

lr_hd_bapi_ext_po>data = VALUE #( z_cfl_field1 = lv_field1 ).


lr_hd_bapi_ext_po->datax = VALUE #( z_cfl_field1 = abap_true ).

CLEAR lo_bapi_mapping.
lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance( ).
TRY.
lo_bapi_mapping->map_to_bapiparex_single(
EXPORTING ir_source_structure = lr_hd_bapi_ext_po
CHANGING ct_bapiparex = lt_bapiextension ).
CATCH cx_cfd_bapi_mapping.
ENDTRY.
Guide for Important BAPI’s to be executed in Business Processes

*&-----------------------BAPI CALL --------------------------------

*&---------------------------
** Remove the delivery block
*&--------------------------
CALL FUNCTION 'BAPI_PO_CHANGE' "#EC CI_USAGE_OK[2438131]
EXPORTING
purchaseorder = lv_doc_num
poheader = ls_po_header
poheaderx = ls_po_headerx
TABLES
return = lt_return
poitem = lt_poitem
poitemx = lt_poitemx
extensionin = lt_bapiextension.

IF NOT line_exists( lt_return[ type = if_xo_const_message=>error ] ).


CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

9. Invoices create without doc. Ref. >>

DATA : lt_billing_doc TYPE TABLE OF bapivbrk,


lt_return TYPE TABLE OF bapiret1,
lt_success TYPE TABLE OF bapivbrksuccess.

*&----------------------Header and Item Change ----------------------

lt_billing_doc = VALUE #( BASE lt_bapi_vbrk


salesorg = VBRK-VKORG
division = VBRK-SPART
distr_chan = VBRK-VTWEG
ordbilltyp = VBRK-FKART
doc_type = VBRK-BLART
item_categ = VBRK-FKTYP
plant = VBRP-WERKS
req_qty = VBRP-FKIMG
sold_to = VBRP-KUNAG_ANA
bill_to = VBRP-KUNRE_ANA
payer = VBRP-KUNAG_ANA
ship_to = VBRP-KUNWE_ANA
material = VBRP-MATNR
currency = VBRP-NETWR

) ).

*&----------------------BAPI CALL ------------------------------------

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'


TABLES
billingdatain = lt_billing_doc
return = lt_return
success = lt_success.
IF NOT line_exists( lt_return[ type= if_xo_const_message=>error ] ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT’
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

10. Accounting Document Posting>>

DATA: lt_accountgl TYPE TABLE OF bapiacgl09,


lt_accountreceivable TYPE TABLE OF bapiacar09,
lt_accountpay TYPE TABLE OF bapiacap09,
lt_accounttax TYPE TABLE OF bapiactx09,
lt_currencyamount TYPE TABLE OF bapiaccr09,
lt_return TYPE TABLE OF bapiret2,
ls_documentheader TYPE bapiache09,
lv_obj_key TYPE bapiache09-obj_key.

*&----------------------Header Change ------------------------------------


*&---------------------------
* Header Details-
*&---------------------------
ls_documentheader = VALUE #( username = sy-uname
header_txt = BKPF-BKTXT
comp_code = BKPF-BUKRS
doc_date = BKPF-BLDAT
pstng_date = BKPF-BUDAT
fisc_year = BKPF-GJAHR
fis_period = BKPF-MONAT
doc_type = BKPF-BLART
).

*&----------------------Item Change ------------------------------------

*&-------------------------------------------------------------
* Item Details-Fill only which are applicable as per scenario
*&----------------------------------------------------------

lt_accountgl = VALUE #( BASE lt_accountgl (

itemno_acc = '0000000001',
gl_account = SKA1-SAKNR
bus_area = BSEG-GSBER
profit_ctr = BSEG-PRCTR
businessplace = BSEG-BUPLA
item_text = BSEG-SGTXT
) ).

lt_accountreceivable = VALUE #( BASE lt_accountreceivable (

itemno_acc = '0000000002',
customer = BSEG-KUNNR
bus_area = BSEG-GSBER
businessplace = BSEG-BUPLA
profit_ctr = BSEG-PRCTR
item_text = BSEG-SGTXT ) ).
Guide for Important BAPI’s to be executed in Business Processes

"Lines in currency amount will be as many defined above GL accounts,

"Customer(account receivable ) , vendor ( account payable )

lt_currencyamount = VALUE #( BASE lt_currencyamount (

itemno_acc = '0000000001'
currency = BSEG-DMBTR
amt_doccur = BSEG-WRBTR
amt_base = BSEG-HWBAS )

( itemno_acc = '0000000002'
currency = BSEG-DMBTR
amt_doccur = BSEG-WRBTR
amt_base = BSEG-HWBAS )).

lt_accountpay = VALUE #( BASE lt_accountpay (

itemno_acc = '0000000001'
vendor_no = BSEG-LIFNR
bus_area = BSEG-GSBER
businessplace = BSEG-BUPLA
sectioncode = BSEG-SECCO
profit_ctr = BSEG-PRCTR
item_text = BSEG-SGTXT ) ).

"Item number account should follow GL numbers sequence as given in

"above tables.

lt_accounttax = VALUE #( ( itemno_acc = '0000000001'


gl_account = SKA1-SAKNR
acct_key = 'CGST'
tax_code = '05'
itemno_tax = '000001'
direct_tax = abap_true
tax_country = LFA1-LAND1 )
( itemno_acc = '0000000002'
gl_account = SKA1-SAKNR
acct_key = 'SGST '
tax_code = '05 '
itemno_tax = '000001'
direct_tax = abap_true
tax_country = LFA1-LAND1 ) ).
Guide for Important BAPI’s to be executed in Business Processes

*&----------------------BAPI CALL --------------------------------

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'


EXPORTING
documentheader = ls_documentheader
IMPORTING
obj_key = lv_obj_key
TABLES
accountgl = lt_accountgl
accountreceivable = lt_accountreceivable
accountpayable = lt_accountpay
accounttax = lt_accounttax
currencyamount = lt_currencyamount
return = lt_return.

IF line_exists( lt_return[ type = if_xo_const_message=>error ] ).


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT’.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

11. BP change Central

DATA : lt_bapiadtel_cen TYPE TABLE OF bapiadtel,


lt_bapiadtelx_cen_x TYPE TABLE OF bapiadtelx,
ls_central_organ TYPE bapibus1006_central_organ,
ls_central_organ_x TYPE bapibus1006_central_organ_x,
lt_bapiret2_rt TYPE TABLE OF bapiret2,

*&----------------------Item Change --------------------------------

lt_bapiadtel_cen = VALUE #( ( telephone = 12345 ).


lt_bapiadtelx_cen_x = VALUE #( ( telephone = abap_true ) ).
ls_central_organ = VALUE #( name1 = 'ABCD ').
ls_central_organ_x = VALUE #( name1 = abap_true ).

*&----------------------BAPI CALL ------------------------------------

CALL FUNCTION 'BAPI_BUPA_CENTRAL_CHANGE'


EXPORTING
businesspartner = BUT000-PARTNER
centraldataorganization = ls_central_organ
centraldataorganization_x = ls_central_organ_x
TABLES
telefondatanonaddress = lt_bapiadtel_cen
telefondatanonaddressx = lt_bapiadtelx_cen_x
return = lt_bapiret2_rt.

IF line_exists( lt_bapiret2_rt[
type = if_xo_const_message=>error ] ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
Guide for Important BAPI’s to be executed in Business Processes

12. BP change address


DATA : ls_bapibus1006_address TYPE bapibus1006_address,
ls_bapibus1006_address_x TYPE bapibus1006_address_x,
lt_bapiadtelx TYPE TABLE OF bapiadtelx,
lt_bapiadsmtp TYPE TABLE OF bapiadsmtp,
lt_bapiadsm_x TYPE TABLE OF bapiadsmtx,
lt_bapiadtel_cen TYPE TABLE OF bapiadtel,
lt_bapiadtelx_cen_x TYPE TABLE OF bapiadtelx,
lt_bapiret2 TYPE TABLE OF bapiret2,

*&----------------------Item Change ----------------------------------

ls_bapibus1006_address = VALUE #(
c_o_name = VALUE1
city = VALUE2
street = VALUE3
country = VALUE4
district = VALUE5
postl_cod1 = VALUE6
region = VALUE7 ).

ls_bapibus1006_address_x = VALUE #(
district = abap_true
street = abap_true
country = abap_true
region = abap_true
city = abap_true
c_o_name = abap_true
postl_cod1 = abap_true ).

lt_bapiadtel = VALUE #( (
telephone = VALUE8
extension = VALUE9
tel_no = VALUE10 ) ).

lt_bapiadsmtp = VALUE #( (
e_mail = VALUE11) ).

lt_bapiadsm_x = VALUE #( ( e_mail = abap_true


updateflag = 'U' ) ).

lt_bapiadtelx = VALUE #( ( telephone = abap_true


extension = abap_true
updateflag = 'U '
tel_no = abap_true ) ).

lt_bapiadtel_cen = VALUE #( ( telephone = VALUE12) ).


lt_bapiadtelx_cen_x = VALUE #( ( telephone = abap_true ) ).
Guide for Important BAPI’s to be executed in Business Processes

*&----------------------BAPI CALL -----------------------------

CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE'


EXPORTING
businesspartner = BUT000-PARTNER
addressguid = BUT020-ADDRESS_GUID
addressdata = ls_bapibus1006_address
addressdata_x = ls_bapibus1006_address_x
TABLES
bapiadtel = lt_bapiadtel
bapiadsmtp = lt_bapiadsmtp
bapiadsmt_x = lt_bapiadsm_x
bapiadtel_x = lt_bapiadtelx
return = lt_bapiret2.

IF line_exists( lt_bapiret2[
type = if_xo_const_message=>error ] ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.

You might also like