更改DN单的相关信息与更改SO的类似,下面这个例子是我做的一个修改的后台作业,其中可以更改抬头route和WE联系人的地址电话等信息。
DATA: ls_head TYPE bapiobdlvhdrchg,
ls_head_f TYPE bapiobdlvhdrctrlchg.
DATA: lt_partner TYPE TABLE OF bapidlvpartnerchg WITH HEADER LINE.
DATA: ls_selection LIKE addr1_sel,
ls_central_addr LIKE addr1_val,
lt_address TYPE TABLE OF bapidlvpartnaddrchg WITH HEADER LINE.
DATA: lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
DATA: gv_tabix TYPE sy-tabix.
TABLES: likp,addr1_data,adrc.
SELECT-OPTIONS: s_vbeln FOR likp-vbeln OBLIGATORY,
s_route FOR likp-route,
s_kunnr FOR likp-kunnr,
s_street FOR adrc-street,
s_city FOR adrc-city1,
s_remark FOR addr1_data-remark,
s_number FOR adrc-tel_number,
s_name1 FOR adrc-name1.
LOOP AT s_vbeln.
gv_tabix = sy-tabix.
READ TABLE s_route INDEX gv_tabix.
READ TABLE s_kunnr INDEX gv_tabix.
READ TABLE s_street INDEX gv_tabix.
READ TABLE s_city INDEX gv_tabix.
READ TABLE s_remark INDEX gv_tabix.
READ TABLE s_number INDEX gv_tabix.
CLEAR: ls_head,ls_head_f.
ls_head-deliv_numb = s_vbeln-low.
ls_head_f-deliv_numb = s_vbeln-low.
IF s_route-low NE ''.
ls_head-route = s_route-low.
ls_head_f-route_flg = 'X'.
ENDIF.
CLEAR:lt_partner[],lt_address[],lt_return[].
SELECT
posnr AS itm_number
parvw AS partn_role
kunnr AS partner_no
adrnr AS address_no
INTO CORRESPONDING FIELDS OF TABLE lt_partner
FROM vbpa
WHERE parvw = 'WE'
AND vbeln = s_vbeln-low.
LOOP AT lt_partner.
gv_tabix = sy-tabix.
ls_selection-addrnumber = lt_partner-address_no.
CALL FUNCTION 'ADDR_GET'
EXPORTING
address_selection = ls_selection
IMPORTING
address_value = ls_central_addr
EXCEPTIONS
parameter_error = 1
OTHERS = 2.
IF sy-subrc = 0.
lt_partner-upd_mode_partn = 'U'.
lt_partner-deliv_numb = s_vbeln-low.
* lt_partner-address_no = gs_out-.
lt_partner-manual_addr = 'X'.
MOVE-CORRESPONDING ls_central_addr TO lt_address.
lt_address-name = ls_central_addr-name1.
lt_address-postl_cod1 = ls_central_addr-post_code1.
lt_address-postl_cod2 = ls_central_addr-post_code2.
lt_address-postl_cod3 = ls_central_addr-post_code3.
lt_address-upd_mode_adr = 'U'.
lt_address-addr_no = lt_partner-address_no.
lt_address-street = s_street-low .
lt_address-city = s_city-low .
lt_address-adr_notes = s_remark-low .
lt_address-tel1_numbr = s_number-low.
lt_address-name = s_name1-low.
APPEND lt_address.
MODIFY lt_partner INDEX gv_tabix.
ENDIF.
ENDLOOP.
IF lt_partner[] IS NOT INITIAL.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
header_data = ls_head
header_control = ls_head_f
delivery = s_vbeln-low
* TECHN_CONTROL =
* HEADER_DATA_SPL =
* HEADER_CONTROL_SPL =
* SENDER_SYSTEM =
TABLES
header_partner = lt_partner[]
header_partner_addr = lt_address[]
* HEADER_DEADLINES =
* item_data = item_data[]
* item_control = item_control[]
* ITEM_SERIAL_NO =
* SUPPLIER_CONS_DATA =
* EXTENSION1 =
* EXTENSION2 =
return = lt_return[]
* TOKENREFERENCE =
* ITEM_DATA_SPL =
* COLLECTIVE_CHANGE_ITEMS =
* NEW_ITEM_DATA =
* NEW_ITEM_DATA_SPL =
* NEW_ITEM_ORG =
* ITEM_DATA_DOCU_BATCH =
.
LOOP AT lt_return WHERE type = 'E' OR type = 'A'.
ENDLOOP.
IF sy-subrc NE 0..
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ENDIF.
ENDLOOP.