IF ELSE conditions ABAP 7.4


Working with COND statements in SAP ABAP 7.4, making conditional statements using COND ABAP 7.4

A+ A-

In NetWeaver 7.4, SAP introduced many new concepts related to conditional logic, with the COND constructor, we can replace IF..ELSE conditional statements in ABAP 7.4.

Using IF..ELSE before ABAP 7.4

  DATA: lv_mtart type mara-mtart.
  DATA : lv_matkl type mara-matkl.
  DATA: lv_text TYPE char30.
  lv_mtart = 'FERT'.
  lv_matkl = '0001'.

  IF lv_mtart ='FERT' AND lv_matkl = '0001'.
     lv_text = 'You selected FERT'.
    ELSEIF lv_mtart ='HALB' AND lv_matkl = '0001'.
      lv_text = 'You selected HALB'.
      ELSEIF lv_mtart ='HAWA' AND lv_matkl = '0001'.
      lv_text = 'You selected HAWA'.
  ENDIF.
  WRITE:/ lv_text.

Using COND to replace IF..ELSE ABAP 7.4

  DATA(lv_mtart) = 'HAWA'.
  DATA(lv_matkl) = '0001'.

  DATA(lv_text) = COND text30(
     WHEN lv_mtart ='FERT' AND lv_matkl = '0001' THEN 'You selected FERT'
     WHEN lv_mtart ='HALB' AND lv_matkl = '0001' THEN 'You Selected HALB'
     WHEN lv_mtart ='HAWA' AND lv_matkl = '0001' THEN 'You Selected HAWA').

  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 0 People out of 0 think this lesson helpful

    Lesson Navigation

    Internal Table Operations with ABAP 7.4← Previous Lesson
    Next Chapter →