2007 Sep 28 10:43 AM
Hi all,
I want to use field symbols in OOPS programming like this...
But the system is giving me dump....help me.
START-OF-SELECTION.
CREATE OBJECT OBJ.
FIELD-SYMBOLS : <AB> TYPE ANY.
ASSIGN OBJ TO <AB>.
CALL METHOD <AB>->add
EXPORTING
a = 4
b = 6
changing
c = Z
.
WRITE : / Z.
2007 Sep 28 12:12 PM
Pradeep,
In this piece of code you have declared your field symbol as TYPE ANY. In this case when you do a call method it will give you errors. Instead of this declare the field sybol as the type of the calling class. refer to this syntax -
REPORT ZSKC_TEST4 MESSAGE-ID IH
NO STANDARD PAGE HEADING.
TYPES : TYP_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : L_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : L_HEIGHT TYPE I.
FIELD-SYMBOLS : <FS> TYPE TYP_CONT.
START-OF-SELECTION.
CREATE OBJECT L_CONT EXPORTING CONTAINER_NAME = 'TEST'.
ASSIGN L_CONT TO <FS>.
CALL METHOD L_CONT->GET_HEIGHT
IMPORTING
HEIGHT = L_HEIGHT
EXCEPTIONS
CNTL_ERROR = 1
others = 2.
WRITE L_HEIGHT.
CALL METHOD <FS>->GET_HEIGHT
IMPORTING
HEIGHT = L_HEIGHT
EXCEPTIONS
CNTL_ERROR = 1
others = 2.
WRITE L_HEIGHT.
Just make sure your OBJ is initialized, u can check that in debugging mode.
Hi all,
I want to use field symbols in OOPS programming like this...
But the system is giving me dump....help me.
START-OF-SELECTION.
CREATE OBJECT OBJ.
FIELD-SYMBOLS : <AB> TYPE ANY.
ASSIGN OBJ TO <AB>.
CALL METHOD <AB>->add
EXPORTING
a = 4
b = 6
changing
c = Z
.
WRITE : / Z.
2007 Sep 28 11:08 AM
2007 Sep 28 11:26 AM
check the code below
TYPES: BEGIN OF t_struct,
col1 TYPE i,
col2 TYPE i,
END OF t_struct.
DATA: dref1 TYPE REF TO data,
dref2 TYPE REF TO data.
FIELD-SYMBOLS: <fs1> TYPE t_struct,
<fs2> TYPE i.
CREATE DATA dref1 TYPE t_struct.
ASSIGN dref1->* TO <fs1>.
<fs1>-col1 = 1.
<fs1>-col2 = 2.
dref2 = dref1.
ASSIGN dref2->* TO <fs2> CASTING.
WRITE / <fs2>.
GET REFERENCE OF <fs1>-col2 INTO dref2.
ASSIGN dref2->* TO <fs2>.
WRITE / <fs2>.
reward points if helpful.........
2007 Sep 28 12:12 PM
Pradeep,
In this piece of code you have declared your field symbol as TYPE ANY. In this case when you do a call method it will give you errors. Instead of this declare the field sybol as the type of the calling class. refer to this syntax -
REPORT ZSKC_TEST4 MESSAGE-ID IH
NO STANDARD PAGE HEADING.
TYPES : TYP_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : L_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : L_HEIGHT TYPE I.
FIELD-SYMBOLS : <FS> TYPE TYP_CONT.
START-OF-SELECTION.
CREATE OBJECT L_CONT EXPORTING CONTAINER_NAME = 'TEST'.
ASSIGN L_CONT TO <FS>.
CALL METHOD L_CONT->GET_HEIGHT
IMPORTING
HEIGHT = L_HEIGHT
EXCEPTIONS
CNTL_ERROR = 1
others = 2.
WRITE L_HEIGHT.
CALL METHOD <FS>->GET_HEIGHT
IMPORTING
HEIGHT = L_HEIGHT
EXCEPTIONS
CNTL_ERROR = 1
others = 2.
WRITE L_HEIGHT.
Just make sure your OBJ is initialized, u can check that in debugging mode.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |