<?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: create new fields dynamically in nested structure in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399417#M1546673</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi MARCIN,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Real thanks for the document. I will try my best to understand and work out with that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Oct 2010 16:13:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-10-15T16:13:45Z</dc:date>
    <item>
      <title>create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399406#M1546662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i have nested structure.&lt;/P&gt;&lt;P&gt;like structure A&lt;/P&gt;&lt;P&gt;      feild1 &lt;/P&gt;&lt;P&gt;      field2&lt;/P&gt;&lt;P&gt;      field3 type structure B,----&amp;gt;nested&lt;/P&gt;&lt;P&gt;       &lt;/P&gt;&lt;P&gt;and structure B,&lt;/P&gt;&lt;P&gt;       field4 type structure C.------&amp;gt;nested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;structure c,&lt;/P&gt;&lt;P&gt;      field5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i wanted to add 3 new fields dynamically to  structure C, so finally structure A ,B should be same but structure C ,should only should contain additional fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me out. What i did till now is getting the components and then appending 3 new fields . but this 3 new fields are reflected as feilds of structure A, where as i need at structure C level.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 03:56:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399406#M1546662</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-14T03:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399407#M1546663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;tHIS IS THE STRUCTURE I AM USING IN MY PROGRAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Types: begin of ty_struct3,&lt;/P&gt;&lt;P&gt;           f5 type string,&lt;/P&gt;&lt;P&gt;           f6 type string,&lt;/P&gt;&lt;P&gt;          end of ty_struct3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types:begin of ty_struct2,&lt;/P&gt;&lt;P&gt;          f4 type ty_struct3,&lt;/P&gt;&lt;P&gt;          end of ty_struct2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Types; begin of ty_struct1,&lt;/P&gt;&lt;P&gt;           f1 type string,&lt;/P&gt;&lt;P&gt;           f2 type string,&lt;/P&gt;&lt;P&gt;           f3 type ty_struct2,&lt;/P&gt;&lt;P&gt;           end of ty_struct1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Final structure should contains two additional fields after f5,f6. of ty_struct3.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 06:47:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399407#M1546663</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-14T06:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399408#M1546664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't change structure C without affecting A and B as long as they inlcude the former as their substructure. What I suggest is to get components of C, append new fields and generate new separate structure without affecting any of the above. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 07:06:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399408#M1546664</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-10-14T07:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399409#M1546665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok i will try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 09:49:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399409#M1546665</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-14T09:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399410#M1546666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you post the code please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 10:47:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399410#M1546666</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-14T10:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399411#M1546667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't think you can change original structure dynamically. It will be rather creating new one based on old one instead.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF gs_c,
        field1 TYPE c,
        field2 TYPE n,
      END OF gs_c.

DATA: gr_structdescr TYPE REF TO cl_abap_structdescr,
      gr_elemdescr   TYPE REF TO cl_abap_elemdescr.
DATA gt_components TYPE cl_abap_structdescr=&amp;gt;component_table WITH HEADER LINE.

DATA: gr_new_str TYPE REF TO data.

FIELD-SYMBOLS &amp;lt;new_str&amp;gt; TYPE ANY.

gr_structdescr ?= cl_abap_typedescr=&amp;gt;describe_by_data( gs_c ).
gt_components[] = gr_structdescr-&amp;gt;get_components( ).

"add new field3 of type I
gr_elemdescr = cl_abap_elemdescr=&amp;gt;get_i( ).
gt_components-name = 'FIELD3'.
gt_components-type = gr_elemdescr.
APPEND gt_components.

