<?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 write dynamic table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417450#M820759</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help me with this.&lt;/P&gt;&lt;P&gt;i have a dynamic table and my output should be in a report format (write:).&lt;/P&gt;&lt;P&gt;how can i WRITE the output using the dynamic table? and another thing, i should write the heading or the column names also...&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;Material Number----&lt;DEL&gt;Material Type&lt;/DEL&gt;-----Material Description    -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;column names&lt;/P&gt;&lt;P&gt;  0000000012--&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;&lt;HR originaltext="--------" /&gt;XXXX--&lt;P&gt;&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;YYYYYY            -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Feb 2008 07:59:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-20T07:59:59Z</dc:date>
    <item>
      <title>write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417450#M820759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help me with this.&lt;/P&gt;&lt;P&gt;i have a dynamic table and my output should be in a report format (write:).&lt;/P&gt;&lt;P&gt;how can i WRITE the output using the dynamic table? and another thing, i should write the heading or the column names also...&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;Material Number----&lt;DEL&gt;Material Type&lt;/DEL&gt;-----Material Description    -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;column names&lt;/P&gt;&lt;P&gt;  0000000012--&lt;DEL&gt;&lt;/DEL&gt;&lt;/P&gt;&lt;HR originaltext="--------" /&gt;XXXX--&lt;P&gt;&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;YYYYYY            -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 07:59:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417450#M820759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T07:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417451#M820760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;we use Dynamic internal tables when we use ABAP oops&lt;/P&gt;&lt;P&gt;we create them by using Field symbols&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a few declarations to make:&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;table&amp;gt; type any.&lt;/P&gt;&lt;P&gt;types: fieldref type ref to data.&lt;/P&gt;&lt;P&gt;data: dyn_table type fieldref.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the actual code to generate the table:&lt;/P&gt;&lt;P&gt;create data dyn_table type (SAP Table).&lt;/P&gt;&lt;P&gt;assign dyn_table-&amp;gt;* to table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table is now a field symbol which can be referenced in the normal way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check out this prg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZCLUST1 . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: how to create a dynamic internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dynamic internal table stucture &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF STRUCT OCCURS 10, 
FILDNAME(8) TYPE C, 
ABPTYPE TYPE C, 
LENGTH TYPE I, 
END OF STRUCT. 


The dynamic program source table 
DATA: BEGIN OF INCTABL OCCURS 10, 
LINE(72), 
END OF INCTABL. 

DATA: LNG TYPE I, TYPESRTING(6). 


Sample dynamic internal table stucture 
STRUCT-FILDNAME = 'field1'. STRUCT-ABPTYPE = 'c'. STRUCT-LENGTH = '6'. 
APPEND STRUCT. CLEAR STRUCT. 

STRUCT-FILDNAME = 'field2'. STRUCT-ABPTYPE = 'd'. 
APPEND STRUCT. CLEAR STRUCT. 

STRUCT-FILDNAME = 'field3'. STRUCT-ABPTYPE = 'i'. 
APPEND STRUCT. CLEAR STRUCT. 


Create the dynamic internal table definition in the dyn. program 
INCTABL-LINE = 'program zdynpro.'. APPEND INCTABL. 
INCTABL-LINE = 'data: begin of dyntab occurs 10,'. APPEND INCTABL. 

LOOP AT STRUCT. 
INCTABL-LINE = STRUCT-FILDNAME. 
LNG = STRLEN( STRUCT-FILDNAME ). 

IF NOT STRUCT-LENGTH IS INITIAL . 
TYPESRTING(1) = '('. 
TYPESRTING+1 = STRUCT-LENGTH. 
TYPESRTING+5 = ')'. 
CONDENSE TYPESRTING NO-GAPS. 
INCTABL-LINE+LNG = TYPESRTING. 
ENDIF. 

