<?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 loop table into SAPscript in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142168#M1620458</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to loop certain lines of an itab into a sapscript.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if the itab looks like below, then all materials with item 10 is outputted under 1 header, whilst all materials under item 20 is outputted under another header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item    matnr&lt;/P&gt;&lt;P&gt;10       abc&lt;/P&gt;&lt;P&gt;10       bcd&lt;/P&gt;&lt;P&gt;10       cde&lt;/P&gt;&lt;P&gt;20       zzz&lt;/P&gt;&lt;P&gt;20       xxx&lt;/P&gt;&lt;P&gt;20       yyy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my sapscript I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/E components&lt;/P&gt;&lt;P&gt;'Hi there',,&amp;amp;vbplp-vbeln&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;st_matnr&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output should look like the following:&lt;/P&gt;&lt;P&gt;Hi there 1001&lt;/P&gt;&lt;P&gt;abc&lt;/P&gt;&lt;P&gt;bcd&lt;/P&gt;&lt;P&gt;cde&lt;/P&gt;&lt;P&gt;Hi there 1002&lt;/P&gt;&lt;P&gt;zzz&lt;/P&gt;&lt;P&gt;xxx&lt;/P&gt;&lt;P&gt;yyy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a loop, write_form function but it is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop itab.&lt;/P&gt;&lt;P&gt;call function write_form.&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how this can be achieved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2011 00:42:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-14T00:42:36Z</dc:date>
    <item>
      <title>loop table into SAPscript</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142168#M1620458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to loop certain lines of an itab into a sapscript.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example if the itab looks like below, then all materials with item 10 is outputted under 1 header, whilst all materials under item 20 is outputted under another header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;item    matnr&lt;/P&gt;&lt;P&gt;10       abc&lt;/P&gt;&lt;P&gt;10       bcd&lt;/P&gt;&lt;P&gt;10       cde&lt;/P&gt;&lt;P&gt;20       zzz&lt;/P&gt;&lt;P&gt;20       xxx&lt;/P&gt;&lt;P&gt;20       yyy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my sapscript I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/E components&lt;/P&gt;&lt;P&gt;'Hi there',,&amp;amp;vbplp-vbeln&amp;amp;&lt;/P&gt;&lt;P&gt;&amp;amp;st_matnr&amp;amp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output should look like the following:&lt;/P&gt;&lt;P&gt;Hi there 1001&lt;/P&gt;&lt;P&gt;abc&lt;/P&gt;&lt;P&gt;bcd&lt;/P&gt;&lt;P&gt;cde&lt;/P&gt;&lt;P&gt;Hi there 1002&lt;/P&gt;&lt;P&gt;zzz&lt;/P&gt;&lt;P&gt;xxx&lt;/P&gt;&lt;P&gt;yyy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a loop, write_form function but it is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop itab.&lt;/P&gt;&lt;P&gt;call function write_form.&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know how this can be achieved?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 00:42:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142168#M1620458</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-14T00:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: loop table into SAPscript</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142169#M1620459</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;I think you need to create a nested loop. Put your item loop within a header loop and call the write_form function once in the header loop and once in the item loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM open_form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab_header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM write_form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab_item WHERE vbeln = itab_header-vbeln&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM write_form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM close_form.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 07:31:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142169#M1620459</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-16T07:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop table into SAPscript</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142170#M1620460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A nested loop solved it, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Sep 2011 13:55:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-table-into-sapscript/m-p/8142170#M1620460</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-16T13:55:18Z</dc:date>
    </item>
  </channel>
</rss>