gr_structdescr = cl_abap_structdescr=&amp;gt;create( gt_components[] ).
CREATE DATA gr_new_str TYPE HANDLE gr_structdescr.
ASSIGN gr_new_str-&amp;gt;* TO &amp;lt;new_str&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 14:21:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399411#M1546667</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-10-14T14:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399412#M1546668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Marcin ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thats true. This is adding aadditional fields dynamically to one structure..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it means the requirement which i have is not feasible at all.?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 17:03:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399412#M1546668</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-14T17:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399413#M1546669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I doubt this is feasible at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regadrs&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Oct 2010 17:34:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399413#M1546669</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-10-14T17:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399414#M1546670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Marcin &amp;amp; Sreenu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AFAIK changing the structure of an existing TYPE is not possible. As mentioned you can get the components of the current structure &amp;amp; create a new one dynamically from it. I remember similar discussion in the forum long back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Watsay Marcin?&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>Fri, 15 Oct 2010 05:45:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399414#M1546670</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-15T05:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399415#M1546671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suhas,marcin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot. &lt;/P&gt;&lt;P&gt;Could you tell me whether  my below query is possible or not ?&lt;/P&gt;&lt;P&gt;lets think there is no structure at all. But at some place in my program i wanted to create the structures as mentioned above dynamically. &lt;/P&gt;&lt;P&gt;I have seen a article which creates complex structures at run time and also fills the values&lt;/P&gt;&lt;P&gt;This is the link.&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.sdn.sap.com/wiki/display/Snippets/Creating%20Flat%20and%20Complex%20Internal%20Tables%20Dynamically%20using%20RTTI" target="test_blank"&gt;https://wiki.sdn.sap.com/wiki/display/Snippets/Creating%20Flat%20and%20Complex%20Internal%20Tables%20Dynamically%20using%20RTTI&lt;/A&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Sreenu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 14:37:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399415#M1546671</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-15T14:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399416#M1546672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to create dynamically such nested strctues please refer my blog [Do you really know everything about typing? - part 2|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20887] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;. It describes the concept from scratch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marcin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 14:49:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399416#M1546672</guid>
      <dc:creator>MarcinPciak</dc:creator>
      <dc:date>2010-10-15T14:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399417#M1546673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi MARCIN,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Real thanks for the document. I will try my best to understand and work out with that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 16:13:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399417#M1546673</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-15T16:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399418#M1546674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI MARCIn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me out with the code? because when i am trying i am not getting the actual structure. I know i am missing many things . So please can post the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 17:26:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399418#M1546674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-15T17:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399419#M1546675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI MARCIn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me out with the code? because when i am trying i am not getting the actual structure. I know i am missing many things . So please can post the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 17:27:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399419#M1546675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-15T17:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399420#M1546676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI MARCIn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me out with the code? because when i am trying i am not getting the actual structure. I know i am missing many things . So please can post the code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Oct 2010 17:27:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399420#M1546676</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-15T17:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399421#M1546677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi MARCIN,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to create nested one as given in the documents but could not succeed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ANyone one help me creating a final structure as given below dynamically.&lt;/P&gt;&lt;P&gt;Actually i need to generate an XML and i require this final structure in exact this way .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_msg,&lt;/P&gt;&lt;P&gt;          f3 ,&lt;/P&gt;&lt;P&gt;          f4,&lt;/P&gt;&lt;P&gt;          f5,&lt;/P&gt;&lt;P&gt;          end of ty_msg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_payload,&lt;/P&gt;&lt;P&gt;          msg type ty_msg,&lt;/P&gt;&lt;P&gt;          end of ty_payload,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my final structure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of ty_final,&lt;/P&gt;&lt;P&gt;         f1 ,&lt;/P&gt;&lt;P&gt;         f2,&lt;/P&gt;&lt;P&gt;        payload type ty_payload,&lt;/P&gt;&lt;P&gt;         end of ty_final.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reagrds&lt;/P&gt;&lt;P&gt;Sreenu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Oct 2010 06:49:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399421#M1546677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-16T06:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399422#M1546678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sreenu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the code snippet i'm attaching i'll try to create a nested structure(as shown below) dynamically:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:
BEGIN OF zc,
  f5 TYPE char4,
  f6 TYPE char4,
  f7 TYPE char4,
END OF zc,

BEGIN OF zb,
  f4 TYPE zc,
END OF zb,

BEGIN OF za,
  f1 TYPE char4,
  f2 TYPE char4,
  f3 TYPE zb,
END OF za.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code snippet:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Step 1: Fill the COMPONENTS table for the innermost structure &amp;amp; move
* upwards (i.e., in this sequence ZC -&amp;gt; ZB -&amp;gt; ZA)

* Step 1.1: Create the innermost structure(i.e., ZC)
DATA: it_comp TYPE cl_abap_structdescr=&amp;gt;component_table,
      wa_comp TYPE cl_abap_structdescr=&amp;gt;component,
      go_elem TYPE REF TO cl_abap_elemdescr.

