cancel
Showing results for 
Search instead for 
Did you mean: 

Filling configuration structures using Standard BAPIs in sales order using se38

Former Member
0 Kudos

Hi all,

I'm trying to update an SD variant configuration characteristics value in sales order using BAPI_SALESORDER_CHANGE. or BAPI_SALESORDER_CREATEFROMDAT2 I tested these BAPIs using SE37 with taking into consideration SAP NOTE 549563,562124 and 900380 and it's working fine and variant configuration characteristics value updated.but when I used the Z-program to call this function in SE38 I get successful messages but no updates happened in sales order and also I am using BAPI_TRANSACTION_COMMIT and Commit work and wait

Note: i considerd the follwing ponts to in code

1. ORDER_ITEMS_IN-PO_ITM_NO = ORDER_CFGS_REF-POSEX.

2. ORDER_ITEM_INX-PO_ITM_NO = X.

3. filling tables CFGS_REF, CFGS_INST and CFGS_VALUE.

What am I missing? Thanks in advance for your help!

kindly find sample code for BAPI_SALESORDER_CHANGE

SALESDOCUMENT = '0000020407' .

ORDER_HEADER_INX-UPDATEFLAG = 'U' .

READ TABLE it_output INTO wa_output WITH KEY count = wa_input-count .

READ TABLE it_cuobj INTO wa_cuobj WITH KEY posnr = wa_input-count .

wa_ORDER_ITEMS_IN-itm_number  = '000010'  .

wa_ORDER_ITEMS_IN-po_itm_no = '000010'  .

wa_ORDER_ITEMS_IN-material = wa_cuobj-matnr .

APPEND wa_ORDER_ITEMS_IN to ORDER_ITEMS_IN .



wa_ORDER_ITEMS_INX-itm_number =  '000010' .

wa_ORDER_ITEMS_INX-UPDATEFLAG = 'U' .

wa_ORDER_ITEMS_INX-PO_ITM_NO = 'X' .

wa_ORDER_ITEMS_INX-material = 'X' .

wa_ORDER_ITEMS_INX-CONFIG_ID ='X' .

*wa_ORDER_ITEMS_INX-target_qty = 'X' .

APPEND wa_ORDER_ITEMS_INX to ORDER_ITEMS_INX .



wa_ORDER_SCHEDULES_IN-itm_number = wa_input-count .

wa_ORDER_SCHEDULES_IN-sched_line = '0001' . "counter . .

wa_ORDER_SCHEDULES_IN-req_qty = wa_output-consumed .

v_date = sy-datum .

wa_ORDER_SCHEDULES_IN-REQ_DATE = v_date.

APPEND wa_ORDER_SCHEDULES_IN to ORDER_SCHEDULES_IN .



wa_ORDER_SCHEDULES_INX-itm_number = wa_input-count.

wa_ORDER_SCHEDULES_INX-sched_line =  '0001' ."counter.

wa_ORDER_SCHEDULES_INX-updateflag = 'U' .

wa_ORDER_SCHEDULES_INX-req_qty = 'X'.

wa_ORDER_SCHEDULES_INX-REQ_DATE = 'X'.

APPEND wa_ORDER_SCHEDULES_INX to ORDER_SCHEDULES_INX .



wa_ORDER_CFGS_REF-posex = '000010'    .

wa_order_cfgs_ref-config_id = '000001'.

wa_order_cfgs_ref-root_id = '00000001'.

wa_order_cfgs_ref-complete = 'T' .

wa_order_cfgs_ref-consistent = 'T' .

append wa_ORDER_CFGS_REF to ORDER_CFGS_REF .


wa_ORDER_CFGS_INST-config_id = '000001' .

wa_ORDER_CFGS_INST-inst_id = '00000001' .

wa_ORDER_CFGS_INST-obj_type = 'MARA' .

wa_ORDER_CFGS_INST-class_type = 300 .

READ TABLE it_cuobj INTO wa_cuobj WITH KEY posnr = wa_input-count .

wa_ORDER_CFGS_INST-obj_key = wa_cuobj-matnr .

