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

CREATE DATA TYPE TABLE

Clemenss
Active Contributor
0 Likes
3,832

Hi Colleagues,

regarding my IDOC viewer project I'm facing a question regarding the SAP release. I started with some success on Release 471, now I tried to continue on 46C.

CREATE DATA gr_ref

TYPE lvc_t_fcat."STANDARD TABLE OF LVC_S_FCAT.

works in both releases, while

CREATE DATA ls_seg_dat-ref

TYPE STANDARD TABLE OF (<edid4>-segnam).

compiles on 471, but generates syntax error in 46C.

The error message "Unable to interpret "TABLE". Possible causes of error: Incorrect spelling or comma error."

does not help too much.

Does this mean that there is no way to create tables dynamically on release 46C?

Hope for a solution!

regards,

C.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,650

Hi Clemens,

The dynamic way of creating an internal table using the create data syntax is not available in 46c. it is available only from 471 onwards.

As somebody pointed out, you cud have fieldsymbols in 46c.

Hope this is clear.

Kindly reward points to the reply that answered ur question. If ur question is answered, clsoe the thread.

Prabhu.

8 REPLIES 8
Read only

Former Member
0 Likes
1,650

Hi,

This a short example how you can create dynamic table in 4.6C

DATA: dref TYPE REF TO DATA.

FIELD-SYMBOLS: <fs> TYPE ANY.

data: booking TYPE sbook occurs 0.

CREATE DATA dref like booking[].

ASSIGN dref->* TO <fs>.

Svetlin

Read only

0 Likes
1,650

Hi Svetlin,

your example shows how to create a data object for a static definition (type sbook). This does not help.

What I need is a table of a dynamically entered structure. May be you can finish this:

Parameters:

p_struc type tabname default 'EDIDC'.

data:

gr_ref type rf to data.

field-symbols:

<ft> type standard table.

  • following statement(s) shold create table with

  • structure 'EDIDC'

create data gr_dref ???

assign gr_dref->* to <ft>.

Possible on 46C? - I think: No way.

regards,

C.

Read only

0 Likes
1,650

Hi,

There are 2 options:

1) to use GENERATE SUBROUTINE POOL itab NAME name.

In this way you can use my code

2) CALL METHOD cl_alv_table_create=>create_dynamic_table

This class method uses GENERATE SUBROUTINE and can create a dynamic table.

But in the both ways there is limitation. You can use GENERATE SUBROUTINE, I think, 36 times.

Svetlin

Read only

0 Likes
1,650

This is a short example.

DATA: dref TYPE REF TO DATA.

PERFORM CREATE_TABLE USING 'BSIK'

dref.

FORM CREATE_TABLE USING TAB_TYPE

dref type ref to data.

data tab_line(72).

DATA itab like table of tab_line.

data mytype(10).

data PROG(8).

mytype = TAB_TYPE.

APPEND 'PROGRAM SUBPOOL.' to itab.

APPEND 'FORM MYSUBR USING dref type ref to data.' to itab.

concatenate 'data mytable TYPE standard table of'

mytype 'WITH DEFAULT KEY.' into tab_line separated by space.

append tab_line to itab.

APPEND 'CREATE DATA dref like mytable.' to itab.

APPEND 'ENDFORM.' to itab.

GENERATE SUBROUTINE POOL itab NAME PROG.

PERFORM ('MYSUBR') IN PROGRAM (PROG) USING dref.

ENDFORM.

Svetlin

Read only

Former Member
0 Likes
1,651

Hi Clemens,

The dynamic way of creating an internal table using the create data syntax is not available in 46c. it is available only from 471 onwards.

As somebody pointed out, you cud have fieldsymbols in 46c.

Hope this is clear.

Kindly reward points to the reply that answered ur question. If ur question is answered, clsoe the thread.

Prabhu.

Read only

Former Member
0 Likes
1,650

Clemens,

As said earlier, it is not possible in 46c. however, as somebody pointed out, you can go for dynamic programming...

whereby u can dynamically create a sub-routine or a program.... in which u can dynamically create ur table.

Remember 2 reward points if this post answered ur Q.

Rgds,

Prabhu.

Read only

Former Member
0 Likes
1,650

Hello,

the only possibility I found was to use available table types in the dictionary. This works on a 4.6C system:

  DATA: lf_type(20)          TYPE c VALUE 'MARA',
        lf_table_type(20)    TYPE c VALUE 'MARA_TAB'.

  DATA: wa_data              TYPE REF TO data,
        lt_data              TYPE REF TO data.

  FIELD-SYMBOLS: <structure> TYPE ANY,
                 <field>     TYPE ANY,
                 <table>     TYPE TABLE.

  CREATE DATA wa_data TYPE (lf_type).
  ASSIGN wa_data->* TO <structure>.

  ASSIGN COMPONENT 'MATNR' OF STRUCTURE <structure> TO <field>.
  <field> = 'My Material'.

  CREATE DATA lt_data TYPE (lf_table_type).
  ASSIGN lt_data->* TO <table>.

  APPEND <structure> TO <table>.

Little curious: An internal table type defined with "TYPES ty_mara_tab TYPE TABLE OF mara" is not accepted by CREATE DATA, but the dictionary type is. So even generating a little top include dynamically with the needed type as a table type will not work on 4.6C

--

Best regards,

Stefan Kozlowski

Read only

Clemenss
Active Contributor
0 Likes
1,650

OK, 46C is history.