Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Moving data from internal table to Dynamic internal table

Former Member
0 Likes
2,358

Hello All,

I am facing a problem i moving the data from a internal table data to Dyn. internal table.

My code is as follows

*******Declartion**************************************

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.

DATA: IT_OUTTAB TYPE STANDARD TABLE OF ZVTEST.

DATA: WA_OUTTAB TYPE ZVTEST.

DATA: LV_LINE LIKE SY-TABIX,

COUNT TYPE I.

FIELD-SYMBOLS: <NEW_TABLE> TYPE REF TO DATA.

FIELD-SYMBOLS: <L_TABLE> TYPE ANY TABLE,

<L_LINE> TYPE ANY.

FIELD-SYMBOLS: <L_FIELD> TYPE ANY.

FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,

<FS_1> TYPE ANY TABLE,

<FS_2>,

<FS_3>.

DATA: NEW_LINE TYPE REF TO DATA.

DATA: LT_DATA TYPE REF TO DATA.

ASSIGN LT_DATA TO <FS_DATA>.

  • Create a new Table

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = IT_FIELDCAT

IMPORTING

EP_TABLE = <FS_DATA>

EXCEPTIONS

GENERATE_SUBPOOL_DIR_FULL = 1

OTHERS = 2.

IF SY-SUBRC = 0.

ASSIGN <FS_DATA>->* TO <FS_1>.

CREATE DATA NEW_LINE LIKE LINE OF <FS_1>.

      • A field-symbol to access that work area

ASSIGN NEW_LINE->* TO <FS_2>.

LOOP AT IT_OUTTAB INTO WA_OUTTAB.

MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.

ENDLoop.

But when I am using MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.

I am getting the error like

"<FS_1>" is not a structure or internal table with header line.

Please check the code and tell where I am making the mistake.

Regards,

Vasanth

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,213

Take a look at these blogs which does exactly the same.

I guess the error is right, becuase <FS_1> is declared as internal table.

You should MOVE-CORRESPONDING to <FS_2> and then append <FS_2> to <FS_1>.

Regards,

Ravi

Note Please mark the helpful answers

Message was edited by: Ravikumar Allampallam

Hello All,

I am facing a problem i moving the data from a internal table data to Dyn. internal table.

My code is as follows

*******Declartion**************************************

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.

DATA: IT_OUTTAB TYPE STANDARD TABLE OF ZVTEST.

DATA: WA_OUTTAB TYPE ZVTEST.

DATA: LV_LINE LIKE SY-TABIX,

COUNT TYPE I.

FIELD-SYMBOLS: <NEW_TABLE> TYPE REF TO DATA.

FIELD-SYMBOLS: <L_TABLE> TYPE ANY TABLE,

<L_LINE> TYPE ANY.

FIELD-SYMBOLS: <L_FIELD> TYPE ANY.

FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,

<FS_1> TYPE ANY TABLE,

<FS_2>,

<FS_3>.

DATA: NEW_LINE TYPE REF TO DATA.

DATA: LT_DATA TYPE REF TO DATA.

ASSIGN LT_DATA TO <FS_DATA>.

  • Create a new Table

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = IT_FIELDCAT

IMPORTING

EP_TABLE = <FS_DATA>

EXCEPTIONS

GENERATE_SUBPOOL_DIR_FULL = 1

OTHERS = 2.

IF SY-SUBRC = 0.

ASSIGN <FS_DATA>->* TO <FS_1>.

CREATE DATA NEW_LINE LIKE LINE OF <FS_1>.

      • A field-symbol to access that work area

ASSIGN NEW_LINE->* TO <FS_2>.

LOOP AT IT_OUTTAB INTO WA_OUTTAB.

MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.

ENDLoop.

But when I am using MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.

I am getting the error like

"<FS_1>" is not a structure or internal table with header line.

Please check the code and tell where I am making the mistake.

Regards,

Vasanth

8 REPLIES 8
Read only

Former Member
0 Likes
1,213

Hi Vasanth,

In FIELD-SYMBOLS declaration <b>remove the statement TYPE ANY TABLE</b> i.e,

FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,

<FS_1> ,

<FS_2>,

<FS_3>.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,213

Does <FS_1> have the same structure as the OUTTAB? If so, try using just MOVE.

REgards,

Rich Heilman

Read only

0 Likes
1,213

Hello Rich,

The outtab internal is the table which has the data.

My exact problem is, when the user savinga Layout variant

in the output, I have to download a text file with same number of columns.

So I have created the dynamic table.

But when I am using the move statement to , its taking header line of the internal table outtab and moving to the field symbol

ie) If the user selects F1, F2, F5 from the output

F1,F2,F3,F4,F5

What I´am getting in the file is

F1,F2,F5.

This is my problem.

Colud please give a solution for this....

Regards,

Vasanth

Read only

0 Likes
1,213

So which part is working, and which part is NOT working?

You can send the entire program(if it is really big) to my email address on my business card.

Regards,

Rich Heilman

Read only

0 Likes
1,213

Hello Rich ,

My is code is as below..

*******************************

Declaration:

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.

DATA: BEGIN OF IT_OUTTAB OCCURS 0,

PSPID LIKE PROJ-PSPID, "Projektdefinition

POSID LIKE PRPS-POSID, "PSP-Element

POST1 LIKE PRPS-POST1, "Kurzbeschreibung

STTXT_INT LIKE CNJ_STAT-STTXT_INT, "Systemstatus

