<?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: Populating internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957753#M1155804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can READ the first internal table based on Retailer (12), Dealer (11) and Processor (14). &lt;/P&gt;&lt;P&gt;Then based on the selected record, READ your second Internal table. &lt;/P&gt;&lt;P&gt;If a record is found MODIFY the existing record.&lt;/P&gt;&lt;P&gt;if NO record is found APPEND the selected records as per the requirement to your second internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.G. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
READ ITAB1 INTO W_ITAB1 WITH KEY CUSTOMER GROUP = 12.
IF SY-SUBRC eq 0.
    " MODIFY
ELSE.
     " APPEND
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This you can carry on in a loop to acheive for multiple records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Dec 2008 12:24:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-12-10T12:24:56Z</dc:date>
    <item>
      <title>Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957750#M1155801</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 have to populate an interbal table with the data in a source table. The tables are in the following format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please tell me the logic, if possible give me the sample code for updating the target internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source database Table 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Description     Customer Group                    Price&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ABC               11                                          XXX&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ABC               12                                          YYY&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ABC               14                                            ZZZ&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Retailer u2013 12; Dealer u2013 11; Processor u2013 14.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Target Internal Table &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Description                     Retailer                   Dealer           Processor &lt;/P&gt;&lt;P&gt;ABC                                 YYY                       XXX                 ZZZ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:16:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957750#M1155801</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957751#M1155802</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;Can you please specify the structures of the tables again. Are there two source tables? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Vartika&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:21:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957751#M1155802</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957752#M1155803</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;check this code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort table1 by Description.&lt;/P&gt;&lt;P&gt;Loop at table1.&lt;/P&gt;&lt;P&gt;if Customer Group eq '12'.&lt;/P&gt;&lt;P&gt;  targett-Retailer = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if Customer Group eq '11'.&lt;/P&gt;&lt;P&gt;  targett-Dealer = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if Customer Group eq '14'.&lt;/P&gt;&lt;P&gt;  targett-Processor = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at end of Description.&lt;/P&gt;&lt;P&gt;append targett.&lt;/P&gt;&lt;P&gt;clear targett.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:22:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957752#M1155803</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957753#M1155804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can READ the first internal table based on Retailer (12), Dealer (11) and Processor (14). &lt;/P&gt;&lt;P&gt;Then based on the selected record, READ your second Internal table. &lt;/P&gt;&lt;P&gt;If a record is found MODIFY the existing record.&lt;/P&gt;&lt;P&gt;if NO record is found APPEND the selected records as per the requirement to your second internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.G. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
READ ITAB1 INTO W_ITAB1 WITH KEY CUSTOMER GROUP = 12.
IF SY-SUBRC eq 0.
    " MODIFY
ELSE.
     " APPEND
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This you can carry on in a loop to acheive for multiple records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Ram.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:24:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957753#M1155804</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957754#M1155805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose internal table itab(with workarea wa) has data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC 11 XXX&lt;/P&gt;&lt;P&gt;ABC 12 YYY&lt;/P&gt;&lt;P&gt;ABC 14 ZZZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and itab2 is the target table with wa2 as workarea&lt;/P&gt;&lt;P&gt;So &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab into wa.&lt;/P&gt;&lt;P&gt;wa2-description = wa-description.&lt;/P&gt;&lt;P&gt;if wa-custgrp = 11.&lt;/P&gt;&lt;P&gt;wa2-dealer = wa-price. "(XXX)&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if wa-custgrp = 12.&lt;/P&gt;&lt;P&gt;wa2-retailer = wa-price. "(YYY)&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if wa-custgrp = 14.  &lt;/P&gt;&lt;P&gt;wa2-processor = wa-price. "(ZZZ)&lt;/P&gt;&lt;P&gt;endif.&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;append wa2 to itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab2 will have data you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:27:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957754#M1155805</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957755#M1155806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; hi all,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I have to populate an interbal table with the data in a source table. The tables are in the following format.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; please tell me the logic, if possible give me the sample code for updating the target internal table.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Source database Table 1&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; Description     Customer Group                    Price&lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; ABC               11                                          XXX&lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; ABC               12                                          YYY&lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; ABC               14                                            ZZZ&lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Retailer u2013 12; Dealer u2013 11; Processor u2013 14.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Target Internal Table &lt;/P&gt;&lt;P&gt;&amp;gt;  &lt;/P&gt;&lt;P&gt;&amp;gt; Description                     Retailer                   Dealer           Processor &lt;/P&gt;&lt;P&gt;&amp;gt; ABC                                 YYY                       XXX                 ZZZ&lt;/P&gt;&lt;P&gt;Make sure that description is the first field of the it (internal table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;it is this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Description Customer Group Price&lt;/P&gt;&lt;P&gt;ABC 11 XXX&lt;/P&gt;&lt;P&gt;ABC 12 YYY&lt;/P&gt;&lt;P&gt;ABC 14 ZZZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and it_aux will be:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Description Retailer Dealer Processor&lt;/P&gt;&lt;P&gt;ABC YYY XXX ZZZ&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*Example:*
SORT it BY description.
LOOP AT it.
  CASE it-customer.
     WHEN 11. 
         it_aux-dealer = it-GroupPrice.
     WHEN 12. 
         it_aux-retailer = it-GroupPrice.
     WHEN 14. 
         it_aux-processor = it-GroupPrice.
  ENDCASE.
