Saturday 28 May 2016

Clear

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(12TYPE C,
        AGE   TYPE I,
        PLACE(20TYPE 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(12TYPE C,
        AGE   TYPE I,
        PLACE(20TYPE 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.




Output






3 comments: