matinal:SAP ABAP FB04清账 POSTING_INTERFACE_CLEARING

2023-10-14 15:21:26 浏览数 (1)

上代码

代码语言:javascript复制
 REPORT  ztest.  
  
*--------------------------------------------------------------------*  
*  INTERNAL TABLE DECLARATION  
*--------------------------------------------------------------------*  
DATA: it_blntab TYPE TABLE OF blntab WITH HEADER LINE,  
      it_ftclear TYPE TABLE OF ftclear WITH HEADER LINE,  
      it_ftpost TYPE TABLE OF ftpost WITH HEADER LINE,  
      it_fttax TYPE TABLE OF fttax WITH HEADER LINE.  
  
  
*--------------------------------------------------------------------*  
*  START-OF-SELECTION  
*--------------------------------------------------------------------*  
START-OF-SELECTION.  
  DEFINE populate_ftpost.  
    it_ftpost-stype = &1.  
    it_ftpost-count = &2.  
    it_ftpost-fnam  = &3.  
    it_ftpost-fval  = &4.  
    append it_ftpost.  
  END-OF-DEFINITION.  
  
  DEFINE populate_ftclear.  
    it_ftclear-agkoa  = 'D'.  
    it_ftclear-agbuk  = 'XXXX'. "company code  
    it_ftclear-selfd  = 'BELNR'.  
    it_ftclear-xnops  = 'X'.  
    it_ftclear-selvon = &1.  
    append it_ftclear.  
  END-OF-DEFINITION.  
  
  CALL FUNCTION 'POSTING_INTERFACE_START'  
    EXPORTING  
      i_function         = 'C'  
      i_keep             = 'X'  
      i_mode             = 'A'  
    EXCEPTIONS  
      client_incorrect   = 1  
      function_invalid   = 2  
      group_name_missing = 3  
      mode_invalid       = 4  
      update_invalid     = 5  
      OTHERS             = 6.  
  
  populate_ftpost: 'K' 1 'BKPF-BUKRS' 'BUKRS', "Company code  
                   'K' 1 'BKPF-BLART' 'DA',  
                   'K' 1 'BKPF-BLDAT' '16.09.2010',  
                   'K' 1 'BKPF-BUDAT' '16.09.2010',  
                   'K' 1 'BKPF-WAERS' 'RMB',  
                   'K' 1 'BKPF-XBLNR' 'Test',  
                   'P' 1 'RF05A-NEWBS' '11',  
                   'P' 1 'BSEG-HKONT' '0090000052',  
                   'P' 1 'BSEG-SGTXT' '20100916-01',  
                   'P' 1 'BSEG-WRBTR' '52'.  
  populate_ftclear '78000020772008001'. "concatenate doc number   fiscal year   line number  
  CALL FUNCTION 'POSTING_INTERFACE_CLEARING'  
    EXPORTING  
      i_auglv                          = 'UMBUCHNG'  
      i_tcode                          = 'FB05'  
      i_sgfunct                        = 'C'  
   IMPORTING  
      e_msgid                          = sy-msgid  
      e_msgno                          = sy-msgno  
      e_msgty                          = sy-msgty  
      e_msgv1                          = sy-msgv1  
      e_msgv2                          = sy-msgv2  
      e_msgv3                          = sy-msgv3  
      e_msgv4                          = sy-msgv4  
*      E_SUBRC                          = SY-SUBRC  
    TABLES  
      t_blntab                         = it_blntab  
      t_ftclear                        = it_ftclear  
      t_ftpost                         = it_ftpost  
      t_fttax                          = it_fttax  
    EXCEPTIONS  
      clearing_procedure_invalid       = 1  
      clearing_procedure_missing       = 2  
      table_t041a_empty                = 3  
      transaction_code_invalid         = 4  
      amount_format_error              = 5  
      too_many_line_items              = 6  
      company_code_invalid             = 7  
      screen_not_found                 = 8  
      no_authorization                 = 9  
      OTHERS                           = 10.  
  IF sy-subrc <> 0.  
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO  
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  
  ENDIF.  
  CALL FUNCTION 'POSTING_INTERFACE_END'  
    EXCEPTIONS  
      session_not_processable = 1  
      OTHERS                  = 2. 

0 人点赞