<?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: Modify internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219190#M1628048</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;As per my last thread, herewith a small example:&lt;/P&gt;&lt;P&gt;First create a macro that will take care of the maintenace of your final table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DEFINE _update_row.
* &amp;amp;1: Column index | &amp;amp;2: Row index | &amp;amp;3: value
  if &amp;amp;2 &amp;gt; g_cnt.
    insert &amp;lt;gs_final&amp;gt; into table &amp;lt;gt_final&amp;gt; assigning &amp;lt;row&amp;gt;.  "Add new row
  else.
    loop at &amp;lt;gt_final&amp;gt; assigning &amp;lt;row&amp;gt;.                       "Update existing row
      check sy-tabix = &amp;amp;2.
      exit.
    endloop.
  endif.
  assign component &amp;amp;1 of structure &amp;lt;row&amp;gt; to &amp;lt;fs&amp;gt;.
  if sy-subrc = 0.
    &amp;lt;fs&amp;gt; = &amp;amp;3.
  endif.
END-OF-DEFINITION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, loop on your main table (that contains all combinations), and maintain your final table at each break:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

  DATA: l_ord TYPE syindex,                     "Order column index
        l_mat TYPE syindex,                     "Material row index
        l_qty TYPE syindex,                     "Quantity row index
        l_com TYPE syindex,                     "Component row index
        l_num_com TYPE i.                       "Components counter

  FIELD-SYMBOLS: &amp;lt;main&amp;gt; TYPE ty_main.

  SORT gt_main BY ord mat qty com.

  LOOP AT gt_main ASSIGNING &amp;lt;main&amp;gt;.
    AT NEW ord.
      DESCRIBE TABLE &amp;lt;gt_final&amp;gt; LINES g_cnt.    "Get number of rows
      l_ord = l_ord + 1.                        "Set Order column index
      l_mat = l_qty = l_com = 1.                "Reset row indexes
      _update_row l_ord 1 &amp;lt;main&amp;gt;-ord.           "Update order row
    ENDAT.

    AT NEW mat.
      l_mat = l_com + 1.                        "New material following components or order
      l_num_com = 0.                            "Reset component counter
      _update_row l_ord l_mat &amp;lt;main&amp;gt;-mat.       "Update material row
    ENDAT.

    AT NEW qty.
      l_qty = l_mat + 1.                        "New quantity following material
      _update_row l_ord l_qty &amp;lt;main&amp;gt;-qty.       "Update quantity row
    ENDAT.

    AT NEW com.
      l_com = l_qty + l_num_com + 1.            "New component following Qty or component
      l_num_com = l_num_com + 1.                "Increase material component counter
      _update_row l_ord l_com &amp;lt;main&amp;gt;-com.       "Update component row
    ENDAT.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your main table is like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
O1 M1 Q1 C1
O1 M1 Q1 C2
O1 M1 Q1 C3
O2 M2 Q2 C1
O2 M2 Q2 C2
O3 M3 Q3 C1
O4 M4 Q4 C1
O4 M4 Q4 C2
O4 M4 Q4 C3
O4 M4 Q4 C4
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Your final table will be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
O1 O2 O3 O4
M1 M2 M3 M4
Q1 Q2 Q3 Q4
C1 C1 C1 C1
C2 C2    C2
C3       C3
         C4
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there should be plenty of ways of doing that...not sure this solution is the best one &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Oct 2011 18:00:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-10-09T18:00:13Z</dc:date>
    <item>
      <title>Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219181#M1628039</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 am facing problem while modifying of my internal table from work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;source code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; modify table &amp;lt;fs&amp;gt; from &amp;lt;fs1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both the field symbols are having same structure. It was not giving any syntax error. But not modifying the internal table &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;Please help on this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;STRONG&gt;Note: My internal table was Dynamically created&lt;/STRONG&gt;*&lt;/P&gt;&lt;P&gt;Thanks In Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Oct 2011 12:38:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219181#M1628039</guid>
      <dc:creator>former_member298409</dc:creator>
      <dc:date>2011-10-08T12:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219182#M1628040</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;Why dont you use the TRANSPORTING suffix addition for the MODIFY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   LOOP AT  i_cust into wa_cust.&lt;/P&gt;&lt;P&gt;     IFwa_cust-name = 'John' and (wa_cust-discount = '40' and wa_cust-type = 'HIGH LEVEL').&lt;/P&gt;&lt;P&gt;        wa_cust-discount =  wa_cust-discount + 10.&lt;/P&gt;&lt;P&gt;        MODIFY i_cust FROM wa_cust TRANSPORTING discount.&lt;/P&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;P&gt;   ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just the ASSIGNING and the allocation of structure is different in case of Field Symbols nothing else changes&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sri&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: SRIKANTH P on Oct 8, 2011 11:41 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Oct 2011 18:11:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219182#M1628040</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-08T18:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219183#M1628041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi kandulaws,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you use field-symbols, you can forget the modify statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at itab assigning &amp;lt;fs&amp;gt;.
  &amp;lt;fs&amp;gt; = &amp;lt;fs1&amp;gt;.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;precondition is that  &amp;lt;fs&amp;gt; is of itab structure type or type any and &amp;lt;fs1&amp;gt; is assigned to a data object of itab structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, all existing records of table itab will have the same value as the data object &amp;lt;fs1&amp;gt; is assigned to.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This does not make too much sense - just as your single code line won't make sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Oct 2011 18:43:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219183#M1628041</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-10-08T18:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219184#M1628042</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;As Clemens says, there is no use of the MODIFY statement within a LOOP if you are working with field-symbols.&lt;/P&gt;&lt;P&gt;If you are not in a LOOP and have to work with field-symbol, you'd better read the entry you need to modify and assign it to your fs first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
