<?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 Nested structures within ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681295#M300257</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 am working on an ABAP report where the output file will need to look something like:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Material No, Description&lt;/P&gt;&lt;P&gt;2 EAN, ...&lt;/P&gt;&lt;P&gt;3 ..., ..., ...&lt;/P&gt;&lt;P&gt;3 ..., ..., ...&lt;/P&gt;&lt;P&gt;4 ..., ..., ...&lt;/P&gt;&lt;P&gt;4 ..., ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some of the record types will only have one line and others will have multiple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to create an internal table into which I could extract all of the relevant data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this, I was thinking of setting up my internal table as a nested structure so I would define some types for each record type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_1&lt;/P&gt;&lt;P&gt; matnr like mara-matnr&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; end of rec_type_1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_2&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; end of rec_type_2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then I could declare my internal table something like:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab&lt;/P&gt;&lt;P&gt;  rec1 type rec_type_1&lt;/P&gt;&lt;P&gt;  rec2 type rec_type_2&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;end of itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could then extract the relevant information for each material into the appropriate record types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work OK for all the record types where this is only going to be 1 line per material but I am not sure how to extend this for the record structures for which there will be multiple lines per material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking of declaring a table and then adding this as an element into the itan structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will this work? And does anyone have any code samples of this sort of thing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ruby&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 Oct 2006 12:47:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-23T12:47:55Z</dc:date>
    <item>
      <title>Nested structures within ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681295#M300257</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 am working on an ABAP report where the output file will need to look something like:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 Material No, Description&lt;/P&gt;&lt;P&gt;2 EAN, ...&lt;/P&gt;&lt;P&gt;3 ..., ..., ...&lt;/P&gt;&lt;P&gt;3 ..., ..., ...&lt;/P&gt;&lt;P&gt;4 ..., ..., ...&lt;/P&gt;&lt;P&gt;4 ..., ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some of the record types will only have one line and others will have multiple.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was hoping to create an internal table into which I could extract all of the relevant data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this, I was thinking of setting up my internal table as a nested structure so I would define some types for each record type&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_1&lt;/P&gt;&lt;P&gt; matnr like mara-matnr&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; end of rec_type_1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_2&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt; end of rec_type_2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then I could declare my internal table something like:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab&lt;/P&gt;&lt;P&gt;  rec1 type rec_type_1&lt;/P&gt;&lt;P&gt;  rec2 type rec_type_2&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;end of itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could then extract the relevant information for each material into the appropriate record types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work OK for all the record types where this is only going to be 1 line per material but I am not sure how to extend this for the record structures for which there will be multiple lines per material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking of declaring a table and then adding this as an element into the itan structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will this work? And does anyone have any code samples of this sort of thing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ruby&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 12:47:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681295#M300257</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T12:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Nested structures within ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681296#M300258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;U seem to be on the right track...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your itab you can include a field called rectype, where you store the record type.ex..1, 2,3 etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the output depending on the rectype you can print the particular fields from the internal table itab.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 12:55:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681296#M300258</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T12:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nested structures within ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681297#M300259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ruby,&lt;/P&gt;&lt;P&gt;  Your approach looks OK atleast in theory.&lt;/P&gt;&lt;P&gt;the declartion can be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types:     BEGIN OF MEEIN_PURCHASE_DOC_PRINT,&lt;/P&gt;&lt;P&gt;         XEKKO   LIKE EKKO,&lt;/P&gt;&lt;P&gt;         XPEKKO  LIKE PEKKO,&lt;/P&gt;&lt;P&gt;         XEKPA   like msgpa  occurs 0,&lt;/P&gt;&lt;P&gt;         XEKPO   LIKE EKPO  OCCURS 0,&lt;/P&gt;&lt;P&gt;         XPEKPO  LIKE PEKPO OCCURS 0,&lt;/P&gt;&lt;P&gt;         XEKET   LIKE EKET  OCCURS 0,&lt;/P&gt;&lt;P&gt;         Xekkn   like ekkn  occurs 0,&lt;/P&gt;&lt;P&gt;         Xekek   like ekek  occurs 0,&lt;/P&gt;&lt;P&gt;         Xekeh   like ekeh  occurs 0,&lt;/P&gt;&lt;P&gt;         XAEND   type meein_xaend occurs 0,&lt;/P&gt;&lt;P&gt;         xtkomv  type komv  occurs 0,&lt;/P&gt;&lt;P&gt;     END OF MEEIN_PURCHASE_DOC_PRINT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 12:55:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681297#M300259</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T12:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nested structures within ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681298#M300260</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 think so but it should be better you structure was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end of rec_type_1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: begin of rec_type_2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end of rec_type_2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types: t_rec_type1 type standard table of rec_type_1,&lt;/P&gt;&lt;P&gt;       t_rec_type2 type standard table of rec_type_2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;matnr type matnr,&lt;/P&gt;&lt;P&gt;rec1 type t_rec_type_1&lt;/P&gt;&lt;P&gt;rec2 type t_rec_type_2&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa1 type rec_type_1,&lt;/P&gt;&lt;P&gt;      wa2 type rec_type_2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB BY MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE ITAB-MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB-REC1 BY ...&lt;/P&gt;&lt;P&gt;LOOP AT ITAB-REC1 INTO WA1.&lt;/P&gt;&lt;P&gt;WRITE WA1.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB-REC2 BY ...&lt;/P&gt;&lt;P&gt;LOOP AT ITAB-REC2 INTO WA2.&lt;/P&gt;&lt;P&gt;WRITE WA2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&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;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 12:58:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681298#M300260</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T12:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Nested structures within ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681299#M300261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ruby,&lt;/P&gt;&lt;P&gt;you can define an internal tabel table in an internal table.&lt;/P&gt;&lt;P&gt;Here a short example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZGRO_TEST1 MESSAGE-ID ZZ.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;TABLES: MARA, MAKT.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF ITABX,&lt;/P&gt;&lt;P&gt;ATWRT LIKE AUSP-ATWRT,&lt;/P&gt;&lt;P&gt;END OF ITABX.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;DATA: WA_ITAB1 TYPE ITABX.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF ITAB OCCURS 0,&lt;/P&gt;&lt;P&gt;MATNR LIKE MARA-MATNR,&lt;/P&gt;&lt;P&gt;MAKTX LIKE MAKT-MAKTX,&lt;/P&gt;&lt;P&gt;ITAB1 TYPE TABLE OF ITABX,&lt;/P&gt;&lt;P&gt;END OF ITAB.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;SELECT * FROM MARA UP TO 10 ROWS.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;CLEAR: ITAB.&lt;/P&gt;&lt;P&gt;REFRESH: ITAB-ITAB1.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM MAKT WHERE MATNR = MARA-MATNR&lt;/P&gt;&lt;P&gt;AND SPRAS = SY-LANGU.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;ITAB-MATNR = MARA-MATNR.&lt;/P&gt;&lt;P&gt;ITAB-MAKTX = MAKT-MAKTX.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill this like you want&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;WA_ITAB1-ATWRT = '100'.&lt;/P&gt;&lt;P&gt;APPEND WA_ITAB1 TO ITAB-ITAB1.&lt;/P&gt;&lt;P&gt;WA_ITAB1-ATWRT = '200'.&lt;/P&gt;&lt;P&gt;APPEND WA_ITAB1 TO ITAB-ITAB1.&lt;/P&gt;&lt;P&gt;WA_ITAB1-ATWRT = '300'.&lt;/P&gt;&lt;P&gt;APPEND WA_ITAB1 TO ITAB-ITAB1.&lt;/P&gt;&lt;P&gt;WA_ITAB1-ATWRT = '400'.&lt;/P&gt;&lt;P&gt;APPEND WA_ITAB1 TO ITAB-ITAB1.*&lt;/P&gt;&lt;P&gt;APPEND ITAB.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;WRITE: / ITAB-MATNR, ITAB-MAKTX.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB-ITAB1 INTO WA_ITAB1.&lt;/P&gt;&lt;P&gt;WRITE: WA_ITAB1-ATWRT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;END-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2006 13:24:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-structures-within-abap/m-p/1681299#M300261</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-23T13:24:04Z</dc:date>
    </item>
  </channel>
</rss>

