Here I am replacing the condition type ZOCH on the sales order item with the price from material master data if this exists, and it’s different.
Here The issue is that for specific sales orders its getting stopped at the following screen.
Here I would like to have an error or information message that data are missing and the report should continue with the next order.
How can I achieve that?
Here is my sample code..
LOOP AT it_konvINTO wa_konv.
TRY.
UPDATE konv
SET kbetr = wa_konv-kbetr
kwert = wa_konv-kwert
kinak = ''
WHERE knumv = wa_konv-knumv
AND kposn = wa_konv-kposn
AND stunr = wa_konv-stunr
AND zaehk = wa_konv-zaehk
AND kschl = 'ZOCH'.
IF sy-subrc EQ 0.
READ TABLE it_vbak_vbap INTO wa_vbak_vbap WITH KEY
knumv = wa_konv-knumv
posnr = wa_konv-kposn
BINARY SEARCH.
IF sy-subrc EQ 0.
DATA: it_order_item_x LIKE bapisditmx OCCURS 1 WITH HEADER LINE,
it_return LIKE bapiret2 OCCURS 5 WITH HEADER LINE,
wa_head_x TYPE bapisdh1x,
lv_vbeln TYPE vbeln,
lv_posnr TYPE posnr.
lv_vbeln = wa_vbak_vbap-vbeln.
wa_head_x-updateflag = 'U'.
it_order_item_x-itm_number = lv_posnr.
it_order_item_x-updateflag = 'U'.
APPEND it_order_item_x.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = lv_vbeln
order_header_inx = wa_head_x
TABLES
return = it_return
order_item_inx = it_order_item_x.
READ TABLE it_return WITH KEY type = 'E'.
IF sy-subrc EQ 0.
WRITE: / 'Error while Update Doc Condition Number', lv_vbeln.
WRITE: / it_return-message.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
ENDIF.
CATCH cx_sy_dynamic_osql_error.
End loop.
Regards,
Ramesh