<?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: concatenating to string from an itab in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735660#M1457792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi venkat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You almost made my day.It works. Thanks a lot...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 question though&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to write to a second_itab structure as follows from the first itab.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:BEGIN OF second_itab,
      matnr TYPE matnr,
      land  TYPE c,
      period1 type p, 
      period2 type p,
      period3 type p,
      period4 type p,
	....
	......
      period12 type p,
      period13 type p,
      Total  type p
     
     END OF t_itab&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the first_itab is sorted by matnr land month, the Deliveryqty could be written directly to the periods.&lt;/P&gt;&lt;P&gt;That is period1 will contain the qty of 11.09,period2 will contain the qty of 12.09 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when writing out the itabs some periods will be empty .That means in my current example only 4 periods are there(That means all the other period columns will be empty).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A sample  code would be useful....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Mar 2010 07:26:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-03-19T07:26:03Z</dc:date>
    <item>
      <title>concatenating to string from an itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735656#M1457788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Need some help to resolve this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have an itab structure as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:BEGIN OF first_itab,
      matnr TYPE matnr,
      land  TYPE c,
      month(5) TYPE c,
      Deliveryqty TYPE p DECIMALS 2,
     END OF t_itab.
TYPES: tt_itab TYPE TABLE OF t_itab WITH KEY matnr land month.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output of the itab is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The itab is sorted by matnr land month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;100                A   11.09             5,00
100                A   12.09             0,00
100                A   01.10             5,00
100                A   02.10             4,00
100                A   03.10             5,00
100                B   11.09             0,00
100                B   12.09             5,00
100                B   01.10             0,00
100                B   02.10             0,00
100                B   03.10             0,00
100                C   01.10             0,00
100                C   02.10             0,00
100                C   03.10             0,00
100                C   11.09             4,00
100                C   12.09             0,00&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an second_itab structure as follows.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;type : begin of second_itab
	
	land type string,
	 WholeString type string.
	
	end of second_itab&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now what I would like to have is loop through the first_itab content and fill the second_itab content as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"land" field should have A ,B and C.&lt;/P&gt;&lt;P&gt;"WholeString" field should have -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;100               A      5     0     5      4      5       
100               B      0     5     0      0      0 
100               C      0     5     0      4      0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is to say  if land type is "A" then "WholeString" is  "100  A      5     0     5      4      5" and so on for other lands as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the first_itab is sorted by matnr land month,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After getting the line "100 A  5" only delivery quantities of land need to be appended at the end.&lt;/P&gt;&lt;P&gt;Same is true for other lands as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A sample code would be very useful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Mar 2010 23:19:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735656#M1457788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-18T23:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating to string from an itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735657#M1457789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT &amp;lt;first internal table&amp;gt;&lt;/P&gt;&lt;P&gt;   clear &amp;lt;second table&amp;gt;.&lt;/P&gt;&lt;P&gt;   sec_t-land = first-land.  "second table&lt;/P&gt;&lt;P&gt;   CONCATENATE first-matnr first-land  into sec_t-WholeString SEPARATED BY space.&lt;/P&gt;&lt;P&gt;   LOOP AT  &amp;lt;first internal table&amp;gt;&lt;/P&gt;&lt;P&gt;                    WHERE land = sec_t-land.  &lt;/P&gt;&lt;P&gt;        v_idx = sy-tabix.&lt;/P&gt;&lt;P&gt;       CONCATENATE sec_t-WholeString first-month  into sec_t-WholeString SEPARATED BY space.&lt;/P&gt;&lt;P&gt;       delete first index v_idx.&lt;/P&gt;&lt;P&gt;   ENDLOOP.&lt;/P&gt;&lt;P&gt;   append sec_t.&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;this will work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thks&lt;/P&gt;&lt;P&gt;Abhi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Mar 2010 23:40:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735657#M1457789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-18T23:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating to string from an itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735658#M1457790</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;Please check this thead, it will resolve your Issue,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Co[Convert Rows of internal table to Columns|http://docs.google.com/Doc?id=dfv2hmgs_5d6bcxqgp&amp;amp;hl=en]&lt;/P&gt;&lt;P&gt;Cheerz&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 03:05:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735658#M1457790</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T03:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating to string from an itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735659#M1457791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;Hi, 
&amp;lt;li&amp;gt;You can follow as Ramakrishna's link insisted if you understand field-symbols concept. 
&amp;lt;li&amp;gt;Otherwise try the below way.
&lt;PRE&gt;&lt;CODE&gt;
REPORT ztest.
TYPES:BEGIN OF t_itab,
      matnr TYPE matnr,
      land  TYPE c,
      month(5) TYPE c,
      deliveryqty TYPE p DECIMALS 2,
     END OF t_itab.
