‎2013 Dec 10 12:25 AM
Hello Experts,
I've a requirement where I need to update Email address and Fax on Bill-to partner at line item of a sales order (as shown in screen shot).
I've written the following code which updates bill-to but doesn't update Fax and Email and copies the master data.
For reference here is my code.
==================================================================================
"HEADER DETAILS.
lwa_order_header_inx-updateflag = c_update.
lwa_order_header_in-sales_org = 'PR01'.
lwa_order_header_inx-sales_org = c_x.
lwa_order_header_in-distr_chan = '90'.
lwa_order_header_inx-distr_chan = c_x.
lwa_order_header_in-division = '90'.
lwa_order_header_inx-division = c_x.
* Update PO number
lwa_order_header_in-purch_no_c = lw_zrerate_dtl-invoice. "lw_zrerate_dtl-zvbeln_pr.
lwa_order_header_inx-purch_no_c = c_x.
* Update billing block
lwa_order_header_in-bill_block = 'Y5'.
lwa_order_header_inx-bill_block = c_x.
* Update order reason
lwa_order_header_in-ord_reason = vbak-augru."'Y5'
lwa_order_header_inx-ord_reason = c_x.
"PARTNER DETAILS
clear: lv_re_adrnr.
select single adrnr
from vbpa
into lv_re_adrnr
where vbeln = lw_zrerate_dtl-zvbeln_pr
and parvw = 'RE'.
if lv_re_adrnr <> 0.
lwa_pchanges-document = lw_zrerate_dtl-zvbeln_pr.
lwa_pchanges-updateflag = 'U'."c_update.
lwa_pchanges-itm_number = '000000'.
lwa_pchanges-partn_role = 'RE'.
lwa_pchanges-P_NUMB_OLD = '0000000033'.
lwa_pchanges-P_NUMB_NEW = '0000000024'.
"lwa_pchanges-address = lv_re_adrnr.
lwa_pchanges-ADDR_LINK = lv_re_adrnr.
append lwa_pchanges to li_pchanges.
lwa_paddress-addr_no = lv_re_adrnr.
lwa_paddress-e_mail = lw_zrerate_hdr-email.
lwa_paddress-fax_number = lw_zrerate_hdr-fax.
append lwa_paddress to li_paddress.
clear: lwa_pchanges, lwa_paddress.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lw_zrerate_dtl-zvbeln_pr
order_header_in = lwa_order_header_in
order_header_inx = lwa_order_header_inx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
LOGIC_SWITCH = l_logic_switch
* NO_STATUS_BUF_INIT = ' '
tables
return = li_return
* order_item_in = li_order_items
* order_item_inx = li_order_items_inx
partnerchanges = li_pchanges
partneraddresses = li_paddress.
loop at li_return into lwa_return where type eq c_success.
lv_updated = c_x.
* Update BAPI
call function 'BAPI_TRANSACTION_COMMIT'
importing
return = lwa_return.
* Move error message to error log table if bapi cannot be updated
if lwa_return is not initial.
" message i025 with lv_vbeln.
endif.
clear: lwa_return.
exit.
endloop.
==================================================================================
Can somebody please tell me how I can change Fax and Email address at line item of a sales order.
Many thanks in advance.
‎2013 Dec 10 5:00 AM
Are we getting any errors on the existing code to start with?
If the objective is to update the sales order partner contact details,then I assume that you are also changing the Partner itself here as per the code ....
lwa_pchanges-P_NUMB_OLD = '0000000033'.
lwa_pchanges-P_NUMB_NEW = '0000000024'.
In such a case,the change of partner and subsequently the update of the same partner information immediately may be a bit confusing.So the first time ,do a partner update and then do the partner contact details update in 2 separate BAPI calls of 'BAPI_SALESORDER_CHANGE'.It might just work.
‎2013 Dec 10 5:07 AM
Hi ,
Can you check once your " lwa_pchanges-itm_number = '000000'." is Correct also check this Note : 205775 - Partner change in CHANGE BAPI .
Regard's
Smruti
‎2013 Dec 10 6:04 AM
Hi,
Put the break point on the below code and find the root cause. The BAPI is updating partner changes on below code.
Include : LVBAKF0C
* 3. Abarbeiten der Partneränderungen
loop at partnerchanges .
if conv_parvw_auart = charx.
call function 'CONVERSION_EXIT_PARVW_INPUT'
exporting
input = partnerchanges-partn_role
importing
output = da_parvw.
------endloop.
Thanks,
Kiran