<?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 Multiple line item posting through INTERFACE_POSTING_CLEARING in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-line-item-posting-through-interface-posting-clearing/m-p/12092441#M1972014</link>
    <description>&lt;P&gt;Hello, &lt;BR /&gt;i am trying to post INTERFACE_POSTING_CLEARING , but getting an error - more than two accounts were transferred&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1740103-capture.jpg" /&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;*** Global Declaration

  DATA: wa_error TYPE zsbtr_checkuploaderror.

  ""Variable declaration

  DATA: l_auglv   TYPE t041a-auglv VALUE 'EINGZAHL', "Posting with Clearing



        l_tcode   TYPE sy-tcode VALUE 'FB05',

        l_sgfunct TYPE rfipi-sgfunct VALUE 'C'.



  CONSTANTS : co_check     TYPE string VALUE 'Duplicate Check Found',

              co_ermsgtype TYPE string VALUE 'E'.



  " internal table and work area  declaration

  DATA: lt_blntab    TYPE STANDARD TABLE OF blntab WITH HEADER LINE,

        lt_ftclear   TYPE STANDARD TABLE OF ftclear WITH HEADER LINE,

        lt_fttax     TYPE STANDARD TABLE OF fttax WITH HEADER LINE,

        lt_ftpost    TYPE STANDARD TABLE OF ftpost,

        wa_ftpost    LIKE LINE OF lt_ftpost,

        ls_return    LIKE bapiret2,

        lv_bapitype  TYPE  bapireturn-type,

        lv_classid   TYPE sy-msgid,

        lv_msgnumber TYPE sy-msgno,

        lv_belnr     TYPE belnr_d,

        wa_post      LIKE LINE OF  zt_post.







  LOOP AT  zt_post INTO wa_post.



    lv_belnr = wa_post-belnr.



    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        input  = lv_belnr

      IMPORTING

        output = lv_belnr.





    SELECT belnr  FROM bsid INTO TABLE @DATA(it_bsid)

      WHERE belnr = @lv_belnr.







    IF  sy-subrc NE 0 .

      wa_error-zmsgid = ls_return-id.

      wa_error-zmsgtype = co_ermsgtype.

      wa_error-zmsg  = co_check.

      APPEND wa_error TO it_error.

      CLEAR wa_error.



    ELSE.



      "Header and line item

      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount. "number of Dynpro

      wa_ftpost-fnam = 'BKPF-BLDAT'. "Document Date

      wa_ftpost-fval = wa_post-bldat.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BUDAT'. "Posting Date

      wa_ftpost-fval = wa_post-budat.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BUKRS'. "Company Code

      wa_ftpost-fval = wa_post-bukrs.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BLART'. "Document Type

      wa_ftpost-fval = wa_post-blart.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BKPF-WAERS'. "Currency

      wa_ftpost-fval = wa_post-waers.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BKPF-monat'. "Currency

      wa_ftpost-fval = wa_post-monat.

      APPEND wa_ftpost TO lt_ftpost.





      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-AUGTX'. " document text

      wa_ftpost-fval = wa_post-augtx.

      APPEND wa_ftpost TO lt_ftpost.







      wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-NEWBS'.    "BSEG-BSCHL Posting Key

      wa_ftpost-fval = wa_post-newbs.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BSEG-WRBTR'.

      wa_ftpost-fval = wa_post-wrbtr.





      DATA : dummy_amt      TYPE p DECIMALS 2,

             gv_gross_total TYPE char20.

      dummy_amt = wa_ftpost-fval.

      WRITE dummy_amt TO gv_gross_total.

      wa_ftpost-fval = gv_gross_total.

      CONDENSE wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.





   wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-AUGTX'.

      wa_ftpost-fval = wa_post-augtx.

      APPEND wa_ftpost TO lt_ftpost.







       wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BSEG-HKONT'.  "Account Number

      wa_ftpost-fval = wa_post-hkont.

      APPEND wa_ftpost TO lt_ftpost.









      wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = 1.

      wa_ftpost-fnam ='RF05A-NEWKO'.

      wa_ftpost-fval = wa_post-newko.

      APPEND wa_ftpost TO lt_ftpost.







      wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = 1.

      wa_ftpost-fnam ='BSEG-SGTXT'.

      wa_ftpost-fval = wa_post-sgtxt.

      APPEND wa_ftpost TO lt_ftpost.





      wa_ftpost-stype = 'P'."Line item

      wa_ftpost-count = 1.

      wa_ftpost-fnam = 'BSEG-VALUT'. "Posting Date

      wa_ftpost-fval = wa_post-valut.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.





      lt_ftclear-agkon = wa_post-kunnr.

      lt_ftclear-agkoa = 'D'. "Account Type

      lt_ftclear-xnops = 'X'. "Indicator: Select only open items which are not special G/L?

      lt_ftclear-xfifo = 'X'.

      lt_ftclear-agbuk = wa_post-bukrs. "Company Code

      lt_ftclear-selfd = 'BELNR'."Selection Field

      lt_ftclear-selvon = wa_post-belnr.

      lt_ftclear-selbis = wa_post-belnr.   "added by me



      APPEND lt_ftclear.

    ENDIF.

  ENDLOOP.



  IF  it_error IS INITIAL.







    CALL FUNCTION 'POSTING_INTERFACE_START'

      EXPORTING

        i_function         = 'C'

        i_mode             = 'N'

        i_update           = 'S'    "ADDED BY ME

      EXCEPTIONS

        client_incorrect   = 1

        function_invalid   = 2

        group_name_missing = 3

        mode_invalid       = 4

        update_invalid     = 5

        user_invalid       = 6

        OTHERS             = 7.

    IF sy-subrc &amp;lt;&amp;gt; 0.

