<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: BAPI for Txn FB60 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161035#M120473</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   It would be gr8 if you could provide the excel file format that is required for upload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Awiating replies..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Apr 2009 09:50:12 GMT</pubDate>
    <dc:creator>premal_mistry2</dc:creator>
    <dc:date>2009-04-02T09:50:12Z</dc:date>
    <item>
      <title>BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161030#M120468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;   I want to upload data to transaction FB60. I have found a BAPI 'BAPI_ACC_DOCUMENT_POST' for the same but I am not sure about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Can anybody help me or if anybody has used the BAPI for uploading data to Txn FB60.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Thanks in Advance,&lt;/P&gt;&lt;P&gt;   Punit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2006 05:41:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161030#M120468</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-09T05:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161031#M120469</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;BAPI_ACC_DOCUMENT_POST or BAPI_ACC_GL_POSTING_POST?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2006 05:49:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161031#M120469</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-09T05:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161032#M120470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kishan,&lt;/P&gt;&lt;P&gt;   Its 'BAPI_ACC_DOCUMENT_POST'. Is it possible with 'BAPI_ACC_GL_POSTING_POST'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   Thanks,&lt;/P&gt;&lt;P&gt;   Punit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2006 05:58:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161032#M120470</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-09T05:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161033#M120471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use the BAPI_ACC_INVOICE_RECEIPT_POST which is specifically for invoice posting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2006 06:03:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161033#M120471</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-09T06:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161034#M120472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;check this code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  Z_FI_GL_POSTING.


include &amp;lt;icon&amp;gt;.

*/ =================================================================== *
CONSTANTS: on  VALUE 'X',
           off VALUE ' ',
           tabx TYPE X VALUE '09',

           c_e1bpache08 TYPE edilsegtyp VALUE 'E1BPACHE08',
           c_e1bpacgl08 TYPE edilsegtyp VALUE 'E1BPACGL08',
           c_e1bpaccr08 TYPE edilsegtyp VALUE 'E1BPACCR08'.

TYPES: BEGIN OF t_tab_index,
          from TYPE i,
          to   TYPE i,
       END   OF t_tab_index.

data :    tab type c.

DATA:
      e1bpache08 LIKE e1bpache08,
      e1bpacgl08 LIKE e1bpacgl08,
      e1bpaccr08 LIKE e1bpaccr08.


DATA:      g_subrc    TYPE subrc.
DATA:      g_file     TYPE string.
DATA:      g_segname  TYPE edilsegtyp.
DATA:      g_sdata    TYPE edi_sdata.
DATA:      g_first_doc.
DATA:      i_dataf     TYPE char2000   OCCURS 900 WITH HEADER LINE,
           i_dataf_doc TYPE char2000   OCCURS  50 WITH HEADER LINE.

DATA:      g_tab_index TYPE t_tab_index OCCURS 100 WITH HEADER LINE.

DATA:      i_accountgl TYPE bapiacgl08 OCCURS 100 WITH HEADER LINE,
           i_curramnt  TYPE bapiaccr08 OCCURS 100 WITH HEADER LINE,
           i_return    TYPE bapiret2   OCCURS  10 WITH HEADER LINE,
           g_docheader TYPE bapiache08.

*/ ======================== SELECTION ================================ *

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETERS: excelf TYPE file_name LOWER CASE
            DEFAULT 'C:my_excel_file.txt'.
SELECTION-SCREEN END   OF BLOCK b1.

*/ =========================== CORE ================================== *
START-OF-SELECTION.

*/ Call text File with GUI_UPLOAD
  g_file = excelf.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                      = g_file
*     FILETYPE                      = 'ASC'
*     HAS_FIELD_SEPARATOR           = ' '
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      data_tab                      = i_dataf
    EXCEPTIONS
      file_open_error               = 1
      file_read_error               = 2
      no_batch                      = 3
      gui_refuse_filetransfer       = 4
      invalid_type                  = 5
      no_authority                  = 6
      unknown_error                 = 7
      bad_data_format               = 8
      header_not_allowed            = 9
      separator_not_allowed         = 10
      header_too_long               = 11
      unknown_dp_error              = 12
      access_denied                 = 13
      dp_out_of_memory              = 14
      disk_full                     = 15
      dp_timeout                    = 16
      OTHERS                        = 17
            .
  IF sy-subrc &amp;lt;&amp;gt; 0.
    write: / Text-032.
    stop.
  ENDIF.

