Friday, March 11, 2011

Simple Example to use FieldSymbols



*&---------------------------------------------------------------------*
*& Report  ZTRPROG03
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZTRPROG03.
TYPES: BEGIN OF T_STRUCT,
         COL1 TYPE I,
         COL2 TYPE i,
         COL3(10) TYPE C,
       END OF T_STRUCT.

DATA: DREF1 TYPE REF TO DATA,
      DREF2 TYPE REF TO DATA.

FIELD-SYMBOLS: TYPE T_STRUCT,
               type any.

CREATE DATA DREF1 TYPE T_STRUCT.

ASSIGN DREF1->* TO .

-COL1 = 1.
-COL2 = 2.
-COL3 = 'AYANTECH'.

DREF2 = DREF1.

ASSIGN DREF2->* TO CASTING TYPE i.
WRITE / .


GET REFERENCE OF -COL3 INTO DREF2.

ASSIGN DREF2->* TO .
WRITE / .

**GET REFERENCE OF -COL2 INTO DREF2.
**
**ASSIGN DREF2->* TO .
*WRITE / .

No comments:

Post a Comment