<?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 variable creation. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388953#M1545110</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello you can try like this. Make changes as necessary . Just in se11 search for data element * XX * and use the required one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA:li_index(2) TYPE n,
wf_str TYPE REF TO data.

FIELD-SYMBOLS:&amp;lt;fs&amp;gt; TYPE ANY.

DATA:lf_element TYPE REF TO cl_abap_elemdescr,
i_tot_comp TYPE cl_abap_structdescr=&amp;gt;component_table,
la_comp LIKE LINE OF i_tot_comp ,
lf_new_type TYPE REF TO cl_abap_structdescr.

DO 10 TIMES.
  CLEAR i_tot_comp[].
  li_index = sy-index.
  lf_element ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'CNTXX_KK' ).
  CONCATENATE 'CNT' li_index '_KK' INTO la_comp-name.
  la_comp-type =
    cl_abap_elemdescr=&amp;gt;get_i(  ).
  APPEND la_comp TO i_tot_comp.
  TRY.
      lf_new_type = cl_abap_structdescr=&amp;gt;create( i_tot_comp ).
    CATCH cx_sy_struct_creation .                       "#EC NO_HANDLER
  ENDTRY.
  CREATE DATA wf_str TYPE HANDLE lf_new_type.
  ASSIGN wf_str-&amp;gt;* TO &amp;lt;fs&amp;gt;.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Nov 2010 11:36:35 GMT</pubDate>
    <dc:creator>kesavadas_thekkillath</dc:creator>
    <dc:date>2010-11-04T11:36:35Z</dc:date>
    <item>
      <title>Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388948#M1545105</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;Is there any method by which I can create variable names dynamically.&lt;/P&gt;&lt;P&gt;My requirement is to assign each of the values in the select option of the screen (p_stat) to separate variables.&lt;/P&gt;&lt;P&gt;Code is as shown below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          LOOP AT p_stat.&lt;/P&gt;&lt;P&gt;          CLEAR: field, l_field.&lt;/P&gt;&lt;P&gt;          l_field = sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            CONCATENATE 'lv_text' l_field INTO field.&lt;/P&gt;&lt;P&gt;            ASSIGN (field) TO &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;            &amp;lt;fs&amp;gt; = p_stat-low.&lt;/P&gt;&lt;P&gt;            GET REFERENCE OF &amp;lt;fs&amp;gt; INTO wa_query-value_low.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            APPEND wa_query TO gt_query.&lt;/P&gt;&lt;P&gt;          ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the first loop pass, the value of p_stat has to be assigned to lv_text1, 2nd loop pass value to lv_text2 etc......&lt;/P&gt;&lt;P&gt;I was able to do so using field symbol. But here I have to then declare the variables like lv_text1, lv_text2 etc separately which will only be known (ie, the no: of variables to declare) only at the runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Soumya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 10:44:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388948#M1545105</guid>
      <dc:creator>soumya_jose3</dc:creator>
      <dc:date>2010-11-04T10:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388949#M1545106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How did you define gt_query &amp;amp; wa_query?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 11:10:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388949#M1545106</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-11-04T11:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388950#M1545107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suhas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Decalartions are as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : gt_query      TYPE mdm_query_table,&lt;/P&gt;&lt;P&gt;       wa_query      TYPE mdm_query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Soumya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 11:11:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388950#M1545107</guid>
      <dc:creator>soumya_jose3</dc:creator>
      <dc:date>2010-11-04T11:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388951#M1545108</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 do not know exactly what you want to do. If it helps you can create dinamyc tables with method cl_alv_table_create=&amp;gt;create_dynamic_table. I show you an example below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_data&amp;gt; TYPE REF TO data.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs_1&amp;gt; type table.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;dat1&amp;gt; type data.&lt;/P&gt;&lt;P&gt;DATA:      es_dfies  LIKE LINE OF et_dfies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'TR_NAMETAB_GET'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      IV_TABNAME                       = 'VIMFLAGTAB'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IV_GET_LENGTHS_IN_CHARMODE       = 'X'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     IV_GET_TEXTS                     = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;   IMPORTING&lt;/P&gt;&lt;P&gt;     ET_DFIES                         = et_dfies.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     ES_HEADER                        =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     NOT_FOUND                        = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     OTHERS                           = 2&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  .&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL METHOD cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;P&gt;      it_fieldcatalog           = lt&lt;/P&gt;&lt;P&gt;    IMPORTING&lt;/P&gt;&lt;P&gt;      ep_table                  = &amp;lt;fs_data&amp;gt;&lt;/P&gt;&lt;P&gt;    EXCEPTIONS&lt;/P&gt;&lt;P&gt;      generate_subpool_dir_full = 1&lt;/P&gt;&lt;P&gt;      OTHERS                    = 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ASSIGN &amp;lt;fs_data&amp;gt;-&amp;gt;* TO &amp;lt;fs_1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      SELECT *&lt;/P&gt;&lt;P&gt;        FROM (from_clause)&lt;/P&gt;&lt;P&gt;            APPENDING TABLE &amp;lt;fs_1&amp;gt;&lt;/P&gt;&lt;P&gt;        WHERE (where_clause).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT &amp;lt;fs_1&amp;gt; ASSIGNING &amp;lt;dat1&amp;gt;.&lt;/P&gt;&lt;P&gt;        DO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            READ TABLE ET_DFIES INTO es_dfies INDEX sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            ASSIGN COMPONENT es_dfies-fieldname OF STRUCTURE &amp;lt;dat1&amp;gt; TO &amp;lt;data&amp;gt;.&lt;/P&gt;&lt;P&gt;            IF SY-SUBRC NE 0.&lt;/P&gt;&lt;P&gt;               EXIT.&lt;/P&gt;&lt;P&gt;           ENDIF.&lt;/P&gt;&lt;P&gt;        ENDDO.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 11:36:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388951#M1545108</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-11-04T11:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388952#M1545109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't find these DDIC elements in my system. Are these specific to MDM? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway why don't you create an internal table of REF TO DATA &amp;amp; store the data references(via GET REFERENCE) as lines of the internal table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the example provided in this SAP online documentation for further details:[http://help.sap.com/abapdocu_70/en/ABAPGET_REFERENCE.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 11:36:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388952#M1545109</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-11-04T11:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic variable creation.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388953#M1545110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello you can try like this. Make changes as necessary . Just in se11 search for data element * XX * and use the required one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA:li_index(2) TYPE n,
