Error in BAPI_ACC_DOCUMENT_POST

Hello,
I am trying to use the bapi in the subject following other post on the sdn, but I get this error message:
Error in document:  200111 AC_DOC_NO
E
Required field OBJ_TYPE was not transferred in parameter DOCUMENTHEADER
E
Required field OBJ_KEY was not transferred in parameter DOCUMENTHEADER
E
Required field OBJ_SYS was not transferred in parameter DOCUMENTHEADER
I think I have to initialize some fields, but I don't know how.
Can anybody pleas help me or explain me what is missing and how can I fix it?
thanks in advance
Gabriele

data:
obj_type like bapiache02-obj_type,
obj_key like bapiache02-obj_key,
obj_sys like bapiache02-obj_sys,
documentheader like bapiache08,
accountgl like bapiacgl08
occurs 0 with header line,
currencyamount like bapiaccr08
occurs 0 with header line,
return like bapiret2
occurs 0 with header line,
extension1 like bapiextc
occurs 0 with header line,
t_edidd like edidd occurs 0 with header line,
bapi_retn_info like bapiret2 occurs 0 with header line.
data: error_flag.
documentheader-username = sy-uname.
documentheader-header_txt = 'Test using BAPI'.
documentheader-comp_code = '1000'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'SA'.
accountgl-itemno_acc = '1'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.
accountgl-itemno_acc = '2'.
accountgl-gl_account = '0000160100'.
accountgl-comp_code = '1000'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'SA'.
accountgl-profit_ctr = '0000010000'.
append accountgl.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '100.00'.
append currencyamount.
currencyamount-itemno_acc = '2'.
currencyamount-currency = 'GBP'.
currencyamount-amt_doccur = '-100.00'.
append currencyamount.
* call BAPI-function in this system *
call function 'BAPI_ACC_GL_POSTING_POST'
exporting
documentheader = documentheader
* importing
* obj_type = obj_type
* obj_key = obj_key
* obj_sys = obj_sys
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.
commit work.
endif.
endif.
source: http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bapi_acc_document_post-622561