* Implement suitable error handling here

      WRITE: 'Error in start'.

    ENDIF.



    CALL FUNCTION 'POSTING_INTERFACE_CLEARING'

      EXPORTING

        i_auglv                    = l_auglv

        i_tcode                    = l_tcode

        i_sgfunct                  = l_sgfunct

      IMPORTING

        e_msgid                    = lv_msgid

        e_msgno                    = lv_errormsg

        e_msgty                    = lv_type

        e_msgv1                    = lv_errorrrr

        e_msgv2                    = lv_msfrw

*       E_MSGV3                    =

*       E_MSGV4                    =

*       E_SUBRC                    =

      TABLES

        t_blntab                   = lt_blntab

        t_ftclear                  = lt_ftclear

        t_ftpost                   = lt_ftpost

        t_fttax                    = lt_fttax

      EXCEPTIONS

        clearing_procedure_invalid = 1

        clearing_procedure_missing = 2

        table_t041a_empty          = 3

        transaction_code_invalid   = 4

        amount_format_error        = 5

        too_many_line_items        = 6

        company_code_invalid       = 7

        screen_not_found           = 8

        no_authorization           = 9

        OTHERS                     = 10.

    IF sy-subrc = 0.

* implement suitable error handling here



      lv_bapitype = lv_type.

      lv_classid = lv_msgid.

      lv_msgnumber = lv_errormsg.





      CALL FUNCTION 'BALW_BAPIRETURN_GET2'

        EXPORTING

          type   = lv_bapitype

          cl     = lv_classid

          number = lv_msgnumber

        IMPORTING

          return = ls_return.



      wa_error-zmsgid = ls_return-id.

      wa_error-zmsgtype = ls_return-type.

      wa_error-zmsg  = ls_return-message.

      APPEND wa_error TO it_error.





    ENDIF.



    IF NOT lt_blntab IS INITIAL .

      READ TABLE lt_blntab ASSIGNING FIELD-SYMBOL(&amp;lt;fs_blntab&amp;gt;) INDEX 1.

      IF sy-subrc EQ 0.

        lv_docno = &amp;lt;fs_blntab&amp;gt;-belnr.

      ENDIF.

    ENDIF.



    CALL FUNCTION 'POSTING_INTERFACE_END'

      EXPORTING

        i_bdcimmed              = 'X'

*       I_BDCSTRTDT             = NO_DATE

*       I_BDCSTRTTM             = NO_TIME

      EXCEPTIONS

        session_not_processable = 1

        OTHERS                  = 2.

    IF sy-subrc &amp;lt;&amp;gt; 0.

* Implement suitable error handling here

    ENDIF.

  ENDIF.

