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 access to dynamic data's structure before runtime?

Former Member
0 Likes
1,039

Hi all,

I am declaring a data that structure depend on a parameter (wich have deep structure).

My requirement is to access to its components before runtime.

example:

parameters : p_tab type dd03L-fieldname.

data : itab type ref  to data..

create data itab type (p_tab).

Then i need to insert values on itab-row.

NB: In my program, all the parameters have the structure : controller, row .

I have the error message itab has no structure and therefore no component called row.

Thanks.

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
967

Hi Raj,

you may check the structure

AT SELECTION-SCREEN ON p_tab.

PERFORM check_p_tab USING p_tab.

FORM check_p_tab

  USING p_tab TYPE dd03L-fieldname.

  FIELD-SYMBOLS:

    <any> TYPE any,

    <any2> TYPE any.

  DATA:

    lr_itab  TYPE REF TO DATA.

  CREATE DATA lr_itab TYPE (p_tab).

  IF sy-subrc <> 0.

    MESSAGE TYPE 'E' "p_tab not defined in data dictionary

  ELSE.

    ASSIGN lr_itab->* TO <any>.

    ASSIGN COMPONENT 'ROW of STRUCTURE <any> to <any2>.

    IF sy-subrc <> 0.

      MESSAGE TYPE 'E' "p_tab has no component 'ROW'.

    ENDIF.

  ENDIF.

ENDFORM.

This is just to give you the idea. BTW create data itab type (p_tab) will never create an internal table. Syntax is create data itab type TABLE OF (p_tab).

Regards,

Clemens

Hi all,

I am declaring a data that structure depend on a parameter (wich have deep structure).

My requirement is to access to its components before runtime.

example:

parameters : p_tab type dd03L-fieldname.

data : itab type ref  to data..

create data itab type (p_tab).

Then i need to insert values on itab-row.

NB: In my program, all the parameters have the structure : controller, row .

I have the error message itab has no structure and therefore no component called row.

Thanks.

5 REPLIES 5
Read only

JuanCarlosDelga
Contributor
0 Likes
967


Hi Raj,

You have dynamic data but you are trying to access them in a static way.

First option, use field-symbols. and assign

DATA: dref TYPE REF TO DATA.
TYPES: booking TYPE sbook.
FIELD-SYMBOLS: <fs> TYPE ANY.

CREATE DATA dref TYPE booking.
ASSIGN dref->* TO <fs>.

Regards.

JCD

Read only

Clemenss
Active Contributor
0 Likes
968

Hi Raj,

you may check the structure

AT SELECTION-SCREEN ON p_tab.

PERFORM check_p_tab USING p_tab.

FORM check_p_tab

  USING p_tab TYPE dd03L-fieldname.

  FIELD-SYMBOLS:

    <any> TYPE any,

    <any2> TYPE any.

  DATA:

    lr_itab  TYPE REF TO DATA.

  CREATE DATA lr_itab TYPE (p_tab).

  IF sy-subrc <> 0.

    MESSAGE TYPE 'E' "p_tab not defined in data dictionary

  ELSE.

    ASSIGN lr_itab->* TO <any>.

    ASSIGN COMPONENT 'ROW of STRUCTURE <any> to <any2>.

    IF sy-subrc <> 0.

      MESSAGE TYPE 'E' "p_tab has no component 'ROW'.

    ENDIF.

  ENDIF.

ENDFORM.

This is just to give you the idea. BTW create data itab type (p_tab) will never create an internal table. Syntax is create data itab type TABLE OF (p_tab).

Regards,

Clemens

Read only

Former Member
0 Likes
967

Thanks ,

But if i use this method, i'll have the first field symbol <any> composed by: Controller (standard table) and Row (deep structure), and the second one <any2> composed by Row (deep structure).

Suppose that i've filled <any2> with the appropriate values, how to insert it into <any>-row?? Because my requirement is to fill <any>-row with values.

Read only

Clemenss
Active Contributor
0 Likes
967

Hi Raj,

may be your requirement is not too clear, you might give an example. Anyway, if you want to access a component wich is an internal table, define the field-symbol as TYPE [STANDARD] TABLE and APPEND to this table.

You may use RTTS run time type services to analyze your structure further, check classes CL_ABAP_*DESCR which may help you with that. See also SAP help

ABAP Keyword Documentation http://help.sap.com/abapdocu_702/en/abenrtti.htm

Regards

Clemens

Read only

Former Member
0 Likes
967

My exact requirement is to send Data to dynamic proxy.

these are steps I dhould do:

step 1: select * from ztable into itab.

step 2: move-corresponding wa to record-row

step 3: append  record to output-mtXXX-records

step 4: export output using a method contained into proxy's SI.

actually, i have filled record-row using two field symbol as you advised me.

otherwise, i did same thing with output : <fs1> for output (without type)

                                                                <fs2> for mtXX   (without type)

                                                                <fs3> for records (type standard table)

i did: append record to <fs3>. it was ok.

now when i try to attach <fs3> to <fs2> it dump because <fs3> has no structured type.