Monday, June 11, 2012

0 FIELD SYMBOLS IN ABAP


Field symbols:
Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol can point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
To declare a Field Symbol, use the statement,
FIELD-SYMBOLS <FS> [<type>|STRUCTURE <s> DEFAULT <wa>].
Typing  Field Symbols:
The <type> addition allows you to specify the type of a field symbol.
Syntax:
FIELD-SYMBOLS <FS> <type>
Ex :
*//variable declaration
      DATA: WA(10VALUE '0123456789'.
DATABEGIN OF LINE1,
COL1(
3),
COL2(
2),
COL3(
5),
END OF LINE1.

DATABEGIN OF LINE2,
COL1(
2),
COL2 
LIKE SY-DATUM,
END OF LINE2.
*//Field symbol declaration
FIELD-SYMBOLS: <F1> STRUCTURE LINE1 DEFAULT WA,
<F2> 
STRUCTURE LINE2 DEFAULT WA.
*//Display output      
WRITE: / <F1>-COL1, <F1>-COL2, <F1>-COL3,
/ <F2>-COL1, <F2>-COL2.
Output:
Static Assign:
The name of the data object you want to assign to a field symbol before run time.
Syntax:
           ASSIGN <f>  TO <FS>.
Ex:
*//Field symbol declaration
FIELD-SYMBOLS:  <F1> , <F2> TYPE I.

*//variable declaration
DATA : NUM  TYPE I VALUE 5,
      
TEXT(10TYPE C  VALUE 'HELLO'.
*//Static assign
      
ASSIGN TEXT TO <F1>.
      
ASSIGN NUM TO <F2>.
*//Display output      
      
WRITE: / <F1> , <F2>. Output:

Dynamic  Assign:
The name of the data object you want to assign to a field symbol only at  run time.
Syntax:  ASSIGN (<f>)  TO <FS>.
 

SAP-ABAP Copyright © 2011 - |- Template created by Vishnu - |- Powered by Blogger Templates