Skip to Content
0
Sep 02, 2020 at 02:38 PM

Commit Issue

95 Views

Hello Experts,

I am trying to update PO in system B based on some change scenario in system A.

I am calling BAPI_PO_CHANGE in system A.

Sometimes PO is not getting changed and also i am not getting any application logs. I tried to simulate in quality, not faced any issue for 5 records.

Am i wrong in commiting?

I am attaching part of the code for your advice.

Thank You in advance!

Best Regards,

LLD

 DATA: ls_aleport TYPE edipoa.
IF NOT lt_poitem[] IS INITIAL.
* Initialize Application Log
    PERFORM init_ballog USING lv_ebeln
                      CHANGING gv_bal_handle.
* Get target system
    CALL FUNCTION 'EDI_PORT_READ'
      EXPORTING
        portname       = 'LDD1'
      IMPORTING
        ale_port       = ls_aleport
      EXCEPTIONS
        port_not_exist = 1
        OTHERS         = 0.

    IF sy-subrc IS INITIAL.
      lv_target_sys = ls_aleport-logdes.
    ELSE.
      PERFORM write_log USING sy-msgty sy-msgid sy-msgno
            lv_msgv1 lv_msgv2 '' '' gv_bal_handle.
* Save BAL
      PERFORM save_ballog_msg USING gv_bal_handle.
      RAISE port_not_exist.
    ENDIF.


    CALL FUNCTION 'CAT_CHECK_RFC_DESTINATION'
      EXPORTING
        rfcdestination = lv_target_sys
      IMPORTING
        msgv1          = lv_msgv1
        msgv2          = lv_msgv2
        rfc_subrc      = lv_subrc.
    IF lv_subrc IS NOT INITIAL.
      PERFORM write_log USING sy-msgty sy-msgid sy-msgno
           lv_msgv1 lv_msgv2 '' '' gv_bal_handle.
* Save BAL
      PERFORM save_ballog_msg USING gv_bal_handle.
      RAISE rfc_issue.
    ENDIF.


* BAPÍ
    CALL FUNCTION 'BAPI_PO_CHANGE'
      DESTINATION lv_target_sys
      EXPORTING
        purchaseorder = lv_ebeln
      TABLES
        poitem        = lt_poitem
        poitemx       = lt_poitemx
        return        = lt_return.
*set log for errors
    LOOP AT lt_return INTO ls_return WHERE type = 'A' OR type = 'E'.
      PERFORM write_log USING ls_return-type ls_return-id ls_return-number ls_return-message_v1
                              ls_return-message_v2 ls_return-message_v3 ls_return-message_v4 gv_bal_handle.
    ENDLOOP.


    IF ls_return IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
         DESTINATION lv_target_sys "commit
       EXPORTING
         wait          = 'X'
       IMPORTING
         return        = ls_return.


      IF ls_return IS NOT INITIAL.
        PERFORM write_log USING ls_return-type ls_return-id ls_return-number ls_return-message_v1
                                ls_return-message_v2 ls_return-message_v3 ls_return-message_v4 gv_bal_handle.
      ENDIF.


    ENDIF.
* Save BAL
    PERFORM save_ballog_msg USING gv_bal_handle.
    CLEAR: ls_return, lt_poitem[], lt_poitemx[],
          lv_target_sys, lt_return[], lt_vbfa[].
  ENDIF.

Attachments