BAPI_ACC_DOCUMENT_CHECK

Dear experts,
We need help in one of the BAPI's BAPI_ACC_DOCUMENT_CHECK to post document.
BAPI working successfully if company code at header and item level is same but if items are from different company codes then we received error saying "Required fieldsOBJ_TYPE, OBJ_KEY, OBJ_SYS are blank.".
When searched forums on this, we found these fields are not mandatory however we receive the error message.
Also, found many threads on this but didnt get a proper link as to how can we proceed to resolve this issue.
Can you please help us if any data we entered is incorrect or we are missing with some functional configuration.
Thanks for your time.

Try to check the routine check_and_fill_acc_document, here you should see the following code:
IF document_header-obj_type = 'BKPFF'.
    PERFORM append_msg_to_return
            USING 'E'              "TYPE
                  'RW'             "ID
                  '628'            "NUMBER
                  'BKPFF'          "MESSAGE_ONE
                  'DOCUMENTHEADER' "MESSAGE_TWO
                  'DOCUMENTHEADER' "PARAMETER
                  1                "ROW
                  'OBJ_TYPE'.      "FIELD
  ENDIF.
  IF document_header-obj_type  IS INITIAL AND
     document_header-obj_key   IS INITIAL AND
     document_header-obj_sys   IS INITIAL AND
     document_header-ac_doc_no IS INITIAL.
    LOOP AT account_gl WHERE NOT stat_con  IS INITIAL
                          or NOT ac_doc_no IS INITIAL.
      EXIT.
    ENDLOOP.
    IF NOT sy-subrc IS INITIAL.
      PERFORM reference_create_prelim
              CHANGING document_header-obj_type
                       document_header-obj_key
                       document_header-obj_sys.
      document_header-bus_act = 'RFBU'.                "note1045412
    ENDIF.
  ENDIF.
The routine reference_create_prelim should be called and those fields should be filled
Max

