Wednesday, December 21, 2011

ABAP Field Symbols

One of the most useful of Field Symbols in ABAP is Dynamic assign statement, meaning if you don't know the name of field to assign to the field symbols during writing your program, you can use this :

ASSIGN (<f>) TO <FS>.
Normally this can be used if you are writing a program to read the name of the field from a customized table, then you can retrieve the value of the field from the field symbols.  


Sample:

Suppose we have three programs. The main program:

REPORT demo_field_symbols_dynami_as_1.
TABLES sbook.
sbook-fldate = sy-datum.
PERFORM form1 IN PROGRAM demo_form1.


The other two programs are:  

REPORT demo_form1.
FORM form1.
  PERFORM form2 IN PROGRAM demo_form2.
ENDFORM.


and

REPORT demo_form2.
FORM form2.
  DATA name(20) TYPE c VALUE 'SBOOK-FLDATE'.
FIELD-SYMBOLS <fs> TYPE ANY.
  ASSIGN (name) TO <fs>.
  IF sy-subrc EQ 0.
    WRITE / <fs>.
ENDIF.
ENDFORM.


The output looks something like this: 02.06.1998

More Detail? please visit :


http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm

No comments:

Post a Comment