READ TABLE &amp;lt;fs&amp;gt; WITH KEY... ASSIGNING &amp;lt;fs1&amp;gt;.
IF sy-subrc NE 0.       
  APPEND INITIAL LINE TO &amp;lt;fs&amp;gt; ASSIGNING &amp;lt;fs1&amp;gt;. "or INSERT INTO
ENDIF.

&amp;lt;fsf1&amp;gt;-fld1 = ...
&amp;lt;fsf1&amp;gt;-fld2 = ...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Oct 2011 20:34:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219184#M1628042</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-08T20:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219185#M1628043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sri,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for reply&lt;/P&gt;&lt;P&gt;I have to modify all the fields .. not for a specific field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 09:57:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219185#M1628043</guid>
      <dc:creator>former_member298409</dc:creator>
      <dc:date>2011-10-09T09:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219186#M1628044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thanks for ur Reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Requirement was different i will give you the scenario.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I have to Download my Internal table data into XL sheet&lt;/P&gt;&lt;P&gt;      But Internal table was not fixed fields it is a dynamic ( Based On the inputRange It was varies )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. My selectionscreen  was Productio order number ( Ranges )&lt;/P&gt;&lt;P&gt;      Suppose user enters 1-20 in th select otions my internal  table has to fetch those many production orders and downloaded into same xl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;output format.&lt;/U&gt; &lt;/P&gt;&lt;P&gt;example: production order range    1 to 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ORD1     ORD2    ORD3  ORD4  ORD5 (first Row Number of Production Orders&lt;/P&gt;&lt;P&gt;MAT1      MAT2    MAT3  MAT4  MAT5 ( second row Header Materials of corresponding Production Order&lt;/P&gt;&lt;P&gt;QUA1     QUA2    QUA3  QUA4  QUA5 (third Row Quantity&lt;/P&gt;&lt;P&gt;child        child      child     child   child    (4th Row child components&lt;/P&gt;&lt;P&gt;child        child      child     child   child    (4th Row child components&lt;/P&gt;&lt;P&gt;child        child      child     child   child    (4th Row child components&lt;/P&gt;&lt;P&gt;child        child      child     child   child    (4th Row child components&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For achiving of this i am using Dynamic internal table creation concept.&lt;/P&gt;&lt;P&gt;Now i am able to get all the three ORD and MAT and QUA in differnt rows .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how to get the child components some times one  production order we are having more than 50 child materials &lt;/P&gt;&lt;P&gt;How to achive this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me on this scenario ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanksin Advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 10:15:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219186#M1628044</guid>
      <dc:creator>former_member298409</dc:creator>
      <dc:date>2011-10-09T10:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219187#M1628045</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;If you fill those dynamic internal tablem you should know how you fill them, so you need to managed a key fields in order to link father and child.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 15:17:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219187#M1628045</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-09T15:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219188#M1628046</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 suppose you have the transposed version of that expected result in another table.&lt;/P&gt;&lt;P&gt;In my opinion you shoud have a table defined with a row type like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: BEGIN OF ty_main,
        ord  TYPE ...,
        mat  TYPE ...,
        qty  TYPE ...,
        comp TYPE ...,
       END OF ty_main,
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so e.g.&lt;/P&gt;&lt;P&gt;ORD1 MAT1 QUA1 CHILD1&lt;/P&gt;&lt;P&gt;ORD1 MAT1 QUA1 CHILD2&lt;/P&gt;&lt;P&gt;ORD1 MAT1 QUA1 CHILD3&lt;/P&gt;&lt;P&gt;ORD1 MAT2 QUA2 CHILD4&lt;/P&gt;&lt;P&gt;ORD1 MAT2 QUA2 CHILD5&lt;/P&gt;&lt;P&gt;ORD2 MAT3 QUA3 CHILD6&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then if you sort that one on all fields, by looping and using AT NEW statement you should be able to easily build your new table in that custom format...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you actually build the ORD and MAT and QUA rows ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 16:18:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219188#M1628046</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-09T16:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219189#M1628047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;please check code..&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;Tab&amp;gt; TYPE STANDARD TABLE,&lt;/P&gt;&lt;P&gt;               &amp;lt;wa&amp;gt;  TYPE any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY &amp;lt;Tab&amp;gt; FROM &amp;lt;wa&amp;gt; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 16:40:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219189#M1628047</guid>
      <dc:creator>Subhankar</dc:creator>
      <dc:date>2011-10-09T16:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Modify internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219190#M1628048</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;As per my last thread, herewith a small example:&lt;/P&gt;&lt;P&gt;First create a macro that will take care of the maintenace of your final table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DEFINE _update_row.
