‎2006 Apr 20 6:42 AM
Hi,
Need some pointers with example on how "CASTING TYPE" is used in case of field symbols.
Regards
Saurabh
‎2006 Apr 20 6:44 AM
HI
GOOD
CHECK THIS OUT
Casting with an Implicit Type Declaration
Provided the field symbol is either fully typed or has one of the generic built-in ABAP types C, N, P, or X you can use the following statement:
ASSIGN ... TO <FS> CASTING.
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS <fs> TYPE t_date.
ASSIGN sy-datum TO <fs> CASTING.
WRITE / sy-datum.
SKIP.
WRITE: / <fs>-year , / <fs>-month, / <fs>-day.
Casting with an Explicit Type Declaration=>
If the field symbol is neither fully typed nor generically typed, use the following form of the ASSIGN statement:
ASSIGN ... TO <FS> CASTING TYPE <type>|LIKE <obj> [DECIMALS <d>].
EXAMPLE->
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS: <fs> TYPE ANY,
<f> TYPE n.
ASSIGN sy-datum TO <fs> CASTING TYPE t_date.
WRITE / sy-datum.
SKIP.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <f>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE / <f>.
ENDDO.
THANKS
MRUTYUN
‎2006 Apr 20 6:44 AM
HI
GOOD
CHECK THIS OUT
Casting with an Implicit Type Declaration
Provided the field symbol is either fully typed or has one of the generic built-in ABAP types C, N, P, or X you can use the following statement:
ASSIGN ... TO <FS> CASTING.
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS <fs> TYPE t_date.
ASSIGN sy-datum TO <fs> CASTING.
WRITE / sy-datum.
SKIP.
WRITE: / <fs>-year , / <fs>-month, / <fs>-day.
Casting with an Explicit Type Declaration=>
If the field symbol is neither fully typed nor generically typed, use the following form of the ASSIGN statement:
ASSIGN ... TO <FS> CASTING TYPE <type>|LIKE <obj> [DECIMALS <d>].
EXAMPLE->
TYPES: BEGIN OF t_date,
year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
END OF t_date.
FIELD-SYMBOLS: <fs> TYPE ANY,
<f> TYPE n.
ASSIGN sy-datum TO <fs> CASTING TYPE t_date.
WRITE / sy-datum.
SKIP.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <f>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE / <f>.
ENDDO.
THANKS
MRUTYUN
‎2011 Jul 28 10:20 AM