<?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 development: assignment with = if the fieldname should be variable in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628683#M1571006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;T_Z1DB6PERF-VALUE = T_DB6PMST4-(field).   "does not work :-(&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt; use field-symbols&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Mar 2011 18:03:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-03-02T18:03:35Z</dc:date>
    <item>
      <title>dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628681#M1571004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Developer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a challenge in "dynamic development", and believe there are people out there for whom this is absolutely no problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After calling the function 'DB6_PM_1ST4' I get back an internal table with exactly one single line, but many many fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For download and further processing I want to to split this up into a 2nd internal table with SID, DATE, KEY and VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the content of the 1st table looked like:&lt;/P&gt;&lt;P&gt;"20101011150647" | "20101018040059" | "" | "0" | "25165824" | ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I want to convert this into:&lt;/P&gt;&lt;P&gt;"PBW" | "2010/10/18" | "DBMSTRTTME" | "20101011150647" &lt;/P&gt;&lt;P&gt;"PBW" | "2010/10/18" | "COMPTIME" | "20101018040059"&lt;/P&gt;&lt;P&gt;"PBW" | "2010/10/18" | "LAST_RESET" | ""   &lt;/P&gt;&lt;P&gt;"PBW" | "2010/10/18" | "BUFFPAGE" | "0"    &lt;/P&gt;&lt;P&gt;"PBW" | "2010/10/18" | "BP_SZ" | "25165824"... &lt;/P&gt;&lt;P&gt;u2026&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've started with the following code but got stuck.&lt;/P&gt;&lt;P&gt;The problem is in the assignment to T_Z1DB6PERF-VALUE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be great if someone could help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*-----------------------------------------------------------------------
* find out fields of structure DB6PM1ST4
TABLES: DD03L.
TYPES: BEGIN OF T_FIELDNAME,
         fieldname TYPE DD03L-FIELDNAME,
       END OF T_FIELDNAME.
data:   T_FIELDS type standard table of T_FIELDNAME with header line.

select FIELDNAME from DD03L into corresponding fields of TABLE T_FIELDS
         where TABNAME = 'DB6PM1ST4'.

*----------------------------------------------------------------------
* call the function
  CALL FUNCTION 'DB6_PM_1ST4'
    EXPORTING
      ACTION  =      12
      PARTITN =      0
    TABLES
      IT_DB6PM1ST4          = T_DB6PM1ST4
    EXCEPTIONS
      ERROR_CALCULATING     = 1
      INVALID_PARAMETER_SET = 2
      ADBC_ERROR            = 3
      others                = 4.
  RET = sy-subrc.
... 

*-----------------------------------------------------------------------
* add result to output structure
       T_Z1DB6PERF-SID = SY-SID.
       T_Z1DB6PERF-DATE = SY-DATUM.
       loop at T_FIELDS.
           field = t_fields-fieldname.

           T_Z1DB6PERF-KEY  = field.
           T_Z1DB6PERF-VALUE = T_DB6PMST4-(field).   "does not work :-(
           append T_Z1DB6PERF.
...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 17:10:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628681#M1571004</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T17:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628682#M1571005</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;Since T_DB6PM1ST4 is a table you can't assign value like that, you have to take the value in work area than only you can assign.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the below code....&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
       loop at T_FIELDS.
           field = t_fields-fieldname.
            T_Z1DB6PERF-KEY  = field.
"you can loop here into work area  with where condition  or
"read the table with the key and take the value in a work Area through 
"work area assign the field values
           T_Z1DB6PERF-VALUE = wa_DB6PMST4-(field).   "Change of code
           append T_Z1DB6PERF.
         .............................
         endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Arbind&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Arbind Prasad on Mar 2, 2011 11:17 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Arbind Prasad on Mar 2, 2011 11:18 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 17:46:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628682#M1571005</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T17:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628683#M1571006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;T_Z1DB6PERF-VALUE = T_DB6PMST4-(field).   "does not work :-(&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt; use field-symbols&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 18:03:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628683#M1571006</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T18:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628684#M1571007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Sebastian:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already tried to use field-symbols, but somehow I did not get the syntax right ... so all attempts ended in a short dump ... could you please give me a code example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 18:34:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628684#M1571007</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T18:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628685#M1571008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Arbind,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is a bit confusing, because the T_DB6PM1ST4 of my original code example is already an internal table with a header line ^ work area:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; DATA:   T_DB6PM1ST4 TYPE STANDARD TABLE OF DB6PM1ST4 with header line.  
 DATA:   T_FIELDS type standard table of T_FIELDNAME with header line.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax error I get for the below code fragment is &lt;/P&gt;&lt;P&gt;&lt;EM&gt;The data object "T_DB6PM1ST4" does not have a component called "".&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please explain this further? Your help is really appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  loop at T_DB6PM1ST4.
    loop at T_FIELDS.
      field = T_FIELDS-FIELDNAME.
      T_Z1DB6PERF-KEY1  = field.
      T_Z1DB6PERF-VALUE = T_DB6PM1ST4-(field).
      append T_Z1DB6PERF.
    endloop.
  endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 18:51:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628685#M1571008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T18:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628686#M1571009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;some time ago i wrote some similiar routine...here are some relevant lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FIELD-SYMBOLS: &amp;lt;fs_excel&amp;gt; TYPE alsmex_tabline,
                                  &amp;lt;campo&amp;gt; TYPE ANY.