DATA: first_itab TYPE TABLE OF t_itab WITH KEY matnr land month WITH HEADER LINE.
TYPES : BEGIN OF t_itab2,
          matnr       TYPE matnr,
          land        TYPE string,
          wholestring TYPE string,
        END OF t_itab2.
DATA: second_itab TYPE TABLE OF t_itab2 WITH HEADER LINE.

DATA: str TYPE string.

START-OF-SELECTION.
  DEFINE populate.
    first_itab-matnr       = &amp;amp;1.
    first_itab-land        = &amp;amp;2.
    first_itab-month       = &amp;amp;3.
    first_itab-deliveryqty = &amp;amp;4.
    append first_itab.
    clear  first_itab.
  END-OF-DEFINITION.
  populate:
           '100' 'A'   '11.09' '5.00',
           '100' 'A'   '12.09' '0.00',
           '100' 'A'   '01.10' '5.00',
           '100' 'A'   '02.10' '4.00',
           '100' 'A'   '03.10' '5.00',
           '100' 'B'   '11.09' '0.00',
           '100' 'B'   '12.09' '5.00',
           '100' 'B'   '01.10' '0.00',
           '100' 'B'   '02.10' '0.00',
           '100' 'B'   '03.10' '0.00',
           '100' 'C'   '01.10' '0.00',
           '100' 'C'   '02.10' '0.00',
           '100' 'C'   '03.10' '0.00',
           '100' 'C'   '11.09' '4.00',
           '100' 'C'   '12.09' '0.00'.
  LOOP AT first_itab.
    second_itab-matnr = first_itab-matnr.
    second_itab-land  = first_itab-land.
    str               = first_itab-deliveryqty.
    CONCATENATE str second_itab-wholestring INTO second_itab-wholestring.
    AT END OF land.
      APPEND second_itab.
      CLEAR  second_itab.
    ENDAT.
  ENDLOOP.

  LOOP AT second_itab.
    WRITE:/ second_itab-matnr, second_itab-land, second_itab-wholestring.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;
Thanks
Venkat.O&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 03:46:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735659#M1457791</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2010-03-19T03:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: concatenating to string from an itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735660#M1457792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi venkat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You almost made my day.It works. Thanks a lot...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 question though&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to write to a second_itab structure as follows from the first itab.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:BEGIN OF second_itab,
      matnr TYPE matnr,
      land  TYPE c,
      period1 type p, 
      period2 type p,
      period3 type p,
      period4 type p,
	....
	......
      period12 type p,
      period13 type p,
      Total  type p
     
     END OF t_itab&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the first_itab is sorted by matnr land month, the Deliveryqty could be written directly to the periods.&lt;/P&gt;&lt;P&gt;That is period1 will contain the qty of 11.09,period2 will contain the qty of 12.09 and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when writing out the itabs some periods will be empty .That means in my current example only 4 periods are there(That means all the other period columns will be empty).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A sample  code would be useful....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 07:26:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/concatenating-to-string-from-an-itab/m-p/6735660#M1457792</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-19T07:26:03Z</dc:date>
    </item>
  </channel>
</rss>

