<?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 Need help with ABAP logic for Internal table split.... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151771#M992768</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an internal table with header and line items for a Customer invoice document. The header and line items are differntiated with a field called record type and it has values as H or L...now i have to check each of these documents using BAPI_ACC_DOCUMENT_CHECK...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So ihave to send lines for both H and L as one document...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Record type &lt;/P&gt;&lt;P&gt;H&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;H&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will from two documents: H L L L and H L L....&lt;/P&gt;&lt;P&gt;How should i loop through the internal table to split....i am not sure of the logic to do that.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KIndly help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Jul 2008 06:53:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-18T06:53:53Z</dc:date>
    <item>
      <title>Need help with ABAP logic for Internal table split....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151771#M992768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an internal table with header and line items for a Customer invoice document. The header and line items are differntiated with a field called record type and it has values as H or L...now i have to check each of these documents using BAPI_ACC_DOCUMENT_CHECK...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So ihave to send lines for both H and L as one document...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Record type &lt;/P&gt;&lt;P&gt;H&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;H&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will from two documents: H L L L and H L L....&lt;/P&gt;&lt;P&gt;How should i loop through the internal table to split....i am not sure of the logic to do that.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KIndly help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 06:53:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151771#M992768</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T06:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ABAP logic for Internal table split....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151772#M992769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi laxman kumar,&lt;/P&gt;&lt;P&gt;well, maybe I don't understand your problem, but you may perform as following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT internal_table.
  IF internal_table-record_type = 'H'.
    IF NOT itab_items[] IS INITIAL.
      " call BAPI for previous document
    ENDIF.

    CLEAR: itab_items.
    REFRESH: itab_items.
    MOVE internal_table TO structure_header. "&amp;lt;-- or whatever the structure is
  ELSEIF internal_table-record_type = 'L'.
    MOVE internal_table TO itab_items. "&amp;lt;-- may need to adjust fields
    APPEND itab_items.
  ENDIF.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...where &lt;EM&gt;structure_header&lt;/EM&gt; is the header for the BAPI, and &lt;EM&gt;itab_items&lt;/EM&gt; the line items. Please take into account that this is just a stub, and you may have to complete it with the proper structures and fields.&lt;/P&gt;&lt;P&gt;Nevertheless, I hope it helps. Kind regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 07:06:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151772#M992769</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T07:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ABAP logic for Internal table split....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151773#M992770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply alvaro...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, i need to separate the different documents in an internal table in groups of HLLL and HLL...i mean i have an internal table with all these documents in the order HLLLLHLLLHLLL...no i have to separate the document individually into HLLLL, HLLLL, HLLL.....&lt;/P&gt;&lt;P&gt;Afte that i have to send each one of them individually to check BAPI...i have logic for that....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am just trying to figure out how to separate these items into documents with HLLLL....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 07:10:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151773#M992770</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T07:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ABAP logic for Internal table split....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151774#M992771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;I dont think if I get it. Well, if you have an internal table with sequence HLLLLLHLLLLHLL, then the piece of code I wrote does so:&lt;/P&gt;&lt;P&gt;1.1. fills the header structure with H&lt;/P&gt;&lt;P&gt;1.2. fills the items table with LLLLL&lt;/P&gt;&lt;P&gt;1.3. calls the BAPI&lt;/P&gt;&lt;P&gt;1.4. clears the items table&lt;/P&gt;&lt;P&gt;2.1. fills the header table with the new H&lt;/P&gt;&lt;P&gt;2.2. fills the items table with LLLL&lt;/P&gt;&lt;P&gt;2.3. calls the BAPI&lt;/P&gt;&lt;P&gt;2.4. clears the items table&lt;/P&gt;&lt;P&gt;3.1. fills the header table with the new H&lt;/P&gt;&lt;P&gt;3.2. fills the items table with LL&lt;/P&gt;&lt;P&gt;3.3. calls the BAPI&lt;/P&gt;&lt;P&gt;3.4. clears the items table&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;On the other side, if you want to identify the LLL's that go together with an H, you should "link" these records together, by populating a field with the same value for the same document, and with different values for different documents.&lt;/P&gt;&lt;P&gt;For example, assume that you populate field BELNR. Then you may have your internal table like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
reg_type  belnr
--------------
H         1
L         1
L         1
L         1
L         1
H         2
L         2
L         2
L         2
H         3
L         3
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;...that means one document with header and 4 items, another one with header and 3 items, and a last one with a header and just one item. Then you may SORT STABLE the table with key &lt;EM&gt;belnr&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;Please answer back if this doesn't meet your requirement, preferrably with some examples of your source table and your desired target table.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2008 07:23:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151774#M992771</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-18T07:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ABAP logic for Internal table split....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151775#M992772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gurus, Thanks for the replies..But still i am not able to split the documents...What i really want to achieve is that I split documents with HLLL values and store all of it in one internal table and not in separate header and internal table....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if i have an internal table with data in from HLLL HLLL HLL HLLLLL...Then i want to divide it into separate docs of HLLL each....and then call BAPI with this internal table ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jul 2008 07:47:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-with-abap-logic-for-internal-table-split/m-p/4151775#M992772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-29T07:47:06Z</dc:date>
    </item>
  </channel>
</rss>

