cancel
Showing results for 
Search instead for 
Did you mean: 

Values in if condition

Former Member
0 Kudos

Hi Everyone,

I have to display something like this

the var TNAME TYPE

/BIC/ADEO_0100 A ( If it ends with 00)

/BIC/ADEO_0140 N ( IF it ends with 40)

so in my if condition i specified like this

If TNAME = '/BIC/A%00

TYPE = 'A'.

But it does display anything, the usual one '/BIC/A' works but my requirement is as explained. How do I achieve this result. Any help will be of great help.

Thanks,

Prabhu.

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you are only considering the two values(/bic/adeo_0100 and /bic/adeo_0140) given in your post, you could do something like this.



data: tname(30) type c value '/bic/adeo_0140'.
data: type(1) type c.

if tname cs '00'.
type = 'A'.
elseif tname cs '40'.
type = 'N'.
endif.


Write:/ type.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is another solution.....

I like this one better cause its looking directly at the last 2 characters of the value.



data: tname(30) type c value '/bic/adeo_0140'.
data: type(1) type c.
data: length type i.

length = ( strlen( tname ) - 2 ).

case tname+length(2).
  when '00'.
    type = 'A'.
  when '40'.
    type = 'N'.
endcase.

If this needs to be an IF statement...



data: tname(30) type c value '/bic/adeo_0140'.
data: type(1) type c.
data: length type i.

length = ( strlen( tname ) - 2 ).

IF tname+length(2) = '00'.
    type = 'A'.
ElseIf tname+length(2) = '40'.
    type = 'N'.
EndIf.

Hope this helps.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Rich,

Thanks for the reply, but this information data is from a table, and i want to display the tname which <b>ends</b> with zero zero as the type 'N' and the tname which ends with 40 as 'A'.

which of the string operations will be much suitable. Any help will be of great to me.

Thanks,

Prabhu.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I'm confused, are you saying that you have a value = '/BIC/ADEO_0100' and you need to display or write this value as '/BIC/A'?

Regards,

Rich Heilman

Former Member
0 Kudos

Thanks a lot Rich, sorry i replied to u before u sent the next two examples. I used the if condition logic and it works, thanks a lot once again.

Prabhu.

Answers (0)