Application Development 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: 

uploading sales orders

Former Member
0 Kudos

hi everyone,

iam trying to upload the sales orders in background job.but while doing this if i get an error in a particular order the job is cancelled and error log is generated.

Is there any way to process all the records even if some orders show errors?

for example

If i want to upload 100 orders and the 50th record has an error it should process all the remaining orders also and in the log it should show the success mesages for all the orders and error message for the 50th order.

please help

regards,

Sravanthi Chilal

1 REPLY 1

Former Member
0 Kudos

Hi,

When your BAPI returns the error table 'GT_RETURN' ... you can proceed further like this..

try using this....



  LOOP AT gt_return INTO gs_return WHERE type CA 'AE'.
    CLEAR gs_bapi_errors.
    CALL FUNCTION 'MESSAGE_TEXT_BUILD'
         EXPORTING
              msgid               = gs_return-id
              msgnr               = gs_return-number
              msgv1               = gs_return-message_v1
              msgv2               = gs_return-message_v2
              msgv3               = gs_return-message_v3
              msgv4               = gs_return-message_v4
         IMPORTING
              message_text_output = gs_bapi_errors.

    APPEND gs_bapi_errors TO gt_bapi_errors.
  ENDLOOP.

  IF gt_bapi_errors[] IS INITIAL.
    REFRESH gt_return.
    CLEAR ls_return.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         EXPORTING
              wait   = c_x
         IMPORTING
              return = ls_return.

    IF NOT ls_return IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      APPEND ls_return TO gt_return.
      PERFORM store_bapi_errors.
    ENDIF.

* Update failed
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  ENDIF.