INCTABL-LINE+15 = 'type '. 
INCTABL-LINE+21 = STRUCT-ABPTYPE. 
INCTABL-LINE+22 = ','. 
APPEND INCTABL. 
ENDLOOP. 
INCTABL-LINE = 'end of dyntab. '. 
APPEND INCTABL. 


Create the code processes the dynamic internal table 
INCTABL-LINE = ' '. APPEND INCTABL. 
INCTABL-LINE = 'dyntab-field1 = ''aaaaaa''.'. APPEND INCTABL. 
INCTABL-LINE = 'dyntab-field1 = ''19970814''.'. APPEND INCTABL. 
INCTABL-LINE = 'dyntab-field1 = 1.'. APPEND INCTABL. 
INCTABL-LINE = 'append dyntab.'. APPEND INCTABL. 
INCTABL-LINE = ' '. APPEND INCTABL. 
INCTABL-LINE = 'loop at dyntab.'. APPEND INCTABL. 
INCTABL-LINE = 'write: / dyntab.'. APPEND INCTABL. 
INCTABL-LINE = 'endloop.'. APPEND INCTABL. 


Create and run the dynamic program 
INSERT REPORT 'zdynpro'(001) FROM INCTABL. 
SUBMIT ZDYNPRO.
--------------------------------------------------------------------------------
 
or Just try out this simpler dynamic internal tables 

DATA: itab TYPE STANDARD TABLE OF spfli, 
wa LIKE LINE OF itab. 

DATA: line(72) TYPE c, 
list LIKE TABLE OF line(72). 

START-OF-SELECTION. 
*line = ' CITYFROM CITYTO '. 
line = ' AIRPTO '. 
APPEND line TO list. 

SELECT DISTINCT (list) 
INTO CORRESPONDING FIELDS OF TABLE itab 
FROM spfli. 

IF sy-subrc EQ 0. 
LOOP AT itab INTO wa. 

WRITE: / wa-cityfrom, wa-cityto. 
WRITE :/ wa-airpto. 
ENDLOOP. 
ENDIF. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;for more info visit&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/ab030.htm" target="test_blank"&gt;http://www.sap-img.com/ab030.htm&lt;/A&gt; &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;Chandru&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 08:02:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417451#M820760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T08:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417452#M820761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check out the below code&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lw_fieldvalue(40) TYPE c,
lw_fieldname(30) TYPE c.

gwa_output TYPE REF TO data.

FIELD-SYMBOLS: &amp;lt;gwa_output&amp;gt; TYPE ANY.

FIELD-SYMBOLS: &amp;lt;l_fvalue&amp;gt; TYPE ANY.


*---Create a pointer to store the workarea of the final output table.
CREATE DATA gwa_output LIKE LINE OF &amp;lt;git_output&amp;gt;.(this is the output table)


*---Assign it to a fieldsymbol which will be used in populating the
*---final output table.
ASSIGN gwa_output-&amp;gt;* TO &amp;lt;gwa_output&amp;gt;.


Loop at i_tab into wa_tab.

move wa_tab-field1 to v_fieldvalue. (moving the first field value into field value variable).

CONDENSE v_fieldvalue NO-GAPS. (Condense the output).

CLEAR: &amp;lt;gwa_output&amp;gt;.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE &amp;lt;gwa_output&amp;gt; TO &amp;lt;l_fvalue&amp;gt;.
&amp;lt;l_fvalue&amp;gt; = V_fieldvalue.



Repeat the same with other fields



*---Append the current record to final output table.
APPEND &amp;lt;gwa_output&amp;gt; TO &amp;lt;git_output&amp;gt;.

endloop.

You need to assign the component of table &amp;lt;dyn_Tab&amp;gt; to field symbol and than give value to that field symbol.

Like:

ASSIGN COMPONENT FLD1 OF STRUCTURE &amp;lt;DYN_TAB&amp;gt; TO &amp;lt;FS&amp;gt;.
&amp;lt;FS&amp;gt; = I_TAB-FLD1. 

Try this code, it generates field names dynamically





Example: how to create a dynamic internal table 
*