ENDFUNCTION.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 Oct 2019 13:19:41 GMT</pubDate>
    <dc:creator>KUNALGURSAHANI</dc:creator>
    <dc:date>2019-10-21T13:19:41Z</dc:date>
    <item>
      <title>Multiple line item posting through INTERFACE_POSTING_CLEARING</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-line-item-posting-through-interface-posting-clearing/m-p/12092441#M1972014</link>
      <description>&lt;P&gt;Hello, &lt;BR /&gt;i am trying to post INTERFACE_POSTING_CLEARING , but getting an error - more than two accounts were transferred&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1740103-capture.jpg" /&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;*** Global Declaration

  DATA: wa_error TYPE zsbtr_checkuploaderror.

  ""Variable declaration

  DATA: l_auglv   TYPE t041a-auglv VALUE 'EINGZAHL', "Posting with Clearing



        l_tcode   TYPE sy-tcode VALUE 'FB05',

        l_sgfunct TYPE rfipi-sgfunct VALUE 'C'.



  CONSTANTS : co_check     TYPE string VALUE 'Duplicate Check Found',

              co_ermsgtype TYPE string VALUE 'E'.



  " internal table and work area  declaration

  DATA: lt_blntab    TYPE STANDARD TABLE OF blntab WITH HEADER LINE,

        lt_ftclear   TYPE STANDARD TABLE OF ftclear WITH HEADER LINE,

        lt_fttax     TYPE STANDARD TABLE OF fttax WITH HEADER LINE,

        lt_ftpost    TYPE STANDARD TABLE OF ftpost,

        wa_ftpost    LIKE LINE OF lt_ftpost,

        ls_return    LIKE bapiret2,

        lv_bapitype  TYPE  bapireturn-type,

        lv_classid   TYPE sy-msgid,

        lv_msgnumber TYPE sy-msgno,

        lv_belnr     TYPE belnr_d,

        wa_post      LIKE LINE OF  zt_post.







  LOOP AT  zt_post INTO wa_post.



    lv_belnr = wa_post-belnr.



    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        input  = lv_belnr

      IMPORTING

        output = lv_belnr.





    SELECT belnr  FROM bsid INTO TABLE @DATA(it_bsid)

      WHERE belnr = @lv_belnr.







    IF  sy-subrc NE 0 .

      wa_error-zmsgid = ls_return-id.

      wa_error-zmsgtype = co_ermsgtype.

      wa_error-zmsg  = co_check.

      APPEND wa_error TO it_error.

      CLEAR wa_error.



    ELSE.



      "Header and line item

      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount. "number of Dynpro

      wa_ftpost-fnam = 'BKPF-BLDAT'. "Document Date

      wa_ftpost-fval = wa_post-bldat.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BUDAT'. "Posting Date

      wa_ftpost-fval = wa_post-budat.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BUKRS'. "Company Code

      wa_ftpost-fval = wa_post-bukrs.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam = 'BKPF-BLART'. "Document Type

      wa_ftpost-fval = wa_post-blart.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BKPF-WAERS'. "Currency

      wa_ftpost-fval = wa_post-waers.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BKPF-monat'. "Currency

      wa_ftpost-fval = wa_post-monat.

      APPEND wa_ftpost TO lt_ftpost.





      wa_ftpost-stype = 'K'."Header

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-AUGTX'. " document text

      wa_ftpost-fval = wa_post-augtx.

      APPEND wa_ftpost TO lt_ftpost.







      wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-NEWBS'.    "BSEG-BSCHL Posting Key

      wa_ftpost-fval = wa_post-newbs.

      APPEND wa_ftpost TO lt_ftpost.



      wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BSEG-WRBTR'.

      wa_ftpost-fval = wa_post-wrbtr.





      DATA : dummy_amt      TYPE p DECIMALS 2,

             gv_gross_total TYPE char20.

      dummy_amt = wa_ftpost-fval.

      WRITE dummy_amt TO gv_gross_total.

      wa_ftpost-fval = gv_gross_total.

      CONDENSE wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.





   wa_ftpost-stype = 'K'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='RF05A-AUGTX'.

      wa_ftpost-fval = wa_post-augtx.

      APPEND wa_ftpost TO lt_ftpost.







       wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = wa_post-zcount.

      wa_ftpost-fnam ='BSEG-HKONT'.  "Account Number

      wa_ftpost-fval = wa_post-hkont.

      APPEND wa_ftpost TO lt_ftpost.









      wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = 1.

      wa_ftpost-fnam ='RF05A-NEWKO'.

      wa_ftpost-fval = wa_post-newko.

      APPEND wa_ftpost TO lt_ftpost.







      wa_ftpost-stype = 'P'."Line Item

      wa_ftpost-count = 1.

      wa_ftpost-fnam ='BSEG-SGTXT'.

      wa_ftpost-fval = wa_post-sgtxt.

      APPEND wa_ftpost TO lt_ftpost.





      wa_ftpost-stype = 'P'."Line item

      wa_ftpost-count = 1.

      wa_ftpost-fnam = 'BSEG-VALUT'. "Posting Date

      wa_ftpost-fval = wa_post-valut.

      CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

        EXPORTING

          input  = wa_ftpost-fval

        IMPORTING

          output = wa_ftpost-fval.

      APPEND wa_ftpost TO lt_ftpost.





      lt_ftclear-agkon = wa_post-kunnr.

      lt_ftclear-agkoa = 'D'. "Account Type

      lt_ftclear-xnops = 'X'. "Indicator: Select only open items which are not special G/L?

      lt_ftclear-xfifo = 'X'.

      lt_ftclear-agbuk = wa_post-bukrs. "Company Code

      lt_ftclear-selfd = 'BELNR'."Selection Field

      lt_ftclear-selvon = wa_post-belnr.

      lt_ftclear-selbis = wa_post-belnr.   "added by me



      APPEND lt_ftclear.

    ENDIF.

  ENDLOOP.



  IF  it_error IS INITIAL.







    CALL FUNCTION 'POSTING_INTERFACE_START'

      EXPORTING

        i_function         = 'C'

        i_mode             = 'N'

        i_update           = 'S'    "ADDED BY ME

      EXCEPTIONS

        client_incorrect   = 1

        function_invalid   = 2

        group_name_missing = 3

        mode_invalid       = 4

        update_invalid     = 5

        user_invalid       = 6

        OTHERS             = 7.

    IF sy-subrc &amp;lt;&amp;gt; 0.

