Using SWITCH statement ABAP 7.4


Working with SWITCH statement in ABAP 7.4, replacing CASE conditions with SWITCH

A+ A-

From SAP NetWeaver 7.4, SAP introduced simple replacement for CASE condition with SWITCH

Using CASE condition before ABAP 7.4

DATA: LV_MTART TYPE MARA-MTART,
      LV_TEXT TYPE TEXT30.

lv_mtart = 'FERT'.
CASE lv_mtart.
	WHEN 'FERT'.
    lv_text = 'Finished Products'.
	WHEN 'HALB'.
    lv_text = 'Semifinished products'.
	WHEN 'HAWA'.
    lv_text = 'Trading goods'.
	WHEN OTHERS.
    lv_text = 'Not Provided'.
ENDCASE.

WRITE:/ lv_text.

Example using SWITCH ABAP 7.4

DATA(lv_mtart) = 'FERT'.

DATA(lv_text) = SWITCH text30( lv_mtart
   when 'FERT' THEN 'Finished Products'
   when 'HALB' THEN 'Semifinished products'
   when 'HAWA' THEN 'Trading goods'
      ELSE
      'Not Provided' ).
WRITE:/ lv_text.

Learner Questions

No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question


    Was this lesson helpful to you? Yes No 2 People out of 3 think this lesson helpful

    Lesson Navigation

    ←Previous Chapter
    Next Chapter →