Clear
- Clear is used to clear the content of variable or work area or Internal table.
- Keyword: Clear.
Ex :
1.Without Clear statement.
Source Code
Types : BEGIN OF TY_STR,
NAME(12) TYPE C,
AGE TYPE I,
PLACE(20) TYPE C,
END OF TY_STR.
DATA : WA_STR TYPE TY_STR.
WA_STR-NAME = 'APPLEX'.
WA_STR-AGE = 12.
WA_STR-PLACE = 'MANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
WA_STR-NAME = 'MANGOX'.
WA_STR-PLACE = 'BANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
NAME(12) TYPE C,
AGE TYPE I,
PLACE(20) TYPE C,
END OF TY_STR.
DATA : WA_STR TYPE TY_STR.
WA_STR-NAME = 'APPLEX'.
WA_STR-AGE = 12.
WA_STR-PLACE = 'MANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
WA_STR-NAME = 'MANGOX'.
WA_STR-PLACE = 'BANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
In second word area for age field value is not entered.
Save ->Check -> Activate->Execute.
Output
Second record takes previous records Age value .This is wrong. So we have to clear it.
--------------------------------------------------------------------
2. With Clear Statement.
Source Code
Types : BEGIN OF TY_STR,
NAME(12) TYPE C,
AGE TYPE I,
PLACE(20) TYPE C,
END OF TY_STR.
DATA : WA_STR TYPE TY_STR.
WA_STR-NAME = 'APPLEX'.
WA_STR-AGE = 12.
WA_STR-PLACE = 'MANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
CLEAR WA_STR.
NAME(12) TYPE C,
AGE TYPE I,
PLACE(20) TYPE C,
END OF TY_STR.
DATA : WA_STR TYPE TY_STR.
WA_STR-NAME = 'APPLEX'.
WA_STR-AGE = 12.
WA_STR-PLACE = 'MANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
CLEAR WA_STR.
WA_STR-NAME = 'MANGOX'.
WA_STR-PLACE = 'BANGALORE'.
WRITE : / WA_STR-NAME ,WA_STR-AGE , WA_STR-PLACE.
Save->Check->Activate->Execute.
This comment has been removed by the author.
ReplyDeleteThe way is very wonderful and helpful
ReplyDelete------------
شركة جلي بلاط رخام بمكة
Nice explanation sir...
ReplyDelete