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

How to create a dynamic internal table?

Former Member
0 Likes
904

Hi ,

I need to get the data of any IDOC into a internal table. Now this internal table should be dynamic in nature.

How can a dynamic internal table be created?

Regards,

Harshit Rungta

Hi ,

I need to get the data of any IDOC into a internal table. Now this internal table should be dynamic in nature.

How can a dynamic internal table be created?

Regards,

Harshit Rungta

6 REPLIES 6
Read only

Former Member
0 Likes
883
Read only

Former Member
0 Likes
883

Hi,

use this method:

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fieldcat

IMPORTING

ep_table = new_table.

Read only

Former Member
0 Likes
883

field-symbols: <dyn_table> type standard table,

<dyn_wa>,

<dyn_field>.

data: dy_table type ref to data,

dy_line type ref to data,

xfc type lvc_s_fcat,

ifc type lvc_t_fcat.

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = ifc

importing

ep_table = dy_table.

assign dy_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data dy_line like line of <dyn_table>.

assign dy_line->* to <dyn_wa>.

Read only

Former Member
0 Likes
883

Hi Harshit,

Find the below code.

FIELD-SYMBOLS: <gt_table> TYPE TABLE,

<gs_line> TYPE ANY,

<gd_field> TYPE ANY.

*Field catalog for dynamic table.

DATA : gt1_fieldcat TYPE lvc_t_fcat,

gt_ex_fieldcat TYPE lvc_t_fcat.

*Fill the field catalog.

PERFORM fill_catalog_dyn USING 'PERNR' 'CHAR' 'Employee Number' '8'.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt1_fieldcat

IMPORTING

ep_table = gt_new_table.

ASSIGN gt_new_table->* TO <gt_table>.

CREATE DATA gs_new_line LIKE LINE OF <gt_table>.

ASSIGN gs_new_line->* TO <gs_line>.

FORM FILL_CATALOG_DYN USING VALUE(P_1704)

VALUE(P_1705)

VALUE(P_1706)

VALUE(P_1707)

VALUE(P_1708).

gd_pos = gd_pos + 1.

gs1_fieldcat-fieldname = P_1704.

gs1_fieldcat-datatype = P_1705.

gs1_fieldcat-scrtext_l = P_1706.

gs1_fieldcat-outputlen = P_1707.

gs1_fieldcat-decimals = P_1708.

gs1_fieldcat-col_pos = gd_pos.

APPEND gs1_fieldcat TO gt1_fieldcat.

CLEAR gs1_fieldcat.

ENDFORM. " FILL_CATALOG_DYN

Read only

Former Member
0 Likes
883

Hi,

Try this:

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/creatingadynamicinternaltablebasedon+data

Regards,

Deepak

Read only

Former Member
0 Likes
883

This message was moderated.