* &amp;amp;1: Column index | &amp;amp;2: Row index | &amp;amp;3: value
  if &amp;amp;2 &amp;gt; g_cnt.
    insert &amp;lt;gs_final&amp;gt; into table &amp;lt;gt_final&amp;gt; assigning &amp;lt;row&amp;gt;.  "Add new row
  else.
    loop at &amp;lt;gt_final&amp;gt; assigning &amp;lt;row&amp;gt;.                       "Update existing row
      check sy-tabix = &amp;amp;2.
      exit.
    endloop.
  endif.
  assign component &amp;amp;1 of structure &amp;lt;row&amp;gt; to &amp;lt;fs&amp;gt;.
  if sy-subrc = 0.
    &amp;lt;fs&amp;gt; = &amp;amp;3.
  endif.
END-OF-DEFINITION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, loop on your main table (that contains all combinations), and maintain your final table at each break:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

  DATA: l_ord TYPE syindex,                     "Order column index
        l_mat TYPE syindex,                     "Material row index
        l_qty TYPE syindex,                     "Quantity row index
        l_com TYPE syindex,                     "Component row index
        l_num_com TYPE i.                       "Components counter

  FIELD-SYMBOLS: &amp;lt;main&amp;gt; TYPE ty_main.

  SORT gt_main BY ord mat qty com.

  LOOP AT gt_main ASSIGNING &amp;lt;main&amp;gt;.
    AT NEW ord.
      DESCRIBE TABLE &amp;lt;gt_final&amp;gt; LINES g_cnt.    "Get number of rows
      l_ord = l_ord + 1.                        "Set Order column index
      l_mat = l_qty = l_com = 1.                "Reset row indexes
      _update_row l_ord 1 &amp;lt;main&amp;gt;-ord.           "Update order row
    ENDAT.

    AT NEW mat.
      l_mat = l_com + 1.                        "New material following components or order
      l_num_com = 0.                            "Reset component counter
      _update_row l_ord l_mat &amp;lt;main&amp;gt;-mat.       "Update material row
    ENDAT.

    AT NEW qty.
      l_qty = l_mat + 1.                        "New quantity following material
      _update_row l_ord l_qty &amp;lt;main&amp;gt;-qty.       "Update quantity row
    ENDAT.

    AT NEW com.
      l_com = l_qty + l_num_com + 1.            "New component following Qty or component
      l_num_com = l_num_com + 1.                "Increase material component counter
      _update_row l_ord l_com &amp;lt;main&amp;gt;-com.       "Update component row
    ENDAT.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your main table is like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
O1 M1 Q1 C1
O1 M1 Q1 C2
O1 M1 Q1 C3
O2 M2 Q2 C1
O2 M2 Q2 C2
O3 M3 Q3 C1
O4 M4 Q4 C1
O4 M4 Q4 C2
O4 M4 Q4 C3
O4 M4 Q4 C4
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Your final table will be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
O1 O2 O3 O4
M1 M2 M3 M4
Q1 Q2 Q3 Q4
C1 C1 C1 C1
C2 C2    C2
C3       C3
         C4
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there should be plenty of ways of doing that...not sure this solution is the best one &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;m.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 18:00:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-internal-table/m-p/8219190#M1628048</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-10-09T18:00:13Z</dc:date>
    </item>
  </channel>
</rss>