wf_str TYPE REF TO data.

FIELD-SYMBOLS:&amp;lt;fs&amp;gt; TYPE ANY.

DATA:lf_element TYPE REF TO cl_abap_elemdescr,
i_tot_comp TYPE cl_abap_structdescr=&amp;gt;component_table,
la_comp LIKE LINE OF i_tot_comp ,
lf_new_type TYPE REF TO cl_abap_structdescr.

DO 10 TIMES.
  CLEAR i_tot_comp[].
  li_index = sy-index.
  lf_element ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'CNTXX_KK' ).
  CONCATENATE 'CNT' li_index '_KK' INTO la_comp-name.
  la_comp-type =
    cl_abap_elemdescr=&amp;gt;get_i(  ).
  APPEND la_comp TO i_tot_comp.
  TRY.
      lf_new_type = cl_abap_structdescr=&amp;gt;create( i_tot_comp ).
    CATCH cx_sy_struct_creation .                       "#EC NO_HANDLER
  ENDTRY.
  CREATE DATA wf_str TYPE HANDLE lf_new_type.
  ASSIGN wf_str-&amp;gt;* TO &amp;lt;fs&amp;gt;.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Nov 2010 11:36:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-variable-creation/m-p/7388953#M1545110</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-11-04T11:36:35Z</dc:date>
    </item>
  </channel>
</rss>

