<?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: Traverse Columns in Internal Table Programatically in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885305#M52375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jerry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please follow this topic and you will find how to achieve the traverse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="23229"&gt;&lt;/A&gt;&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;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Jan 2005 21:47:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-01-07T21:47:41Z</dc:date>
    <item>
      <title>Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885303#M52373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAP BW, I have an internal table "COMM_STRUCTURE" composed of 52 columns, one for each week of the year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rather than appending 52 times to RESULT_TABLE, is there a way to do it in a loop, and traverse each column of a row programatically?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The codes looks like this.  I want to eliminate the repeated lines.  Thanks for any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM compute_data_field&lt;/P&gt;&lt;P&gt;  TABLES   MONITOR STRUCTURE RSMONITOR "user defined monitoring&lt;/P&gt;&lt;P&gt;           RESULT_TABLE STRUCTURE /BIC/VIC_BUD_JCT&lt;/P&gt;&lt;P&gt;  USING    COMM_STRUCTURE LIKE /BIC/CSIS_MONBUD&lt;/P&gt;&lt;P&gt;           RECORD_NO LIKE SY-TABIX&lt;/P&gt;&lt;P&gt;           RECORD_ALL LIKE SY-TABIX&lt;/P&gt;&lt;P&gt;           SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS&lt;/P&gt;&lt;P&gt;           ICUBE_VALUES LIKE /BIC/VIC_BUD_JCT&lt;/P&gt;&lt;P&gt;  CHANGING RETURNCODE LIKE SY-SUBRC&lt;/P&gt;&lt;P&gt;           ABORT LIKE SY-SUBRC. "set ABORT &amp;lt;&amp;gt; 0 to cancel update&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RESULT_TABLE = ICUBE_VALUES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RESULT_TABLE-/BIC/IO_BUDINC = COMM_STRUCTURE-/BIC/IO_BAMT01.&lt;/P&gt;&lt;P&gt;RESULT_TABLE-CALMONTH = 200401.&lt;/P&gt;&lt;P&gt;APPEND RESULT_TABLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RESULT_TABLE-/BIC/IO_BUDINC = COMM_STRUCTURE-/BIC/IO_BAMT02.&lt;/P&gt;&lt;P&gt;RESULT_TABLE-CALMONTH = 200402.&lt;/P&gt;&lt;P&gt;APPEND RESULT_TABLE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2005 20:05:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885303#M52373</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-07T20:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885304#M52374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can use Field Symbols &amp;lt;fs&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2005 20:26:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885304#M52374</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-07T20:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885305#M52375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jerry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please follow this topic and you will find how to achieve the traverse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="23229"&gt;&lt;/A&gt;&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;Srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jan 2005 21:47:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885305#M52375</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-07T21:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885306#M52376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the responses.  I don't have much experience with ABAP, so I appreciate your patience.  I still can't get it to work.  The following, which is trying to turn the 52 week columns (ignoring the first column) into 52 rows, doesn't write anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone see what my error is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROGRAM UPDATE_ROUTINE.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS &amp;lt;FS&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM compute_data_field&lt;/P&gt;&lt;P&gt;  TABLES   MONITOR STRUCTURE RSMONITOR "user defined monitoring&lt;/P&gt;&lt;P&gt;           RESULT_TABLE STRUCTURE /BIC/VIC_BUD_JCT&lt;/P&gt;&lt;P&gt;  USING    COMM_STRUCTURE LIKE /BIC/CSIS_MONBUD&lt;/P&gt;&lt;P&gt;           RECORD_NO LIKE SY-TABIX&lt;/P&gt;&lt;P&gt;           RECORD_ALL LIKE SY-TABIX&lt;/P&gt;&lt;P&gt;           SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS&lt;/P&gt;&lt;P&gt;           ICUBE_VALUES LIKE /BIC/VIC_BUD_JCT&lt;/P&gt;&lt;P&gt;  CHANGING RETURNCODE LIKE SY-SUBRC&lt;/P&gt;&lt;P&gt;           ABORT LIKE SY-SUBRC. "set ABORT &amp;lt;&amp;gt; 0 to cancel update&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RESULT_TABLE = ICUBE_VALUES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  ASSIGN COMPONENT SY-INDEX OF STRUCTURE COMM_STRUCTURE TO &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF SY-INDEX &amp;gt; 1.&lt;/P&gt;&lt;P&gt;      RESULT_TABLE-/BIC/IO_BUDAMT = &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;      RESULT_TABLE-CALMONTH = SY-INDEX.&lt;/P&gt;&lt;P&gt;      APPEND RESULT_TABLE.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  RETURNCODE = 0.&lt;/P&gt;&lt;P&gt;  ABORT = 0.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2005 14:34:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885306#M52376</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-10T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885307#M52377</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;At first sight your code looks okay but I am doubting at the usage of sy-index as a counter ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest making following changes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- define a local counter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: w_fieldindex type i value 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- use the counter in stead of sy-index and of course you need to increase the counter by hand &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- you can get ridd of the test 'if sy-index &amp;gt; 1' ... Just give the counter already the default value for the second index lookup so you can ommit that if statement (should give some performance)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Not sure but doesn't the index starts at 0 - so first field is index 0 (check that ... so then the default index to start can be set to 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steven&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2005 08:45:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885307#M52377</guid>
      <dc:creator>StevenDeSaeger</dc:creator>
      <dc:date>2005-01-11T08:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885308#M52378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jerry,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the delayed response to this question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are using the &amp;lt;i&amp;gt;ASSIGN COMPONENT OF&amp;lt;/i&amp;gt; option in your code here. Have you checked whether the fields -/BIC/IO_BAMT01 , -/BIC/IO_BAMT02....are consecutive and contiguous in the structure COMM_STRUCTURE (which is of type /BIC/CSIS_MONBUD) ? If not then you will have problems. Also, the statement &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;RESULT_TABLE-CALMONTH = SY-INDEX.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; seems to be incorrect. You want tthe CALMONTHs to be in the format 2004xx, right? If yes, then the above statement will not do. I have altered your code a little hwere necessary. Please see if it works. If you still find some problems, please give the structure of /BIC/CSIS_MONBUD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also please confirm whether your original program is working as intended.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;====================================================================&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROGRAM UPDATE_ROUTINE.