* Implement suitable error handling here

      WRITE: 'Error in start'.

    ENDIF.



    CALL FUNCTION 'POSTING_INTERFACE_CLEARING'

      EXPORTING

        i_auglv                    = l_auglv

        i_tcode                    = l_tcode

        i_sgfunct                  = l_sgfunct

      IMPORTING

        e_msgid                    = lv_msgid

        e_msgno                    = lv_errormsg

        e_msgty                    = lv_type

        e_msgv1                    = lv_errorrrr

        e_msgv2                    = lv_msfrw

*       E_MSGV3                    =

*       E_MSGV4                    =

*       E_SUBRC                    =

      TABLES

        t_blntab                   = lt_blntab

        t_ftclear                  = lt_ftclear

        t_ftpost                   = lt_ftpost

        t_fttax                    = lt_fttax

      EXCEPTIONS

        clearing_procedure_invalid = 1

        clearing_procedure_missing = 2

        table_t041a_empty          = 3

        transaction_code_invalid   = 4

        amount_format_error        = 5

        too_many_line_items        = 6

        company_code_invalid       = 7

        screen_not_found           = 8

        no_authorization           = 9

        OTHERS                     = 10.

    IF sy-subrc = 0.

* implement suitable error handling here



      lv_bapitype = lv_type.

      lv_classid = lv_msgid.

      lv_msgnumber = lv_errormsg.





      CALL FUNCTION 'BALW_BAPIRETURN_GET2'

        EXPORTING

          type   = lv_bapitype

          cl     = lv_classid

          number = lv_msgnumber

        IMPORTING

          return = ls_return.



      wa_error-zmsgid = ls_return-id.

      wa_error-zmsgtype = ls_return-type.

      wa_error-zmsg  = ls_return-message.

      APPEND wa_error TO it_error.





    ENDIF.



    IF NOT lt_blntab IS INITIAL .

      READ TABLE lt_blntab ASSIGNING FIELD-SYMBOL(&amp;lt;fs_blntab&amp;gt;) INDEX 1.

      IF sy-subrc EQ 0.

        lv_docno = &amp;lt;fs_blntab&amp;gt;-belnr.

      ENDIF.

    ENDIF.



    CALL FUNCTION 'POSTING_INTERFACE_END'

      EXPORTING

        i_bdcimmed              = 'X'

*       I_BDCSTRTDT             = NO_DATE

*       I_BDCSTRTTM             = NO_TIME

      EXCEPTIONS

        session_not_processable = 1

        OTHERS                  = 2.

    IF sy-subrc &amp;lt;&amp;gt; 0.

* Implement suitable error handling here

    ENDIF.

  ENDIF.

ENDFUNCTION.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 13:19:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/multiple-line-item-posting-through-interface-posting-clearing/m-p/12092441#M1972014</guid>
      <dc:creator>KUNALGURSAHANI</dc:creator>
      <dc:date>2019-10-21T13:19:41Z</dc:date>
    </item>
  </channel>
</rss>

