Use switch statement instead of case statement. (7.4+).
Switch statement.
* From ABAP 7.4 onwards, SAP introduced SWITCH statement.
* We need to use SWITCH statement instead of CASE statement.
* In CASE statement, we need to specify the variable which is getting filled in every condition.
* In SWITCH statement, we need not to mention the variable which is getting filled in every condition.
CASE (Old).
REPORT zab_rp_switch.
PARAMETERS: p_day TYPE i.
DATA: lv_output(15) TYPE c.
CASE p_day.
WHEN 1.
lv_output = TEXT-000. " SUNDAY.
WHEN 2.
lv_output = TEXT-001. " MONDAY.
WHEN 3.
lv_output = TEXT-002. " TUESDAY.
WHEN 4.
lv_output = TEXT-003. " WEDNESDAY.
WHEN 5.
lv_output = TEXT-004. " THURSDAY.
WHEN 6.
lv_output = TEXT-005. " FRIDAY.
WHEN 7.
lv_output = TEXT-006. " SATURDAY.
WHEN OTHERS.
lv_output = TEXT-007. " Pls enter correct day number.
ENDCASE.
Input1
Output1
Switch statement
Refer - switch statement
*****************************Thank You*******************
Comments
Post a Comment