Similar Messages

  • Error on bapi_acc_document_post

    Hi experts,
         when i executing this bapi_acc_document_post, am getting error  " FI/CO interface: Line item entered several times"  i mention code below  so please give me suggestion.
    *& Report  ZSAMPLE
    REPORT  ZSAMPLE.
    data: BEGIN OF WA_HEADER,
            ID TYPE I,
            KUNNR TYPE n LENGTH 10,
            INV_DATE TYPE c LENGTH 10,
            PST_DATE TYPE c LENGTH 10,
            REF TYPE invfo-xblnr,
            AMT_DOCCUR TYPE PA2010-BETRG,
            TXT(40),
       END OF WA_HEADER.
    DATA : IT_HEADER like WA_HEADER OCCURS 0  WITH HEADER LINE.
    data: BEGIN OF WA_ITEM,
            ID TYPE I,
            GL_ACCOUNT TYPE n LENGTH 10,
            ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
            BUS_AREA  TYPE BAPIACGL09-BUS_AREA,
            AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
            KOSTL TYPE CSKT-KOSTL,
    *       VAT(2),
       END OF WA_ITEM.
    DATA : IT_ITEM like WA_ITEM OCCURS 0  WITH HEADER LINE.
    *      value of excel-cell
    TYPES: ty_d_itabvalue             TYPE alsmex_tabline-value,
    *      internal table containing the excel data
            ty_t_itab                  TYPE alsmex_tabline   OCCURS 0,
    *      line type of sender table
            BEGIN OF ty_s_senderline,
              line(4096)               TYPE c,
            END OF ty_s_senderline,
    *      sender table
            ty_t_sender                TYPE ty_s_senderline  OCCURS 0.
    CONSTANTS:  gc_esc              VALUE '"'.
    DATA  temp_row TYPE I.
    DATA  TEMP(4).
    INCLUDE lalsmexf01.
    DATA: it_data1 TYPE ty_t_itab.
    DATA: it_data2 TYPE ty_t_itab.
    DATA: it_data_wa LIKE LINE OF it_data1.
    DATA: it_data_wa2 LIKE LINE OF it_data1.
    * DATA DECLARATION
    data: st_rw_s1 TYPE i VALUE '2'.
    data: st_cl_s1 TYPE i VALUE '1'.
    data: st_rw_s2 TYPE i VALUE '2'.
    data: st_cl_s2 TYPE i VALUE '1'.
    data: ed_rw_s1 TYPE i VALUE '3'.
    data: ed_cl_s1 TYPE i VALUE '7'.
    data: ed_rw_s2 TYPE i VALUE '5'.
    data: ed_cl_s2 TYPE i VALUE '8'.
    DATA: excel_tab TYPE ty_t_sender,
    excel_tab1 TYPE ty_t_sender.
    DATA: ld_separator TYPE c.
    DATA: application TYPE ole2_object,
    workbook TYPE ole2_object,
    sheet TYPE ole2_object,
    range TYPE ole2_object,
    worksheet TYPE ole2_object.
    DATA: h_cell TYPE ole2_object,
    h_cell1 TYPE ole2_object.
    DATA: ld_rc TYPE i.
    TYPE-POOLS ole2.
    *AT SELECTION-SCREEN.
       PARAMETERS: filename LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
       PERFORM value_help.
    sTART-OF-SELECTION.
    *  CASE sy-ucomm .
    *    WHEN 'ONLI'.
           PERFORM execute.
           PERFORM bapi.
    *  ENDCASE.
    * MESSAGE DEFINATION
       DEFINE m_message.
         case sy-subrc.
           when 0.
           when 1.
             message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
           when others. raise upload_ole.
         endcase.
       END-OF-DEFINITION.
    *&      Form  VALUE_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VALUE_HELP .
       CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
         EXPORTING
           def_filename     = ' '
           def_path         = ' '
           mask             = ',*.*,*.*.'
           mode             = 'O'
           title            = ' '
         IMPORTING
           filename         = filename
         EXCEPTIONS
           inv_winsys       = 1
           no_batch         = 2
           selection_cancel = 3
           selection_error  = 4
           OTHERS           = 5.
       IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    ENDFORM.                    " VALUE_HELP
    *&      Form  EXECUTE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM EXECUTE .
    * PARAMETER CHECK
       IF st_rw_s1 > ed_rw_s1.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_cl_s1 > ed_cl_s1.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_rw_s2 > ed_rw_s2.
         RAISE inconsistent_parameters.
       ENDIF.
       IF st_cl_s2 > ed_cl_s2.
         RAISE inconsistent_parameters.
       ENDIF.
       CLASS cl_abap_char_utilities DEFINITION LOAD.
       ld_separator = cl_abap_char_utilities=>horizontal_tab.
    * OPENING EXCEL FILE
       IF application-header = space OR application-handle = -1.
         CREATE OBJECT application 'Excel.Application'.
         m_message.
       ENDIF.
       CALL METHOD OF
           application
           'Workbooks' = workbook.
       m_message.
       CALL METHOD OF
           application
           'Workbooks' = workbook.
       m_message.
       CALL METHOD OF
           workbook
           'Open'
         EXPORTING
           #1       = filename.
       m_message.
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 1.
       m_message.
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 1.
       m_message.
       CALL METHOD OF
           sheet
           'Activate'.
       m_message.
       GET PROPERTY OF application 'ACTIVESHEET' = sheet.
       m_message.
    * MARKING OF WHOLE SPREADSHEET
       CALL METHOD OF
           sheet
           'Cells' = h_cell
         EXPORTING
           #1      = st_rw_s1
           #2      = st_cl_s1.
       m_message.
       CALL METHOD OF
           sheet
           'Cells' = h_cell1
         EXPORTING
           #1      = ed_rw_s1
           #2      = ed_cl_s1.
       m_message.
       CALL METHOD OF
           sheet
           'RANGE' = range
         EXPORTING
           #1      = h_cell
           #2      = h_cell1.
       m_message.
       CALL METHOD OF
           range
           'SELECT'.
       m_message.
    * Copy marked area (SHEET1) into Clippboard
       CALL METHOD OF
           range
           'COPY'.
       m_message.
    * Read clipboard into ABAP
       CALL METHOD cl_gui_frontend_services=>clipboard_import
         IMPORTING
           data                 = excel_tab
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
       IF sy-subrc <> 0.
         MESSAGE a037(alsmex).
       ENDIF.
       PERFORM separated_to_intern_convert TABLES excel_tab it_data1
       USING ld_separator.
    * Clear the clipboard
       REFRESH excel_tab.
       CALL METHOD cl_gui_frontend_services=>clipboard_export
         IMPORTING
           data                 = excel_tab
         CHANGING
           rc                   = ld_rc
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
    * Working in Second Excel Work Sheet
       CALL METHOD OF
           application
           'Worksheets' = sheet
         EXPORTING
           #1           = 2.
       m_message.
       CALL METHOD OF
           sheet
           'Activate'.
       m_message.
       GET PROPERTY OF application 'ACTIVESHEET' = sheet.
       m_message.
    * Mark Sheet2
       CALL METHOD OF
           sheet
           'Cells' = h_cell
         EXPORTING
           #1      = st_rw_s2
           #2      = st_cl_s2.
       m_message.
       CALL METHOD OF
           sheet
           'Cells' = h_cell1
         EXPORTING
           #1      = ed_rw_s2
           #2      = ed_cl_s2.
       m_message.
       CALL METHOD OF
           sheet
           'RANGE' = range
         EXPORTING
           #1      = h_cell
           #2      = h_cell1.
       m_message.
       CALL METHOD OF
           range
           'SELECT'.
       m_message.
    * Copy Marked Area (Sheet2) into Clippboard
       CALL METHOD OF
           range
           'COPY'.
       m_message.
    * Read Clipboard into ABAP
       CALL METHOD cl_gui_frontend_services=>clipboard_import
         IMPORTING
           data                 = excel_tab1
         EXCEPTIONS
           cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
           OTHERS               = 4.
       IF sy-subrc <> 0.
         MESSAGE a037(alsmex).
       ENDIF.
       PERFORM separated_to_intern_convert TABLES excel_tab1 it_data2
       USING ld_separator.
    * Clear Clipboard
       REFRESH excel_tab.
       CALL METHOD cl_gui_frontend_services=>clipboard_export
       IMPORTING
       data = excel_tab1
       CHANGING
       rc = ld_rc
       EXCEPTIONS
       cntl_error = 1
    * ERROR_NO_GUI = 2
    * NOT_SUPPORTED_BY_GUI = 3
       OTHERS = 4
    * Leaving Application
       CALL METHOD OF
           application
           'QUIT'.
       m_message.
       FREE OBJECT application.
       m_message.
       LOOP AT it_data1 INTO it_data_wa2.
         IF temp_row ne it_data_wa2-ROW AND temp_row IS NOT INITIAL.
           temp_row = it_data_wa2-ROW.
           APPEND IT_HEADER.
         ELSE.
           temp_row = it_data_wa2-ROW.
         ENDIF.
         CASE it_data_wa2-COL.
           WHEN '0001'.
             IT_HEADER-ID = it_data_wa2-VALUE.
           WHEN '0002'.
             IT_HEADER-KUNNR = it_data_wa2-VALUE.
           WHEN '0003'.
             IT_HEADER-INV_DATE = it_data_wa2-value.
           WHEN '0004'.
             IT_HEADER-PST_DATE = it_data_wa2-VALUE.
           WHEN '0005'.
             IT_HEADER-REF = it_data_wa2-VALUE.
           WHEN '0006'.
             IT_HEADER-AMT_DOCCUR = it_data_wa2-VALUE.
           WHEN '0007'.
             IT_HEADER-TXT = it_data_wa2-VALUE.
         ENDCASE.
       ENDLOOP.
       APPEND IT_HEADER.
       CLEAR:temp_row.
       LOOP AT it_data2 INTO it_data_wa ."WHERE ROW = it_data_wa2-ROW.
         IF temp_row ne it_data_wa-ROW AND temp_row IS NOT INITIAL.
           temp_row = it_data_wa-ROW.
           APPEND IT_ITEM.
         ELSEIF ( temp_row NE it_data_wa-ROW AND temp_row IS  INITIAL ).
           temp_row = it_data_wa-ROW.
    *           ELSE
         ENDIF.
         CASE it_data_wa-COL.
           WHEN '0001'.
             IT_ITEM-ID = it_data_wa-VALUE.
           WHEN '0002'.
             IT_ITEM-GL_ACCOUNT = it_data_wa-VALUE.
           WHEN '0003'.
             IT_ITEM-AMT_DOCCUR = it_data_wa-value.
           WHEN '0004'.
             IT_ITEM-ITEM_TEXT = it_data_wa-VALUE.
           WHEN '0005'.
             IT_ITEM-BUS_AREA = it_data_wa-VALUE.
           WHEN '0006'.
             IT_ITEM-KOSTL = it_data_wa-VALUE.
    *      WHEN '0007'.
    *        IT_ITEM-VAT = it_data_wa-VALUE.
         ENDCASE.
       ENDLOOP.
       APPEND IT_ITEM.
    ENDFORM.                    " EXECUTE
    *ENDLOOP.
    *&      Form  BAPI
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM BAPI .
       DATA: it_acc_gl LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
      it_acc_ap LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,
      it_acc_aR LIKE bapiacaR09 OCCURS 0 WITH HEADER LINE,
      it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
      it_curr_amt LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
      it_doc_header LIKE bapiache09 OCCURS 0 WITH HEADER LINE,
      it_acc_tax LIKE bapiactx09 OCCURS 0 WITH HEADER LINE,
      obj_type LIKE bapiache09-obj_type,
      obj_key LIKE bapiache09-obj_key,
      obj_sys LIKE bapiache09-obj_sys,
      pstng_date LIKE it_doc_header-pstng_date,
      doc_date LIKE it_doc_header-doc_date,
      loop_cnt TYPE i VALUE 0,
      gv_vendor(10) TYPE c,
      gv_gl_acc(10) TYPE c.
       DATA  conv_s_amt TYPE BETRG.
       DATA  cur_line TYPE P.
       data item_no type POSNR_ACC.
       data item_no1 type POSNR_ACC.
       CLEAR: obj_type, obj_sys, obj_key, pstng_date, doc_date, gv_vendor, gv_gl_acc.
    *  CLEAR: it_doc_header,it_acc_gl,it_curr_amt,IT_ACC_AR,IT_RETURN.
       LOOP AT it_HEADER INTO WA_HEADER .
         REFRESH it_doc_header.
         it_doc_header-bus_act = 'RFBU'.
         it_doc_header-username = sy-uname.
    *   it_doc_header = WA_HEADER-KUNNR." Customer Number
         it_doc_header-header_txt = WA_HEADER-TXT." bdc_source-col_h. " Invoice Text
         it_doc_header-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
         CONCATENATE WA_HEADER-INV_DATE+6(4) WA_HEADER-INV_DATE+3(2) WA_HEADER-INV_DATE(2)
         into it_doc_header-doc_date.
         CONCATENATE WA_HEADER-pst_date+6(4) WA_HEADER-pst_date+3(2) WA_HEADER-pst_date(2)
          into it_doc_header-pstng_date.
         it_doc_header-doc_type = 'DR'. " Return Order...?
         it_doc_header-fisc_year = '2013'. " Return Order...?
         it_doc_header-fis_period = '02'. " Return Order...?
         it_doc_header-ref_doc_no = '123'."bdc_source-col_d. " Invoice Number
         APPEND it_doc_header.
         REFRESH it_acc_aR.
         it_acc_aR-itemno_acc = '1'. " Invoice Number
         it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
         it_acc_aR-comp_code = 'JPOL'. " Company Code
         it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
         APPEND it_acc_aR.
    *    it_acc_aR-itemno_acc = '4'. " Invoice Number
    *    it_acc_aR-customer = WA_HEADER-KUNNR. " Customer Number
    *    it_acc_aR-comp_code = 'JPOL'. " Company Code
    *    it_acc_aR-item_text = WA_HEADER-txt. " Line Item Text
    *    APPEND it_acc_aR.
         REFRESH it_acc_gl.
         REFRESH IT_CURR_AMT.
    *    ITEM_NO = 1.
         "GL Information details collected
    CLEAR : ITEM_NO,item_no1.
         LOOP AT it_ITEM INTO WA_ITEM where id = wa_header-ID.
           ITEM_NO = ITEM_NO + 1.
           it_acc_gl-itemno_acc = ITEM_NO.
           it_acc_gl-gl_account = WA_ITEM-GL_ACCOUNT."gv_gl_acc. " GL Account
           it_acc_gl-item_text = WA_ITEM-ITEM_TEXT. "bdc_source-col_o. " Line Item Text
           it_acc_gl-doc_type = 'DR'. " Return Order...?
           it_acc_gl-comp_code = 'JPOL'."bdc_source-col_a. " Company Code
           it_acc_gl-bus_area = WA_ITEM-BUS_AREA."bdc_source-col_a. " Company Code
           it_acc_gl-CUSTOMER = WA_HEADER-KUNNR.
           conv_s_amt = WA_ITEM-AMT_DOCCUR."bdc_source-col_f. " Invoice Amount
           IF conv_s_amt < 0.
             it_acc_gl-de_cre_ind = 'H'. " H-Credit
             conv_s_amt = - conv_s_amt.
           ELSE.
             it_acc_gl-de_cre_ind = 'S'. " S-Debit
           ENDIF.
           APPEND it_acc_gl.
           ITEM_NO1 = ITEM_NO1 + 1.
           it_curr_amt-itemno_acc =  ITEM_NO1 . " Invoice Number
           it_curr_amt-curr_type = '00'.
           it_curr_amt-currency = 'INR'. " Currancy
           it_curr_amt-amt_doccur = conv_s_amt . " Line Item Amount
           APPEND it_curr_amt.
           ITEM_NO1 = ITEM_NO1 + 1.
           it_curr_amt-itemno_acc =  ITEM_NO1 . " Invoice Number
           it_curr_amt-curr_type = '00'.
           it_curr_amt-currency = 'INR'. " Currancy
           it_curr_amt-amt_doccur = conv_s_amt * -1. " Line Item Amount
                  APPEND it_curr_amt.
         ENDLOOP.
         REFRESH it_return.
         "Customer Invoice
    * Do the post to GL Account and AP
         CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
           EXPORTING
             documentheader    = it_doc_header
           IMPORTING
             obj_type          = obj_type
             obj_key           = obj_key
             obj_sys           = obj_sys
           TABLES
             accountgl         = it_acc_gl
             currencyamount    = it_curr_amt
             accountreceivable = it_acc_aR
             return            = it_return.
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             wait = 'X'.
    * Check for any errors
         WRITE : obj_key.
         LOOP at IT_RETURN WHERE TYPE = 'E'.
           WRITE : / 'Error :', IT_RETURN-MESSAGE .
         endloop.
       ENDLOOP.
    ENDFORM.                    " BAPI
    Result:

    Hi
    Thank you for your help i did small modification i mention code below
    REPORT  ZCUS_INVOICE.
    data: BEGIN OF WA_HEADER,
    ID TYPE I,
    KUNNR TYPE n LENGTH 10,
    INV_DATE TYPE c LENGTH 10,
    PST_DATE TYPE c LENGTH 10,
    REF TYPE invfo-xblnr,
    PRD_TEXT TYPE BAPIACGL09-ITEM_TEXT,
    CMP_CODE TYPE BAPIACGL09-COMP_CODE,
    AMT_DOCCUR TYPE PA2010-BETRG,
    TXT(40),
    END OF WA_HEADER.
    DATA : IT_HEADER like WA_HEADER OCCURS 0  WITH HEADER LINE.
    data: BEGIN OF WA_ITEM,
    ID TYPE I,
    GL_ACCOUNT TYPE n LENGTH 10,
    ITEM_TEXT TYPE BAPIACGL09-ITEM_TEXT,
    BUS_AREA  TYPE BAPIACGL09-BUS_AREA,
    AMT_DOCCUR TYPE BAPIACCR09-AMT_DOCCUR,
    KOSTL TYPE CSKT-KOSTL,
    *       VAT(2),
    END OF WA_ITEM.
    DATA : IT_ITEM like WA_ITEM OCCURS 0  WITH HEADER LINE.
    *      value of excel-cell
    TYPES: ty_d_itabvalue             TYPE alsmex_tabline-value,
    *      internal table containing the excel data
    ty_t_itab                  TYPE alsmex_tabline   OCCURS 0,
    *      line type of sender table
    BEGIN OF ty_s_senderline,
    line(4096)               TYPE c,
    END OF ty_s_senderline,
    *      sender table
    ty_t_sender                TYPE ty_s_senderline  OCCURS 0.
    CONSTANTS:  gc_esc              VALUE '"'.
    DATA  temp_row TYPE I.
    DATA  TEMP(4).
    INCLUDE lalsmexf01.
    DATA: it_data1 TYPE ty_t_itab.
    DATA: it_data2 TYPE ty_t_itab.
    DATA: it_data_wa LIKE LINE OF it_data1.
    DATA: it_data_wa2 LIKE LINE OF it_data1.
    * DATA DECLARATION
    data: st_rw_s1 TYPE i value '2'.
    data: st_cl_s1 TYPE i value '1'.
    data: st_rw_s2 TYPE i value '2'.
    data: st_cl_s2 TYPE i value '1'.
    data: ed_rw_s1 TYPE i value '50'.
    data: ed_cl_s1 TYPE i value '9'.
    data: ed_rw_s2 TYPE i value '50'.
    data: ed_cl_s2 TYPE i value '6'.
    DATA: excel_tab TYPE ty_t_sender,
    excel_tab1 TYPE ty_t_sender.
    DATA: ld_separator TYPE c.
    DATA: application TYPE ole2_object,
    workbook TYPE ole2_object,
    sheet TYPE ole2_object,
    range TYPE ole2_object,
    worksheet TYPE ole2_object.
    DATA: h_cell TYPE ole2_object,
    h_cell1 TYPE ole2_object.
    DATA: ld_rc TYPE i.
    TYPE-POOLS ole2.
    *AT SELECTION-SCREEN.
    PARAMETERS: filename LIKE rlgrap-filename.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
    PERFORM value_help.
    sTART-OF-SELECTION.
    *  CASE sy-ucomm .
    *    WHEN 'ONLI'.
    PERFORM execute.
    PERFORM bapi.
    *  ENDCASE.
    * MESSAGE DEFINATION
    DEFINE m_message.
    case sy-subrc.
    when 0.
    when 1.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    when others. raise upload_ole.
    endcase.
    END-OF-DEFINITION.
    *&      Form  VALUE_HELP
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM VALUE_HELP .
    CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
    EXPORTING
    def_filename     = ' '
    def_path         = ' '
    mask             = ',*.*,*.*.'
    mode             = 'O'
    title            = ' '
    IMPORTING
    filename         = filename
    EXCEPTIONS
    inv_winsys       = 1
    no_batch         = 2
    selection_cancel = 3
    selection_error  = 4
    OTHERS           = 5.
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " VALUE_HELP
    *&      Form  EXECUTE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM EXECUTE .
    * PARAMETER CHECK
    IF st_rw_s1 > ed_rw_s1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_cl_s1 > ed_cl_s1.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_rw_s2 > ed_rw_s2.
    RAISE inconsistent_parameters.
    ENDIF.
    IF st_cl_s2 > ed_cl_s2.
    RAISE inconsistent_parameters.
    ENDIF.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    ld_separator = cl_abap_char_utilities=>horizontal_tab.
    * OPENING EXCEL FILE
    IF application-header = space OR application-handle = -1.
    CREATE OBJECT application 'Excel.Application'.
    m_message.
    ENDIF.
    CALL METHOD OF
    application
    'Workbooks' = workbook.
    m_message.
    CALL METHOD OF
    application
    'Workbooks' = workbook.
    m_message.
    CALL METHOD OF
    workbook
    'Open'
    EXPORTING
    #1       = filename.
    m_message.
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 1.
    m_message.
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 1.
    m_message.
    CALL METHOD OF
    sheet
    'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    * MARKING OF WHOLE SPREADSHEET
    CALL METHOD OF
    sheet
    'Cells' = h_cell
    EXPORTING
    #1      = st_rw_s1
    #2      = st_cl_s1.
    m_message.
    CALL METHOD OF
    sheet
    'Cells' = h_cell1
    EXPORTING
    #1      = ed_rw_s1
    #2      = ed_cl_s1.
    m_message.
    CALL METHOD OF
    sheet
    'RANGE' = range
    EXPORTING
    #1      = h_cell
    #2      = h_cell1.
    m_message.
    CALL METHOD OF
    range
    'SELECT'.
    m_message.
    * Copy marked area (SHEET1) into Clippboard
    CALL METHOD OF
    range
    'COPY'.
    m_message.
    * Read clipboard into ABAP
    CALL METHOD cl_gui_frontend_services=>clipboard_import
    IMPORTING
    data                 = excel_tab
    EXCEPTIONS
    cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
    OTHERS               = 4.
    IF sy-subrc <> 0.
    MESSAGE a037(alsmex).
    ENDIF.
    PERFORM separated_to_intern_convert TABLES excel_tab it_data1
    USING ld_separator.
    * Clear the clipboard
    REFRESH excel_tab.
    CALL METHOD cl_gui_frontend_services=>clipboard_export
    IMPORTING
    data                 = excel_tab
    CHANGING
    rc                   = ld_rc
    EXCEPTIONS
    cntl_error           = 1
    *     ERROR_NO_GUI         = 2
    *     NOT_SUPPORTED_BY_GUI = 3
    OTHERS               = 4.
    * Working in Second Excel Work Sheet
    CALL METHOD OF
    application
    'Worksheets' = sheet
    EXPORTING
    #1           = 2.
    m_message.
    CALL METHOD OF
    sheet
    'Activate'.
    m_message.
    GET PROPERTY OF application 'ACTIVESHEET' = sheet.
    m_message.
    * Mark Sheet2
    CALL METHOD OF
    sheet
    'Cells' = h_cell
    EXPORTING
    #1      = st_rw_s2
    #2     

  • Error in BAPI_ACC_DOCUMENT_POST to post Special GL transactions

    Hi,
    I could not able to post the Special GL transactions like Bill of exchange payment request through BAPI BAPI_ACC_DOCUMENT_POST. It is giving error message BAPI could not process special G/L transacitons of type W not processed. Do we have any other bapi to process these special GL transactions.
    Best Regards,
    Radhakrishna.

    Hi Arun,
    Actually Special G/L Transction of type W i am posting through BAPI_ACC_DOCUMENT_POST
    it is saying Special G/L transactions of type w are not supported. I have alreday searched for SAP note did not get anything.
    So i thougt of working alternative process.
    error message F5 246 Special G/L transactions of type & are not supported
    Best Regards,
    Radhakrishna.

  • Errors in BAPI_ACC_DOCUMENT_POST

    i m calling BAPI BAPI_ACC_DOCUMENT_POST for GL posting...i have append some values which i get from the excel sheet...but the thing i m getting below errors..i m unable to sort out these...
    Error in document: BKPF E000000024DM102009
    Required field OBJ_SYS was not transferred in parameter DOCUMENTHEADER
    Incorrect entry in field OBJ_TYPE: BKPF
    Required field GL_ACCOUNT was not transferred in parameter ACCOUNTGL
    G/L account  is not defined in chart of accounts CADC

    Ok. Let me give this sample coding to you. I have extensively used this BAPI including the check accounting bapi.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
            EXPORTING
              DOCUMENTHEADER          = DOCUMENTHEADER
              CUSTOMERCPD             = CUSTOMERCPD
    *     CONTRACTHEADER          =
         IMPORTING
           OBJ_TYPE                = DOCUMENTHEADER-OBJ_TYPE
           OBJ_KEY                 = OBJ_KEY2
           OBJ_SYS                 = DOCUMENTHEADER-OBJ_SYS
            TABLES
             ACCOUNTGL               = ACCOUNTGL
             ACCOUNTRECEIVABLE       = ACCOUNTRECEIVABLE
             ACCOUNTPAYABLE          = ACCOUNTPAYABLE
    *       ACCOUNTTAX              = ACCOUNTTAX
              CURRENCYAMOUNT         = CURRENCYAMOUNT
    *     CRITERIA                =
    *     VALUEFIELD              =
              EXTENSION1              = EXTENSION1
              RETURN                  = RETURN
    *     PAYMENTCARD             =
    *     CONTRACTITEM            =
    *     EXTENSION2              =
    *     REALESTATE              =
           ACCOUNTWT               = ACCOUNTWT
    Now the Document header
       Build DOCUMENTHEADER
        DOCUMENTHEADER-OBJ_TYPE = OBJ_TYPE.  (OBJ_TYPE(5) VALUE 'BKPF')
        DOCUMENTHEADER-OBJ_KEY  = OBJ_KEY. (Concatenate itab-REF_DOC_NO itab-COMP_CODE w_year 'OR' into OBJ_KEY)
        DOCUMENTHEADER-OBJ_SYS  = SY-MANDT.
        DOCUMENTHEADER-BUS_ACT =  BUS_ACT. (BUS_ACT(4) VALUE 'RFBU')
        DOCUMENTHEADER-USERNAME = SY-UNAME.
        DOCUMENTHEADER-COMP_CODE = itab2-COMP_CODE.
        DOCUMENTHEADER-DOC_DATE = itab2-DOC_DATE.
        DOCUMENTHEADER-PSTNG_DATE = itab2-PSTNG_DATE.
        DOCUMENTHEADER-TRANS_DATE = itab2-TRANS_DATE.
        DOCUMENTHEADER-FISC_YEAR = w_year.
        DOCUMENTHEADER-FIS_PERIOD = w_period.
        DOCUMENTHEADER-DOC_TYPE = itab2-DOC_TYPE.
        DOCUMENTHEADER-REF_DOC_NO = itab2-REF_DOC_NO
    *    Build DOCUMENTHEADER
        IF ITAB2-NAME <> ''.
          CUSTOMERCPD-NAME   = ITAB2-NAME.
          CUSTOMERCPD-NAME_2 = ITAB2-NAME_2.
          CUSTOMERCPD-NAME_3 = ITAB2-NAME_3.
          CUSTOMERCPD-NAME_4 = ITAB2-NAME_4.
          CUSTOMERCPD-POSTL_CODE = ITAB2-POSTL_CODE.
          CUSTOMERCPD-CITY = ITAB2-CITY.
          CUSTOMERCPD-REGION = ITAB2-REGION.
          CUSTOMERCPD-COUNTRY = ITAB2-COUNTRY.
          CUSTOMERCPD-STREET = ITAB2-STREET.
          CUSTOMERCPD-BANK_ACCT = ITAB2-BANK_ACCT.
          CUSTOMERCPD-BANK_NO = ITAB2-BANK_NO.
          CUSTOMERCPD-BANK_CTRY = ITAB2-BANK_CTRY.
          CUSTOMERCPD-CTRL_KEY = ITAB2-CTRL_KEY.
        ENDIF.
    *Build Account G/L
           itemno = itemno + 1.
            ACCOUNTGL-ITEMNO_ACC = ITEMNO.
    *        ACCOUNTGL-GL_ACCOUNT  = itab-sapcode.
            ACCOUNTGL-ITEM_TEXT  = itab-ITEM_TEXT_GL.
            ACCOUNTGL-REF_KEY_1  = itab-REF_KEY_1_GL.
            ACCOUNTGL-REF_KEY_2  = itab-REF_KEY_2_GL.
            ACCOUNTGL-ACCT_TYPE = itab-ACCT_TYPE_GL.
            ACCOUNTGL-BUS_AREA = itab-BUS_AREA_GL.
            ACCOUNTGL-TAX_CODE = itab-TAX_CODE_GL.
            ACCOUNTGL-TAXJURCODE = itab-TAXJURCODE_GL.
            ACCOUNTGL-COSTCENTER = itab-COSTCENTER_GL.
            ACCOUNTGL-PROFIT_CTR = itab-PROFIT_CTR_GL.
            ACCOUNTGL-ORDERID = itab-ORDERID_GL.
            ACCOUNTGL-ASSET_NO = itab-ASSET_NO_GL.
            ACCOUNTGL-SUB_NUMBER = itab-SUB_NUMBER_GL.
            ACCOUNTGL-SALES_ORD = itab-SALES_ORD_GL.
            ACCOUNTGL-S_ORD_ITEM = itab-S_ORD_ITEM_GL.
            ACCOUNTGL-DE_CRE_IND = itab-DE_CRE_IND_GL.
            ACCOUNTGL-QUANTITY = itab-QUANTITY_GL.
            ACCOUNTGL-BASE_UOM = itab-BASE_UOM_GL.
            ACCOUNTGL-MATERIAL = itab-MATERIAL_GL.
            ACCOUNTGL-PO_NUMBER = itab-PO_NUMBER_GL.
            ACCOUNTGL-PO_ITEM = itab-PO_ITEM_GL.
            Append ACCOUNTGL.
    *  Build accountreceivable
            itemno = itemno + 1.
            ACCOUNTRECEIVABLE-ITEMNO_ACC = ITEMNO.
    *      ACCOUNTRECEIVABLE-CUSTOMER  = itab-sapcode.
            ACCOUNTRECEIVABLE-BUS_AREA  = itab-BUS_AREA_GL.
            ACCOUNTRECEIVABLE-PMNTTRMS  = itab-PMNTTRMS_AP.
            ACCOUNTRECEIVABLE-BLINE_DATE  = itab2-BLINE_DATE_AR.
            ACCOUNTRECEIVABLE-PYMT_METH = itab-PYMT_METH_AR.
            ACCOUNTRECEIVABLE-PMNT_BLOCK = itab-PMNT_BLOCK_AR.
            ACCOUNTRECEIVABLE-BANK_ID = itab-BANK_ID_AR.
            ACCOUNTRECEIVABLE-SP_GL_IND = itab-SP_GL_IND_AR.
            ACCOUNTRECEIVABLE-ALT_PAYEE = itab-ALT_PAYEE_AR.
            ACCOUNTRECEIVABLE-PROFIT_CTR = itab-PROFIT_CTR_GL.
            Append ACCOUNTRECEIVABLE.
    *  Build Accounts payable
           itemno = itemno + 1.
            ACCOUNTPAYABLE-ITEMNO_ACC = ITEMNO.
    *      ACCOUNTPAYABLE-VENDOR_NO  = itab-sapcode.
            ACCOUNTPAYABLE-BUS_AREA  = itab-BUS_AREA_GL.
            ACCOUNTPAYABLE-PMNTTRMS  = itab-PMNTTRMS_AP.
            ACCOUNTPAYABLE-ALLOC_NMBR  = itab-ALLOC_NMBR_GL.
            ACCOUNTPAYABLE-SP_GL_IND  = itab-SP_GL_IND_AR.
            ACCOUNTPAYABLE-BLINE_DATE  = itab-BLINE_DATE_AR.
            ACCOUNTPAYABLE-PROFIT_CTR = itab-PROFIT_CTR_GL.
            Append ACCOUNTPAYABLE.
    * Build Currency Amount
         CURRENCYAMOUNT-ITEMNO_ACC = ITEMNO.
          CURRENCYAMOUNT-CURR_TYPE  = CURR_TYPE1.
          CURRENCYAMOUNT-CURRENCY  = itab-CURRENCY_CUR.
          CURRENCYAMOUNT-AMT_DOCCUR = itab-AMT_DOCCUR_DOC.
          CURRENCYAMOUNT-EXCH_RATE = itab-EXCH_RATE_CUR.
          Append CURRENCYAMOUNT.
          if itab-CURRENCY_CUR ne w_currency.
            CURRENCYAMOUNT-ITEMNO_ACC = ITEMNO.
            CURRENCYAMOUNT-CURR_TYPE  = CURR_TYPE2.
            CURRENCYAMOUNT-CURRENCY  = w_currency.
            CURRENCYAMOUNT-AMT_DOCCUR = itab-AMT_DOCCUR_LOC.
            CURRENCYAMOUNT-EXCH_RATE = itab-EXCH_RATE_CUR.
            Append CURRENCYAMOUNT.
          endif.
    *       Witholding Tax
          if ITAB-WT_TYPE_WT <> ''.
            itemno = itemno + 1 .
            ACCOUNTWT-ITEMNO_ACC = ITEMNO.
            ACCOUNTWT-WT_TYPE  = itab-WT_TYPE_WT.
            ACCOUNTWT-WT_CODE  = itab-WT_CODE_WT.
            Append ACCOUNTWT.
          endif.
    Tell me if you don't understand any part. This is working in production at my place.
    Varun Mathur
    Edited by: Varun Mathur on Aug 17, 2009 12:42 PM
    Edited by: Varun Mathur on Aug 17, 2009 12:44 PM

  • Posting error in BAPI_ACC_DOCUMENT_POST

    Hi Experts,
    I am trying to post an asset transaction by means of a BAPI BAPI_ACC_DOCUMENT_POST.In Release R/3 Enterprise the posting is rejected with error message (msg id : AA,msg num: 001)  'Asset & & not in company code &' .I have also checked the following things which can cause the error:
    1. The asset is initially created with a non-0 sub-number, a defect
    causes the error.
    2. It is also possible that this asset is defined as a group asset. In
    that case, it cannot be used as an asset.
    3. The asset is not acquired.
    But above things are OK,still I am getting the error message.I have also tried to implement sapnote '0000643232' but failed.Can anyone give  any solution/reason for this error?.
    Thanks,
    Vineet

    Hi Arjun
    Pls find the code that I have tested for Asset Posting...
    Header
    BUS_ACT                        RMWE
    USERNAME                     Sy-uname
    COMP_CODE                   1200
    DOC_DATE                       11.11.2008
    PSTNG_DATE                   11.11.2008
    DOC_TYPE                       SA
    Asset and GL  Items
    ITEMNO_ACC                     0000000001
    GL_ACCOUNT                    1000
    ACCT_TYPE                       A
    COMP_CODE                     1200
    COND_ST_NO                     000
    FUNDS_CTR                      S00001
    ASSET_NO                        100000007
    SUB_NUMBER                    0    
    CS_TRANS_T                     120
    ITEMNO_ACC                     0000000002
    GL_ACCOUNT                     476000
    COSTCENTER                     S00001
    FUNDS_CTR                      S00001
    Currency Items
    ITEMNO_ACC                     0000000001
    CURRENCY                       SGD
    AMT_DOCCUR                     100,0000
    ITEMNO_ACC                     0000000002
    CURRENCY                       SGD
    AMT_DOCCUR                     100,0000-
    Pls Advise
    Thanks

  • Business Area error in BAPI_ACC_DOCUMENT_POST

    I am using BAPI_ACC_DOCUMENT_POST to post an accounting document (FB50). In the header of BAPI parameter I pass BUS_ACT as 'RFBU'.
    I am getting an error message Cost center belong to business area 'XXX' not 'YYY'. The reason is see for this error is there is a substitution rule defined saying if business area is blank, default this to 'YYY'. Business area is not passed through interface of BAPI, but business area 'XXX' is maintained in Cost Center master data.
    In the case of BAPI, BAPI is getting the business area from substitution and during the function call 'K_COBL_CHECK' inside BAPI, the business area of G/L line item and business are from cost center is not matching.
    But when the same is entered through FB50, its getting the business area from cost center and business area. Is there any SAP Note to solve this issue. Is any one aware of this.
    Thanks
    Vishnu

    And if business area is blank (not maintained in cost center master) and you don't pass anything, BAPI works correctly right? If you could determine the business area , why not pass it to BAPI?
    BAPI sometimes do have minor differences from online transactions.. I don't see it as a big issue.. you can look for OSS notes or see how others handled it...

  • Balance in local currency error in BAPI_ACC_DOCUMENT_POST

    Hi,
    When I call BAPI_ACC_DOCUMENT_POST, I take below error from bapi return message,
    the code related filling bapi header,item and currency also is below.Is tehere any body can help me to solve my problem.
    Thanks,
    form fill_header .
      "Header
      t_doc_header-comp_code  = 'NETS'.
      t_doc_header-header_txt = 'CS stok'.
      t_doc_header-fisc_year  = gv_year.
      t_doc_header-fis_period = gv_month.
      t_doc_header-doc_date   = sy-datum.  "?
      t_doc_header-pstng_date = sy-datum.  "?
      t_doc_header-bus_act    = 'RFBU'.
      t_doc_header-username   = sy-uname.
      t_doc_header-doc_type   = 'SA'.
      append t_doc_header.
    t_doc_header-ac_doc_no  = ''.
    t_doc_header-acc_principle = ''.
    t_doc_header-neg_postng    = ''.
    endform.                    " fill_header
    form fill_item using p_no .
      "item
    t_accountgl_item-ac_doc_no  = ''. "Accounting Document Number
    t_accountgl_item-doc_type   = ''. "Document type
      t_accountgl_item-comp_code  = 'NETS'.   "Company Code
      t_accountgl_item-plant      = '1300'.   "Plant
      t_accountgl_item-fisc_year  = gv_year.  "Fiscal Year
      t_accountgl_item-fis_period = gv_month. "Fiscal month
      if p_no = '1'.
        t_accountgl_item-itemno_acc = '1'.
        t_accountgl_item-gl_account = '1522000111'.
        t_accountgl_item-item_text  = 'CS Vuk Item-1'.
        t_accountgl_item-pstng_date = gv_last_day.
        append t_accountgl_item.
      elseif p_no ='2'.
        t_accountgl_item-itemno_acc = '2'. "Accounting Document Line Item Number
        t_accountgl_item-gl_account = '6220000111'. "General Ledger Account
        t_accountgl_item-item_text  = 'CS Vuk Item-2'.
        t_accountgl_item-pstng_date =  gv_first_day_for_next_month.
        append t_accountgl_item.
      endif.
    endform.                    " fill_item_1
    form fill_currency using p_no p_fark .
      data: miktar1 type ckmlcr-salk3,
            miktar2 type ckmlcr-salk3.
      "currency
    t_currencyamount-exch_rate   = ''.       "Exchange rate
      t_currencyamount-curr_type   = '10'.     "Currency type and valuation view
      t_currencyamount-currency    = 'TRY'.
      miktar1 = p_fark.
      miktar2 = - p_fark.
      if p_no = '1'.
        t_currencyamount-itemno_acc  = 1.
        t_currencyamount-amt_doccur  =  miktar1. "Amount in document currency
        append t_currencyamount.
        t_currencyamount-itemno_acc  = 2.
        t_currencyamount-amt_doccur  =  miktar2.
        append t_currencyamount.
      elseif p_no = '2'.
        t_currencyamount-itemno_acc  = 1.
        t_currencyamount-amt_doccur  =  miktar2.
        append t_currencyamount.
        t_currencyamount-itemno_acc  = 2.
        t_currencyamount-amt_doccur  =  miktar1.
        append t_currencyamount.
      endif.
      append t_currencyamount.
    endform.                    " fill_currency
    form call_bapi_post .
      call function 'BAPI_ACC_DOCUMENT_POST'
        exporting
          documentheader            =    t_doc_header
         importing
           obj_type                =  gv_obj_type
           obj_key                 =  gv_obj_key
           obj_sys                 =  gv_obj_sys
        tables
            accountgl               =  t_accountgl_item
          ACCOUNTRECEIVABLE       =
          ACCOUNTPAYABLE          =
          ACCOUNTTAX              =
          currencyamount            =  t_currencyamount
          CRITERIA                =
          VALUEFIELD              =
          EXTENSION1              =
          return                    =  t_return.
      gs_doc =  gv_obj_key.
      perform check_error tables t_return.
      perform call_bapi_trans.
    endform.                    " execute_bapi

    check below code....
    FUNCTION ZF_BAPI_ACC_GL_POSTING.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(SIMULATE) TYPE  CHAR1 OPTIONAL
    *"     VALUE(FILEPATH) LIKE  RLGRAP-FILENAME OPTIONAL
    *"  TABLES
    *"      DATA_RECORD STRUCTURE  ZFGL_ACCOUNT_POSTING
    *"      RETURN STRUCTURE  BAPIRET2
    This is a common function module is to simulate & post a GL document
    using input file. If file got  more than 999 items for the combination
    of company code, Currency & accounting base, the function module will
    post first 998 Items of the above combination & balances the GL
    document with 999 item having GL account 0000299998. First line item
    of  the subsequent document would be similar to 999th item of the
    previous *document.
    Read all input records into an internal table.
      clear: IT_DATA,
             IT_DATA[],
             w_simulate,
             flg_err,
             IT_US_DATA,
             RETURN,
             RETURN[],
             it_return,
             it_return[],
             IT_US_DATA[].
      w_simulate = simulate.
      w_filepath = filepath.
      DATA: L_index LIKE SY-TABIX,
            L_NEWBS LIKE RF05A-NEWBS.
      loop at DATA_RECORD.
        move-corresponding data_record to it_data.
        move :  data_record-SAKNR to it_data-newKO,
                data_record-MWSKZ to it_data-VAL2.
    Function module to convert NEWKO
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = IT_DATA-NEWKO
          IMPORTING
            OUTPUT = IT_DATA-NEWKO.
    Function module to convert KOSTL
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = IT_DATA-KOSTL
          IMPORTING
            OUTPUT = IT_DATA-KOSTL.
        append it_data.
        clear it_data.
      endloop.
    If no data is passed in an input table
      if  it_data[] is initial.
        PERFORM UPLOAD_DATA.
        IF SY-SUBRC = 0 .
          PERFORM INSERT_IT_DATA.
        ENDIF.
      endif.
    The below logic written for US payroll. As the US Payroll file is not
    standard file and do not have the credit and debit amount balanced.
    The logic below would take care the debit/credit amount balances
      read table it_data index 1.
      if it_data-zzdatsrc = '3311'.
        loop at it_data.
          if it_data-newbs = '40'.
            L_NEWBS = '50'.
            PERFORM CREATE_GL_ITEMS USING L_NEWBS
                                          v_gen
                                          IT_DATA-BUKRS.
            CLEAR L_NEWBS.
          else.
            L_NEWBS = '40'.
            PERFORM CREATE_GL_ITEMS USING L_NEWBS
                                          v_gen
                                          IT_DATA-BUKRS.
            CLEAR L_NEWBS.
          endif.
        endloop.
    The below logic written for P-card. As the US P-Card file is not
    standard file and do not have the credit and debit amount balanced,
    the logic below would take care the debit/credit amount balances
      elseif it_data-zzdatsrc = '3312'.
        sort it_data by   BUKRS
                          WAERS
                          ZZACCBAS
                          seq_num
                          NEWKO.
        loop at it_data.
          if it_data-newbs = '40'.
            IT_US_DATA-WRBTR = IT_US_DATA-WRBTR + IT_DATA-WRBTR.
          else.
            IT_US_DATA-WRBTR = IT_US_DATA-WRBTR - IT_DATA-WRBTR.
          endif.
          at end of NEWKO.
            if it_us_data-wrbtr = 0.
              clear: it_us_data,
                     L_NEWBS.
              continue.
            elseif it_us_data-wrbtr > 0.
              L_NEWBS = '40'.
            else.
              L_NEWBS = '50'.
            endif.
            move-corresponding it_data to it_us_data.
            clear: it_us_data-newko,
                   it_us_data-newbs,
                   it_us_data-kostl,
                   IT_us_data-sgtxt,
                   it_us_data-wrbtr.
            MOVE: v_pcard_ac TO IT_US_DATA-NEWKO,
                  L_NEWBS TO IT_US_DATA-NEWBS,
                  IT_DATA-WRBTR to IT_US_DATA-WRBTR,
                  '3312' TO IT_US_DATA-ZZDATSRC,
                  'GGA' TO IT_US_DATA-ZZACCBAS.
            append it_us_data.
            clear: it_us_data,
                   L_NEWBS.
          endat.
        endloop.
        LOOP AT IT_US_DATA.
          MOVE-CORRESPONDING IT_US_DATA TO IT_DATA.
          APPEND IT_DATA.
          CLEAR IT_DATA.
        ENDLOOP.
      endif.
    Populate  Sequence number
      loop at it_data.
        it_data-seq_num  = sy-tabix.
        modify it_data index sy-tabix transporting seq_num.
      endloop.
    Sort table
      sort it_data by bukrs waers budat zzACCBAS seq_num.
    Populate reconciliation account for 999th record
      v_rec_account = '0000299998'.
    Process input data
      loop at it_data.
        L_INDEX = SY-TABIX.
    Populate document heade for every combination of
    company code & currency code
        At new ZZACCBAS.
          READ TABLE IT_DATA INDEX L_INDEX.
          CLEAR: it_documentheader[],
                 it_documentheader,
                 it_accountgl[],
                 it_accountgl,
                 it_currencyamount[],
                 it_currencyamount,
                 W_COUNT,
                 W_TL_AMNT,
                 w_seq,
                 flg_eod.
          perform populate_header.
        endat.
        W_COUNT = W_COUNT + 1.
        IF IT_DATA-NEWBS = '40'.
          W_TL_AMNT = W_TL_AMNT - IT_DATA-WRBTR.
        ELSEIF IT_DATA-NEWBS = '50'.
          W_TL_AMNT = W_TL_AMNT + IT_DATA-WRBTR.
        ENDIF.
        perform populate_items.
        if flg_err = 'X'.
          exit.
        endif.
        AT END OF ZZACCBAS.
    Call BAPI to check input data.
          perform call_posting_bapi.
          loop at it_return where type = 'S' or type = 'E' or type ='A'.
            move-corresponding it_return to return.
            append return.
            clear return.
          endloop.
          flg_EOD    =  'X'.
          CLEAR: W_TL_AMNT,
                  W_COUNT,
                  it_documentheader[],
                  it_documentheader,
                  it_accountgl[],
                  it_accountgl,
                  it_currencyamount[],
                  it_currencyamount.
        ENDAT.
    *Creating the reconcillation record
        if flg_EOD <> 'X'.
          IF W_COUNT EQ 998.
            IF W_TL_AMNT <> 0.
              W_COUNT = W_COUNT + 1.
              IF W_TL_AMNT LT 0.
                IT_DATA-NEWBS = '50'.
                it_data-newko =  v_rec_account.
                W_WRBTR = ABS( W_TL_AMNT ).
                IT_DATA-WRBTR = W_WRBTR.
                flg_fi = 'X'.
                w_seq = w_seq + 1 .
                perform populate_items.
                if flg_err = 'X'.
                  exit.
                endif.
                perform call_posting_bapi.
              loop at it_return where type = 'S' or type = 'E' or type ='A'.
                  move-corresponding it_return to return.
                  append return.
                  clear return.
                endloop.
                cleAR:it_accountgl[],
                      it_accountgl,
                      it_currencyamount[],
                      it_currencyamount.
                W_COUNT = 1.
                IT_DATA-NEWBS = '40'.
                it_data-newko =  v_rec_account.
                W_WRBTR = ABS( W_TL_AMNT ).
                IT_DATA-WRBTR = W_WRBTR.
                flg_fi = 'X'.
                perform populate_items.
                if flg_err = 'X'.
                  exit.
                endif.
              ELSE.
                IT_DATA-NEWBS = '40'.
                it_data-newko =  v_rec_account.
                W_WRBTR = ABS( W_TL_AMNT ).
                IT_DATA-WRBTR = W_WRBTR.
                flg_fi = 'X'.
                perform populate_items.
                if flg_err = 'X'.
                  exit.
                endif.
                perform call_posting_bapi.
              loop at it_return where type = 'S' or type = 'E' or type ='A'.
                  move-corresponding it_return to return.
                  append return.
                  clear return.
                endloop.
                cleAR:it_accountgl[],
                      it_accountgl,
                      it_currencyamount[],
                      it_currencyamount.
                W_COUNT = 1.
                IT_DATA-NEWBS = '50'.
                it_data-newko =  v_rec_account.
                W_WRBTR = ABS( W_TL_AMNT ).
                IT_DATA-WRBTR = W_WRBTR.
                flg_fi = 'X'.
                perform populate_items.
                if flg_err = 'X'.
                  exit.
                endif.
              ENDIF.
            endif.
          endif.
        endif.
      endloop.
      IF FLG_ERR = 'X'.
        loop at it_return where type = 'E' or type ='A'.
          move-corresponding it_return to return.
          append return.
          clear return.
        endloop.
      ENDIF.
    ENDFUNCTION.

  • BAPI_ACC_DOCUMENT_POST Profit Center Auto-Populated.

    Hi Experts,
    I need to create fi documents trought BAI_ACC_DOCUMENT_POST, the documents contains FM relations on RES_DOC and The position, the functional consultor tolls me that the respective profit center is populated automatically, but i receiving an error telling me that i need to inclue the profit center, so, this is telling me that is not pupulated by the bapi. Any Suggestions?.
    Thanks in advance,
    Steve.

    Hi Steve,
    You can check the Function module documentation.
    Please check the below links for sample code of this BAPI.
    BAPI_ACC_DOCUMENT_POST having error message RW 609
    Re: Error in BAPI_ACC_DOCUMENT_POST to post Special GL transactions
    Re: BAPI  BAPI_ACC_DOCUMENT_POST
    BAPI_ACC_DOCUMENT_POST not generating accounting document
    Re: Tax problem in BAPI_ACC_DOCUMENT_POST >Help
    Thanks.

  • 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

  • Error when using BAPI_ACC_DOCUMENT_POST...

    [code]
    Hello Experts,
    Iam using the said BAPI for the first time and I am not sure if I filled up the
    fields correctly. What I want to do is to post multiple debit entries(40) and a
    special G/L entry for vendor(posting key 39). I also need to generate the tax and
    withholding tax. So my entries will be like:
    40 -->amount = 1,120(This value has a VAT included which is 12% or 120)
    39 -->amount = 1,120(Special G/L for vendor)
    For these 2 entries below, they must be generated automatically.
    40 -->amount = 120(Tax)
    50 -->amount = 20(This is the EWT or withholding tax)
    Below is my code:
    wa_documentheader-obj_type = 'BKPFF'.
    CONCATENATE sy-sysid sy-mandt INTO wa_documentheader-obj_sys.
    wa_documentheader-obj_key = '$'.
      wa_documentheader-username = sy-uname.
      wa_documentheader-comp_code = '1000'.
      wa_documentheader-bus_act = 'RFBU'.
      wa_documentheader-header_txt = 'AVH Testing...'.
      wa_documentheader-fisc_year = '2007'.
      wa_documentheader-doc_date = sy-datum.
      wa_documentheader-pstng_date = sy-datum.
      wa_documentheader-fis_period = '11'.
      wa_documentheader-doc_type = 'S3'.
      CLEAR wa_accountpayable.
      wa_accountpayable-itemno_acc = 1.
      wa_accountpayable-vendor_no  = '2000000058'.
      wa_accountpayable-sp_gl_ind  = 'V'.
      wa_accountpayable-tax_code   = 'DI'.
      APPEND wa_accountpayable TO it_accountpayable.
      CLEAR: wa_accountgl.
      wa_accountgl-itemno_acc = 2.
      wa_accountgl-gl_account = '0060000061'.
      wa_accountgl-item_text = 'Aris' .
      wa_accountgl-DE_CRE_IND = 'S'.
      wa_accountgl-tax_code  = 'DI'.
      wa_accountgl-comp_code = '1000'.
      wa_accountgl-fisc_year = '2007'.
      wa_accountgl-fis_period = '11'.
      wa_accountgl-pstng_date = sy-datum.
      wa_accountgl-doc_type = 'S3'.
      INSERT wa_accountgl INTO TABLE it_accountgl.
      CLEAR wa_accounttax.
      wa_accounttax-itemno_acc = 3.
      wa_accounttax-tax_code = 'DI'.
      wa_accounttax-gl_account = '0010018291'.
      wa_accounttax-acct_key = 'VST'.
      APPEND wa_accounttax TO it_accounttax.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 1.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 1120.
      wa_currency-amt_base = 1000.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 2.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 1120.
      wa_currency-amt_base = 1000.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
      CLEAR: wa_currency.
      wa_currency-itemno_acc = 3.
      wa_currency-currency = 'PHP'.
      wa_currency-curr_type = '00'.
      wa_currency-amt_doccur = 120.
    wa_currency-amt_base = 120.
    wa_currency-exch_rate = 1.
      APPEND wa_currency TO it_currency.
    Post
      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          documentheader = wa_documentheader
        IMPORTING
          obj_type       = obj_type
          obj_key        = obj_key
          obj_sys        = obj_sys
        TABLES
          accountgl      = it_accountgl
          currencyamount = it_currency
          return         = it_return.
      LOOP AT it_return INTO wa_return.
        WRITE : /1 wa_return-message.
      ENDLOOP.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = wa_return3.
    When I checked the return table there are 2 problems that says:
    1. Error in document: BKPFF $ ED1CLNT140
    2. Balance in transaction currency
    Hope you can help me guys. Simple examples will be appreciated. Thank you and take care!
    [/code]

    <u>you can check the code.</u>
    IF NOT wa_data-lifnr  IS INITIAL.
          ADD 1 TO g_lino.
          x_vendoritem-itemno_acc        = g_lino.
          x_vendoritem-vendor_no         = wa_data-lifnr.
          IF wa_data-newbk IS INITIAL.
            x_vendoritem-comp_code = wa_data-bukrs.
          ELSE.
            x_vendoritem-comp_code = wa_data-newbk.
          ENDIF.
          x_vendoritem-comp_code         = t001-bukrs.
          x_vendoritem-item_text         = wa_data-csgtxt.
          x_vendoritem-pmnttrms          = wa_data-pyterm.
          x_vendoritem-bline_date        = wa_data-bldate.
          x_vendoritem-pymt_meth         = wa_data-zlsch.
          x_vendoritem-alloc_nmbr        = wa_data-zuonr.
          x_vendoritem-tax_code          = wa_data-mwskz.
          x_vendoritem-taxjurcode        = wa_data-txjcd.
          APPEND x_vendoritem TO it_vendoritem.
          x_currencyamount-itemno_acc    = g_lino.
          x_currencyamount-curr_type     = c_ct1.
          x_currencyamount-currency      = t001-waers.
          x_currencyamount-amt_doccur    = wa_data-cwrbtr.
          APPEND x_currencyamount TO it_currencyamount.
          x_currencyamount-curr_type     = c_ct2.
          APPEND x_currencyamount TO it_currencyamount.
          IF t001-land1 = c_lnd.
            x_currencyamount-curr_type   = c_ct3.
            APPEND x_currencyamount TO it_currencyamount.
          ENDIF.
        ENDIF.
        IF NOT wa_data-dsaknr IS INITIAL.
          CLEAR:
            x_accountgl,
            x_currencyamount,
            x_vendoritem.
          ADD 1 TO g_lino.
          x_accountgl-itemno_acc         = g_lino.
          x_accountgl-doc_type           = x_doc_hdr-doc_type.
          IF wa_data-newbk IS INITIAL.
            x_accountgl-comp_code = wa_data-bukrs.
          ELSE.
            x_accountgl-comp_code = wa_data-newbk.
          ENDIF.
          x_accountgl-gl_account         = wa_data-dsaknr.
          x_accountgl-costcenter         = wa_data-dkostl.
          x_accountgl-item_text          = wa_data-dsgtxt.
          x_accountgl-orderid            = wa_data-daufnr.
          x_accountgl-wbs_element        = wa_data-dwbs.
          x_accountgl-pstng_date         = p_pdate.
          x_accountgl-vendor_no          = wa_data-lifnr .
          x_accountgl-alloc_nmbr         = wa_data-zuonr.
          x_accountgl-tax_code           = wa_data-mwskz.
          x_accountgl-taxjurcode         = wa_data-txjcd.
          APPEND x_accountgl TO it_accountgl.
          x_currencyamount-itemno_acc    = g_lino.
          x_currencyamount-curr_type     = c_ct1.
          x_currencyamount-currency      = t001-waers.
          x_currencyamount-amt_doccur    = - wa_data-dwrbtr.
          APPEND x_currencyamount TO it_currencyamount.
          x_currencyamount-curr_type     = c_ct2.
          APPEND x_currencyamount TO it_currencyamount.
          IF t001-land1 = c_lnd.
            x_currencyamount-curr_type     = c_ct3.
            APPEND x_currencyamount TO it_currencyamount.
          ENDIF.
        ENDIF.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'                   
        EXPORTING
          documentheader = x_doc_hdr
        TABLES
          accountgl      = it_accountgl
          accountpayable = it_vendoritem
          currencyamount = it_currencyamount
          return         = it_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    Reward if helpful.

  • Error getting while using BAPI "BAPI_ACC_DOCUMENT_POST" in the Web Dynpro

    Hello Everyone,
    I am trying to use BAPI_ACC_DOCUMENT_POST to post a docuemnt, for this I have created a web application and in that I have created one view. In the layout of the view I have developed three groups 1. document header 2.Currency 3. GL account. for user inputs and at the root node i have created a button and on the action f the button I am calling the BAPI but when i tested it I am getting the following error:
    The following error text was processed in the system RS2 : Adapter error in INPUT_FIELD "GROUP_2_ITEMNO_ACC" of view "ZTEST_RAGI_INVOICE_POST.MAIN": Context binding of property VALUE cannot be resolved: Node MAIN.1.CURRENCYAMOUNT does not contain any elements .
    Can you please help me in this.
    Thanks,
    Rajat

    helll rajat ,
    The following error text was processed in the system RS2 : Adapter error in INPUT_FIELD "GROUP_2_ITEMNO_ACC" of view "ZTEST_RAGI_INVOICE_POST.MAIN": Context binding of property VALUE cannot be resolved: Node MAIN.1.CURRENCYAMOUNT does not contain any elements .
    ---> pass amount to that currency table.
    regards
    Prabhu

  • BAPI_ACC_DOCUMENT_POST    Giving an error while posting

    Hi friends,
    I wanted to post a Document using  bapi BAPI_ACC_DOCUMENT_POST with tax data and jurisdiction code. Getting an error message " E RW 003 No currency information transferred into Accounting" though I have given  the Currency info.    
    Below is the data that passed to the BAPI
    <header> data
    OBJ_TYPE                       BKPFF         
    OBJ_KEY                        $             
    OBJ_SYS                        T90CLNT810    
    BUS_ACT                        RFBU          
    USERNAME                       MNAGOORI      
    HEADER_TXT                      DOCU POST MD 
    COMP_CODE                      3000          
    DOC_DATE                       17.01.2007    
    PSTNG_DATE                     17.01.2007    
    TRANS_DATE                                   
    FISC_YEAR                      2007          
    FIS_PERIOD                     01            
    DOC_TYPE                       WE            
    REF_DOC_NO                                   
    ACCOUNTGL TABLE DATA
    ITEMNO_ACC                  0000000001 
    GL_ACCOUNT                  445000     
    ITEM_TEXT                      TEST FOR MD1
    REF_KEY_3                      40         
    ACCT_KEY                                  
    ACCT_TYPE                      S          
    COMP_CODE                    3000       
    BUS_AREA                       9900       
    ACCOUNTPAYABLE
    ITEMNO_ACC                     0000000002
    VENDOR_NO                      9999      
    GL_ACCOUNT                     191100    
    REF_KEY_1                                
    REF_KEY_2                                
    REF_KEY_3                      50        
    COMP_CODE                      3000      
    BUS_AREA                       9900      
    ITEM_TEXT                        TEST
    AccountTax table
    ITEMNO_ACC                     0000000001
    GL_ACCOUNT                     445000   
    COND_KEY                       JP1I     
    ACCT_KEY                       NVV      
    TAX_CODE                       I1       
    TAX_RATE                          6,000 
    TAX_DATE                                
    TAXJURCODE                     PA0000000
    ITEMNO_ACC                     0000000002
    GL_ACCOUNT                     191100    
    COND_KEY                       JP1I      
    ACCT_KEY                       NVV       
    TAX_CODE                       I1        
    TAX_RATE                          6,000  
    TAX_DATE                                 
    TAXJURCODE                     PA0000000 
    CurrencyAmount table
    ITEMNO_ACC                     0000000001                    
    CURR_TYPE                      00                            
    CURRENCY                       USD                           
    CURRENCY_ISO                   USD                           
    AMT_DOCCUR                                          100,0000 
    EXCH_RATE                                                    
    EXCH_RATE_V                                                  
    AMT_BASE                                            100,0000 
    ITEMNO_ACC                     0000000002                     
    CURR_TYPE                      00                             
    CURRENCY                       USD                            
    CURRENCY_ISO                   USD                            
    AMT_DOCCUR                                          100,0000- 
    EXCH_RATE                                                     
    EXCH_RATE_V                                                   
    AMT_BASE                                            100,0000- 
    I could able to post without tax data.
         I feel some of the feilds are missing the required data. Please any one could help me.
    Thanks
    Md

    Hi Aaron,
                I am testing the BAPI in SE37, the values are given below  which I am trying to post.
    [code]
    ****<header> data
    OBJ_TYPE         BKPFF
    OBJ_KEY           $
    OBJ_SYS           T90CLNT810
    BUS_ACT            RFBU
    USERNAME        MNuser
    HEADER_TXT      DOCU POST MD
    COMP_CODE      3000
    DOC_DATE          17.01.2007
    PSTNG_DATE      17.01.2007
    TRANS_DATE
    FISC_YEAR          2007
    FIS_PERIOD         01
    DOC_TYPE           WE
    REF_DOC_NO
    ACCOUNTGL TABLE DATA
    ITEMNO_ACC             0000000001
    GL_ACCOUNT            445000
    ITEM_TEXT                 TEST FOR MD1
    REF_KEY_3                40
    ACCT_TYPE                S
    COMP_CODE              3000
    BUS_AREA                 9900
    ACCOUNTPAYABLE
    ITEMNO_ACC                0000000002
    VENDOR_NO                9999
    GL_ACCOUNT               191100
    REF_KEY_1
    REF_KEY_2
    REF_KEY_3                   50
    COMP_CODE                3000
    BUS_AREA                    9900
    ITEM_TEXT                     TEST
    AccountTax table
    ITEMNO_ACC               0000000001
    GL_ACCOUNT               445000
    COND_KEY                 JP1I
    ACCT_KEY                  NVV
    TAX_CODE                   I1
    TAX_RATE                   6,000
    TAX_DATE
    TAXJURCODE                PA0000000
    ITEMNO_ACC               0000000002
    GL_ACCOUNT             191100
    COND_KEY                 JP1I
    ACCT_KEY                  NVV
    TAX_CODE                    I1
    TAX_RATE                   6,000
    TAX_DATE
    TAXJURCODE               PA0000000
    CurrencyAmount table
    ITEMNO_ACC            0000000001
    CURR_TYPE             00
    CURRENCY               USD
    CURRENCY_ISO         USD
    AMT_DOCCUR           100,0000
    AMT_BASE               100,0000
    ITEMNO_ACC               0000000002
    CURR_TYPE                00
    CURRENCY                 USD
    CURRENCY_ISO          USD
    AMT_DOCCUR             100,0000-
    AMT_BASE                 100,0000-
    [/code]
    Thanks
    Md

  • Lock Error while posting document through bapi_acc_document_post

    Hi,
       We are trying to Post documents in R/3 using Bapi_acc_document_post from BW system using ABAP report. The report groups data using certain criteria and makes a Bapi call for each group.
    Problem : The program has 2 modes test mode and actual run.
    When the program was run in a test mode 15 groups were created. Hence 15 documents should get created in R/3.
    Now when the actual run was done the program gave an output saying doc1 created,doc2 created....doc11 created.. and suddenly Bapi error .. doc1 is locked by another user, doc1 is locked by another user, doc1 is locked by another user, doc1 is locked by another user.
    Moreover Doc1 never got created in R/3. Doc 2 to Doc11 were created in R/3 and then the BApi error.
    Can anyone please help me understand why this could have happened?
    P.S : We use same Bapi for Check run as well as Actual run. Only difference is that in actual run a BApi_commit is done.
    Do you think using BAP_ACC_DOCUMENT_CHECK during check run will help ?
    PLease advice.

    Setting the WAIT parameter = 'X' will make your updates synchronous which might solve your problem.
    Please try and let me know.

  • Getting error while posting doc using BAPI BAPI_ACC_DOCUMENT_POST

    Hi,
    I am passing the value for posting key in BAPI through TAX_CODE field in ACCOUNTGL (parameter name under tables).
    It is giving error "Tax code 01 in procedure TAXR0 is invalid".
    Can anyone help me to solve this .

    Try in these :
    BAPI_ACC_DOCUMENT_POST error
    Error in using BAPI_ACC_DOCUMENT_POST (urgent!!)
    BAPI_ACC_DOCUMENT_POST - Check error
    Regards
    Neha

  • Getting Error while posting through BAPI_ACC_DOCUMENT_POST

    Hi Folks,
       I could not post an GL account using the BAPI function module BAPI_ACC_DOCUMENT_POST . The code was,
    wa_docheader-bus_act    =  'RFBU'.
    wa_docheader-username   =  'CHARAN'.
    wa_docheader-comp_code  =  '0147'.
    wa_docheader-doc_date   =  '20101006'.
    wa_docheader-pstng_date =  '20101006'.
    wa_docheader-DOC_TYPE   =      'SA'.
    *wa_docheader-REF_DOC_NO =     'UNASSIGNED'.
    wa_glaccnt-itemno_acc  = '0010'.
    wa_glaccnt-gl_account  = '0000100632'.
    wa_glaccnt-item_text   = 'POSTING TO GL'.
    APPEND wa_glaccnt TO i_glaccnt.
    wa_glaccnt-itemno_acc  = '0020'.
    wa_glaccnt-gl_account  = '0000100634'.
    wa_glaccnt-item_text   = 'POSTING TO GL'.
    APPEND wa_glaccnt TO i_glaccnt.
    *wa_pyaccnt-itemno_acc  = '0000100634'.
    *wa_pyaccnt-gl_account  = '0001234567'.
    *APPEND wa_pyaccnt TO i_pyaccnt.
    wa_curamt-itemno_acc    =      '0010'.
    wa_curamt-currency      =        'USD'.
    wa_curamt-curr_type     = '00'.
    wa_curamt-amt_doccur    =  200 .
    APPEND wa_curamt TO i_curamt.
    wa_curamt-itemno_acc    =      '0020'.
    wa_curamt-currency      =        'USD'.
    wa_curamt-curr_type     = '00'.
    wa_curamt-amt_doccur    =     200.
    APPEND wa_curamt TO i_curamt.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader          =  wa_docheader
      CUSTOMERCPD             =
      CONTRACTHEADER          =
    IMPORTING
      OBJ_TYPE                =
      OBJ_KEY                 =
      OBJ_SYS                 =
      TABLES
        accountgl               = i_glaccnt
      ACCOUNTRECEIVABLE       =
        accountpayable          = i_pyaccnt
      ACCOUNTTAX              =
        currencyamount          = i_curamt
      CRITERIA                =
      VALUEFIELD              =
      EXTENSION1              =
        return                  = i_ret
      PAYMENTCARD             =
      CONTRACTITEM            =
        extension2              = i_ext2
      REALESTATE              =
      ACCOUNTWT               =
    The Output error i'm getting is :
    Error in document : BKPFF $ BH2CLNT200 400.00 USD
    Balance in transaction currency.
    Please help me in posting the Gl document successfully. Help will be rewarded.
    Thanks in advance.

    Total amount of internal table I_CURAMT-AMT_DOCCURR should be zero (Credit & Debit).
    Edit : See [Accounting Document Interface |http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=195726664] for reference.
    Edited by: Vinod Kumar on Oct 8, 2010 1:04 PM