Similar Messages

  • Error in BAPI_ACC_DOCUMENT_CHECK

    Hi!
    I would like to call function "BAPI_ACC_DOCUMENT_CHECK" and I encounter the error: <i>Type conflict when calling a function module (field length).</i>
    First, I upload an excel file. Then, I fill in my document header and line items as below:
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME                = p_file
          I_BEGIN_COL             = '1'
          I_BEGIN_ROW             = '7'
          I_END_COL               = '21'
          I_END_ROW               = '999'
        TABLES
          INTERN                  = intern
        EXCEPTIONS
          INCONSISTENT_PARAMETERS = 1
          UPLOAD_OLE              = 2
          OTHERS                  = 3.
    SORT intern by row col.
    * I loop at the intern and append to an internal table 'xcel'.
    * then I fill in the document header 'bapiache09'.
          bapiache09-doc_type   = 'PC'.
          bapiache09-doc_date   = sy-datum.
          bapiache09-pstng_date = p_budat.         "p_budat is declared as
                                                  "bapiache09-pstng_date on selection screen
          bapiache09-comp_code  = 'B000'.
          bapiache09-header_txt = 'SCTA (AB28)-P11/06'.
          bapiache09-ref_doc_no = 'Test'.
          bapiache09-username = sy-uname.
          bapiache09-bus_act = 'RFBU'.
    * now i fill in the line items
      LOOP AT xcel INTO wa_xcel.
        ADD 1 to item_no.
    * internal table of gl account, type bapiacap09
        IF wa_xcel-post_key EQ '40' OR wa_xcel-post_key EQ '50'.
          wa_gl_account-itemno_acc = item_no.
          wa_gl_account-doc_type   = wa_xcel-fld2.
          wa_gl_account-gl_account  = wa_xcel-fld3.
          wa_gl_account-costcenter = wa_xcel-fld7.
          wa_gl_account-alloc_nmbr = wa_xcel-fld11.
          wa_gl_account-item_text  = wa_xcel-fld12.
          wa_gl_account-cs_trans_t = wa_xcel-fld18.
          wa_gl_account-tax_code   = wa_xcel-fld20.
          APPEND wa_gl_account TO gl_account.
          CLEAR wa_gl_account.
    * internal table of payable account, type bapiacap09
        ELSEIF wa_xcel-post_key EQ '21' OR wa_xcel-post_key EQ '31'.
          wa_py_account-itemno_acc = item_no.
          wa_py_account-vendor_no  = wa_xcel-fld3.
          wa_py_account-bline_date = wa_xcel-fld5.
          wa_py_account-alloc_nmbr = wa_xcel-fld11.
          wa_py_account-item_text  = wa_xcel-fld12.
          wa_py_account-sp_gl_ind  = wa_xcel-fld14.
          wa_py_account-tax_code   = wa_xcel-fld20.
          APPEND wa_py_account TO py_account.
          CLEAR wa_py_account.
        ENDIF.
    * internal table of currency amount, type bapiaccr09.
        wa_curr_amt-itemno_acc = item_no.
        wa_curr_amt-currency = wa_xcel-fld6.
        wa_curr_amt-amt_doccur = wa_xcel-fld15.
        APPEND wa_curr_amt TO curr_amt.
        CLEAR wa_curr_amt.
      ENDLOOP.
      PERFORM bapi_check.
    ENDFORM.                    " fill_line_item
    FORM bapi_check .
      DATA: wa_ret_tab    LIKE LINE OF ret_tab.
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
        EXPORTING
          DOCUMENTHEADER    = bapiache09
        TABLES
          ACCOUNTGL         = gl_account
          ACCOUNTRECEIVABLE = py_account
          CURRENCYAMOUNT    = curr_amt
          RETURN            = ret_tab.
    ENDFORM.
    Does anyone know what is the exact problem as I declared all the internal tables according to the type in FM 'BAPI_ACC_DOCUMENT_CHECK'. Why I get the error of type conflict?
    thanks in advance!
    ying ying..

    Hi, I have figured out what is the problem, I passed the py_account to ACCOUNTRECEIVABLE. It should be ACCOUNTPAYABLE.
    FORM bapi_check .
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
        EXPORTING
          DOCUMENTHEADER    = bapiache09
        TABLES
          ACCOUNTGL         = gl_account
    *      ACCOUNTRECEIVABLE = py_account
    <b>ACCOUNTPAYABLE </b>= py_account
    "should be payable account, not receivable account
          CURRENCYAMOUNT    = curr_amt
          RETURN            = ret_tab.
    ENDFORM.                    " bapi_check
    cheers,
    ying

  • Error occurs, BAPI_ACC_DOCUMENT_CHECK for creation of accounting document

    Hi Experts,
    I am creating accounting document using BAPI_ACC_DOCUMENT_CHECK  Bapi F.M.  Profit segment number  is mandatory ( T.code KEDR)  for G/L account 411103 .when i am using this G/L account for creation of accounting document, occurs below error message.
    1.Field  Prof. Segmt  is required field  for G/L account 0495 411103
    2. Account 411103 requires an  assignment  to a CO Object.
    Please let me know how i can resolve this problem using with BAPI.
    Thanks
    Jaya Reddy

    The BAPI you have mentioned is used to check whether a posting to accounting is possible.  You can use the Bapi "BAPI_ACC_DOCUMENT_POST" for posting accounting documents.  Depending on the GL account configuration you have to pass PROFIT CENTER / COST CENTER to the BAPI.
    Regards
    vinod

  • BAPI_ACC_DOCUMENT_CHECK for Vendor Items

    Hi friends,
    I am using the BAPI BAPI_ACC_DOCUMENT_CHECK to check the data to be posted for Vendor lines
    items. It is giving the error:
    'For document type RE, an entry is required in field Reference'
    I have written the code like this:
        Loop at t_final into wa_final.
    *       Populate data for accounting doc. header to populate to BAPI
            IF v_count = '1'.
              wa_documentheader_ap1-username     = sy-uname.
              wa_documentheader_ap1-header_txt   = wa_final-bktxt.
              wa_documentheader_ap1-comp_code    = wa_final-bukrs.
              PERFORM convert_dates using wa_final-bldat CHANGING wa_documentheader_ap1-doc_date.
              PERFORM convert_dates using wa_final-budat CHANGING wa_documentheader_ap1-pstng_date.
              wa_documentheader_ap1-doc_type     = wa_final-blart.             "= 'RE'
              wa_documentheader_ap1-ref_doc_no   = wa_final-xblnr.             "Passing the 'Ref 1' as value
              APPEND wa_documentheader_ap1 TO t_documentheader_ap1.
    *         Populate Vendor Line Item
              CLEAR wa_ACCOUNTPAYABLE_ap1.
              wa_ACCOUNTPAYABLE_ap1-ITEMNO_ACC = v_count.
              wa_ACCOUNTPAYABLE_ap1-VENDOR_NO = wa_final-lifnr.
              wa_ACCOUNTPAYABLE_ap1-GL_ACCOUNT = c_hkont_v.
              wa_ACCOUNTPAYABLE_ap1-COMP_CODE = wa_final-bukrs.
              wa_ACCOUNTPAYABLE_ap1-PMNTTRMS = wa_final-zterm.
              wa_ACCOUNTPAYABLE_ap1-BLINE_DATE = wa_final-zfbdt.
              wa_ACCOUNTPAYABLE_ap1-PYMT_METH = wa_final-zlsch.
              wa_ACCOUNTPAYABLE_ap1-TAX_CODE  = wa_final-mwskz.
              wa_ACCOUNTPAYABLE_ap1-REF_KEY_1 = wa_final-xblnr.                       "Ref 1 as value
              wa_ACCOUNTPAYABLE_ap1-REF_KEY_2 = wa_final-xblnr.                       "ref 1  as value
              wa_ACCOUNTPAYABLE_ap1-REF_KEY_3 = wa_final-xblnr.                       "Ref 1 as value
              APPEND wa_ACCOUNTPAYABLE_ap1 to t_ACCOUNTPAYABLE_ap1.
    *       Amount and Currecy details
              wa_currencyamount_ap1-itemno_acc = v_count.
              wa_currencyamount_ap1-currency = wa_final-waers.
              v_wrbtr =  wa_final-wrbtr * -1.
              wa_currencyamount_ap1-amt_doccur = v_wrbtr.
              v_wrbtr_cr_ap1 = wa_final-wrbtr.
              APPEND wa_currencyamount_ap1 TO t_currencyamount_ap1.
              CLEAR wa_currencyamount_ap1.
              v_count = v_count + 1.
           ENDIF.
    *       GL Line Item
            wa_accountgl_ap1-itemno_acc =  V_count.
            wa_accountgl_ap1-gl_account =  wa_final-hkont.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                input  = wa_accountgl_ap1-gl_account
              IMPORTING
                output = wa_accountgl_ap1-gl_account.
            wa_accountgl_ap1-item_text  =  wa_final-sgtxt.
            wa_accountgl_ap1-profit_ctr =  wa_final-prctr.
            wa_accountgl_ap1-costcenter =  wa_final-kostl.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                input  = wa_accountgl_ap1-costcenter
              IMPORTING
                output = wa_accountgl_ap1-costcenter.
            wa_accountgl_ap1-REF_KEY_1  = wa_final-xblnr.  "Ref 1 as a value
            wa_accountgl_ap1-REF_KEY_2 = wa_final-xblnr.  ""Ref 1 as a value
            wa_accountgl_ap1-REF_KEY_3 = wa_final-xblnr.  ""Ref 1 as a value
            wa_accountgl_ap1-costobject =  wa_final-kstrg.
            APPEND wa_accountgl_ap1 TO t_accountgl_ap1.
            CLEAR wa_accountgl_ap1.
    *       Amount and Currecy details
            wa_currencyamount_ap1-itemno_acc = v_count.
            wa_currencyamount_ap1-currency = wa_final-waers.
             wa_currencyamount_ap1-amt_doccur = wa_final-wrbtr_it.
            APPEND wa_currencyamount_ap1 TO t_currencyamount_ap1.
            CLEAR wa_currencyamount_ap1.
            v_count = v_count + 1.
    endloop.
    * Validating against BAPI_ACC_DOCUMENT_CHECK
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
        EXPORTING
          documentheader = wa_documentheader_gl2
        TABLES
          accountgl      = t_accountgl_gl2
          currencyamount = t_currencyamount_gl2
          return         = t_return_gl1.
    But it is giving the error: ' 'For document type RE, an entry is required in field Reference''
    Is rthe value entered for Reference is valid document?
    Do i need to pass any other table to this FM to populate vendor data?
    What is the problem in my code?
    Thanks,
    Sreenivas reddy
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 4:01 PM

    Hi Srinivas,
    The minimun field required to make a vendor posting are as follows,
            wa_vendoritem-itemno_acc  = gv_count.
            wa_vendoritem-vendor_no    =  wa_vendor-newko.
            wa_vendoritem-item_text     = wa_vendor-sgtxt.
            wa_vendoritem-comp_code  = wa_vendor-bukrs.
            wa_vendoritem-pmnttrms     = wa_vendor-zterm.
            wa_vendoritem-bline_date   = wa_vendor-zfbdt.
            wa_vendoritem-item_text    = wa_vendor-sgtxt.
            wa_vendoritem-tax_code    = wa_vendor-mwskz.
            wa_vendoritem-profit_ctr     = wa_vendor-prctr.
    I think you missed the profir centre field which is mandatory for a vendor posting,or if is a new gl, it will derive the profit centre from the cost centre of the previous line(i.e. G/L line).  if it is not a new G/l , then you need to manually find the profit centre from cost centre and put the values. So double check passing these field , it should be working. Still have doubts please contact me.
    regards,
    Shobana.K
    Edited by: Shobana k on Jan 8, 2009 8:05 AM
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 4:01 PM

  • Issue with BAPI_ACC_DOCUMENT_CHECK & BAPI_ACC_DOCUMENT_POST

    I wrote a program code to post a document for F-43 transaction using a BAPI.
    Unfortunately, the BAPI comes back with an error message
    1 E RW 609     Error in document: BKPF 1900022387208 2010 SYS01                  1900022387208 2010
    2 E RW 628     Incorrect entry in field OBJ_TYPE: BKPF                                          DOCUMENTHEADER 1 OBJ_TYPE
    Any help would be appreciated.
    REPORT z_test_f44 NO STANDARD PAGE HEADING LINE-COUNT 65 LINE-SIZE 132
    MESSAGE-ID zfi.
    TABLES: bsik, t003.
    TYPES:
      BEGIN OF tp_tab_bsik,
        bukrs TYPE bukrs,
        lifnr TYPE lifnr,
        gjahr TYPE gjahr,
        budat TYPE budat,
        bldat TYPE bldat,
        blart TYPE blart,
        bschl TYPE bschl,
      END OF tp_tab_bsik.
    SELECTION-SCREEN:BEGIN OF BLOCK blck01 WITH FRAME TITLE text-001.
    PARAMETERS:
        p_per(2)            TYPE c                    DEFAULT sy-datum+4(2),
        p_dt                LIKE sy-datum             DEFAULT sy-datum,
        p_hkont             TYPE hkont                DEFAULT '105010',
        p_waers             LIKE bkpf-waers           DEFAULT 'USD',
        p_blart             LIKE bkpf-blart           DEFAULT 'KR',
        p_xblnr            LIKE bkpf-xblnr            DEFAULT 'V01',
        p_xblnr1           LIKE bkpf-xblnr            DEFAULT 'A01',
        p_amt              LIKE bseg-wrbtr            DEFAULT '10.00',
        p_bukrs            LIKE bkpf-bukrs            DEFAULT '208',
        p_lifnr            LIKE lfa1-lifnr            DEFAULT '1000165'.
    SELECTION-SCREEN:END OF BLOCK blck01.
    *----------------end of selection parameters-----------------------*
    *------------------START OF SELECTION----------------------------------*
    START-OF-SELECTION.
      PERFORM process_data.          "Posting using F-44(Bapi)
    *&      Form  process_data
    *       text
    FORM process_data.
      DATA:
      l_documentheader   LIKE bapiache09,
      l_accountgl        LIKE bapiacgl09 OCCURS 2 WITH HEADER LINE,
      l_vendoritem       LIKE bapiacap09 OCCURS 2 WITH HEADER LINE,
      l_currencyamount   LIKE bapiaccr09 OCCURS 2 WITH HEADER LINE,
      l_currencytype     LIKE bapiaccr09-currency_iso,
      l_return           LIKE bapiret2 OCCURS 5 WITH HEADER LINE,
      l_obj_type         LIKE bapiache02-obj_type,
      l_obj_key          LIKE bapiache02-obj_key,
      l_obj_sys          LIKE bapiache02-obj_sys,
      l_obj_sys_1        LIKE tbdls-logsys,
      ls_t003            TYPE t003,
      l_belnr            TYPE bkpf-belnr,
      l_awtyp            LIKE acchd-awtyp,   " Anwendungsreferenz
      l_awref            LIKE acchd-awref,   "
      l_aworg            LIKE acchd-aworg,   "
      l_awsys            LIKE acchd-awsys,   "
      l_awkey            LIKE bkpf-awkey.    "
      BREAK-POINT.
      CLEAR:
             l_documentheader, l_vendoritem, l_accountgl,
             l_currencyamount, l_return.
      REFRESH:l_vendoritem, l_currencyamount, l_return.
    * Get Your Logical System
      CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
        IMPORTING
          own_logical_system             = l_obj_sys_1
        EXCEPTIONS
          own_logical_system_not_defined = 1
          OTHERS                         = 2.
    * Number Range Information
      SELECT SINGLE *
        FROM t003
        INTO CORRESPONDING FIELDS OF t003
       WHERE blart = p_blart.
    * Get the additional Number Range Details.
      CALL FUNCTION 'FAGL_GET_NUMBER_RANGE_FOR_PN'
        EXPORTING
          i_rldnr       = '0L'     "Ledger
          i_blart       = p_blart
        IMPORTING
          es_t003       = ls_t003
        EXCEPTIONS
          error_message = 1.
    * Get the next BELNR
      t003-numkr = ls_t003-numkr.
      CALL FUNCTION 'RF_GET_DOCUMENT_NUMBER'
        EXPORTING
          company         = p_bukrs
          range           = t003-numkr
          year            = sy-datum+0(4)
        IMPORTING
          document_number = l_belnr.
    * Create Reference Keys
      CALL FUNCTION 'FI_REFERENCE_CREATE'
        EXPORTING
          i_awtyp           = 'BKPF '
          i_bukrs           = p_bukrs
          i_gjahr           = sy-datum+0(4)
          i_belnr           = l_belnr
        IMPORTING
          e_awtyp           = l_awtyp
          e_awref           = l_awref
          e_aworg           = l_aworg
          e_awkey           = l_awkey
          e_awsys           = l_awsys
        EXCEPTIONS
          object_type       = 1
          missing_parameter = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * Build Document Header
      l_documentheader-obj_type   = l_awtyp. "'BKPF'.
      l_documentheader-obj_key    = l_awkey.
      l_documentheader-obj_sys    = l_obj_sys_1.
      l_documentheader-bus_act    = 'RFBU'.
      l_documentheader-ac_doc_no  = l_belnr.
      l_documentheader-username   = sy-uname.
      l_documentheader-comp_code  = p_bukrs.
      l_documentheader-fis_period = p_per.
      l_documentheader-doc_date   = p_dt.
      l_documentheader-pstng_date = sy-datum.
      l_documentheader-fisc_year  = sy-datum+0(4).
      l_documentheader-doc_type   = p_blart.
      l_documentheader-ref_doc_no = p_xblnr.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = p_hkont
        IMPORTING
          output = p_hkont.
    * G/L Item
      l_accountgl-itemno_acc     = '000000001'.
    *  l_accountgl-acct_key       = 'RFBU'.
      l_accountgl-gl_account     = p_hkont.
      l_accountgl-comp_code      = p_bukrs.
      l_accountgl-pstng_date     = sy-datum.
      l_accountgl-doc_type       = p_blart.
      APPEND l_accountgl. CLEAR l_accountgl.
    * G/L Item $$$s
    * Posting Key 50
      l_currencyamount-itemno_acc   = '000000001'.
      l_currencyamount-currency_iso = p_waers.
      l_currencyamount-currency     = p_waers.
      l_currencyamount-amt_doccur   = p_amt.
      APPEND l_currencyamount. CLEAR l_currencyamount.
    * Vendor Item
      l_vendoritem-itemno_acc     = '000000002'.
    *  l_accountgl-acct_key       = 'RFBU'.
      l_vendoritem-vendor_no     = p_lifnr.
      l_vendoritem-comp_code     = p_bukrs.
      APPEND l_vendoritem. CLEAR l_vendoritem.
    * Vendor Item $$$s
    * Posting Key 31
      l_currencyamount-itemno_acc   = '000000002'.
      l_currencyamount-currency_iso = p_waers.
      l_currencyamount-currency     = p_waers.
      l_currencyamount-amt_doccur   = p_amt.
      l_currencyamount-amt_doccur = l_currencyamount-amt_doccur * -1.
      APPEND l_currencyamount. CLEAR l_currencyamount.
      BREAK-POINT.
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
        EXPORTING
          documentheader = l_documentheader
        TABLES
          accountgl      = l_accountgl
          accountpayable = l_vendoritem
          currencyamount = l_currencyamount
          return         = l_return.
    *  CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    *    EXPORTING
    *      documentheader = l_documentheader
    *    IMPORTING
    *      obj_key        = l_obj_key
    *    TABLES
    *      accountgl      = l_accountgl
    *      accountpayable = l_vendoritem
    *      currencyamount = l_currencyamount
    *      return         = l_return.
      BREAK-POINT.
    *  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDFORM.                    "process_data

    Actually I am using Standard SAP Function modules to generate the OBJ_TYP.
    Unfortunately the "Code" tag is not working for me in this browser to align the program code correctly.
    But yes, to answer your question obj_typ is correctly done.
    * Create Reference Keys
      call function 'FI_REFERENCE_CREATE'
        exporting
          i_awtyp           = 'BKPF '
          i_bukrs           = p_bukrs
          i_gjahr           = sy-datum+0(4)
          i_belnr           = l_belnr
        importing
          e_awtyp           = l_awtyp
          e_awref           = l_awref
          e_aworg           = l_aworg
          e_awkey           = l_awkey
          e_awsys           = l_awsys
        exceptions
          object_type       = 1
          missing_parameter = 2
          others            = 3.

  • Validation for a extension field in the BAPI ( BAPI_ACC_DOCUMENT_CHECK)

    Hi,
    I am working on an in terface for upload of data in journal ledger(FB50)
    Actually i need to validate a field which has been included in transaction FB50 as an enhancement based on customer need .
    a function module was created as suggested in note 487722 earlier but now we require to validate that field(transaction type) as i am using this BAPI in an interface for journal ledger posting FB50 for data validation of the file data.
    this field has been populated as a part of the extension parameter in the bapi -
    (( BAPI_ACC_DOCUMENT_CHECK)
    field values for this field have been passed in the business transaction.
    but i am not sure where to code the validation for this field .
    could anybody suggest if we need to do it in include ZXACCU15 .
    if so then how do we populate the values for the return parameter.
    i am post ing document using IDOC and need to generate the for the errors generated.
    it already shows for all the standard fields of the transaction.
    Its a bit urgent,
    help wud be appreciated
    jy

    Hello Jy
    The following coding shows how to evaluate the existence of the transaction type in table T856 and how to create the corresponding BAPI message (using function module <b>BALW_BAPIRETURN_GET2</b>):
    *& Report  ZUS_SDN_BAPIRETURN_GET2
    REPORT  zus_sdn_bapireturn_get2.
    START-OF-SELECTION.
      " Call BTE function within BAPI (actually OPEN_FI_PERFORM_RWBAPI01_P
      " calls the z-function module)
    **  CALL FUNCTION 'Z_FI_INTERFACE_RWBAPI01'
    **    TABLES
    **      c_accit           =
    **      c_acccr           =
    **      c_return          =
    **      c_extension       =
    **      c_accwt           =
    **    changing
    **      c_acchd           =
      " Coding within your BTE function module:
      DATA:
        ls_return    TYPE bapiret2.
    * transaction type
      READ TABLE it_accit INTO ls_accit
           WITH KEY posnr = ld_posnr.
      CHECK ( sy-subrc EQ 0 ).
      ld_tabix = sy-tabix.
      ls_accit-posnr = ld_posnr.
      ls_accit-rmvct = ls_bapi_extension-field3.
      MODIFY it_accit FROM ls_accit INDEX ld_tabix.
    " Validate existence of transaction type
      SELECT SINGLE * FROM  t856 into ls_t856
             WHERE  trtyp  = ls_accit-rmvct.
      if ( syst-subrc ne 0 ).
        " Note: the following IF condition looks apparently strange yet its primary
        "         use is to ensure that the Where-Used-List for message 014(GC)
        "         will find our function module
        if 1 = 2.  MESSAGE e014(gc) WITH ls_accit-rmvct.  endif.
    *   Transaction type & is not defined
        clear: ls_return.
        ls_return-message_v1 = ls_accit-rmvct.  " type conversion
        CALL FUNCTION 'BALW_BAPIRETURN_GET2'
          EXPORTING
            type             = 'E'
            cl               = 'GC'
            number           = '814'
            PAR1             = ls_return-message_v1
    *       PAR2             = ' '
    *       PAR3             = ' '
    *       PAR4             = ' '
    *       LOG_NO           = ' '
    *       LOG_MSG_NO       = ' '
    *       PARAMETER        = ' '
    *       ROW              = 0      " ld_tabix
    *       FIELD            = ' '    " RMVCT
          IMPORTING
            RETURN           = ls_return.
        APPEND ls_return TO c_return.
      ENDIF.
    END-OF-SELECTION.
    The advantage of using the function module over directly filling the BAPIRET2 message variable is that the function module generated the message text (field BAPIRET2-message = 'Transaction type '<type>' is not defined').
    Regards
      Uwe

  • Which field represents 'LEDGER GROUP'  in BAPI_ACC_DOCUMENT_CHECK.

    Hi Experts,
    I am posting documents in FB50l. Before posting i am checking the documents using BAPI : BAPI_ACC_DOCUMENT_CHECK.
    After execution I am getting error 'Ledger group-Blank not permitted for doc type  ZL'.
    In this bapi i am not able to pass 'LEDGER GROUP'  field.
    can any one tell me how to pass LDGRP  field thorough this BAPI.
    Is there any other BAPI avialable to check GL document for posting for specefic ledger group.
    any one give me solution for this.
    Thanks in advance.
    Kiran.
    9986918125.
    Edited by: venkat25 on Feb 27, 2012 2:54 PM

    Hi lakshmi,
    See sample code below
    METHOD if_ex_acc_document~change.
         DATA: wa_extension TYPE bapiparex.
         DATA: wa_wtax TYPE accit_wt.
         FIELD-SYMBOLS <fs_accit> TYPE accit.
         LOOP AT c_extension2 INTO wa_extension.
           IF wa_extension-structure = 'ZBUSSEC'.
             LOOP AT c_accit ASSIGNING <fs_accit>.
               <fs_accit>-bupla = wa_extension-valuepart1.
               <fs_accit>-secco = wa_extension-valuepart2.
             ENDLOOP.
           ENDIF.
           IF wa_extension-structure = 'ZWTAX'.
             wa_wtax-wt_key    = wa_extension-valuepart1.
             wa_wtax-witht     = wa_extension-valuepart2.
             wa_wtax-wt_withcd = wa_extension-valuepart3.
             APPEND wa_wtax TO c_accwt.
             READ TABLE c_accit ASSIGNING <fs_accit> WITH KEY koart = 'K'.
             IF sy-subrc = 0.
               <fs_accit>-wt_key = wa_wtax-wt_key.
             ENDIF.
           ENDIF.
         ENDLOOP.
       ENDMETHOD.
    Reagrds
    kiran

  • Error message in BAPI_ACC_DOCUMENT_CHECK

    HI everybody
    im having an error while exceuting the BAPI BAPI_ACC_DOCUMENT_CHECK , 'FI/CO interface: Currency item entered several times'
    see the code below
    clear l_amount.
      l_wrbtr = gw_accpostline-wrbtr.
      gw_currency_amount-itemno_acc = l_itemno.
      gw_currency_amount-currency = gw_accpost-waers.
      IF gw_accpostline-newbs = '40' OR gw_accpostline-newbs = '21' OR gw_accpostline-newbs = '29'.
        MOVE gw_accpostline-wrbtr TO l_amount.
        CONCATENATE '-' l_amount INTO l_amount.
        MOVE l_amount TO gw_currency_amount-amt_doccur.
      ENDIF.
      IF gw_accpostline-newbs = '31' OR gw_accpostline-newbs = '39' OR gw_accpostline-newbs = '50'.
    *calculate the sum of the credit
        gw_currency_amount-amt_doccur = gw_accpostline-wrbtr.
      ENDIF.
        APPEND gw_currency_amount TO gi_currency_amount.
       IF gw_accpostline-dmbtr IS NOT INITIAL.
       gw_currency_amount-itemno_acc = l_itemno.
       gw_currency_amount-CURR_TYPE = '10'.
      gw_currency_amount-currency = gw_accpost-waers.
        IF gw_accpostline-newbs = '40' OR gw_accpostline-newbs = '21' OR gw_accpostline-newbs = '29'.
        MOVE gw_accpostline-dmbtr TO l_amount.
        CONCATENATE '-' l_amount INTO l_amount.
        MOVE l_amount TO gw_currency_amount-amt_doccur.
      ENDIF.
      IF gw_accpostline-newbs = '31' OR gw_accpostline-newbs = '39' OR gw_accpostline-newbs = '50'.
        gw_currency_amount-amt_doccur = gw_accpostline-dmbtr.
      ENDIF.
        APPEND gw_currency_amount TO gi_currency_amount.

    Hi
    U're transfering the amount in document currency twice, the currency type 10 means internal currency, so the currency of company code:
    CLEAR l_amount.
    l_wrbtr = gw_accpostline-wrbtr.
    gw_currency_amount-CURR_TYPE  = '00'. "<----- Document currency
    gw_currency_amount-itemno_acc = l_itemno.
    gw_currency_amount-CURRENCY   = gw_accpost-waers.
    MOVE gw_accpostline-wrbtr to gw_currency_amount-amt_doccur.
    IF gw_accpostline-newbs = '40' OR gw_accpostline-newbs = '21' OR gw_accpostline-newbs = '29'.
      gw_currency_amount-amt_doccur = - gw_currency_amount-amt_doccur.
    ENDIF.
    APPEND gw_currency_amount TO gi_currency_amount.
    IF not gw_accpostline-dmbtr IS INITIAL.
      gw_currency_amount-itemno_acc = l_itemno.
      gw_currency_amount-CURR_TYPE = '10'.
    *  gw_currency_amount-CURRENCY = gw_accpost-waers. <----- Company currency
      gw_currency_amount-CURRENCY = t001-waers. "<----------- Company currency
      MOVE gw_accpostline-dmbtr TO gw_currency_amount-amt_doccur.
      IF gw_accpostline-newbs = '40' OR gw_accpostline-newbs = '21' OR gw_accpostline-newbs = '29'.
        gw_currency_amount-amt_doccur = - gw_currency_amount-amt_doccur.
      ENDIF.
      APPEND gw_currency_amount TO gi_currency_amount.
    endif.
    Max

  • 'BAPI_ACC_DOCUMENT_CHECK' for Korea

    Hi Guys,
    I am using the following BAPI for checking the accounting docuement before posting for korea:
    FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
      EXPORTING
        documentheader    = ti_doc_head
      TABLES
        accountgl         = ti_acc_gl
        accountreceivable = ti_acc_re
             accountpayable    = ti_acc_pa
        currencyamount    = ti_curr_amo
        return            = ti_return.
    The posting is for gl accounts.
    I am getting the following error message:
    Change business place in document > long text
    It seems it is asking to specify the Buisness Place. Can anybody tell me how to specify buisness place for GL posting.
    Or you have any other solution then it is welcome.
    Regards,
    Prakash Pandey

    Business Place refers to the tax deposit authority in SAP. Business place can be defined through customizing under the Finance Global setting - Witholding taxes - South Korea.
    Please check and make the necessary update.
    Regards,
    Mamta Sarda

  • Unable to resolve errors thrown by BAPI FM "BAPI_ACC_DOCUMENT_CHECK"

    We are facing problems with BAPI function module BAPI_ACC_DOCUMENT_CHECK. We are currently using SAP R/3 Enterprise 4.7. The current support patch applied in our server is SAPKH47028. The BAPI in our Z-program respons with errors "Error in document: BKPFF $ DEV320" and "Period 01 is not allowed".
    We are trying to transfer existing FI entries of some G/L codes from one company code to another company code.
    Regarding mandatory fields, in our Z-program, we followed the instruction of SAP Note 561175. For your reference, we have given below the source code.
    We seek your help to sort out the issue.
    Thanks and regards,
    K. Rangarajan
    ABAPER
    M/s STRIDES ARCOLAB LIMITED
    Bangalore, INDIA.
    Source Code of the Program:
    Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
    Edited by: Rob Burbank on Apr 7, 2010 3:39 PM

    Hi Prakash Reddy
    Fm : OWN_LOGICAL_SYSTEM_GET to get obj_sys
    FM :BAPI_ACC_DOCUMENT_REV_POST to get bus_act
    cHECK the test program ACC_BAPI_TEST_DOCUMENT and it helps you
    to under stand BAPI_ACC_DOCUMENT_CHECK.
    i think above info helps you
    Thanks
    Ramesh Reddy

  • Issue with BAPI_ACC_DOCUMENT_CHECK

    Hi All,
    I am using above mentioned BAPI to check if the document is ok to Park (FB01) .
    I have issue with two fields mainly:
    1) What should be the Object type value
    2) What should be the reference key value.
    I tried running this with object type as 'BKPF' but got error saying that
    incorrect object type.
    Regards,
    Shahu

    Hi Abhishek,
    Its not working with BKPFF and for FIPP it is saying that object type not defined. I think we need to have this object present in the table 'TTYP'. FIPP is not present in this table.
    Regards,
    Shahu
    Message was edited by:
            shahuraj shirure

  • Script modification need

    DOCU – WINDOW
    This is the window on the top right side
    1.Document no (hard coded)
    2.Then display the document number for the first document for the current row. Maybe you should check prior to printing if the current row was posted error free   
       and invoke printing only if this is the case. Then get the first(!!!) document number from the error/message log for this row. ZGF_ICO_RECHR_L-DOCFR
    3. Document date (hard coded) it is P_BLDAT on the selection screen, already correct in the form
    4. VAT No (hard coded)
    5. Then display the EU VAT reg.no of that company. This is in table KNA1, where KUNNR = L_ROW-CUSTFR. The field is KNA1-STCEG, if it is empty, try to populate
         KNA1-STCD1.
    6. Order number(Hard coded)
    7. Just concatenate L_ROW-REF + the last number for that reference from the log table ZGF_ICO_RECHR_L (notice this table has not yet been created!!! and also
        the part is missing where we populate that table when posting both documents for a particular row) ZGF_ICO_RECHR_L-REF+NUMBER
    report  ZG00F_.
    Top Include for the data declarations
    class LCL_REF definition deferred.
    include ZG00F_INT_POST_INVOICE_TOP.
    data: G_ALV_TREE         type ref to CL_GUI_ALV_TREE,
          G_CUSTOM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER,
          G_TEXT_CONTAINER   type ref to CL_GUI_CUSTOM_CONTAINER,
          G_LOGGER           type ref to CL_GUI_TEXTEDIT,
          G_TOOLBAR          type ref to CL_GUI_TOOLBAR.
    data: " gt_zgf_ico_rechr      type zgf_ico_rechr occurs 0,
                           "Output-Table
          OKCODE like SY-UCOMM.
          CLASS LCL_REF DEFINITION
    class LCL_REF definition.
      public section.
        data : VALID type BOOLEAN,
               CAN type BOOLEAN.
        methods : CONSTRUCTOR
                    importing IM_REF type ZGF_ICO_RECHR,
                  CAN_POST
                    returning VALUE(CAN) type BOOLEAN,
                  IS_VALID
                    returning VALUE(IS_VALID) type BOOLEAN,
                  GET_DIVA  returning VALUE(DIVA) type LVC_S_LAYN,
                  GET_DIVAC returning VALUE(DIVAC) type LVC_S_LACN,
                  FILL_BAPI_TABLES,
                  GET_REF returning VALUE(R_REF) type ZGF_ICO_RECHR-REF,
                  POST_INVOICE,
                  PRINT_INVOICE,
                  GET_ERRORS returning
                  VALUE(R_ERROR_TAB) type ABAPTXT255_TAB,
                  GET_PRDATA returning
                  VALUE(PR_REF) type ZGF_ICO_RECHR.
      private section.
        data: LINE type ABAPTXT255,
              ERROR_TAB type ABAPTXT255_TAB,
              FIELD like LINE.
        methods :  CHECK_VALIDITY.
    endclass.                    "lcl_ref DEFINITION
          CLASS lcl_ref IMPLEMENTATION
    class LCL_REF implementation.
      method GET_ERRORS.
        R_ERROR_TAB = ME->ERROR_TAB.
      endmethod.                    "get_errors
      method IS_VALID.
        IS_VALID = ME->VALID.
      endmethod.                    "is_valid
      method GET_PRDATA.
        PR_REF = L_REF.
      endmethod.                    "is_valid
      method PRINT_INVOICE.
        data: L_KUNNR type KNA1-KUNNR.
        data: L_ROW type ZGF_ICO_RECHR.
        call function 'OPEN_FORM'
         exporting
           APPLICATION                       = 'TX'
        ARCHIVE_INDEX                     =
        ARCHIVE_PARAMS                    =
           DEVICE                            = 'PRINTER'
           DIALOG                            = 'X'
             FORM                              = 'ZGF_INVOICE'
             LANGUAGE                          = SY-LANGU
         OPTIONS                           = is_options
         exceptions
             CANCELED                          = 1
             DEVICE                            = 2
             others                            = 12.
        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 'START_FORM'
         exporting
           ARCHIVE_INDEX          =
           FORM                   = 'ZGF_INVOICE'
           LANGUAGE               = SY-LANGU
         exceptions
           FORM                   = 1
           others                 = 8.
        if SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
        IF L_REF-TOTAL >= 0.
          IV_INVOICE = 'INVOICE  (COMCoE Recharge)'.
        ELSE.
          IV_INVOICE = 'Credit Memo  (COMCoE Recharge)'.
        ENDIF.
        call method ME->GET_PRDATA
          receiving
            PR_REF = L_ROW.
        L_KUNNR = L_ROW-CUSTFR.
        select single RCOMP ADRNR LAND1 ORT01
        into (IV_RCOMP, IV_ADRNR, IV_COMPLAND1, IV_COMPORT01)
        from T001 where BUKRS = L_ROW-CCFR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'INVOICE'
            ELEMENT = 'T3'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        IV_DOCDATE = P_BLDAT.
        IV_ORDNU = L_ROW-REF.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'DOCU'
            ELEMENT = 'T2'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        select single KUNNR STRAS NAME1 LAND1 ORT01 STCEG
        into
        (IV_CUSTNO, IV_CUSTADD, IV_CUSTNAME1, IV_CUSTLAND1, IV_CUSTCITY,
    IV_DOCVAT)
        from KNA1
        where KUNNR = L_KUNNR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'CUST'
            ELEMENT = 'T6'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        IV_CUSTNO = L_KUNNR.
        IV_CURR = L_ROW-CURR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'CUSTNO'
            ELEMENT = 'T4'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        data: L_VAR(21).
        concatenate P_DATEFR0(4) '/' P_DATEFR4(2) '/' P_DATEFR+6(2)
        '-' P_DATETO0(4) '/' P_DATETO4(2) '/' P_DATETO+6(2)
        into L_VAR.
        IV_PERDAT = L_VAR.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'MAIN'
            ELEMENT = 'T1'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
        call function 'WRITE_FORM'
          exporting
            WINDOW  = 'FOOTER'
            ELEMENT = 'T5'
          exceptions
            WINDOW  = 1
            ELEMENT = 2.
    *CALL FUNCTION 'END_FORM'
    IMPORTING
      RESULT                         =
    EXCEPTIONS
      UNOPENED                       = 1
      BAD_PAGEFORMAT_FOR_PRINT       = 2
      SPOOL_ERROR                    = 3
    CODEPAGE                        = 4
      OTHERS                         = 5.
        call function 'END_FORM'
          exceptions
            UNOPENED = 1.
        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 'CLOSE_FORM'
          exceptions
            others = 6.
        if SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
      endmethod.                    "is_valid
      method GET_REF.
        R_REF = REF.
      endmethod.                    "get_ref
      method CONSTRUCTOR.
        L_REF = IM_REF.
        REF = IM_REF-REF.
        call method ME->CHECK_VALIDITY.
      endmethod.                    "constructor
      method GET_DIVA.
        DIVA-ISFOLDER = ''.
        if VALID <> 'X'.
          DIVA-N_IMAGE = ICON_NEGATIVE.
        else.
          DIVA-N_IMAGE = ICON_POSITIVE.
        endif.
      endmethod.                    "get_diva
      method GET_DIVAC.
        if V_ERROR1 = 'Y' or V_ERROR2 = 'Y'.
          DIVAC-N_IMAGE = ICON_RED_LIGHT.
        elseif V_ERROR1 = 'N' and V_ERROR2 = 'N'.
          DIVAC-N_IMAGE = ICON_GREEN_LIGHT.
        endif.
        DIVAC-U_N_IMAGE = 'X'.
      endmethod.                    "get_divac
      method CAN_POST.
        CAN = 'X'.
        call method ME->FILL_BAPI_TABLES.
      endmethod.                    "can_post
      method CHECK_VALIDITY.
    *Reference field must begin with M, Q, Y or J. Otherwise display an
    *error msg with text symbol TEXT-001 (ZGF_ICO_RECHR validation error –
    *Reference incorrect – rec.x) where x ist the numebr of the incorrect
    *record.
        data:  L_CHAR(1),
               L_REF1 type ZGF_ICO_RECHR-REF,
               L_ERR type OUTTAB_LINE_ERROR,
               L_NUM type N,
               L_KNB1 type KNB1,
               L_TBSL type TBSL,
               L_CSKS type CSKS,
               L_LFB1 type LFB1.
              l_flag(1).
        clear: L_CHAR, L_NUM, VALID.
        VALID = 'X'.
        L_REF1 = L_REF-REF.
        L_CHAR = L_REF1+0(1).
        if not ( L_CHAR = 'M'  or L_CHAR = 'Q'
                 or L_CHAR = 'Y' or L_CHAR = 'J').
         MESSAGE E398(00) WITH TEXT-001 ' ' ' ' ' '.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-001.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+1(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+2(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
        clear: L_CHAR, L_NUM.
        L_CHAR = L_REF1+3(1).
        L_NUM = L_CHAR.
        if not L_CHAR = '0'.
          if L_NUM = 0.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-001.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR-ERR_MESG to GT_ZGF_ICO_RECHR_ERRORS.
            VALID = 'F'.
          endif.
        endif.
        if not ( L_REF-FREQ = 'M' or L_REF-FREQ = 'Q' or L_REF-FREQ = 'Y').
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-002.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        if not ( L_REF-CODE = 'A' or L_REF-CODE = 'B' or L_REF-CODE = 'C'
                 or L_REF-CODE = 'D' or L_REF-CODE = 'E'
                 or L_REF-CODE = 'F' ).
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-003.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
    *Customer FROM must not be flagged for deletion in KNB1. (KNB1-LOEVM
    *must be space), otherwise error message with TEXT-007. (ZGF_ICO_RECHR
    *validation error – From customer marked for deletion– rec.x) where x
    *ist the number of the incorrect record.
        select single * from KNB1 into L_KNB1
               where KUNNR = L_REF-CUSTFR.
        if SY-SUBRC = 0.
          if not L_KNB1-LOEVM is initial.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-007.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
          if not L_KNB1-SPERR  is initial.
            clear L_ERR.
            L_ERR = L_REF.
            L_ERR-ERR_MESG = TEXT-006.
            L_ERR-REC_NO = G_CNTR.
            append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
            append L_ERR-ERR_MESG to ERROR_TAB.
            VALID = 'F'.
          endif.
        endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKFRD.
       if not L_TBSL-KOART = 'D'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-008.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKFRS.
       if not L_TBSL-KOART = 'S'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-009.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       if not L_REF-PLTFR is initial.
         select single * from CSKS into L_CSKS
         where ZZWERKS = L_REF-PKFRS.
         if SY-SUBRC <> 0.
           clear L_ERR.
           L_ERR = L_REF.
           L_ERR-ERR_MESG = TEXT-012.
           L_ERR-REC_NO = G_CNTR.
           append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
           append L_ERR-ERR_MESG to ERROR_TAB.
           VALID = 'F'.
         endif.
       endif.
        select single * from LFB1 into L_LFB1
               where LIFNR = L_REF-CUSTTO.
        if not L_LFB1-LOEVM is initial.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-018.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
        if not LFB1-SPERR is initial.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-019.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKTOK.
       if not L_TBSL-KOART = 'K'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-020.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
       select single * from TBSL into L_TBSL
              where BSCHL = L_REF-PKTOS.
       if not L_TBSL-KOART = 'S'.
         clear L_ERR.
         L_ERR = L_REF.
         L_ERR-ERR_MESG = TEXT-021.
         L_ERR-REC_NO = G_CNTR.
         append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
         append L_ERR-ERR_MESG to ERROR_TAB.
         VALID = 'F'.
       endif.
        if not L_REF-TOTAL > 0.
          clear L_ERR.
          L_ERR = L_REF.
          L_ERR-ERR_MESG = TEXT-017.
          L_ERR-REC_NO = G_CNTR.
          append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
          append L_ERR-ERR_MESG to ERROR_TAB.
          VALID = 'F'.
        endif.
       return valid.
      endmethod.                    "check_validity
    --- Method Post Invoice Start ---
      method POST_INVOICE.
      endmethod.                    "post_invoice
    --- Method Post Invoice End ---
    --- Method Filling Bapi Tables Start ---
      method FILL_BAPI_TABLES.
    *---- Populating Bapi for Customer
        V_TOTAL = L_REF-TOTAL.
        perform FILL_BAPI_CUSTOMER.
        V_ERROR1 = 'N'.
        V_ERROR2 = 'N'.
        delete IT_ERROR where NODE_ID = L_SELECTED_NODE.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = SY-ULINE(30).
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = L_REF-REF.
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR  = SY-ULINE(30).
        append IS_ERROR to IT_ERROR.
        IS_ERROR-NODE_ID = L_SELECTED_NODE.
        IS_ERROR-ERROR   = '*** Checking Customer Document ***'.
        append IS_ERROR to IT_ERROR.
        clear IS_ERROR.
    *---- Checking for 1st Document
        call function 'BAPI_ACC_DOCUMENT_CHECK'
          exporting
            DOCUMENTHEADER       = WA_DOCUMENTHEADER
          tables
            ACCOUNTGL            = LT_ACCOUNTGL
            ACCOUNTRECEIVABLE     =
            LT_ACCOUNTRECEIVABLE
            ACCOUNTTAX           = LT_ACCOUNTTAX
            CURRENCYAMOUNT       = LT_CURRENCYAMOUNT
            RETURN               = LT_RETURN.
        loop at LT_RETURN into WA_RETURN.
          if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
            V_ERROR1 = 'Y'.
          endif.
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
            separated by '-'.
          append IS_ERROR to IT_ERROR.
        endloop.
    *--- Checking for 2nd Document
        if V_ERROR1 = 'N'.
    *---- Populating Bapi for Vendor
          L_REF-TOTAL = V_TOTAL.
          perform FILL_BAPI_VENDOR.
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Checking for Vendor Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_CHECK'
            exporting
              DOCUMENTHEADER = WA_DOCUMENTHEADER2
            tables
              ACCOUNTGL      = LT_ACCOUNTGL2
              ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
              ACCOUNTTAX     = LT_ACCOUNTTAX2
              CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
              RETURN         = LT_RETURN2.
          loop at LT_RETURN2 into WA_RETURN2.
            if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
              V_ERROR2 = 'Y'.
            endif.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
            concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
             IS_ERROR-ERROR separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
        endif.
    *--- CHECK WHETHER BOTH DOCUMENTS ARE CORRECT OR NOT returned SUCCESS
        if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
    *--- Posting 1st Document - Customer
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Posting Customer Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_POST'
            exporting
              DOCUMENTHEADER       = WA_DOCUMENTHEADER
            tables
              ACCOUNTGL            = LT_ACCOUNTGL
              ACCOUNTRECEIVABLE     =
              LT_ACCOUNTRECEIVABLE
              ACCOUNTTAX           = LT_ACCOUNTTAX
              CURRENCYAMOUNT       = LT_CURRENCYAMOUNT
              RETURN               = LT_RETURN.
          call function 'BAPI_TRANSACTION_COMMIT'.
          loop at LT_RETURN into WA_RETURN.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
           concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
             separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
    *--- Posting 2nd Document - Vendor
          IS_ERROR-NODE_ID = L_SELECTED_NODE.
          IS_ERROR-ERROR   = '*** Posting Vendor Document ***'.
          append IS_ERROR to IT_ERROR.
          clear IS_ERROR.
          call function 'BAPI_ACC_DOCUMENT_POST'
            exporting
              DOCUMENTHEADER = WA_DOCUMENTHEADER2
            tables
              ACCOUNTGL      = LT_ACCOUNTGL2
              ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
              ACCOUNTTAX     = LT_ACCOUNTTAX2
              CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
              RETURN         = LT_RETURN2.
          call function 'BAPI_TRANSACTION_COMMIT'.
          loop at LT_RETURN2 into WA_RETURN2.
            IS_ERROR-NODE_ID = L_SELECTED_NODE.
            concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
             IS_ERROR-ERROR separated by '-'.
            append IS_ERROR to IT_ERROR.
          endloop.
        endif. "if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
    *--- Setting colour of node.
        data:  LO_REF type ref to LCL_REF,
               IS_NODE_LAYOUT type LVC_S_LACN,
               L_NODE_TEXT type LVC_VALUE,
               WA_OREF type TY_REF.
        clear :IS_NODE_LAYOUT,L_NODE_TEXT, WA_OREF, LO_REF.
        create object LO_REF exporting IM_REF = LS_ZGF_ICO_RECHR.
        IS_NODE_LAYOUT = LO_REF->GET_DIVAC( ).
        read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
        L_NODE_TEXT = L_REF-REF.
        call method G_ALV_TREE->CHANGE_NODE
          exporting
            I_NODE_KEY     = L_SELECTED_NODE
            I_OUTTAB_LINE  = L_REF
            IS_NODE_LAYOUT = IS_NODE_LAYOUT
            I_NODE_TEXT    = L_NODE_TEXT
            I_U_NODE_TEXT  = 'X'
          exceptions
            NODE_NOT_FOUND = 1
            others         = 2.
        call method G_ALV_TREE->FRONTEND_UPDATE.
        call method CL_GUI_CFW=>FLUSH
          exceptions
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
      endmethod.                    "fill_int_tables
    endclass.                    "lcl_ref IMPLEMENTATION
          CLASS lcl_event_handler DEFINITION
    class LCL_EVENT_HANDLER definition.
      public section.
        class-methods : ON_NODE_CLICK for event
          NODE_DOUBLE_CLICK of CL_GUI_ALV_TREE
            importing NODE_KEY.
        methods: ON_FUNCTION_SELECTED
                   for event FUNCTION_SELECTED of CL_GUI_TOOLBAR
                     importing FCODE.
    endclass.                    "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    class LCL_EVENT_HANDLER implementation.
      method  ON_NODE_CLICK.
      endmethod.                    "on_node_click
      method ON_FUNCTION_SELECTED.
        data: LT_SELECTED_NODES type LVC_T_NKEY,
              L_RC              type C,
              L_CAN             type C,
              L_REC             type I,
              WA_OREF           type TY_REF,
              L_LINE            type SY-TABIX.
    Determine which line is selected
        call method G_ALV_TREE->GET_SELECTED_NODES
          changing
            CT_SELECTED_NODES = LT_SELECTED_NODES.
        call method CL_GUI_CFW=>FLUSH.
    remark: The user can not select more than one node since the
            default value of NODE_SELECTION_MODE is
            cl_gui_column_Tree=>NODE_SEL_MODE_SINGLE (see constructor).
        describe table LT_SELECTED_NODES lines L_REC.
        if L_REC = 0 and FCODE = 'ERROR'.
    *--- Show log for all if nothing is selected then.
          refresh LT_ERRORS.
          clear LT_ERRORS.
          loop at IT_ERROR into IS_ERROR.
            IS_ERRORS-LINE = IS_ERROR-ERROR.
            append IS_ERRORS to LT_ERRORS.
          endloop.
          call method G_LOGGER->SET_TEXT_AS_R3TABLE
            exporting
              TABLE = LT_ERRORS.
        endif.
        loop at  LT_SELECTED_NODES into L_SELECTED_NODE.
          clear : L_REF, WA_OREF.
          L_LINE = SY-TABIX.
          read table GT_OREF into WA_OREF index L_SELECTED_NODE.
          read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
          if SY-SUBRC = 0.
            case FCODE.
              when 'ERROR'.
                refresh LT_ERRORS.
                clear LT_ERRORS.
                loop at IT_ERROR into IS_ERROR where NODE_ID =
                                                      L_SELECTED_NODE.
                  IS_ERRORS-LINE = IS_ERROR-ERROR.
                  append IS_ERRORS to LT_ERRORS.
                endloop.
                call method G_LOGGER->SET_TEXT_AS_R3TABLE
                  exporting
                    TABLE = LT_ERRORS.
              when 'POST'.
                if L_LINE = 1.
                  if WA_OREF-O_REF->IS_VALID( ) = 'X'.
                    clear L_RC.
                    call function 'POPUP_TO_CONFIRM_STEP'
                      exporting
                        TEXTLINE1      = 'Do you want to post'  "(902)
                        TEXTLINE2      = '?'                    "(903)
                        TITEL          = 'Confirmation'         "(904)
                        CANCEL_DISPLAY = ' '
                      importing
                        ANSWER         = L_RC.
                  else.
                    call function 'POPUP_TO_INFORM'
                      exporting
                        TITEL = 'Select Another Record..'
                        TXT1  = 'Data Wrong,'
                        TXT2  = 'Posting Can Not be Done'.
                  endif.
                else.
                  L_RC = 'J'.
                endif.
                if L_RC eq 'J'.
    *---Post Invoice.
                  if WA_OREF-O_REF->CAN_POST( ) = 'X'.
                    call method WA_OREF-O_REF->POST_INVOICE.
    *---Printing Log.
                    refresh LT_ERRORS.
                    clear LT_ERRORS.
                    loop at IT_ERROR into IS_ERROR.
                      IS_ERRORS-LINE = IS_ERROR-ERROR.
                      append IS_ERRORS to LT_ERRORS.
                    endloop.
                    call method G_LOGGER->SET_TEXT_AS_R3TABLE
                      exporting
                        TABLE = LT_ERRORS.
                  endif.
                endif.
              when 'PRINT'.
                call method WA_OREF-O_REF->PRINT_INVOICE.
            endcase.
          else.
            message I000(0K) with 'Please select a node.'.
          endif.
        endloop.
      endmethod.                    "on_function_selected
    endclass.                    "lcl_event_handler IMPLEMENTATION
    START-OF-SELECTION.
    start-of-selection.
    end-of-selection.
      call screen 100.
    *&      Module  STATUS_0100  OUTPUT
    module STATUS_0100 output.
      set pf-status 'MAIN100'.
      set titlebar 'MAINTITLE'.
      if G_ALV_TREE is initial.
        perform INIT_TREE.
        call method CL_GUI_CFW=>FLUSH
          exceptions
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
        if SY-SUBRC ne 0.
         call function 'POPUP_TO_INFORM'
           exporting
             titel = 'Automation Queue failure'(801)
             txt1  = 'Internal error:'(802)
             txt2  = 'A method in the automation queue'(803)
             txt3  = 'caused a failure.'(804).
        endif.
      endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    form INIT_TREE .
      data: L_TREE_CONTAINER_NAME(30) type C.
    *Reference tree
      L_TREE_CONTAINER_NAME = 'ZCONTAINER'.
      create object G_CUSTOM_CONTAINER
         exporting
               CONTAINER_NAME = L_TREE_CONTAINER_NAME
         exceptions
               CNTL_ERROR                  = 1
               CNTL_SYSTEM_ERROR           = 2
               CREATE_ERROR                = 3
               LIFETIME_ERROR              = 4
               LIFETIME_DYNPRO_DYNPRO_LINK = 5.
      if SY-SUBRC <> 0.
       MESSAGE x208(00) WITH 'ERROR'(100).
      endif.
    create tree control
      create object G_ALV_TREE
        exporting
            PARENT              = G_CUSTOM_CONTAINER
            NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_MULTIPLE
           NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
            ITEM_SELECTION      = 'X'
            NO_HTML_HEADER      = ''
            NO_TOOLBAR          = ''
        exceptions
            CNTL_ERROR                   = 1
            CNTL_SYSTEM_ERROR            = 2
            CREATE_ERROR                 = 3
            LIFETIME_ERROR               = 4
            ILLEGAL_NODE_SELECTION_MODE  = 5
            FAILED                       = 6
            ILLEGAL_COLUMN_NAME          = 7.
      if SY-SUBRC <> 0.
        message X208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    ****logger
      L_TREE_CONTAINER_NAME = 'ZLOGGER'.
      create object G_TEXT_CONTAINER
         exporting
               CONTAINER_NAME = L_TREE_CONTAINER_NAME
         exceptions
               CNTL_ERROR                  = 1
               CNTL_SYSTEM_ERROR           = 2
               CREATE_ERROR                = 3
               LIFETIME_ERROR              = 4
               LIFETIME_DYNPRO_DYNPRO_LINK = 5.
      create object G_LOGGER
          exporting PARENT = G_TEXT_CONTAINER
          NAME = 'Error Log'.
      call method G_LOGGER->SET_READONLY_MODE.
    endlogger
      data L_HIERARCHY_HEADER type TREEV_HHDR.
      data: LT_LIST_COMMENTARY type SLIS_T_LISTHEADER,
            L_LOGO             type SDYDO_VALUE.
      data : WA_FIELDCATALOG type LVC_S_FCAT.
      perform BUILD_HIERARCHY_HEADER changing L_HIERARCHY_HEADER.
      perform BUILD_COMMENT using LT_LIST_COMMENTARY
                                  L_LOGO.
      clear : WA_FIELDCATALOG, GT_FIELDCATALOG.
    get fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          I_STRUCTURE_NAME = 'ZGF_ICO_RECHR'
        changing
          CT_FIELDCAT      = GT_FIELDCATALOG.
      loop at GT_FIELDCATALOG into WA_FIELDCATALOG.
        case WA_FIELDCATALOG-FIELDNAME.
          when 'REF'.
            WA_FIELDCATALOG-NO_OUT = 'X'.
        endcase.
        WA_FIELDCATALOG-OUTPUTLEN = 15.
        modify GT_FIELDCATALOG from WA_FIELDCATALOG.
      endloop.
      call method G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
        exporting
          IT_LIST_COMMENTARY  = LT_LIST_COMMENTARY
          I_LOGO              = L_LOGO
         i_structure_name    = 'ZGF_ICO_RECHR'
          IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
        changing
          IT_FIELDCATALOG     = GT_FIELDCATALOG
          IT_OUTTAB           = GT_ZGF_ICO_RECHR. "table must be empty !
      perform CREATE_HIERARCHY.
      perform CHANGE_TOOLBAR.
      perform REGISTER_EVENTS.
      call method G_ALV_TREE->FRONTEND_UPDATE.
    endform.                    " init_tree
    *&      Form  build_hierarchy_header
    form BUILD_HIERARCHY_HEADER  changing
            P_HIERARCHY_HEADER type TREEV_HHDR.
      P_HIERARCHY_HEADER-HEADING = 'Reference Number'(300).
      P_HIERARCHY_HEADER-TOOLTIP = 'Reference numbers for invoices'(400).
      P_HIERARCHY_HEADER-WIDTH = 30.
      P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
    endform.                    " build_hierarchy_header
    *&      Form  create_hierarchy
    form CREATE_HIERARCHY .
      clear : LS_ZGF_ICO_RECHR, L_LAST_KEY.
    §4a. Select data
      refresh GT_ZGF_ICO_RECHR.
      select * from ZGF_ICO_RECHR into table LT_ZGF_ICO_RECHR
       where FREQ in SO_FREQ
         and  REF in SO_REF.
      sort LT_ZGF_ICO_RECHR by REF.
    Note: The top level nodes do not correspond to a field of the
    output table. Instead we use data of the table to invent another
    hierarchy level above the levels that can be build by sorting.
    §4c. Add data to tree
      G_CNTR = 1.
    sort by oref->get_diva->image .
      loop at LT_ZGF_ICO_RECHR into LS_ZGF_ICO_RECHR.
        perform ADD_COMPLETE_LINE using  LS_ZGF_ICO_RECHR
                                          changing L_LAST_KEY.
        G_CNTR = G_CNTR + 1.
    perform add_node using ls_zgf_ico_rechr-ref
                      changing l_last_key.
      endloop.
    endform.                    " create_hierarchy
    *&      Module  USER_COMMAND_0100  INPUT
    module USER_COMMAND_0100 input.
      SAVE_OK = OKCODE.
      clear OKCODE.
      case SAVE_OK.
        when 'EXIT' or 'BACK' or 'CANC'.
          perform EXIT_PROGRAM.
        when others.
    §6. Call dispatch to process toolbar functions
          call method CL_GUI_CFW=>DISPATCH.
      endcase.
      call method CL_GUI_CFW=>FLUSH.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  exit_program
          text
    form EXIT_PROGRAM .
      call method G_CUSTOM_CONTAINER->FREE.
      leave to screen 0.
    endform.                    " exit_program
    *&      Form  add_complete_line
    form ADD_COMPLETE_LINE  using    P_LS_ZGF_ICO_RECHR type ZGF_ICO_RECHR
                                     P_RELAT_KEY type LVC_NKEY
                            changing P_NODE_KEY type LVC_NKEY.
      data: L_NODE_TEXT type LVC_VALUE,
            LO_REF type ref to LCL_REF,
            L_NODE_LAYOUT type LVC_S_LAYN.
    add leaf:
    ALV Tree firstly inserts this node as a leaf if you do not provide
    IS_NODE_LAYOUT with field ISFOLDER set.
    Since these nodes will never get children they stay leaves
    (as intended).
      clear L_NODE_LAYOUT.
      create object LO_REF exporting IM_REF = P_LS_ZGF_ICO_RECHR.
      data : WA_OREF type TY_REF.
      clear WA_OREF.
      WA_OREF-O_REF = LO_REF.
      append WA_OREF to GT_OREF.
      L_NODE_LAYOUT = LO_REF->GET_DIVA( ).
      L_NODE_TEXT = P_LS_ZGF_ICO_RECHR-REF.
      call method G_ALV_TREE->ADD_NODE
        exporting
          I_RELAT_NODE_KEY = P_RELAT_KEY
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          IS_OUTTAB_LINE   = P_LS_ZGF_ICO_RECHR   "_REF
          I_NODE_TEXT      = L_NODE_TEXT
          IS_NODE_LAYOUT   = L_NODE_LAYOUT
        importing
          E_NEW_NODE_KEY   = P_NODE_KEY.
    endform.                    " add_complete_line
    *&      Form  add_node
    form ADD_NODE  using    P_REF
                   changing P_NODE_KEY type LVC_NKEY.
      clear L_NODE_LAYOUT.
      L_NODE_LAYOUT-ISFOLDER = ''.
      L_NODE_LAYOUT-N_IMAGE = ICON_POSITIVE.
      L_NODE_TEXT =  'Reference1'. " ps_sflight-carrid.
      call method G_ALV_TREE->ADD_NODE
        exporting
          I_RELAT_NODE_KEY = '' " p_relat_key
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          I_NODE_TEXT      = L_NODE_TEXT
          IS_OUTTAB_LINE   = P_REF
          IS_NODE_LAYOUT   = L_NODE_LAYOUT
        importing
          E_NEW_NODE_KEY   = P_NODE_KEY.
    endform.                    " add_node
    *&      Form  register_events
    form REGISTER_EVENTS .
      data: LT_EVENTS type CNTL_SIMPLE_EVENTS,
            L_EVENT type CNTL_SIMPLE_EVENT,
            L_EVENT_RECEIVER type ref to LCL_EVENT_HANDLER.
      call method G_ALV_TREE->GET_REGISTERED_EVENTS
        importing
          EVENTS = LT_EVENTS.
    *NODE_DOUBLE_CLICK
      clear L_EVENT.
      move CL_GUI_COLUMN_TREE=>EVENTID_NODE_DOUBLE_CLICK to L_EVENT-EVENTID.
      append L_E

    Ok fine that can be acchived by setting the retention policy and by issuing delete obsolete command.That's perfect.If FRA is configured then even delete obsolete command is also not required.
    but i want to keep the last full backup for 15 days and archived logs only for one day.In this case can we set seperate retention policy for full backup and backup of archived logs
    for the time being i just want to modify my present existing OS script to acchive my task and i will conside changing RMAN script later on.Can u provide me the modified OS script so that my work gets finishes succesfully.
    Thank You...

  • Error when using functions BAPI_ACC_DOCUMENT_POST

    Hello,
    When I used BAPI_ACC_DOCUMENT_POST function, the message: Document posted successfully appears, but really not documens are created, and the FI number range are modified.
    See the example code:
    *& Report  ZPBA_PC                                                     *
    REPORT  zpba_pc MESSAGE-ID m3.
    DATA: obj_type LIKE bapiache09-obj_type,
          obj_key LIKE  bapiache09-obj_key,
          obj_sys LIKE  bapiache09-obj_sys.
    DATA: it_hdr    LIKE bapiache09,
          it_gl     LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
          it_curr   LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
          t_result  LIKE bapiret2   OCCURS 0 WITH HEADER LINE.
    Header Data
    it_hdr-obj_type   = 'BKPFF'.
    it_hdr-obj_key    = '$'.
    it_hdr-obj_sys    = 'LA122D'.
    it_hdr-bus_act    = 'RFBU'.
    it_hdr-comp_code  = 'VEZS'.
    it_hdr-fisc_year  = '2004'.
    it_hdr-fis_period = '12'.
    it_hdr-doc_date   = '20041218'..
    it_hdr-pstng_date = '20041218'.
    it_hdr-doc_type   = 'ZI'.
    it_hdr-header_txt = 'TEXTO CAB'.
    it_hdr-username   = sy-uname.
    it_hdr-compo_acc  = 'GL'.
    it_hdr-ref_doc_no_long = 'REFERENCIA'.
    First Item
    Account number
    it_gl-itemno_acc = '1'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text  = 'PRUEBA TEXTO 1'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Second Item
    Account number
    it_gl-itemno_acc = '2'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text  = 'PRUEBA TEXTO 2'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Set amount
    it_curr-itemno_acc = '1'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '10'.
    APPEND it_curr.
    it_curr-itemno_acc = '2'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '-10'.
    APPEND it_curr.
    check posting
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
      EXPORTING
        documentheader = it_hdr
      TABLES
        accountgl      = it_gl
        currencyamount = it_curr
        return         = t_result.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
      EXIT.
    ENDLOOP.
    if sy-subrc ne 0.
    REFRESH t_result.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader = it_hdr
      IMPORTING
        obj_type       = obj_type
        obj_key        = obj_key
        obj_sys        = obj_sys
      TABLES
        accountgl      = it_gl
        currencyamount = it_curr
        return         = t_result.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    COMMIT WORK.
    WRITE: obj_key.
    endif.
    I appreciated your help to solve that error.
    Regards,
    Piero Cimule.
    <b></b>

    Hi,
    Please check the changes :
    *& Report ZPBA_PC *
    REPORT zpba_pc MESSAGE-ID m3.
    DATA: obj_type LIKE bapiache09-obj_type,
    obj_key LIKE bapiache09-obj_key,
    obj_sys LIKE bapiache09-obj_sys,
    <b>l_flag type c.</b>
    DATA: it_hdr LIKE bapiache09,
    it_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
    it_curr LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
    t_result LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    Header Data
    it_hdr-obj_type = 'BKPFF'.
    it_hdr-obj_key = '$'.
    it_hdr-obj_sys = 'LA122D'.
    it_hdr-bus_act = 'RFBU'.
    it_hdr-comp_code = 'VEZS'.
    it_hdr-fisc_year = '2004'.
    it_hdr-fis_period = '12'.
    it_hdr-doc_date = '20041218'..
    it_hdr-pstng_date = '20041218'.
    it_hdr-doc_type = 'ZI'.
    it_hdr-header_txt = 'TEXTO CAB'.
    it_hdr-username = sy-uname.
    it_hdr-compo_acc = 'GL'.
    it_hdr-ref_doc_no_long = 'REFERENCIA'.
    First Item
    Account number
    it_gl-itemno_acc = '1'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text = 'PRUEBA TEXTO 1'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Second Item
    Account number
    it_gl-itemno_acc = '2'.
    it_gl-gl_account = '0014401001'.
    it_gl-item_text = 'PRUEBA TEXTO 2'.
    it_gl-profit_ctr = 'VE2020'.
    APPEND it_gl.
    Set amount
    it_curr-itemno_acc = '1'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '10'.
    APPEND it_curr.
    it_curr-itemno_acc = '2'.
    it_curr-currency = 'VEB'.
    it_curr-amt_doccur = '-10'.
    APPEND it_curr.
    check posting
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
    EXPORTING
    documentheader = it_hdr
    TABLES
    accountgl = it_gl
    currencyamount = it_curr
    return = t_result.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
    <b>l_flag = 'X'.</b>
    EXIT.
    ENDLOOP.
    <b>if l_flag is initial.</b>
    REFRESH t_result.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
    documentheader = it_hdr
    IMPORTING
    obj_type = obj_type
    obj_key = obj_key
    obj_sys = obj_sys
    TABLES
    accountgl = it_gl
    currencyamount = it_curr
    return = t_result.
    <b>Clear l_flag.
    LOOP AT t_result WHERE ( type = 'E' OR type = 'A' ).
    l_flag = 'X'.
    EXIT.
    ENDLOOP.</b><b>if l_flag is initial.</b>
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    <b>COMMIT WORK AND WAIT.</b>
    <b>endif.</b>
    WRITE: obj_key.
    endif.
    Best regards,
    Prashant

  • Problem posting through FBV0 with BTE enhancement

    Dear Gurus,
    I created BTE enhancement event 1030 in P/S modules.
    The BTE program used to post another document after original (standard) document is posted.
    If we post directly without park, the document all posted successfully.
    So when the document is parked through FV50 or FV60 and then post with FBV0.
    But when we use FBV1 and F-65, then post FBV0 it raised error: No batch input data for screen SAP***
    This error apparently because we commit document while updating document park (from parked document to posted document in BKPF).
    this symptoms found when we use BAPI_ACC_DOCUMENT_POST or BAPI_ACC_DOCUMENT_CHECK.
    the only way making both document (standard and BTE doc) posted is to call BAPI_ACC_DOCUMENT_POST in background task.
    But we can't get the message in return parameter.
    I try to use function AC_DOCUMENT_DIRECT_INPUT then the error change into "UPDATE ERROR FBVB".
    I change the BTE event to Process Module 1140, results the same.
    The question is, can we post another document using FM and commit during standard updating routine in SAP?
    Is there another FM/method i could use to post another document while posting park document FBV0?
    Really need your help.
    Thanks,
    Tiara
    Edited by: tiara astari on Nov 24, 2009 8:14 AM

    Hi,
    Maybe it could help.
    When you do a POST document in asyncrounous update, try to use IN BACKGROUND TASK.
    In your case, when you call function BAPI_ACC_DOCUMENT_POST add statement IN BACKGROUND TASK.
    like this
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' IN BACKGROUND TASK
    IMPORTING
    EXPORTING

  • Can any one pls tell me the mandatory fields for BAPI_ACC_DOCUMENT_POST

    hi all ,
    Can any one pls tell me the mandatory fields for BAPI_ACC_DOCUMENT_POST
    what all data i need to give to post a document.
    Thanks and Regards
    JK

    Hi...
    part of my source code:
    ** Header Data " Sending comp code
    wa_documentheader-comp_code = 'XXXXX'.
    wa_documentheader-doc_date = '20060620'.
    wa_documentheader-pstng_date = '20060620'.
    wa_documentheader-doc_type = 'XX'.
    wa_documentheader-username = sy-uname.
    wa_documentheader-ref_doc_no = 'XXxxxxxx'.
    wa_documentheader-header_txt = 'Text Header.
    wa_documentheader-bus_act = 'XXXX'.
    *it_currencyamount
    wa_currencyamount-itemno_acc = '1'.
    wa_currencyamount-currency = 'COP'.
    wa_currencyamount-amt_doccur  = 1943.
    APPEND wa_currencyamount TO it_currencyamount.
    *it_accountpayable
    wa_accountpayable-itemno_acc = '1'.
    wa_accountpayable-gl_account = '1234567890'.
    wa_accountpayable-bus_area = 'DIV'.
    wa_accountpayable-item_text = 'Text 1 XXxxxxx '.
    wa_accountpayable-pmnt_block = ''.
    APPEND wa_accountpayable TO it_accountpayable.
    *it_accountgl
    wa_accountgl-itemno_acc = '2'.
    wa_accountgl-gl_account = '1234567890'.
    wa_accountgl-item_text = 'Text 2 XXxxxxx'.
    wa_accountgl-bus_area = 'DIV'.
    APPEND wa_accountgl TO it_accountgl.
    wa_currencyamount-itemno_acc = '2'.
    wa_currencyamount-currency = 'COP'.
    wa_currencyamount-amt_doccur  = ( 1943 ) * -1.
    APPEND wa_currencyamount TO it_currencyamount.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
      EXPORTING
        documentheader = wa_documentheader
      TABLES
        accountgl      = it_accountgl
        accountpayable = it_accountpayable
        currencyamount = it_currencyamount
        return         = it_return.
    clear it_return.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
          EXPORTING
            documentheader = wa_documentheader
          TABLES
            return         = it_return
            currencyamount = it_currencyamount "currencyamount
            accountpayable = it_accountpayable "accountpayable
            accountgl      = it_accountgl "accountgl
          EXCEPTIONS
            OTHERS         = 01.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

Maybe you are looking for

  • How do I get an new 10.3 client license

    I have an iMac G3 (Ruby w/ slot-load CD drive, & USB) that I believe to be 10.3 compatible based on docs here in Apple.com (am I right about that?). I'm handing this down to the grandkids, so I don't need to spend the money for a full 10.4 and go thr

  • Contact form functionality

    Hello there, Ok so here's my problem. I have almost completed my website with all the buttons and MC's communicating nicely with their respective frames. I am on my final frame being the "Contact Form" frame. I searched the web to find a tutorial in

  • Batch class at plant level

    Hi Guys, Is it possible to assign batch class for a material at plant level, the scenario is the material is produced in two plants the batch characteristics for the both plants are different , and hence i want to assign two different batch class to

  • IS MILL - Customizing of material provision indicators incomplete

    Dear PM Gurus,                       We are currently implementing SAP IS-MILL. We have completed the basic configurations for Technical objects and BOM. But whenever we try to create a BOM, it throws an error in the ITEM/LONG text screen, Customizin

  • VI waiting for another VI finishing before completing

    Howdy i have a goniometer.vi which should move the detectorarm 1°, then starts a spectrometer.vi and measures the spectrum. after completing measurements the goniospectrometer.vi should move another 1° and again... i have made the spectrometer.vi a s