<?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: Dynamic field in select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484243#M1061604</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Asik,&lt;/P&gt;&lt;P&gt;I m selecting all fields now as suggestd by u so in one record i have hsl01 to hsl12.&lt;/P&gt;&lt;P&gt;I have to calculate balance into e_glt0_bal-bal .This balance is summation of e_glt0_bal-hsl01 till  e_glt0_bal-hsl12 (depending on monat).&lt;/P&gt;&lt;P&gt;I m using logic in process then &lt;/P&gt;&lt;P&gt;my code now :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:    w_monat_bal type string  . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          DO p_monat TIMES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            MOVE c_01 TO w_count .&lt;/P&gt;&lt;P&gt;            CONCATENATE 'e_glt0_bal-hsl'&lt;/P&gt;&lt;P&gt;                         w_count&lt;/P&gt;&lt;P&gt;                   INTO w_monat_bal.&lt;/P&gt;&lt;P&gt;            ASSIGN w_monat_bal TO &amp;lt;fs_monat_bal&amp;gt;.&lt;/P&gt;&lt;P&gt;            e_glt0_bal-bal = e_glt0_bal-bal + &amp;lt;fs_monat_bal&amp;gt;.&lt;/P&gt;&lt;P&gt;            w_count = w_count + c_01.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But &amp;lt;fs_monat_bal&amp;gt; can not be added.&lt;/P&gt;&lt;P&gt;Giving exception :&lt;/P&gt;&lt;P&gt;Unable to interpret "e_glt0_bal-hsl01" as a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do &amp;lt;fs_monat_bal&amp;gt; type GLT0-hslvt instead to type any&lt;/P&gt;&lt;P&gt;Then assigning from w_monat_bal  is not possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Sep 2008 14:26:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-08T14:26:36Z</dc:date>
    <item>
      <title>Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484238#M1061599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to select dynamic fields from database table GLT0.&lt;/P&gt;&lt;P&gt;This depends on period value given on screen.&lt;/P&gt;&lt;P&gt;If period is 01 then fields will be hsl01.&lt;/P&gt;&lt;P&gt;If period is 02 then fields will be hsl01 and hsl02.&lt;/P&gt;&lt;P&gt;If period is 03 then fields will be hsl01,hsl02 and hsl03 .&lt;/P&gt;&lt;P&gt;so on...till 12..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is throwing exception at select query.&lt;/P&gt;&lt;P&gt;"Error in module RSQL of the database interface."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code :&lt;/P&gt;&lt;P&gt;*"      Type declaration to store field name as per given period&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF y_fieldname        ,&lt;/P&gt;&lt;P&gt;           fieldname(10)  TYPE c    ,&lt;/P&gt;&lt;P&gt;         END OF y_fieldname         .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data  t_fieldname  TYPE  STANDARD TABLE OF y_fieldname   .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DO p_monat TIMES.&lt;/P&gt;&lt;P&gt;     clear w_count .&lt;/P&gt;&lt;P&gt;      MOVE sy-index TO w_count &lt;/P&gt;&lt;P&gt;      IF sy-index LE c_9.&lt;/P&gt;&lt;P&gt;        CONCATENATE c_hsl&lt;/P&gt;&lt;P&gt;                    c_0&lt;/P&gt;&lt;P&gt;                    w_count&lt;/P&gt;&lt;P&gt;        INTO      e_fieldname-fieldname.&lt;/P&gt;&lt;P&gt;        APPEND e_fieldname TO t_fieldname.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        CONCATENATE c_hsl&lt;/P&gt;&lt;P&gt;                    w_count&lt;/P&gt;&lt;P&gt;        INTO     e_fieldname-fieldname.&lt;/P&gt;&lt;P&gt;        APPEND e_fieldname TO t_fieldname.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Get Local Currency Amounts&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  from table glt0 depending on period&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    SELECT (t_fieldname)&lt;/P&gt;&lt;P&gt;      FROM glt0&lt;/P&gt;&lt;P&gt;      INTO TABLE t_glto_with_saknr&lt;/P&gt;&lt;P&gt;      FOR ALL ENTRIES IN t_bukrs&lt;/P&gt;&lt;P&gt;     WHERE rldnr EQ c_00&lt;/P&gt;&lt;P&gt;       AND rrcty EQ c_0&lt;/P&gt;&lt;P&gt;       AND rvers EQ c_001&lt;/P&gt;&lt;P&gt;       AND bukrs EQ t_bukrs-bukrs&lt;/P&gt;&lt;P&gt;       AND ryear EQ p_gjahr&lt;/P&gt;&lt;P&gt;       AND racct IN r_saknr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please guide me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanking u in advance.&lt;/P&gt;&lt;P&gt;Sangeeta Verma&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 13:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484238#M1061599</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-08T13:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484239#M1061600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try INTO CORRESPONDING FIELDS OF TABLE t_glto_with_saknr&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 13:20:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484239#M1061600</guid>
      <dc:creator>Sm1tje</dc:creator>
      <dc:date>2008-09-08T13:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484240#M1061601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sangeeta,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;seems very much strange and scattred code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data t_fieldname TYPE STANDARD TABLE OF y_fieldname .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT (t_fieldname)"check t_fieldname what is it?its a internal table as you defined (its not a field of GLT0 table)
