Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need Condition statement syntax

Former Member
0 Likes
716

Hi Frnds,

I have a requirement ,A condition needs to be written.

If 2nd element of PRDHA is 'D' then

.........

...........

............

............

endif.

In field values may be PRDHA = FD21,RS31,EDS4,RSDE etc....,

Now My if condition should satisfy only if the second field has D .So in the above case for 1st & third fields My condition should satisfy.

thank U very much

1 ACCEPTED SOLUTION
Read only

former_member195698
Active Contributor
0 Likes
693

In field values may be PRDHA = FD21,RS31,EDS4,RSDE etc....,

Now My if condition should satisfy only if the second field has D .So in the above case for 1st & third fields My condition should satisfy.

how is the 2nd element D in case of FD21 and EDS4 ?

5 REPLIES 5
Read only

former_member195698
Active Contributor
0 Likes
694

In field values may be PRDHA = FD21,RS31,EDS4,RSDE etc....,

Now My if condition should satisfy only if the second field has D .So in the above case for 1st & third fields My condition should satisfy.

how is the 2nd element D in case of FD21 and EDS4 ?

Read only

0 Likes
693

Sorry they are FD21 and EDS4 .

Read only

0 Likes
693

If PRDHA+1(1) = 'D'.
 .. your condition...
Endif.
Read only

amit_khare
Active Contributor
0 Likes
693

As an alternative SPLIT the string at D and get the position.

If its greater than 2 then get the charater before it and check its an special character than use it.

If its equal to 2 then use it directly.

If its less than 2 then check for the second occurance of D and Repeat Step 1 and 2.

Read only

former_member156446
Active Contributor
0 Likes
693
DATA: BEGIN OF itab OCCURS 0,
   string TYPE string,
  END OF itab.

itab-string = 'FD21'.
APPEND itab.
itab-string = 'RS31'.
APPEND itab.
itab-string = 'EDS4'.
APPEND itab.
itab-string = 'RSDE'.
APPEND itab.


LOOP AT itab.
  IF itab-string+1(1) = 'D'.
    WRITE: itab-string.
  ELSE.
    DELETE itab INDEX sy-tabix.
  ENDIF.
ENDLOOP.