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_CUSTOMERRETURN_CREATE not updating net value and condition record.

0 Likes
3,056

Hi,

I am using the BAPI_CUSTOMERRETURN_CREATE for sales order return process to create sales order.

Although, the sales order is created but it is not updating net value and condition record. I am using the below code.

**HEADER DATA ************
wa_ord_header-doc_type = vbak-auart.
wa_ord_header-sales_org = vbak-vkorg.
wa_ord_header-distr_chan = vbak-vtweg.
wa_ord_header-division = vbak-spart.
wa_ord_header-ref_doc = it_vbrk-vbeln.
wa_ord_header-refdoc_cat = 'M'.
wa_ord_header-ord_reason = it_vbrk-augru. "wa_head-augru.
wa_ord_header-sd_doc_cat = 'H'.
* wa_ord_header-purch_date = sy-datum.
wa_ord_header-price_date = it_vbrk-fkdat. "wa_head-fkdat.
wa_ord_headerx-updateflag = 'I'.
wa_ord_headerx-doc_type = 'X'.
wa_ord_headerx-sales_org = 'X'.
wa_ord_headerx-distr_chan = 'X'.
wa_ord_headerx-division = 'X'.
wa_ord_headerx-ord_reason = 'X'.
wa_ord_headerx-ref_doc = 'X'.
wa_ord_headerx-refdoc_cat = 'X'.
wa_ord_headerx-sd_doc_cat = 'X'.
* wa_ord_headerx-purch_date = 'X'.
wa_ord_headerx-price_date = 'X'.

wa_ord_header-currency = 'INR'.
wa_ord_headerx-currency = 'X'.

** wa_auto_srn-bill_no = IT_VBRK-vbeln.

READ TABLE it_pbcdgr INTO wa_item WITH KEY vbeln = it_vbrk-vbeln.
wa_ord_item-itm_number = wa_item-posnr.
wa_ord_item-material = wa_item-mcode.
wa_ord_item-plant = wa_item-werks.
* wa_ord_item-target_qty = wa_item-retqty.
wa_ord_item-target_qu = 'PC'. "wa_item-vrkme.
wa_ord_item-ref_doc = it_vbrk-vbeln.
wa_ord_item-ref_doc_it = wa_item-posnr.
wa_ord_item-ref_doc_ca = 'M'.

wa_ord_item-ship_point = zpbcdgr-werks. "wa_item-vstel.

wa_ord_item-SALES_UNIT = 'PC'. "wa_item-vstel. ++
wa_ord_itemx-ship_point = abap_true. "wa_item-vstel. ++

wa_ord_itemx-itm_number = wa_item-posnr.
wa_ord_itemx-updateflag = 'I'.
wa_ord_itemx-material = 'X'.
wa_ord_itemx-plant = 'X'.
wa_ord_itemx-target_qty = 'X'.
wa_ord_itemx-target_qu = 'X'.
wa_ord_itemx-ref_doc = 'X'.
wa_ord_itemx-ref_doc_it = 'X'.
wa_ord_itemx-ref_doc_ca = 'X'.

wa_schld-itm_number = wa_item-posnr.
wa_schld-sched_line = '0001'.
wa_schld-req_qty = wa_item-retqty.

wa_schldx-itm_number = wa_item-posnr.
wa_schldx-sched_line = '0001'.
wa_schldx-req_qty = 'X'.
wa_schldx-updateflag = 'I'.

APPEND wa_ord_item TO it_ord_item.
APPEND wa_ord_itemx TO it_ord_itemx.
APPEND wa_schld TO it_schld.
APPEND wa_schldx TO it_schldx.
CLEAR: wa_ord_item, wa_ord_itemx, wa_schld, wa_schldx.

wa_part-partn_role = 'AG'.
wa_part-partn_numb = it_vbrk-kunag.
APPEND wa_part TO it_part.
CLEAR wa_part.

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
EXPORTING
return_header_in = wa_ord_header
return_header_inx = wa_ord_headerx
convert = 'X'
IMPORTING
salesdocument = wa_vbeln
TABLES
return = it_ret1
return_items_in = it_ord_item
return_items_inx = it_ord_itemx
return_partners = it_part
return_schedules_in = it_schld
return_schedules_inx = it_schldx.

IF wa_vbeln IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '1'.

Hi,

I am using the BAPI_CUSTOMERRETURN_CREATE for sales order return process to create sales order.

Although, the sales order is created but it is not updating net value and condition record. I am using the below code.