*/ Initialisation
  write tabx to tab.          " required as of ABAP 610 split cannot
*/                             have mixed char and byte types
  CLEAR   g_tab_index.
  REFRESH g_tab_index.

*/ how to process several doc : detecting docs in i_dataf
  g_first_doc = on.
  LOOP AT i_dataf.
    CLEAR: g_segname, g_sdata.
    SPLIT i_dataf AT tab INTO g_segname g_sdata.
    CHECK:  g_segname = c_e1bpache08,
            sy-tabix &amp;gt; 1.
*/ 1st document
    IF g_first_doc = on.
      g_tab_index-from = 1.
      g_tab_index-to   = sy-tabix - 1.
      APPEND g_tab_index.
*/ Next Documents
    ELSE.
      g_tab_index-from = g_tab_index-to + 1.
      g_tab_index-to   = sy-tabix - 1.
      APPEND g_tab_index.
    ENDIF.
    g_first_doc = off.
  ENDLOOP.
*/ Last doc.
  g_tab_index-from = g_tab_index-to + 1.
  g_tab_index-to   = sy-tfill.
  APPEND g_tab_index.

*/ Process documents.
  loop at g_tab_index.
     clear   i_dataf_doc.
     refresh i_dataf_doc.
     append lines of i_dataf from g_tab_index-from
                             to   g_tab_index-to
                             to   i_dataf_doc.
     perform process_document.
  endloop.

END-OF-SELECTION.

*/ =========================== ROUTINES ============================== *

*---------------------------------------------------------------------*
*       FORM process_document                                         *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM process_document.
*/ Clearing Memory
  CLEAR:   g_docheader, i_accountgl, i_curramnt, i_return, g_subrc.
  REFRESH:              i_accountgl, i_curramnt, i_return.

*/ Checking i_dataf_doc
*/ Mapping dataf =&amp;gt; Bapi structures &amp;amp; internal tables

  CLEAR g_subrc.
  CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.
    LOOP AT i_dataf_doc.
      CLEAR g_sdata.
      SPLIT i_dataf_doc AT tab INTO g_segname g_sdata.

      CASE g_segname.
*/ HEADER
        WHEN c_e1bpache08.
          PERFORM do_split_ache08.
          MOVE-CORRESPONDING e1bpache08 TO g_docheader.

          IF e1bpache08-doc_date IS INITIAL.
            CLEAR g_docheader-doc_date.
          ENDIF.
          IF e1bpache08-pstng_date IS INITIAL.
            CLEAR g_docheader-pstng_date.
          ENDIF.
          IF e1bpache08-trans_date IS INITIAL.
            CLEAR g_docheader-trans_date.
          ENDIF.

*/ Account GL
        WHEN c_e1bpacgl08.
          PERFORM do_split_acgl08.
          MOVE-CORRESPONDING e1bpacgl08 TO i_accountgl.
          IF e1bpacgl08-pstng_date IS INITIAL.
            CLEAR i_accountgl-pstng_date.
          ENDIF.
          APPEND i_accountgl.

*/ Account Currency &amp;amp; Amounts
        WHEN c_e1bpaccr08.
          PERFORM do_split_accr08.
          MOVE-CORRESPONDING e1bpaccr08 TO i_curramnt.
          APPEND i_curramnt.

*/ kick the line if segment name not filled
        WHEN space.

*/ Other names =&amp;gt; Bad file structure !
        WHEN OTHERS.
          g_subrc = 2.
      ENDCASE.

    ENDLOOP. " i_dataf_doc
  ENDCATCH.


  IF sy-subrc = 1 OR
  NOT g_subrc IS INITIAL.
    perform message_output using on.
    exit.
  ENDIF.


*/ Calling the BAPI
  CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
    EXPORTING
      documentheader       = g_docheader
    TABLES
      accountgl            = i_accountgl
      currencyamount       = i_curramnt
      return               = i_return
