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: 

Can I use field-symbols in a class?

Former Member
0 Kudos
1,364

Hi experts,

i have a class and i want to create a field-symbol but its showing syntax error

CLASS ZCL_COLLEGE DEFINITION ABSTRACT.

  PUBLIC SECTION.  " PUBLIC SCETION CONTAINS TWO ABSTRACT METHODS.

    METHODS: SETVALUE IMPORTING LT_TBL1 TYPE ANY TABLE OPTIONAL,

             GETVALUE IMPORTING LT_TBL2 TYPE ANY TABLE OPTIONAL

                       EXPORTING LT_RES TYPE ANY TABLE .

  PRIVATE SECTION.  "PRIVATE SECTION CONTAINS REF TYPE STRUCTURE.

    FIELD-SYMBOLS: <FS_ITTAB> TYPE ANY,

                   <FS_WA> TYPE ANY.

    DATA: LT_DYNTBL TYPE REF TO DATA,

          LV_DYWA   TYPE REF TO DATA.

ENDCLASS.

syntax error

Include ZZFMRASSIGN_TOP

You cannot use the current statement between "CLASS ... DEFINITION" and

"ENDCLASS".

Thanks.

Rohit Kumar

4 REPLIES 4

Private_Member_49934
Contributor
0 Kudos
248

I think not. You can use variable of type ref to data. It will solve the same purpose.

You can use the filed symbols in the method implementation though

Former Member
0 Kudos
248

Hi,

You can refer to the link below:

http://help.sap.com/abapdocu_70/en/ABENABAP_OBJECTS_DIFF_FIELD_SYMBOL.htm

Hope it serves useful.

wozjac
Product and Topic Expert
Product and Topic Expert
0 Kudos
248

PRIVATE SECTION.  "PRIVATE SECTION CONTAINS REF TYPE STRUCTURE.

   FIELD-SYMBOLS: <FS_ITTAB> TYPE ANY,

This is not permitted.

You can use field symbols in implementation, here you can only use DATA ...

naimesh_patel
Active Contributor
0 Kudos
248

You can't use the Field-Symbols as attributes of the class.

You can create an attribute with TYPE REF TO DATA. In your method implementation, ASSIGN the data reference to field symbol to work with it.

Regards,
Naimesh Patel