Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3523

Issue in updating Z table

$
0
0

Dear Friends,

 

I have an issue in Updating Ztable sequentially.

 

Scenario : One program updates my Ztable, from that table my program read records and post the documents ( BAPI_ACC_DOCUMENT_POST) . After successful posting of  document that Z-table has to update with document number. Programs are scheduled in background(SM37). Here problem is for few records even document get created successfully it's not updating the Z-Table. Please check the code below and suggest. Thanks in advance.

 

Code :   

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
         EXPORTING
           DOCUMENTHEADER    = BAPIACHE09
         IMPORTING
           OBJ_TYPE          = OBJ_TYPE
           OBJ_KEY           = OBJ_KEY
           OBJ_SYS           = OBJ_SYS
         TABLES
           ACCOUNTGL         = IT_ACCOUNTGL[]
           ACCOUNTRECEIVABLE = IT_ACCOUNTRECEIVABLE[]
           CURRENCYAMOUNT    = IT_CURRENCYAMOUNT[]
           RETURN            = IT_RETURN[].

       READ TABLE IT_RETURN WITH KEY TYPE = 'E'.
       IF SY-SUBRC = 0. " ERROR OCCURED
         CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
         " updating error status in staging table
         LS_HEADER-BAPI_FLAG = 'E'.
         LS_HEADER-SAP_DATE = SY-DATUM.
         LS_HEADER-SAP_TIME = SY-UZEIT.
         READ TABLE IT_RETURN INDEX 2.
         LS_HEADER-STS_DESC = IT_RETURN-MESSAGE.
        UPDATE ZIB_INVOICE_HD FROM LS_HEADER.
         COMMIT WORK.
         WAIT UP TO 1 SECONDS.
       ELSEIF OBJ_KEY IS NOT INITIAL. " SUCCESS
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
         WAIT UP TO 2 SECONDS.
*       CONDENSE OBJ_KEY.
         LS_HEADER-BAPI_FLAG = 'S'.
         LS_HEADER-SAP_DATE = SY-DATUM.
         LS_HEADER-SAP_TIME = SY-UZEIT.
         LS_HEADER-STS_DESC = OBJ_KEY.
         UPDATE ZIB_INVOICE_HD FROM LS_HEADER.
         COMMIT WORK.
         WAIT UP TO 1 SECONDS.
       ENDIF.
     ELSE.
       LS_HEADER-BAPI_FLAG = 'E'.
       LS_HEADER-SAP_DATE = SY-DATUM.
       LS_HEADER-SAP_TIME = SY-UZEIT.
       LS_HEADER-STS_DESC = 'ERROR: Data issue'.
       UPDATE ZIB_INVOICE_HD FROM LS_HEADER.
       COMMIT WORK.
       WAIT UP TO 1 SECONDS.

ENDIF.


Viewing all articles
Browse latest Browse all 3523

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>