*   EXTENSION1           =
            .
  LOOP AT i_return WHERE type CA 'AE'.
    g_subrc = 1.
    EXIT.
  ENDLOOP.

  IF NOT g_subrc IS INITIAL.
    perform message_output using on.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
*        EXPORTING
*           WAIT          =
*        IMPORTING
*           RETURN        =
              .
      perform message_output using off.
  ENDIF.

ENDFORM.



*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  do_split_ACHE08
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM do_split_ache08.

  CLEAR e1bpache08.

  SPLIT g_sdata AT tab INTO

  e1bpache08-obj_type
  e1bpache08-obj_key
  e1bpache08-obj_sys
  e1bpache08-username
  e1bpache08-header_txt
  e1bpache08-obj_key_r
  e1bpache08-comp_code
  e1bpache08-ac_doc_no
  e1bpache08-fisc_year
  e1bpache08-doc_date
  e1bpache08-pstng_date
  e1bpache08-trans_date
  e1bpache08-fis_period
  e1bpache08-doc_type
  e1bpache08-ref_doc_no
  e1bpache08-compo_acc
  e1bpache08-reason_rev
        .
ENDFORM.                    " do_split_ACHE08
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  do_split_ACGL08
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM do_split_acgl08.
  CLEAR e1bpacgl08.
  SPLIT  g_sdata AT tab INTO
                  e1bpacgl08-itemno_acc
                  e1bpacgl08-gl_account
                  e1bpacgl08-comp_code
                  e1bpacgl08-pstng_date
                  e1bpacgl08-doc_type
                  e1bpacgl08-ac_doc_no
                  e1bpacgl08-fisc_year
                  e1bpacgl08-fis_period
                  e1bpacgl08-stat_con
                  e1bpacgl08-ref_key_1
                  e1bpacgl08-ref_key_2
                  e1bpacgl08-ref_key_3
                  e1bpacgl08-customer
                  e1bpacgl08-vendor_no
                  e1bpacgl08-alloc_nmbr
                  e1bpacgl08-item_text
                  e1bpacgl08-bus_area
                  e1bpacgl08-costcenter
                  e1bpacgl08-acttype
                  e1bpacgl08-orderid
                  e1bpacgl08-orig_group
                  e1bpacgl08-cost_obj
                  e1bpacgl08-profit_ctr
                  e1bpacgl08-part_prctr
                  e1bpacgl08-wbs_element
                  e1bpacgl08-network
                  e1bpacgl08-routing_no
                  e1bpacgl08-order_itno
                  .
ENDFORM.                    " do_split_ACGL08

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  do_split_ACCR08
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM do_split_accr08.
  data: l_filler(100).
  CLEAR  e1bpaccr08.
  SPLIT  g_sdata AT tab INTO
            e1bpaccr08-itemno_acc
            e1bpaccr08-curr_type
            e1bpaccr08-currency
            e1bpaccr08-currency_iso
            e1bpaccr08-amt_doccur
            e1bpaccr08-exch_rate
            e1bpaccr08-exch_rate_v
            l_filler
            .
ENDFORM.                    " do_split_ACCR08
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  message_output
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM message_output using if_error.

  data: l_message(200),
        l_return type i.

   format color 1.
   skip.
   write: / text-020, g_tab_index-from,
            text-021, g_tab_index-to.
   skip.

   if if_error = on.
    write: / icon_red_light as icon, text-030 color 6.
   else.
    write: / icon_green_light as icon, text-031 color 5.
   endif.
   describe table i_return lines l_return.
   if l_return is initial.
     write: / text-032.
   endif.
   loop at i_return.
      CALL FUNCTION 'FORMAT_MESSAGE'
        EXPORTING
          ID              = i_return-id
          LANG            = sy-langu
          NO              = i_return-number
          V1              = i_return-MESSAGE_V1
          V2              = i_return-MESSAGE_V2
          V3              = i_return-MESSAGE_V3
          V4              = i_return-MESSAGE_V4
        IMPORTING
          MSG             = l_message
        EXCEPTIONS
          NOT_FOUND       = 1
          OTHERS          = 2
                .
      check sy-subrc = 0.
      write: / l_message.
   endloop.