**HEADER DATA ************
wa_ord_header-doc_type = vbak-auart.
wa_ord_header-sales_org = vbak-vkorg.
wa_ord_header-distr_chan = vbak-vtweg.
wa_ord_header-division = vbak-spart.
wa_ord_header-ref_doc = it_vbrk-vbeln.
wa_ord_header-refdoc_cat = 'M'.
wa_ord_header-ord_reason = it_vbrk-augru. "wa_head-augru.
wa_ord_header-sd_doc_cat = 'H'.
* wa_ord_header-purch_date = sy-datum.
wa_ord_header-price_date = it_vbrk-fkdat. "wa_head-fkdat.
wa_ord_headerx-updateflag = 'I'.
wa_ord_headerx-doc_type = 'X'.
wa_ord_headerx-sales_org = 'X'.
wa_ord_headerx-distr_chan = 'X'.
wa_ord_headerx-division = 'X'.
wa_ord_headerx-ord_reason = 'X'.
wa_ord_headerx-ref_doc = 'X'.
wa_ord_headerx-refdoc_cat = 'X'.
wa_ord_headerx-sd_doc_cat = 'X'.
* wa_ord_headerx-purch_date = 'X'.
wa_ord_headerx-price_date = 'X'.

wa_ord_header-currency = 'INR'.
wa_ord_headerx-currency = 'X'.

** wa_auto_srn-bill_no = IT_VBRK-vbeln.

READ TABLE it_pbcdgr INTO wa_item WITH KEY vbeln = it_vbrk-vbeln.
wa_ord_item-itm_number = wa_item-posnr.
wa_ord_item-material = wa_item-mcode.
wa_ord_item-plant = wa_item-werks.
* wa_ord_item-target_qty = wa_item-retqty.
wa_ord_item-target_qu = 'PC'. "wa_item-vrkme.
wa_ord_item-ref_doc = it_vbrk-vbeln.
wa_ord_item-ref_doc_it = wa_item-posnr.
wa_ord_item-ref_doc_ca = 'M'.

wa_ord_item-ship_point = zpbcdgr-werks. "wa_item-vstel.

wa_ord_item-SALES_UNIT = 'PC'. "wa_item-vstel. ++
wa_ord_itemx-ship_point = abap_true. "wa_item-vstel. ++

wa_ord_itemx-itm_number = wa_item-posnr.
wa_ord_itemx-updateflag = 'I'.
wa_ord_itemx-material = 'X'.
wa_ord_itemx-plant = 'X'.
wa_ord_itemx-target_qty = 'X'.
wa_ord_itemx-target_qu = 'X'.
wa_ord_itemx-ref_doc = 'X'.
wa_ord_itemx-ref_doc_it = 'X'.
wa_ord_itemx-ref_doc_ca = 'X'.

wa_schld-itm_number = wa_item-posnr.
wa_schld-sched_line = '0001'.
wa_schld-req_qty = wa_item-retqty.

wa_schldx-itm_number = wa_item-posnr.
wa_schldx-sched_line = '0001'.
wa_schldx-req_qty = 'X'.
wa_schldx-updateflag = 'I'.

APPEND wa_ord_item TO it_ord_item.
APPEND wa_ord_itemx TO it_ord_itemx.
APPEND wa_schld TO it_schld.
APPEND wa_schldx TO it_schldx.
CLEAR: wa_ord_item, wa_ord_itemx, wa_schld, wa_schldx.

wa_part-partn_role = 'AG'.
wa_part-partn_numb = it_vbrk-kunag.
APPEND wa_part TO it_part.
CLEAR wa_part.

CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'
EXPORTING
return_header_in = wa_ord_header
return_header_inx = wa_ord_headerx
convert = 'X'
IMPORTING
salesdocument = wa_vbeln
TABLES
return = it_ret1
return_items_in = it_ord_item
return_items_inx = it_ord_itemx
return_partners = it_part
return_schedules_in = it_schld
return_schedules_inx = it_schldx.

IF wa_vbeln IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = '1'.

1 REPLY 1
Read only

VeselinaPeykova
Active Contributor
2,454

You are not populating any conditions via the BAPI.

Check in VA01 when you create a return order without reference, but with exactly the same data (customer, material, plant, pricing date, etc.) whether the condition record is determined.

You can also use the pricing determination analysis from VA02 of the problematic document and find out why your condition was not determined.

I hope that you do not expect that the pricing will be copied from the referenced document. This feature is not supported, read 370988 - BAPIs in SD: Creation with reference for workarounds.