Maybe you are looking for

  • Iphone 6 Order Confusion

    I'm not sure what's going on with Verizon's ordering system. I ordered two Iphone 6 Plus on 9/19. When I returned from the weekend, I decided to call and check status, and I was told that there was only one phone on my order. They had to cancel that

  • How can I set a password for firefox so that everyone have to enter the password before executing firefox

    My younger sister executed my firefox just at this afternoon(she originally use IE), and she saw something that can't be seen. How can I set a password for firefox so that everyone have to enter the password before executing firefox?

  • My solaris can't catch the internet

    I have finished my installation of solaris 10, but I can't browse any web site. The msg said that "The XXX.com can't found, pls try again and check the name". But I am sure that the name of web site and the web site is exited since I can open it with

  • Performance of PL/SQL-packages under Oracle 11gR2

    Under Oracle 9i I have used PL/SQL-packages/procedures to perform complicated initializations of the tables of a database schema. This was always a long job ... but an execution time of about 4 hours was acceptable! Now I changed to Oracle 11g. And n

  • Excel Macro Virus

    Someone sent me a PC excel file that had 4.0 macros. I'm running Office 2004 for the Mac. Now, whenever I open that sheet, even with macros off, any file open then has a macro. No virus is showing with virus scans. I've scanned the file in Windows as