ENDFORM.                    " message_output&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2006 06:06:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161034#M120472</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-09T06:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161035#M120473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   It would be gr8 if you could provide the excel file format that is required for upload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Awiating replies..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2009 09:50:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161035#M120473</guid>
      <dc:creator>premal_mistry2</dc:creator>
      <dc:date>2009-04-02T09:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI for Txn FB60</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161036#M120474</link>
      <description>&lt;P&gt;This BAPI worked well: &lt;STRONG&gt;BAPI_ACC_INVOICE_RECEIPT_POST&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can check sample program in SAP: &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ACC_BAPI_TEST_INVOICE_RECEIPT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Here's my sample code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*

*&amp;amp;      Form  F_CREATE_DOC

*&amp;amp;---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      &amp;lt;--P_LS_DATA  text

*      &amp;lt;--P_LV_ERROR  text

*----------------------------------------------------------------------*

FORM f_create_doc  CHANGING p_ls_data LIKE LINE OF gt_data

                            p_lv_error TYPE c.



  DATA: ls_documentheader TYPE bapiache03,

        ls_customercpd    TYPE bapiacpa00,

        lt_accountpayable TYPE TABLE OF bapiacap03,

        ls_accountpayable LIKE LINE OF lt_accountpayable,

        lt_accountgl      TYPE TABLE OF bapiacgl03,

        ls_accountgl      LIKE LINE OF lt_accountgl,

        lt_accounttax     TYPE TABLE OF bapiactx01,

        ls_accounttax     LIKE LINE OF lt_accounttax,

        lt_currencyamount TYPE TABLE OF bapiaccr01,

        ls_currencyamount LIKE LINE OF lt_currencyamount,

        lt_return         TYPE TABLE OF bapiret2,

        ls_return         LIKE LINE OF lt_return,

        ls_message        TYPE string.



  DATA: lv_hdr_txt(25)   TYPE c,

        lv_dt(8)         TYPE c,

        lv_ref_doc(16)   TYPE c,

        lv_rec_count(10) TYPE c,

        ev_error         TYPE c.







  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

      input  = p_ls_data-vendor

    IMPORTING

      output = p_ls_data-vendor.



  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

      input  = p_ls_data-gl_acct

    IMPORTING

      output = p_ls_data-gl_acct.









  CLEAR: ls_documentheader, ls_customercpd, ls_accountpayable, lv_hdr_txt.

  REFRESH: lt_accountpayable, lt_accountgl, lt_accounttax, lt_currencyamount, lt_return.







  CONCATENATE 'CNCLD ACCT' p_ls_data-acct_num INTO lv_hdr_txt SEPARATED BY space.

  CONCATENATE 'CANCEL' space sy-datum+6(2) sy-datum+4(2) sy-datum(4) INTO lv_ref_doc.



  ls_documentheader-username = sy-uname.

  ls_documentheader-header_txt = lv_hdr_txt.

  ls_documentheader-comp_code = p_bukrs.

  ls_documentheader-fisc_year = sy-datum(4).

  ls_documentheader-doc_date = sy-datum.

  ls_documentheader-pstng_date = sy-datum.

  ls_documentheader-fis_period = sy-datum+4(2).

  ls_documentheader-doc_type = c_blart.

  ls_documentheader-ref_doc_no = lv_ref_doc.



  ls_customercpd-name = p_ls_data-name.

  ls_customercpd-name_2 = p_ls_data-address2.

  ls_customercpd-postl_code = p_ls_data-postalcode.

  ls_customercpd-city = p_ls_data-city.

  ls_customercpd-country = p_ls_data-country.

  ls_customercpd-street = p_ls_data-address1.

  ls_customercpd-region = p_ls_data-province.

  ls_customercpd-langu_iso = 'EN'.



  ls_accountpayable-itemno_acc = 1.

  ls_accountpayable-vendor_no = p_ls_data-vendor.