FIELD-SYMBOLS &amp;lt;FS&amp;gt; TYPE ANY.

FORM compute_data_field TABLES MONITOR        STRUCTURE RSMONITOR 
                               RESULT_TABLE   STRUCTURE /BIC/VIC_BUD_JCT
                         USING COMM_STRUCTURE LIKE      /BIC/CSIS_MONBUD
                               RECORD_NO      LIKE      SY-TABIX
                               RECORD_ALL     LIKE      SY-TABIX
                               SOURCE_SYSTEM  LIKE      RSUPDSIMULH-LOGSYS
                               ICUBE_VALUES   LIKE      /BIC/VIC_BUD_JCT
                      CHANGING RETURNCODE     LIKE      SY-SUBRC
                               ABORT          LIKE      SY-SUBRC. "set ABORT &amp;lt;&amp;gt; 0 to cancel update"

  DATA TEMP_CALMONTH(6) TYPE N. 
  
  TEMP_CALMONTH = '200401'.  

  RESULT_TABLE = ICUBE_VALUES.

  DO.
    ASSIGN COMPONENT SY-INDEX OF STRUCTURE COMM_STRUCTURE TO &amp;lt;FS&amp;gt;.
    IF SY-SUBRC &amp;lt;&amp;gt; 0.
      EXIT.
    ENDIF.

    IF SY-INDEX &amp;gt; 1.
      RESULT_TABLE-/BIC/IO_BUDAMT = &amp;lt;FS&amp;gt;.
      MOVE SY-INDEX TO TEMP_CALMONTH+4(2).  
      RESULT_TABLE-CALMONTH = TEMP_CALMONTH.
      APPEND RESULT_TABLE.
    ENDIF.
  ENDDO.

  RETURNCODE = 0.
  ABORT = 0.

ENDFORM. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;====================================================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DO..ENDDO loop above can also be coded in a different way - &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA : TEMP_INDEX(2) TYPE N,
       TEMP_MONBUD(29) TYPE C VALUE 'COMM_STRUCTURE-/BIC/IO_BAMT'.
	
DO.
  MOVE SY-INDEX TO TEMP_INDEX.
  CONCATENATE TEMP_MONBUD 
              TEMP_INDEX
         INTO TEMP_MONBUD.
  ASSIGN COMPONENT TEMP_MONBUD OF STRUCTURE COMM_SRTUCTURE TO &amp;lt;FS&amp;gt;.
* Rest of the code is same as above. Here, you do not have to know the actual structure of COMM_STRUCTURE,
so long as you know that there will be fields with the name /BIC/IO_BAMTxx.  
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope to see your problem resolved ASAP. All the best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anand Mandalika.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2005 10:05:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885308#M52378</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-12T10:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Traverse Columns in Internal Table Programatically</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885309#M52379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Anand.  I had multiple problems with my code, and your suggestions were on target for a lot of my problems.  Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2005 15:53:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/traverse-columns-in-internal-table-programatically/m-p/885309#M52379</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-12T15:53:34Z</dc:date>
    </item>
  </channel>
</rss>