FROM glt0
INTO TABLE t_glto_with_saknr
FOR ALL ENTRIES IN t_bukrs
WHERE rldnr EQ c_00
AND rrcty EQ c_0
AND rvers EQ c_001
AND bukrs EQ t_bukrs-bukrs
AND ryear EQ p_gjahr
AND racct IN r_saknr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 13:22:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484240#M1061601</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-08T13:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484241#M1061602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know what is the data type for W_COUNT in your program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this way:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data: w_count(2) type c.

DO p_monat TIMES.
clear w_count .
MOVE sy-index TO w_count .
unpack w_count to w_count.
CONCATENATE 'HSL' " c_hsl
w_count
INTO e_fieldname-fieldname.
APPEND e_fieldname TO t_fieldname.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 13:27:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484241#M1061602</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-09-08T13:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484242#M1061603</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;Dot add your logic in SELECT query. I wud suggest you to add the logic in the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT all the periods fields HSL01, HSL02,..,HSL12 into Internal table t_glto_with_saknr in SELECT Query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While processing the record, do your logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FIELD-SYMBOLS: &amp;lt;fs_field&amp;gt; TYPE ANY.

LOOP AT t_glto_with_saknr.
  CONCATENATE 'GLTO_WTH_SAKNR-HSL' p_period into gv_field.
  ASSIGN gv_field TO &amp;lt;fs_field&amp;gt;.
  
  " Now &amp;lt;fs_field&amp;gt; will have the value of particular period which is mentioned in screen
  " &amp;lt;&amp;lt; your code Here &amp;gt;&amp;gt;

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 13:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484242#M1061603</guid>
      <dc:creator>asik_shameem</dc:creator>
      <dc:date>2008-09-08T13:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484243#M1061604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Asik,&lt;/P&gt;&lt;P&gt;I m selecting all fields now as suggestd by u so in one record i have hsl01 to hsl12.&lt;/P&gt;&lt;P&gt;I have to calculate balance into e_glt0_bal-bal .This balance is summation of e_glt0_bal-hsl01 till  e_glt0_bal-hsl12 (depending on monat).&lt;/P&gt;&lt;P&gt;I m using logic in process then &lt;/P&gt;&lt;P&gt;my code now :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:    w_monat_bal type string  . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          DO p_monat TIMES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            MOVE c_01 TO w_count .&lt;/P&gt;&lt;P&gt;            CONCATENATE 'e_glt0_bal-hsl'&lt;/P&gt;&lt;P&gt;                         w_count&lt;/P&gt;&lt;P&gt;                   INTO w_monat_bal.&lt;/P&gt;&lt;P&gt;            ASSIGN w_monat_bal TO &amp;lt;fs_monat_bal&amp;gt;.&lt;/P&gt;&lt;P&gt;            e_glt0_bal-bal = e_glt0_bal-bal + &amp;lt;fs_monat_bal&amp;gt;.&lt;/P&gt;&lt;P&gt;            w_count = w_count + c_01.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But &amp;lt;fs_monat_bal&amp;gt; can not be added.&lt;/P&gt;&lt;P&gt;Giving exception :&lt;/P&gt;&lt;P&gt;Unable to interpret "e_glt0_bal-hsl01" as a number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do &amp;lt;fs_monat_bal&amp;gt; type GLT0-hslvt instead to type any&lt;/P&gt;&lt;P&gt;Then assigning from w_monat_bal  is not possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 14:26:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484243#M1061604</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-08T14:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484244#M1061605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sangeetha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to select hsl01 to hsl12 for all the records, based on the period consider the field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if period is 01 then consider hsl01 for that perticular record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can have CASE... ENDCASE to identify the period &amp;amp; according to period u can calculate the balance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see the sample code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CASE w_monat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WHEN '01'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; apply the summation logic here.&lt;/P&gt;&lt;P&gt;WHEN '02'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you are clear with the above explanation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sujatha&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sujatha Reddy on Sep 8, 2008 4:46 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 14:40:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484244#M1061605</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-08T14:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484245#M1061606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sangeetha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do in the following way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: n           TYPE i VALUE 12,
      w_count     TYPE i,
      gv_val(2)   TYPE c,
      w_monta_val TYPE i,
      gv_total    TYPE i,
      w_monat_bal TYPE string.


DATA: BEGIN OF itab OCCURS 10,
        hsl01 TYPE i,
        hsl02 TYPE i,
        hsl03 TYPE i,
        hsl04 TYPE i,
        END OF itab.

itab-hsl01 = 10.
itab-hsl02 = 20.
itab-hsl03 = 30.
itab-hsl04 = 40.
APPEND itab.

FIELD-SYMBOLS: &amp;lt;fs_monat_bal&amp;gt;.

w_count = 1.

DO 4 TIMES.

  gv_val = w_count.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = gv_val
    IMPORTING
      output = gv_val.

  CONCATENATE 'itab-hsl' gv_val INTO w_monat_bal.

  ASSIGN (w_monat_bal) TO &amp;lt;fs_monat_bal&amp;gt;.

  gv_total = gv_total + &amp;lt;fs_monat_bal&amp;gt;.

  ADD 1 TO w_count.

ENDDO.

write: gv_total. " Will have 100  ie. 10+20+30+40

BREAK-POINT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 14:53:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484245#M1061606</guid>
      <dc:creator>asik_shameem</dc:creator>
      <dc:date>2008-09-08T14:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic field in select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484246#M1061607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The easy way would be to use the DO ... VARYING construction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Sep 2008 15:07:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-field-in-select-query/m-p/4484246#M1061607</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-08T15:07:08Z</dc:date>
    </item>
  </channel>
</rss>