TRY .
    go_elem = cl_abap_elemdescr=&amp;gt;get_c( 4 ).
  CATCH cx_parameter_invalid_range.
ENDTRY.

wa_comp-name = 'F5'.
wa_comp-type = go_elem. "f5 TYPE char4
APPEND wa_comp TO  it_comp.
CLEAR wa_comp.

wa_comp-name = 'F6'.
wa_comp-type = go_elem. "f6 TYPE char4
APPEND wa_comp TO  it_comp.
CLEAR wa_comp.

wa_comp-name = 'F7'.
wa_comp-type = go_elem. "f7 TYPE char4
APPEND wa_comp TO  it_comp.
CLEAR wa_comp.

DATA: go_struc_zc TYPE REF TO cl_abap_structdescr.

TRY .
    go_struc_zc = cl_abap_structdescr=&amp;gt;create( it_comp ).
    CLEAR it_comp.
  CATCH cx_sy_struct_creation.
ENDTRY.

* Step 1.2: Move one step up &amp;amp; create the next structure(i.e., ZB)
wa_comp-name = 'F4'.
wa_comp-type = go_struc_zc. "f4 TYPE zc
APPEND wa_comp TO it_comp.
CLEAR wa_comp.

DATA: go_struc_zb TYPE REF TO cl_abap_structdescr.

TRY .
    go_struc_zb = cl_abap_structdescr=&amp;gt;create( it_comp ).
    CLEAR it_comp.
  CATCH cx_sy_struct_creation.
ENDTRY.

* Step 1.3: Move one step up &amp;amp; create the next structure(i.e., ZA)
wa_comp-name = 'F1'.
wa_comp-type = go_elem. "f1 TYPE char4
APPEND wa_comp TO  it_comp.
CLEAR wa_comp.

wa_comp-name = 'F2'.
wa_comp-type = go_elem. "f2 TYPE char4
APPEND wa_comp TO  it_comp.
CLEAR wa_comp.

wa_comp-name = 'F3'.
wa_comp-type = go_struc_zb. "f3 TYPE zb
APPEND wa_comp TO it_comp.
CLEAR wa_comp.

DATA: go_struc_za TYPE REF TO cl_abap_structdescr.

TRY .
    go_struc_za = cl_abap_structdescr=&amp;gt;create( it_comp ).
    CLEAR it_comp.
  CATCH cx_sy_struct_creation.
ENDTRY.

* Step 2: Use the RTTC object generated to get the dynamic nested struc

* Step 2.1: Create the dynamic data object based on the RTTC object
DATA: do_nested_struc TYPE REF TO data.
CREATE DATA do_nested_struc TYPE HANDLE go_struc_za.

* Step 2.2: Dereference the data object
FIELD-SYMBOLS &amp;lt;st_nested&amp;gt; TYPE ANY.
ASSIGN do_nested_struc-&amp;gt;* TO &amp;lt;st_nested&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can check the structure &amp;lt;ST_NESTED&amp;gt; in the debugger &amp;amp; see that it is identical to the statically defined structure ZA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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>Sat, 16 Oct 2010 15:20:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399422#M1546678</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-10-16T15:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399423#M1546679</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;Thanks a lot..Its great.No words man. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you help me in filling the values and appending to an itnernal table. You have helped me in my last post.&lt;/P&gt;&lt;P&gt;But here i am not able to fill vales  in the nested structure 'ZC'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I finally need to append an internal table of type 'ZA'..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sreenu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Oct 2010 05:37:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399423#M1546679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-17T05:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields dynamically in nested structure</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399424#M1546680</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;A real thanks . i really appreciate your help. I am able to populate the values in the nested structure and finally able to append to internal able as needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to MARCIN also for providing such good document link &lt;/P&gt;&lt;P&gt;I never did dynamic programming till i got the requirement. And you guys helped me all the way with code .&lt;/P&gt;&lt;P&gt;Thanks for helping.keep it up&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;&lt;/P&gt;&lt;P&gt;Sreenu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Oct 2010 07:57:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-new-fields-dynamically-in-nested-structure/m-p/7399424#M1546680</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-18T07:57:20Z</dc:date>
    </item>
  </channel>
</rss>

