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

condition

SG141
Active Participant
0 Likes
1,096

In the if / else condition i want to check whether the field is initial or has a value with Z*

this is the code i've written...


      if l_field = ''.
      l_field = 'VALUE'.
      elseif l_field like 'z*'
      l_field = 'VALUE'.
      endif.

and it's returning error...

1 ACCEPTED SOLUTION
Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
1,038

Hi,

Try this way,

      
IF l_field EQ SPACE.
    l_field = 'VALUE'.
"All value starting with Z will be treated.
ELSEIF l_field(1) EQ 'Z'     " 'Z' Must be in Upper Case 
    l_field = 'VALUE'.
ENDIF.

Regards.

Marcelo Ramos

8 REPLIES 8
Read only

Former Member
0 Likes
1,038

Try this:

IF L_FIELD IS INITIAL OR L_FIELD+1(1) EQ 'Z'.

L_FIELD = ' VALUE'.

ENDIF.

Thanks,

SKJ

Read only

Former Member
0 Likes
1,038

if l_field = ''.

l_field = 'VALUE'.

elseif l_field CP 'z*'

l_field = 'VALUE'.

endif.

use this.

Read only

Former Member
0 Likes
1,038

Hi,

Instead of using that logic, use this logic which would serve your purpose

if l_field = ''.

l_field = 'VALUE'.

elseif l_field+0(1) eq 'z'.

l_field = 'VALUE1'.

endif.

Regards,

Vinod.

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
1,038

Hi,

Try this way,

      
IF l_field = SPACE.
    l_field = 'VALUE'.
ELSEIF l_field(1) = 'Z'     " 'Z' Must be in Upper Case
    l_field = 'VALUE'.
ENDIF.

Regards.

Marcelo Ramos

Read only

0 Likes
1,038

Z

  • here means any thing value Z like ZVALUE, ZINSERT and ZMODIFY.....

Read only

0 Likes
1,038

yeah karthik..

The logic given by me would help u in finding out all the objects starting with 'Z" like ZTBALE, ZELEMENT, etc etc

Read only

0 Likes
1,038

I guess you can use below logic :

if l_field = ''.

l_field = 'VALUE'.

elseif l_field+0(1) ca 'Z'.

l_field = 'VALUE'.

endif.

since like will not work in if condition

Thanks

Seshu

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
1,039

Hi,

Try this way,

      
IF l_field EQ SPACE.
    l_field = 'VALUE'.
"All value starting with Z will be treated.
ELSEIF l_field(1) EQ 'Z'     " 'Z' Must be in Upper Case 
    l_field = 'VALUE'.
ENDIF.

Regards.

Marcelo Ramos