*ls_ACCOUNTPAYABLE-GL_ACCOUNT = '0000211000'.

  ls_accountpayable-pmnttrms = c_pmt_trms.

  ls_accountpayable-bline_date = sy-datum.

  ls_accountpayable-alloc_nmbr = p_ls_data-name.

  ls_accountpayable-item_text = lv_hdr_txt.

  APPEND ls_accountpayable TO lt_accountpayable.



*Currency line item 1

  ls_currencyamount-itemno_acc = 1.

  ls_currencyamount-currency = c_waers.

  ls_currencyamount-amt_doccur = p_ls_data-amount * -1.

  APPEND ls_currencyamount TO lt_currencyamount.



*GL line item 2

  ls_accountgl-itemno_acc = 2.

  ls_accountgl-gl_account = p_ls_data-gl_acct.

  ls_accountgl-comp_code = p_bukrs.

  ls_accountgl-pstng_date = sy-datum.

  ls_accountgl-doc_type = c_blart.

  ls_accountgl-fisc_year = sy-datum(4).

  ls_accountgl-fis_period = sy-datum+4(2).

  ls_accountgl-profit_ctr = p_ls_data-profit_center.

  ls_accountgl-alloc_nmbr = sy-datum.

  ls_accountgl-de_cre_ind = 'S'.

  APPEND ls_accountgl TO lt_accountgl.



*Currency line item 2

  ls_currencyamount-itemno_acc = 2.

  ls_currencyamount-currency = c_waers.

  ls_currencyamount-amt_doccur = p_ls_data-amount.

  APPEND ls_currencyamount TO lt_currencyamount.

















  CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'

    EXPORTING

      documentheader = ls_documentheader

      customercpd    = ls_customercpd

* IMPORTING

*     OBJ_TYPE       =

*     OBJ_KEY        =

*     OBJ_SYS        =

    TABLES

      accountpayable = lt_accountpayable

      accountgl      = lt_accountgl

      accounttax     = lt_accounttax

      currencyamount = lt_currencyamount

*     PURCHASEORDER  =

*     PURCHASEAMOUNT =

      return         = lt_return

*     CRITERIA       =

*     VALUEFIELD     =

*     EXTENSION1     =

    .



  lv_rec_count = gv_tot_rec.

  READ TABLE lt_return INTO ls_return

        WITH KEY type = 'S' id = 'RW' number = '605'.



  IF sy-subrc = 0.

    COMMIT WORK AND WAIT.

    CONCATENATE 'Line Index' lv_rec_count ':' INTO ls_message SEPARATED BY space.

    APPEND ls_message TO gt_success_msg.

    APPEND ls_message TO gt_complete_log.



    CONCATENATE 'Document sucessfully created:' ls_return-message_v2(10)

           INTO ls_message.

    APPEND ls_message TO gt_success_msg.

    APPEND ls_message TO gt_complete_log.



*   add blank line

    CLEAR ls_message.

    APPEND ls_message TO gt_success_msg.

    APPEND ls_message TO gt_complete_log.

  ELSE.

    ROLLBACK WORK.

    ev_error = c_x.

    CONCATENATE 'Line Index' lv_rec_count ':' INTO ls_message SEPARATED BY space.

    APPEND ls_message TO gt_error_msg.

    APPEND ls_message TO gt_complete_log.



*   read error message

    DELETE ADJACENT DUPLICATES FROM lt_return COMPARING message.

    LOOP AT lt_return INTO ls_return.

      CLEAR ls_message.

      ls_message = ls_return-message.

      CONDENSE ls_message.

      CONCATENATE ls_message '.' INTO ls_message.

      APPEND ls_message TO gt_error_msg.

      APPEND ls_message TO gt_complete_log.

    ENDLOOP.



    p_lv_error = ev_error.



*   add blank line

    CLEAR ls_message.

    APPEND ls_message TO gt_error_msg.

    APPEND ls_message TO gt_complete_log.

  ENDIF.

ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Mar 2020 23:33:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-for-txn-fb60/m-p/1161036#M120474</guid>
      <dc:creator>zeeshan_xt</dc:creator>
      <dc:date>2020-03-19T23:33:46Z</dc:date>
    </item>
  </channel>
</rss>

