<?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: Internal table manipulation.....? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868242#M672896</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;Try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* create another internal table with the same structure as your data internal table.
* 
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.

LOOP AT itab INTO wa.

* Move the ledger value to a temporary variable.
  v_ledger = wa-ledger.

  AT NEW fis_year.

* Move the values to final internal table.
     APPEND wa TO itab_final.

* Process the next record.
     CONTINUE.
  ENDAT.


* Clear the structure and just move the ledger.
  CLEAR: wa.

  wa-ledger = v_ledger.

  APPEND wa TO itab_final.


ENDLOOP.

* Now ITAB_FINAL will have all the values..
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2007 02:23:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-02T02:23:21Z</dc:date>
    <item>
      <title>Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868239#M672893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all the help in building the logic for me in the previous post...Now I have a internal table in which i have four columns: &amp;lt;b&amp;gt;Comp_code Doc_no Fis_year Ledger&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;the internal table is filled with data like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Comp_code              Doc_no           Fis_year           Ledger
1001           7000000345                 2007                  L1
1001           7000000345                 2007                  L2
1001           7000000345                 2007                  L3
1001           7000000467                2007                  L1
1001           7000000467                 2007                  L2
1001           7000000467                 2007                  L3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want the data to be present in internal table in this format: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Comp_code              Doc_no           Fis_year           Ledger
1001           7000000345                 2007                  L1
                                                                         L2    
                                                                         L3
2000           7000000467                 2007              L1
                                                                          L2
                                                                          L3&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i do this...the code for the internal table with this data is as follows:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select bukrs belnr gjahr from BKPF into TABLE t_parked_docs where blart = 'SY'
                                                              and cpudt eq DATE_OF_ENTRY
                                                              and ppnam IS NOT NULL.
  if sy-subrc  = 0.

    select bukrs belnr gjahr from BKPF into table t_posted_docs
                                      for all entries in t_parked_docs
                                      where BUKRS = t_parked_docs-v_comp_code and
                                      BELNR = t_parked_docs-v_doc_no and
                                      GJAHR = t_parked_docs-v_fiscal_year and
                                      BSTAT = ''.

    loop at t_posted_docs into wa_posted_docs.

      select distinct rldnr from faglflexa into (wa_posted_docs-v_ledger)
                                                            where rbukrs = wa_posted_docs-v_comp_code
                                                            and docnr = wa_posted_docs-v_doc_no
                                                            and ryear = wa_posted_docs-v_fiscal_year.
        APPEND wa_posted_docs to t_docs_posted_with_ledger.

      endselect.


    endloop.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly give some suggestions.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers:&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:00:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868239#M672893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868240#M672894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Sam,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Didnt this work??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_docs_posted_with_ledger into wa_posted_docs.&lt;/P&gt;&lt;P&gt;idx = sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_posted_docs1 = wa_posted_docs. " Temperory Work Area&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lv_belnr = wa_posted_docs-v_doc_no and sy-tabix ne 1.&lt;/P&gt;&lt;P&gt;clear: wa_posted_docs-v_comp_code, wa_posted_docs-v_doc_no, wa_posted_docs-v_fiscal_year.&lt;/P&gt;&lt;P&gt;modify t_docs_posted_with_ledger INDEX idx transporting wa_posted_docs.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_belnr = wa_posted_docs1-v_doc_no.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:19:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868240#M672894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868241#M672895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No Sri...It did not...it is clearing all the values....just leaving the first value...let me try again....&lt;/P&gt;&lt;P&gt;and what is lv_belnr...?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Sam williams&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:22:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868241#M672895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868242#M672896</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;Try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* create another internal table with the same structure as your data internal table.
* 
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.

LOOP AT itab INTO wa.

* Move the ledger value to a temporary variable.
  v_ledger = wa-ledger.

  AT NEW fis_year.

* Move the values to final internal table.
     APPEND wa TO itab_final.

* Process the next record.
     CONTINUE.
  ENDAT.


* Clear the structure and just move the ledger.
  CLEAR: wa.

  wa-ledger = v_ledger.

  APPEND wa TO itab_final.


ENDLOOP.

* Now ITAB_FINAL will have all the values..
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:23:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868242#M672896</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868243#M672897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmm...just tweak it a lil..it should work...may be you an debug and see...i am not sure abt the exact field names you have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically the logic i tried is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab into wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;idx = sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*transfer entries into temperory wa.&lt;/P&gt;&lt;P&gt;wa1 = wa.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lv_belnr = wa-belnr and idx ne 1.&lt;/P&gt;&lt;P&gt; clear wa, except the ledger field.&lt;/P&gt;&lt;P&gt; modify itab index idx transporting wa.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_belnr = wa1-belnr.&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;You can play with it...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sri&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:26:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868243#M672897</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868244#M672898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;lv_belnr is a variable to store belnr or doc number.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:28:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868244#M672898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868245#M672899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi narendara,&lt;/P&gt;&lt;P&gt;thanks for the reply....it worls upto an extent but it doesnt get the ledger for the first time it runs...i mean it is able to get the ledger L2 and L3 but not L1 which is the first row....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can i try somethin else...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:38:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868245#M672899</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868246#M672900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey sri,&lt;/P&gt;&lt;P&gt;Thanks for the reply buddy...&lt;/P&gt;&lt;P&gt;Let me tweak with it a little and then will let u know....&lt;/P&gt;&lt;P&gt;ANywayz really want to thak u for ur immediate replies....will definitely let u know...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:39:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868246#M672900</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868247#M672901</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;Sorry..One small change..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: ITAB_FINAL LIKE TABLE OF itab.
DATA: v_ledger LIKE wa-ledger.
DATA: wa_tmp LIKE wa.
 
LOOP AT itab INTO wa.
 
*********** NEW CHANGE
* Move the values to a temporary structure.
  wa_tmp = wa.
*********** NEW CHANGE.

* Move the ledger value to a temporary variable.
  v_ledger = wa-ledger.
 
  AT NEW fis_year.
 
* Move the values to final internal table.
     APPEND wa_tmp TO itab_final.  " Changed here..
 
* Process the next record.
     CONTINUE.
  ENDAT.
 
 
* Clear the structure and just move the ledger.
  CLEAR: wa.
 
  wa-ledger = v_ledger.
 
  APPEND wa TO itab_final.
 
 
ENDLOOP.
 
* Now ITAB_FINAL will have all the values..

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:40:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868247#M672901</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Internal table manipulation.....?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868248#M672902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Narendara,&lt;/P&gt;&lt;P&gt;It worked for me....i think it shud be fine now...thanks buddy....i am closing this thread for now but will always come back in case of queries....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2007 02:49:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-manipulation/m-p/2868248#M672902</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-02T02:49:36Z</dc:date>
    </item>
  </channel>
</rss>

