<?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 typing error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468869#M554787</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;PRE&gt;&lt;CODE&gt;
  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = p_table
    changing
      ct_fieldcat      = i_fcat
    exceptions
      others           = 1.
  if sy-subrc = 0.
    loop at i_fcat assigning &amp;lt;fcat&amp;gt;.
      &amp;lt;fcat&amp;gt;-tabname = p_table.
    endloop.
    call function 'LVC_FIELDCAT_COMPLETE'
      changing
        ct_fieldcat = i_fcat
      exceptions
        others      = 1.
  else.
    write: 'Error building field catalog'.
    stop.
  endif.

  call method cl_alv_table_create=&amp;gt;create_dynamic_table
    exporting
      it_fieldcatalog = i_fcat
    importing
      ep_table        = i_content.
  if sy-subrc = 0.
    assign i_content-&amp;gt;* to &amp;lt;ptab&amp;gt;.
  else.
    write: 'Error creating internal table'.
    stop.
  endif.

  create data dref1 type (p_table).
  assign dref1-&amp;gt;* to &amp;lt;xtab&amp;gt;.

  field-symbols : &amp;lt;l_f3&amp;gt; type any,
                  &amp;lt;l_f4&amp;gt; type any.

  
  loop at &amp;lt;ptab&amp;gt; assigning &amp;lt;xtab&amp;gt;.
     read table i_fcat assigning &amp;lt;fcat&amp;gt; with key
                                  tabname = p_table
                                  fieldname = 'SUBST_C'.
    if sy-subrc eq 0.
     assign component &amp;lt;fcat&amp;gt;-col_id of structure &amp;lt;xtab&amp;gt; to &amp;lt;l_f3&amp;gt;.
     if &amp;lt;l_f3&amp;gt; is initial.
                               " Do your code here         
     endif.
    endif.
  endloop.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jun 2007 02:38:03 GMT</pubDate>
    <dc:creator>former_member194669</dc:creator>
    <dc:date>2007-06-28T02:38:03Z</dc:date>
    <item>
      <title>Dynamic typing error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468868#M554786</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'm trying to build a generic application to check values into any table.&lt;/P&gt;&lt;P&gt;But I'm facing the following problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fstable&amp;gt; TYPE table,&lt;/P&gt;&lt;P&gt;               &amp;lt;fscond&amp;gt; TYPE table,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs_line&amp;gt; TYPE ANY,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt; TYPE any,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt; TYPE any.&lt;/P&gt;&lt;P&gt;data: tipo(20) TYPE c VALUE '/FRE/SUBST_ASSMT'.&lt;/P&gt;&lt;P&gt;data:       dy_line  type ref to data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN it_data TO &amp;lt;fstable&amp;gt; CASTING TYPE (tipo).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  create data dy_line TYPE (tipo)."like line of &amp;lt;fstable&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt; CASTING TYPE (tipo).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP at &amp;lt;fstable&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;---&amp;gt;  if &amp;lt;dyn_wa&amp;gt;-subst_c = '0'.&lt;/P&gt;&lt;P&gt;--&amp;gt;    endif.&lt;/P&gt;&lt;P&gt;    do.&lt;/P&gt;&lt;P&gt;     assign component  sy-index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&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;    enddo.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's clear that since the variable is untyped I can not perform this check. SE80 says that there is no structure, therefore no component.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's say, I've got a table, MARA and I want to check if a field is 0, and then later on I have to check if MARC has field 'X' to 0... I want to reuse the code.&lt;/P&gt;&lt;P&gt;Any ideas how can achieve that?&lt;/P&gt;&lt;P&gt;Any help will be apprecitad,&lt;/P&gt;&lt;P&gt;Isidoro!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2007 15:09:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468868#M554786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-27T15:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic typing error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468869#M554787</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;PRE&gt;&lt;CODE&gt;
  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = p_table
    changing
      ct_fieldcat      = i_fcat
    exceptions
      others           = 1.
  if sy-subrc = 0.
    loop at i_fcat assigning &amp;lt;fcat&amp;gt;.
      &amp;lt;fcat&amp;gt;-tabname = p_table.
    endloop.
    call function 'LVC_FIELDCAT_COMPLETE'
      changing
        ct_fieldcat = i_fcat
      exceptions
        others      = 1.
  else.
    write: 'Error building field catalog'.
    stop.
  endif.

  call method cl_alv_table_create=&amp;gt;create_dynamic_table
    exporting
      it_fieldcatalog = i_fcat
    importing
      ep_table        = i_content.
  if sy-subrc = 0.
    assign i_content-&amp;gt;* to &amp;lt;ptab&amp;gt;.
  else.
    write: 'Error creating internal table'.
    stop.
  endif.

  create data dref1 type (p_table).
  assign dref1-&amp;gt;* to &amp;lt;xtab&amp;gt;.

  field-symbols : &amp;lt;l_f3&amp;gt; type any,
                  &amp;lt;l_f4&amp;gt; type any.

  
  loop at &amp;lt;ptab&amp;gt; assigning &amp;lt;xtab&amp;gt;.
     read table i_fcat assigning &amp;lt;fcat&amp;gt; with key
                                  tabname = p_table
                                  fieldname = 'SUBST_C'.
    if sy-subrc eq 0.
     assign component &amp;lt;fcat&amp;gt;-col_id of structure &amp;lt;xtab&amp;gt; to &amp;lt;l_f3&amp;gt;.
     if &amp;lt;l_f3&amp;gt; is initial.
                               " Do your code here         
     endif.
    endif.
  endloop.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aRs&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2007 02:38:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468869#M554787</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2007-06-28T02:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic typing error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468870#M554788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your solution is not bad, actually I like it, but I solved the problem in a different way. Have a look at:&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fstable&amp;gt; TYPE table,&lt;/P&gt;&lt;P&gt;               &amp;lt;fscond&amp;gt; TYPE table,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs_line&amp;gt; TYPE ANY,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt; TYPE any,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt; TYPE any.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;data:  lt_wheres         TYPE rsds_twhere,&lt;/P&gt;&lt;P&gt;       lrt_cond          TYPE STANDARD TABLE OF rsds_range,&lt;/P&gt;&lt;P&gt;       lrs_cond          LIKE LINE OF lrt_cond.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:  dy_line  type ref to data.&lt;/P&gt;&lt;P&gt;DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.&lt;/P&gt;&lt;P&gt;DATA: lt_comp TYPE cl_abap_structdescr=&amp;gt;component_table.&lt;/P&gt;&lt;P&gt;DATA: ls_comp LIKE LINE OF lt_comp.&lt;/P&gt;&lt;P&gt;data: campos type DDFIELDS,&lt;/P&gt;&lt;P&gt;      ls_campos LIKE LINE OF campos.&lt;/P&gt;&lt;P&gt;DATA: index TYPE i VALUE '1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Assign the dynamic structures.&lt;/P&gt;&lt;P&gt;ASSIGN it_data TO &amp;lt;fstable&amp;gt;.&lt;/P&gt;&lt;P&gt;create data dy_line like line of &amp;lt;fstable&amp;gt;.&lt;/P&gt;&lt;P&gt;assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*get the description of the elements from DDIC&lt;/P&gt;&lt;P&gt;lr_rtti_struc ?= cl_abap_structdescr=&amp;gt;DESCRIBE_BY_DATA_REF( dy_line ).&lt;/P&gt;&lt;P&gt;lr_rtti_struc-&amp;gt;GET_DDIC_FIELD_LIST( EXPORTING P_INCLUDING_SUBSTRUCTRES = 'X'&lt;/P&gt;&lt;P&gt;                                    RECEIVING P_FIELD_LIST = campos ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP at campos INTO ls_campos.&lt;/P&gt;&lt;P&gt;    if ls_campos-fieldname = 'SUBST_CTRL'.&lt;/P&gt;&lt;P&gt;      index = sy-tabix.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP at &amp;lt;fstable&amp;gt; INTO &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;    do.&lt;/P&gt;&lt;P&gt;     assign component  sy-index of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&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;if sy-index = index.&lt;/P&gt;&lt;P&gt;if  &amp;lt;dyn_field&amp;gt; = '3'.&lt;/P&gt;&lt;P&gt;  WRITE / 'OK!&lt;IMG src="'.

endif.
endif.
    enddo.
ENDLOOP.

But still, the awnser was interesting and helpfull, thanks,
Isidoro" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2007 10:55:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-typing-error/m-p/2468870#M554788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-28T10:55:33Z</dc:date>
    </item>
  </channel>
</rss>

