0% found this document useful (0 votes)
122 views

Ztest Bapi

This document defines data structures and calls a BAPI function to change sales orders. It selects sales order data into internal tables, loops through the order items to populate input structures for the function call, calls the BAPI function to change the orders, and commits any changes.

Uploaded by

Satyaprasad Chi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Ztest Bapi

This document defines data structures and calls a BAPI function to change sales orders. It selects sales order data into internal tables, loops through the order items to populate input structures for the function call, calls the BAPI function to change the orders, and commits any changes.

Uploaded by

Satyaprasad Chi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

*& Report ZTEST_BAPI

*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

report ztest_bapi.
types: begin of ts_vbak,
vbeln type vbeln_va,
auart type vbak-auart,
vkorg type vkorg,
end of ts_vbak.

types: begin of ts_vbap,


vbeln type vbeln_va,
posnr type vbap-posnr,
matnr type vbap-matnr,
netwr type vbap-netwr,
end of ts_vbap.
data: it_return type zzbapiret2,
gs_vbak type ts_vbak,
gt_vbak type standard table of ts_vbak,
gs_vbap type ts_vbap,
gt_vbap type standard table of ts_vbap,
it_bitem type standard table of bapisditm,
it_bitemx type standard table of bapisditmx,
is_bitem type bapisditm,
is_bitemx type bapisditmx,
is_bhead type bapisdh1,
is_bheadx type bapisdh1x.
select-options: s_vbeln for gs_vbak-vbeln.
select vbeln posnr matnr netwr from vbap
into table gt_vbap
where vbeln in s_vbeln.
is_bhead-collect_no = s_vbeln-low.
is_bheadx-collect_no = 'X'.
is_bheadx-updateflag = 'U'.
loop at gt_vbap into gs_vbap.
is_bitem-itm_number = gs_vbap-posnr.
is_bitemx-itm_number = gs_vbap-posnr.
is_bitem-material = gs_vbap-matnr.
is_bitemx-updateflag = 'U'.
is_bitemx-material = 'X'.
append is_bitem to it_bitem.
append is_bitemx to it_bitemx.
clear: is_bitem,is_bitemx.
endloop.
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument = s_vbeln-low
* ORDER_HEADER_IN = IS_BHEAD
order_header_inx = is_bheadx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
* LOGIC_SWITCH =
* NO_STATUS_BUF_INIT = ' '
tables
return = it_return
order_item_in = it_bitem
order_item_inx = it_bitemx
* PARTNERS =
* PARTNERCHANGES =
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
* SCHEDULE_LINES =
* SCHEDULE_LINESX =
* ORDER_TEXT =
* ORDER_KEYS =
* CONDITIONS_IN =
* CONDITIONS_INX =
* EXTENSIONIN =
.
read table it_return with key type = 'E'
transporting no fields.
if sy-subrc ne 0.
call function 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT = BAPIWAIT
* IMPORTING
* RETURN = IT_RETURN
.

endif.

clear: is_bheadx,is_bhead,it_bitemx[],it_bitem[].

You might also like