<?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 get field name from dynamic structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667034#M1447184</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dynamic structure of a dynamic table.  I want to loop thru table and check if there is field name 'ABC' exist in the structure.  If it exists, depending on value of the field I will change value of another field in the structure.  &lt;/P&gt;&lt;P&gt;For example if field struct-fieldname = 'ABC ' and field value = 'S', I will display field XYZ (struct-xyz) as positive, otherwise display as negative.  Can this be achieved using dynamic structure and dynamic table via field symbol?  Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Feb 2010 04:12:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-02-25T04:12:09Z</dc:date>
    <item>
      <title>get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667034#M1447184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dynamic structure of a dynamic table.  I want to loop thru table and check if there is field name 'ABC' exist in the structure.  If it exists, depending on value of the field I will change value of another field in the structure.  &lt;/P&gt;&lt;P&gt;For example if field struct-fieldname = 'ABC ' and field value = 'S', I will display field XYZ (struct-xyz) as positive, otherwise display as negative.  Can this be achieved using dynamic structure and dynamic table via field symbol?  Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2010 04:12:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667034#M1447184</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-25T04:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667035#M1447185</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;&lt;/P&gt;&lt;P&gt;try like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;        ls_comp    type abap_componentdescr,&lt;/P&gt;&lt;P&gt;        ls_stru    type ref to cl_abap_structdescr,&lt;/P&gt;&lt;P&gt;        lt_comp    type standard table of abap_componentdescr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ls_stru ?= cl_abap_typedescr=&amp;gt;describe_by_data(&amp;lt;FS1&amp;gt;).&lt;/P&gt;&lt;P&gt;  lt_comp = ls_stru-&amp;gt;get_components( ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;internal table lt_comp with have both field name , values as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at lt_comp into ls_comp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ls_comp-name  --&amp;gt;fieldname&lt;/P&gt;&lt;P&gt;    assign component sy-tabix&lt;/P&gt;&lt;P&gt;        of structure i_copaitem&lt;/P&gt;&lt;P&gt;                  to &amp;lt;fs_value&amp;gt;.---&amp;gt;fieldvalue&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Prabhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2010 05:26:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667035#M1447185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-25T05:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667036#M1447186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt; you can use the below code snippet &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;lv_value&amp;gt; TYPE any.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ASSIGN COMPONENT 'ABC' of STRUCTURE struc to &amp;lt;lv_value&amp;gt;.&lt;/P&gt;&lt;P&gt;    IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;      IF &amp;lt;lv_value&amp;gt; IS INITIAL.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;   ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will read the value of field 'ABC' from your structure to &amp;lt;lv_value&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Mar 2010 11:57:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667036#M1447186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-10T11:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667037#M1447187</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;You can try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA:       tb_struct TYPE REF TO cl_abap_structdescr,
      tb_comp   TYPE        abap_component_tab.

* Populate the fields of wa_pc_model_data2
  tb_struct ?=
  cl_abap_typedescr=&amp;gt;describe_by_data( wa_pc_model_data2 ).

  LOOP AT tb_struct-&amp;gt;components ASSIGNING &amp;lt;fs_components&amp;gt;.
    wf_var1 = &amp;lt;fs_components&amp;gt;-name.

    PERFORM fill_fields  USING    wf_var1
                                  wa_pc_model_data2
                         CHANGING wf_update_coc.
    CLEAR: wf_var1.
  ENDLOOP.

  CLEAR tb_struct.
  UNASSIGN: &amp;lt;fs_components&amp;gt;,
            &amp;lt;fs&amp;gt;,
            &amp;lt;fs_name&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM fill_fields USING    pf_wf_var1
                          pf_wa_pc_data_field
                 CHANGING pf_wf_update_coc.

** Assign the component of the structure to the field symbol
  ASSIGN COMPONENT pf_wf_var1
    OF STRUCTURE pf_wa_pc_data_field TO &amp;lt;fs_name&amp;gt;.
  IF sy-subrc  = 0.

    ASSIGN COMPONENT pf_wf_var1
      OF STRUCTURE wa_coc_tech TO &amp;lt;fs&amp;gt;.
    IF sy-subrc = 0.

** Check if the IDOC data is filled
** Also check if the IDOC and database table data are same
      IF NOT &amp;lt;fs_name&amp;gt; IS INITIAL AND  "IDOC data
         &amp;lt;fs_name&amp;gt; NE &amp;lt;fs&amp;gt;.    "IDOC data NE database table data
        &amp;lt;fs&amp;gt; = &amp;lt;fs_name&amp;gt;.      "Update database field from IDOC field
        pf_wf_update_coc = 'X'. "Set the flag
      ENDIF.
    ENDIF.
  ENDIF.

ENDFORM.                    " fill_fields

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Mar 2010 09:05:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667037#M1447187</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-11T09:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667038#M1447188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, but your code gave me compilation errors due to no data definition for: &amp;lt;fs_components&amp;gt;&lt;/P&gt;&lt;P&gt;If I declare &amp;lt;fs_components&amp;gt; as any,&lt;/P&gt;&lt;P&gt;there will be no component name &amp;lt;fs_components&amp;gt;-name.&lt;/P&gt;&lt;P&gt;Also what is wf_var1, wf_update_coc?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I solved the problem.  I just loop at the dynamic structure check if the component field name 'XXX' and 'YYY' exist, if both field name exist,&lt;/P&gt;&lt;P&gt;then I can change value via command&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign component 'XXX' of structure &amp;lt;fs&amp;gt; to &amp;lt;fval&amp;gt;.&lt;/P&gt;&lt;P&gt;assign component 'YYY' of structure &amp;lt;fs&amp;gt; to &amp;lt;fval2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;lt;fval&amp;gt; = 'H'.&lt;/P&gt;&lt;P&gt;      &amp;lt;fval2&amp;gt; = &amp;lt;fval2&amp;gt; * - 1.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks all for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Mar 2010 14:19:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667038#M1447188</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-11T14:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: get field name from dynamic structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667039#M1447189</link>
      <description>&lt;P&gt;Hi Valerie,&lt;/P&gt;&lt;P&gt;Glad to hear you solved this issue but for those who are not aware you can declare &amp;lt;fs_components&amp;gt; as &amp;lt;fs_components&amp;gt; type abap_compdescr.&lt;/P&gt;&lt;P&gt;You can declare lv_name as string. &lt;/P&gt;&lt;P&gt;lv_name = &amp;lt;fs_components&amp;gt;-name.&lt;/P&gt;&lt;P&gt;So here in LV_NAME you will get the feild name of any dynamic Structure. Now using Assign Component you can get the values from the structure.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jayesh&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 15:42:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-field-name-from-dynamic-structure/m-p/6667039#M1447189</guid>
      <dc:creator>jayesh_mudaliar</dc:creator>
      <dc:date>2020-03-17T15:42:37Z</dc:date>
    </item>
  </channel>
</rss>

