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

Case statement query

Former Member
0 Likes
1,271

Hi,

In a case statement having the code sample below,

CAse v_xausz.

when '1'.

p_xausz = '2'.

when others.

p_xausz = '1'.

endcase.

if upon entering this case, v_xausz is blank, will it process the when others statement?

Thanks!

1 ACCEPTED SOLUTION
Read only

gopi_narendra
Active Contributor
0 Likes
1,248

Yes, it will go to the OTHERS case.

Regards

Gopi

11 REPLIES 11
Read only

gopi_narendra
Active Contributor
0 Likes
1,249

Yes, it will go to the OTHERS case.

Regards

Gopi

Read only

0 Likes
1,248

I was also assuming that that must be the case, however it failed me.

We have that codes inside a window in a sapscript. and we used the below codes to put value to v_xausz.

p_xausz in this case is blank upon entering the FM.

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'

EXPORTING

name = v_xausz

value = p_xausz

value_length = 15

EXCEPTIONS

OTHERS = 1.

Read only

0 Likes
1,248

Hi Mark, Can you check the data type of the variable, is it to be treated as text or integer?

Read only

0 Likes
1,248

Hi Eswar,

the variable is treated as a text....

v_xausz is defaulted as &xausz&...

Thanks a lot!

Read only

0 Likes
1,248

To test, can you try changing as below and see if it can make any difference:

CASE v_xausz.
WHEN '1'.
  p_xausz = '2'.
WHEN space.
  p_xausz = '1'.
WHEN others.
  p_xausz = '1'.
ENDCASE.

Read only

0 Likes
1,248

Thanks Eswar!

Does this mean that the space value is not covered under the when others condition?

Thanks a lot!

Read only

0 Likes
1,248

Normally it should work, but am just wondering if there is any problem w.r.t conversion and comparision. I do remember data type plays an important role. When we have data type criteria the length can be considered as well. Btw, how did the system react when you have specified SPACE in case statement?

Read only

0 Likes
1,248

Hi Eswar,

It still didnt worked...

/: WHEN ' '.

/: IF &V_GLSPLT& EQ 'X'.

HL STATEMENT &v_indicator&

/: ELSE.

LF ,,STATEMENT

/: ENDIF.

I added the above codes in the case statement inside a variable window in the sapscript... but it still not working...

Read only

0 Likes
1,248

Do you think the problem lies with this FM?

CALL FUNCTION 'TEXT_SYMBOL_SETVALUE'

EXPORTING

name = v_xausz

value = p_xausz

value_length = 15

EXCEPTIONS

OTHERS = 1.

Will it assign a value to v_xausz even if p_xausz is blank?

Thanks a lot for your time! Really appreaciate it...

Read only

Former Member
0 Likes
1,248

hi,

yes it works.............if not then try


CAse v_xausz.

when '1'.
p_xausz = '2'.
when others.
p_xausz = '1'.
when space .
p_xausz = '1'.
endcase.

regards,

pankaj

Read only

ak_upadhyay
Contributor
0 Likes
1,248

Hi,

Yes, It will work.....

Regards

AK