" gt_excel has fields: row, col and value.
  LOOP AT gt_excel ASSIGNING &amp;lt;fs_excel&amp;gt;.


" gt_camposcarga contains a list of fields to be filled from the excel file
"  looks like this: 
" orden |   destino
"      1   |    bukrs
"      2   |   belnr


    READ TABLE gt_camposcarga INTO gs_camposcarga WITH KEY orden = &amp;lt;fs_excel&amp;gt;-col.
    IF sy-subrc NE 0.
      MESSAGE e003.
    ENDIF.



ASSIGN COMPONENT gs_camposcarga-destino OF STRUCTURE &amp;lt;gs_dynamic&amp;gt; TO &amp;lt;campo&amp;gt;.
    TRY .
        &amp;lt;campo&amp;gt; = &amp;lt;fs_excel&amp;gt;-value.
      CATCH cx_sy_conversion_no_number.
        MESSAGE e004 WITH &amp;lt;fs_excel&amp;gt;-col &amp;lt;fs_excel&amp;gt;-row.
    ENDTRY.
    AT END OF row.
      IF &amp;lt;gs_dynamic&amp;gt; IS NOT INITIAL.
        PERFORM conv_routines.

        INSERT &amp;lt;gs_dynamic&amp;gt; INTO TABLE &amp;lt;gt_dynamic&amp;gt;.
        CLEAR &amp;lt;gs_dynamic&amp;gt;.
      ENDIF.
    ENDAT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 19:01:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628686#M1571009</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-02T19:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628687#M1571010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if your problem is just at this statement then try this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:lv type char100.
field-symbols:&amp;lt;fs&amp;gt; type any.
  loop at T_DB6PM1ST4.
    loop at T_FIELDS.
      field = T_FIELDS-FIELDNAME.
      T_Z1DB6PERF-KEY1  = field.
      concatenate 'T_DB6PM1ST4-' field into lv.
      condense lv no-gaps.
      assign (lv) to &amp;lt;fs&amp;gt;.
      if &amp;lt;fs&amp;gt; is assigned.
      T_Z1DB6PERF-VALUE = &amp;lt;fs&amp;gt;.
      endif.
      append T_Z1DB6PERF.
    endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data:lv type char100.
field-symbols:&amp;lt;fs&amp;gt; type any.
  loop at T_DB6PM1ST4.
    loop at T_FIELDS.
      field = T_FIELDS-FIELDNAME.
      T_Z1DB6PERF-KEY1  = field.
      assign component T_Z1DB6PERF-KEY1  of structure T_DB6PM1ST4 to &amp;lt;fs&amp;gt;.
      if &amp;lt;fs&amp;gt; is assigned.
      T_Z1DB6PERF-VALUE = &amp;lt;fs&amp;gt;.
      endif.
      append T_Z1DB6PERF.
    endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 19:12:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628687#M1571010</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-03-02T19:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic development: assignment with = if the fieldname should be variable</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628688#M1571011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks to everybody who helped me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The credits goes to &lt;U&gt;Keshav.T&lt;/U&gt;&lt;/P&gt;&lt;P&gt;His code fragment worked perfectly for my purpose. &lt;/P&gt;&lt;P&gt;Again, many thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
field-symbols:&amp;lt;fs&amp;gt; type any.
  loop at T_DB6PM1ST4.
    loop at T_FIELDS.
      field = T_FIELDS-FIELDNAME.
      T_Z1DB6PERF-KEY1  = field.
      assign component T_Z1DB6PERF-KEY1  of structure T_DB6PM1ST4 to &amp;lt;fs&amp;gt;.
      if &amp;lt;fs&amp;gt; is assigned.
      T_Z1DB6PERF-VALUE = &amp;lt;fs&amp;gt;.
      endif.
      append T_Z1DB6PERF.
    endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Mar 2011 07:52:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-development-assignment-with-if-the-fieldname-should-be-variable/m-p/7628688#M1571011</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-03T07:52:03Z</dc:date>
    </item>
  </channel>
</rss>