STTXT_EXT LIKE CNJ_STAT-STTXT_EXT, "Anwenderstatus

END OF IT_OUTTAB.

DATA: WA_OUTTAB LIKE IT_OUTTAB.

DATA: LV_LINES LIKE SY-TABIX,

COUNT TYPE I.

FIELD-SYMBOLS: type any.

DATA: NEW_LINE TYPE REF TO DATA.

DATA: LT_DATA TYPE REF TO DATA.

*************************************

G_R_DISP_VARIANT-REPORT = SY-REPID.

G_R_DISP_VARIANT-VARIANT = PA_VAR.

CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'

EXPORTING

I_DIALOG = 'N'

I_USER_SPECIFIC = 'A'

I_DEFAULT = 'X'

IT_DEFAULT_FIELDCAT = G_T_FIELDCAT

I_LAYOUT = G_R_LAYOUT

IMPORTING

ET_FIELDCAT = G_T_FIELDCAT

  • et_sort = l_tab_sort

  • et_filter = l_tab_filter

  • ES_LAYOUT = G_R_LAYOUT

CHANGING

CS_VARIANT = G_R_DISP_VARIANT

EXCEPTIONS

ERROR_MESSAGE = 4

OTHERS = 4.

LOOP AT G_T_FIELDCAT INTO G_R_FIELDCAT WHERE NO_OUT IS INITIAL

AND TECH IS INITIAL.

MOVE-CORRESPONDING G_R_FIELDCAT TO IS_FIELDCAT.

IS_FIELDCAT-FIELDNAME = G_R_FIELDCAT-FIELDNAME.

IS_FIELDCAT-INTTYPE = G_R_FIELDCAT-INTTYPE.

IS_FIELDCAT-OUTPUTLEN = G_R_FIELDCAT-OUTPUTLEN.

IS_FIELDCAT-REF_FIELD = G_R_FIELDCAT-FIELDNAME.

IS_FIELDCAT-REF_TABLE = G_R_FIELDCAT-REF_TABNAME.

APPEND IS_FIELDCAT TO IT_FIELDCAT.

ENDLOOP.

DATA: WA_LISTE LIKE P_T_LISTE.

CLEAR:IT_OUTTAB.

REFRESH: IT_OUTTAB.

LOOP AT P_T_LISTE INTO WA_LISTE.

WA_OUTTAB-PSPID = WA_LISTE-PSPID .

WA_OUTTAB-POSID = WA_LISTE-POSID.

WA_OUTTAB-POST1 = WA_LISTE-POST1.

WA_OUTTAB-STTXT_INT = WA_LISTE-STTXT_INT.

WA_OUTTAB-STTXT_EXT = WA_LISTE-STTXT_EXT.

APPEND WA_OUTTAB TO IT_OUTTAB.

ENDLOOP.

**dynamic table creation for data

ASSIGN LT_DATA TO .

  • Create a new Table

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

EXPORTING

IT_FIELDCATALOG = IT_FIELDCAT

IMPORTING

EP_TABLE = .

      • A field-symbol to access that work area

ASSIGN NEW_LINE->* TO = WA_OUTTAB-PSPID.

  • ASSIGN COMPONENT 'POSID' OF STRUCTURE WA_OUTTAB TO <FS_3>.

ASSIGN COMPONENT 'POSID' OF STRUCTURE = WA_OUTTAB-POSID.

  • ASSIGN COMPONENT 'POST1' OF STRUCTURE WA_OUTTAB TO <FS_3>.

ASSIGN COMPONENT 'POST1' OF STRUCTURE .

  • <FS_5> = <FS_3>.

= WA_OUTTAB-POST1.

  • ASSIGN COMPONENT 'STTXT_INT' OF STRUCTURE WA_OUTTAB TO <FS_3>.

ASSIGN COMPONENT 'STTXT_INT' OF STRUCTURE TO P_FILE.

ENDLOOP.

ELSE.

MESSAGE E041(S9) WITH P_FILE.

ENDIF.

CLOSE DATASET P_FILE.

Here my problem is ´´, I am not able to use move corresponding statement.

So I am not getting the exact values to the fields of the dynamic table...

Please check it and give me a solution,

Regards,

Vasanth

Read only

Former Member
0 Likes
1,214

Take a look at these blogs which does exactly the same.

I guess the error is right, becuase <FS_1> is declared as internal table.

You should MOVE-CORRESPONDING to <FS_2> and then append <FS_2> to <FS_1>.

Regards,

Ravi

Note Please mark the helpful answers

Message was edited by: Ravikumar Allampallam

Read only

0 Likes
1,213

Hello Ravi,

I am moving to <fs_2> only even though it's giving error.

LOOP AT IT_OUTTAB INTO WA_OUTTAB.

MOVE-CORRESPONDING WA_OUTTAB TO <FS_2>.

INSERT <FS_2> INTO TABLE <FS_1>.

ENDLOOP.

Please tell me a solution for this.

Please check the declaration part.

Regards,

Vasanth

Read only

Former Member
0 Likes
1,213

Hi Vasanth,

i have the exact same issue.

I have an internal displayed in alv and i want to download a txt file based on the columns selected in the layout.

So far i have created the internal table <FS_DATA>.But, the following

Loop at internal_table.

move-corresponding internal_table to <FS_DATA>.

endloop.

Does not work.

How did u solve it??

Thank u in advance!!!