AT END OF Description.
  it_aux-Description = it-description.
  APPEND it_aux.
ENDAT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tell me If u had any problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:27:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957755#M1155806</guid>
      <dc:creator>Rodrigo-Giner</dc:creator>
      <dc:date>2008-12-10T12:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957756#M1155807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab_source where cust_group = '11'.
  itab_target-description = itab-source-description.
  APPEND itab_target.
ENDLOOP.

LOOP AT itab_target.
  wa_tabix = sy-tabix.
  READ TABLE itab_source WITH KEY cust_group = '12'.
  IF sy-subrc = 0.
    itab-target-retailer = itab_source-price.
  ENDIF.
  READ TABLE itab_source WITH KEY cust_group = '13'.
  IF sy-subrc = 0.
    itab-target-dealer = itab_source-price.
  ENDIF.
  MODIFY itab INDEX wa_tabix TRANSPORTING retailer dealer.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This should solve your problem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:33:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957756#M1155807</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957757#M1155808</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;check this code..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort table1 by Description.&lt;/P&gt;&lt;P&gt;Loop at table1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if Customer Group eq '12'.&lt;/P&gt;&lt;P&gt;targett-Retailer = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if Customer Group eq '11'.&lt;/P&gt;&lt;P&gt;targett-Dealer = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if Customer Group eq '14'.&lt;/P&gt;&lt;P&gt;targett-Processor = table1-price.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at end of Description.&lt;/P&gt;&lt;P&gt;targett-description = table1-description. (Corrected&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;)&lt;/P&gt;&lt;P&gt;append targett.&lt;/P&gt;&lt;P&gt;clear targett.&lt;/P&gt;&lt;P&gt;endat.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:34:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957757#M1155808</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957758#M1155809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajan,&lt;/P&gt;&lt;P&gt;I assume that 'Description, Customer Group and Price' are in table1 and&lt;/P&gt;&lt;P&gt;'Retailer, Dealer and Processor' are present in another table say table2,&lt;/P&gt;&lt;P&gt;then you can try the following logic,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_table2 INTO wa_table2.
  READ TABLE it_table1 INTO wa1_table1
           WITH KEY custgrp = wa_table2-retailer.

  READ TABLE it_table1 INTO wa2_table1
           WITH KEY custgrp = wa_table2-dealer.

  READ TABLE it_table1 INTO wa3_table1
           WITH KEY custgrp = wa_table2-processor.
*  Checking whether decription are same
  IF wa1_table1-desc EQ wa2_table1-desc.
    IF wa1_table1-desc EQ wa3_table1-desc.

*  If they are same then fill the target table
      wa_target-desc = wa1_table1-desc.
      wa_target-retailer = wa1_table1-price.
      wa_target-dealer = wa2_table1-price.
      wa_target-processor = wa3_table1-price.

      APPEND wa_target TO it_target.

    ENDIF.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Manoj Kumar P&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manoj Kumar on Dec 10, 2008 2:11 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 12:55:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957758#M1155809</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T12:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957759#M1155810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks got the logic right!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 13:30:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-table/m-p/4957759#M1155810</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-10T13:30:11Z</dc:date>
    </item>
  </channel>
</rss>