The dynamic internal table stucture 
DATA: BEGIN OF struct OCCURS 10,
fildname(8) TYPE c,
abptype TYPE c,
length TYPE i,
END OF struct.


The dynamic program source table 
DATA: BEGIN OF inctabl OCCURS 10,
line(72),
END OF inctabl.

DATA: lng TYPE i, typesrting(6).


Sample dynamic internal table stucture 
struct-fildname = 'field1'. struct-abptype = 'c'. struct-length = '6'.
APPEND struct. CLEAR struct.

struct-fildname = 'field2'. struct-abptype = 'd'.
APPEND struct. CLEAR struct.

struct-fildname = 'field3'. struct-abptype = 'i'.
APPEND struct. CLEAR struct.


Create the dynamic internal table definition in the dyn. program 
inctabl-line = 'program zdynpro.'. APPEND inctabl.
inctabl-line = 'data: begin of dyntab occurs 10,'. APPEND inctabl.

LOOP AT struct.
inctabl-line = struct-fildname.
lng = STRLEN( struct-fildname ).

IF NOT struct-length IS INITIAL .
typesrting(1) = '('.
typesrting+1 = struct-length.
typesrting+5 = ')'.
CONDENSE typesrting NO-GAPS.
inctabl-line+lng = typesrting.
ENDIF.

inctabl-line+15 = 'type '.
inctabl-line+21 = struct-abptype.
inctabl-line+22 = ','.
APPEND inctabl.
ENDLOOP.
inctabl-line = 'end of dyntab. '.
APPEND inctabl.


Create the code processes the dynamic internal table 
inctabl-line = ' '. APPEND inctabl.
inctabl-line = 'dyntab-field1 = ''aaaaaa''.'. APPEND inctabl.
inctabl-line = 'dyntab-field2 = ''19970814''.'. APPEND inctabl.
inctabl-line = 'dyntab-field3 = 1.'. APPEND inctabl.
inctabl-line = 'append dyntab.'. APPEND inctabl.
inctabl-line = ' '. APPEND inctabl.
inctabl-line = 'loop at dyntab.'. APPEND inctabl.
inctabl-line = 'write: / dyntab-field1, dyntab-field2, dyntab-field3.'.
APPEND inctabl.
inctabl-line = 'endloop.'. APPEND inctabl.


Create and run the dynamic program 
INSERT REPORT 'ZDYNPRO' FROM inctabl.
IF sy-subrc = 0.
SUBMIT zdynpro.

ELSE.
WRITE : / 'error'.
ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandru&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 08:03:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417452#M820761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417453#M820762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;i already created the dynamic table and populated the values. i just have to have a report output using WRITE statement..&lt;/P&gt;&lt;P&gt;how can i WRITE the output using the dynamic table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks..:-)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 08:05:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417453#M820762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T08:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417454#M820763</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;just a clarification, the fieldnames should not be like MATNR of MAKTX. it should be like: Material number (for matnr), Material description...i believe it's in the field SELTEXT or column identifier of structure LVC_S_FCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can i also write that one?before i write the values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 08:12:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417454#M820763</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T08:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: write dynamic table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417455#M820764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;To Output material Number instead of MATNR then you must use SELECTION TEXT.&lt;/P&gt;&lt;P&gt;For this you need to &lt;/P&gt;&lt;P&gt;1. go to the Goto tab on the menu bar select Selection Text &lt;/P&gt;&lt;P&gt;2. If you have already activated the program then all the fields will be available there if not then enter manually and &lt;/P&gt;&lt;P&gt;3. If you want to display the names available for the fields in the  dictionary  then tick the checkbox in the last column&lt;/P&gt;&lt;P&gt;4. if you want to display your own name for that field enter the name manaully without selecting the checkbox.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandru&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2008 08:21:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/write-dynamic-table/m-p/3417455#M820764</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-20T08:21:08Z</dc:date>
    </item>
  </channel>
</rss>