APPEND wa_ORDER_CFGS_INST to ORDER_CFGS_INST .



 wa_ORDER_CFGS_VALUE-config_id = '000001' .

 wa_ORDER_CFGS_VALUE-inst_id = '00000001' .

 wa_ORDER_CFGS_VALUE-charc = 'HEIGHT' .

 wa_ORDER_CFGS_VALUE-value =  wa_input-height .

 APPEND wa_ORDER_CFGS_VALUE to ORDER_CFGS_VALUE .


 wa_ORDER_CFGS_VALUE-config_id = '000001' .

 wa_ORDER_CFGS_VALUE-inst_id = '00000001' .

 wa_ORDER_CFGS_VALUE-value =  wa_input-width .

 wa_ORDER_CFGS_VALUE-charc = 'WIDTH' .

 APPEND wa_ORDER_CFGS_VALUE to ORDER_CFGS_VALUE .



 wa_ORDER_CFGS_VALUE-config_id = '000001' .

 wa_ORDER_CFGS_VALUE-inst_id = '00000001' .

 wa_ORDER_CFGS_VALUE-value =  wa_output-roll_quantity.

 wa_ORDER_CFGS_VALUE-charc =   'ROLL_QUANTITY' .

   APPEND wa_ORDER_CFGS_VALUE to ORDER_CFGS_VALUE .



 wa_ORDER_CFGS_VALUE-config_id = '000001' .

 wa_ORDER_CFGS_VALUE-inst_id = '00000001' .

 wa_ORDER_CFGS_VALUE-charc = 'COLOR' .

 wa_ORDER_CFGS_VALUE-value =  '003' .

 APPEND wa_ORDER_CFGS_VALUE to ORDER_CFGS_VALUE .





 wa_ORDER_CFGS_VK-config_id = '000001' .

 wa_ORDER_CFGS_VK-inst_id = '00000001' .

 wa_ORDER_CFGS_VK-vkey = 'HEIGHT' .

 APPEND wa_ORDER_CFGS_VK to ORDER_CFGS_VK .



 wa_ORDER_CFGS_VK-config_id = '000001' .

 wa_ORDER_CFGS_VK-inst_id = '00000001' .

 wa_ORDER_CFGS_Vk-vkey = 'WIDTH' .

 APPEND wa_ORDER_CFGS_VK to ORDER_CFGS_VK .



 wa_ORDER_CFGS_VK-config_id = '000001'.

 wa_ORDER_CFGS_VK-inst_id = '00000001'  .

 wa_ORDER_CFGS_Vk-vkey = 'ROLL_QUANTITY' .

 APPEND wa_ORDER_CFGS_VK to ORDER_CFGS_VK .


 wa_ORDER_CFGS_VK-config_id = '000001' .

 wa_ORDER_CFGS_VK-inst_id = '00000001' .

 wa_ORDER_CFGS_Vk-vkey = 'COLOR' .

 APPEND wa_ORDER_CFGS_Vk to ORDER_CFGS_Vk .


call function 'BAPI_SALESORDER_CHANGE'

  exporting

    salesdocument               = SALESDOCUMENT

    order_header_inx            = ORDER_HEADER_INX

  tables

   return                      = return

   ORDER_ITEM_IN               = ORDER_ITEMS_IN

   ORDER_ITEM_INX              = ORDER_ITEMS_INX

   ORDER_CFGS_REF              = ORDER_CFGS_REF

   ORDER_CFGS_INST             = ORDER_CFGS_INST

   ORDER_CFGS_VALUE            = ORDER_CFGS_VALUE

   ORDER_CFGS_VK               = ORDER_CFGS_VK

   SCHEDULE_LINES              = ORDER_SCHEDULES_IN

   SCHEDULE_LINESX             = ORDER_SCHEDULES_INX .

call function 'BAPI_TRANSACTION_COMMIT'
 EXPORTING
   WAIT          = 'X'
 IMPORTING
   RETURN        = ret
commit WORK AND WAIT .
Jelena
Active Contributor

You're not checking SY-SUBRC or RETURN after BAPI call. I seriously doubt that there is no indication whatsoever that something is off. Try to look closer.

Also if something works in one case and doesn't work in the other then it's reasonable to look for the differences between those two cases.

Former Member
0 Kudos

Hi Jelena,

Thanks for your response.

Kindly find RETURN screen shot with successful messages but no updates happened with variant configuration characteristics values.

and i'm sure that the two cases in se37 and se38 are identical

Regards,

M

Accepted Solutions (0)

Answers (1)

Answers (1)

Jelena
Active Contributor
0 Kudos

Messages in RETURN don't say that configuration was processed. Go through this note: 1896387 - How to fill the configuration structure of the BAPI_SALESORDER_CHANGE

If there is still an issue afterwards, contact SAP Support.

Former Member
0 Kudos

Thank you for your support.

The problem is solved. However, i still could not find a user exit in order to update the variant configuration after saving the sales order.

Note:

I'm trying to use USEREXIT_SAVE_DOCUMENT and USEREXIT_SAVE_DOCUMENT_PREPARE but in both cases when it reaches to the line which executes our BAPI , strangely it returns to the first line in the userexit and the return table resulted from the BAPI is empty.

Jelena
Active Contributor
0 Kudos

There are no user exits "after saving" because the transaction is complete at that point.

Please post any additional questions separately.

Thank you.