Application Development 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: 

Field Symbols help

Former Member
0 Kudos
72

HI,

i have to use read for table type field-symbols

i try

FIELD-SYMBOLS: <col_actual>  TYPE STANDARD TABLE,
<t_act> type any.
 
READ TABLE <col_actual>  ASSIGNING  <t_act> WITH KEY child = wa_node_tab-znode.

and i get error :

The specified type has no structure and therefore no component called"CHILD". component called "CHILD".

and in debugger i have Colman with name child.

what i wont is to use value of colman child in table <col_actual> for with key

how can i solve it?

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos
47

You had just defined a field symbol of type standard table. In order to read from the field symbols, you have to assign a table/structure with field CHILD to the field symbol so that it can refer to the contents in memory.

That is why it is giving out an error.

Here is an example: -

DATA: BEGIN OF LINE,
        COL1 TYPE I VALUE '11',
        COL2 TYPE I VALUE '22',
        COL3 TYPE I VALUE '33',
      END OF LINE.

DATA COMP(5) VALUE 'COL3'.

FIELD-SYMBOLS: <F1>, <F2>, <F3>.

ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.

DO 3 TIMES.
  ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
  WRITE <F3>.
ENDDO.

ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.

The output is:

11         22         33

33

Here is the link to know more about field symbols.

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm

Thanks,

Naren

Edited by: Naren K Someneni on Jul 17, 2008 3:39 PM

2 REPLIES 2

Former Member
0 Kudos
48

You had just defined a field symbol of type standard table. In order to read from the field symbols, you have to assign a table/structure with field CHILD to the field symbol so that it can refer to the contents in memory.

That is why it is giving out an error.

Here is an example: -

DATA: BEGIN OF LINE,
        COL1 TYPE I VALUE '11',
        COL2 TYPE I VALUE '22',
        COL3 TYPE I VALUE '33',
      END OF LINE.

DATA COMP(5) VALUE 'COL3'.

FIELD-SYMBOLS: <F1>, <F2>, <F3>.

ASSIGN LINE TO <F1>.
ASSIGN COMP TO <F2>.

DO 3 TIMES.
  ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
  WRITE <F3>.
ENDDO.

ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
WRITE / <F3>.

The output is:

11         22         33

33

Here is the link to know more about field symbols.

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm

Thanks,

Naren

Edited by: Naren K Someneni on Jul 17, 2008 3:39 PM

Former Member
0 Kudos
47

Here field symbol <col_actual> is defined as generic standard table and its actual structure is getting populated in runtime, before runtime sap does not have any clue about its structure definition.

FIELD-SYMBOLS: <col_actual> TYPE STANDARD TABLE,

<t_act> type any.

But in the read statement u have mentioned the component name that is not exists till runtime. That's why sap is showing syntax error during compilation of the code.

READ TABLE <col_actual> ASSIGNING <t_act> WITH KEY child = wa_node_tab-znode.

instead of it try this:

loop at <col_actual> ASSIGNING <t_act>.

ASSIGN COMPONENT 'CHILD' OF STRUCTURE <t_act> TO <w_field>.

check sy-subrc = 0.

if <w_field> = wa_node_tab-znode.

endif.

endloop.

Regards,

Joy.