Quantcast
Viewing all articles
Browse latest Browse all 9076

MIRO Posting Issue

Hi,

 

We have one requirement, where we have to post 2 more entries for MIRO as soon as the invoice document created successfully.

We searched many threads in SCN to find the user exit or BADI after COMMIT (invoice being created successfully), but couldn't able to find.

 

Later we found one include LMR1MF2Y after the commit work and we implemented an implicit enhancement to post the 2 new entries w.r.t Invoice created. Here we are facing an issue while posting the entries and below is the code and error.

 

LOOP AT LT_BSEG INTO LS_BSEG.

     IF LS_BSEG-shkzg = 'H'.
        CONCATENATE LS_BSEG-BELNR LS_BSEG-gjahr INTO documentheader-header_txt.
        documentheader-username = sy-uname.
        documentheader-obj_type = LS_BKPF-TCODE.
        documentheader-comp_code = LS_BSEG-bukrs.
        documentheader-doc_date = ls_bkpf-bldat.
        documentheader-pstng_date = ls_bkpf-budat.
        documentheader-doc_type = 'SA'.
        documentheader-fisc_year = LS_BSEG-gjahr.
*       documentheader-ref_doc_no = LS_BSEG-xblnr.
****line item 1
       accountgl-itemno_acc = '1'.
       accountgl-gl_account = LS_BSEG-HKONT.
       accountgl-comp_code = LS_BSEG-bukrs.
       accountgl-pstng_date = ls_bkpf-budat.
       accountgl-doc_type = 'SA'.
       accountgl-stat_con = 'H'.
       accountgl-profit_ctr = LS_BSEG-prctr.
       accountgl-alloc_nmbr = LS_BSEG-zuonr.
       accountgl-VENDOR_NO  = LS_BSEG-lifnr.
       accountgl-TAX_CODE   = LS_BSEG-MWSKZ.
       APPEND accountgl.

       currencyamount-itemno_acc = '1'.
       currencyamount-currency = LS_BSEG-PSWSL.
       currencyamount-amt_doccur = LS_BSEG-WRBTR.
       APPEND currencyamount.


      ELSE.
****line item 2
       accountgl-itemno_acc = '2'.
       accountgl-gl_account = LS_BSEG-HKONT.
       accountgl-comp_code = LS_BSEG-bukrs.
       accountgl-pstng_date = ls_bkpf-budat.
       accountgl-doc_type = 'SA'.
       accountgl-stat_con = 'S'.
       accountgl-profit_ctr = LS_BSEG-prctr.
       accountgl-costcenter = LS_BSEG-kostl.
       accountgl-alloc_nmbr = LS_BSEG-zuonr.
       accountgl-VENDOR_NO  = LS_BSEG-lifnr.
       accountgl-TAX_CODE   = LS_BSEG-MWSKZ.
       APPEND accountgl.

       currencyamount-itemno_acc = '2'.
       currencyamount-currency = LS_BSEG-PSWSL.
       currencyamount-amt_doccur = LS_BSEG-WRBTR.
       APPEND currencyamount.
     ENDIF.

    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
       EXPORTING
         documentheader = documentheader
       TABLES
         accountgl      = accountgl
         currencyamount = currencyamount
         return         = return
         extension1     = extension1
       EXCEPTIONS
         OTHERS         = 1.
     IF sy-subrc <> 0.
       MESSAGE e999(re) WITH 'Problem occured'.
     ELSE.
       .
       LOOP AT return.
         IF NOT return IS INITIAL.
           CLEAR bapi_retn_info.
           MOVE-CORRESPONDING return TO bapi_retn_info.
           IF return-type = 'A' OR return-type = 'E'.
             error_flag = 'X'.
           ENDIF.
           APPEND bapi_retn_info.
         ENDIF.
       ENDLOOP.
       IF error_flag = 'X'.
         MESSAGE e999(re) WITH 'Problem occured'.
         ROLLBACK WORK.
       ELSE.
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             wait   = gs_wait
           IMPORTING
             return = wa_comm_return.
         WRITE :/ return-message+0(30),return-message+36(10).
       ENDIF.

     ENDIF.
     REFRESH: currencyamount,accountgl,return,extension1.
     CLEAR: currencyamount,accountgl,documentheader,return,extension1.

ENDLOOP.


Image may be NSFW.
Clik here to view.

 

  • Please let us know if we have any user exits or BADIs after commit for MIRO.
  • Please let us know if we missed any other parameters for above BAPI.

 

Please help us to resolve this issue.

 

Thanks

Gangadhar


Viewing all articles
Browse latest Browse all 9076

Trending Articles



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