2008 Feb 11 7:05 PM
Hi All,
I have itab_output2-storeno field which usually gets store number in it but sometimes I get a string with characters in it. How can I send a error message when itab_output2-storeno has chracters.
Thanks,
Veni.
FORM FORMAT_STORENO.
IF itab_output2-storeno >= 1 AND itab_output2-storeno <= 9.
CONCATENATE '1012'
'00000'
itab_output2-storeno
INTO wa1-storeno.
ELSEIF itab_output2-storeno > 9 AND itab_output2-storeno < 100.
CONCATENATE '1012'
'0000'
itab_output2-storeno
INTO wa1-storeno.
ELSEIF itab_output2-storeno > 99 AND itab_output2-storeno < 1000.
CONCATENATE '1012'
'000'
itab_output2-storeno
INTO wa1-storeno.
ELSEIF itab_output2-storeno > 999 AND itab_output2-storeno < 10000.
CONCATENATE '1012'
'00'
itab_output2-storeno
INTO wa1-storeno.
ENDIF.
ENDFORM. " FORMAT_STORENO
2008 Feb 11 7:07 PM
IF itab_output2-storeno co sy-abcde
message E999 with 'Error'.
endif.
or
IF itab_output2-storeno ca sy-abcde
message E999 with 'Error'.
endif.
a®
2008 Feb 11 7:07 PM
IF itab_output2-storeno co sy-abcde
message E999 with 'Error'.
endif.
or
IF itab_output2-storeno ca sy-abcde
message E999 with 'Error'.
endif.
a®
2008 Feb 11 7:21 PM
Hi ARS,
I tried the logic but it is giving me dump with error message 'Unable to interpret "IONS " as a number'.
IF itab_output2-storeno co sy-abcde.
WRITE: /01 'StoreNo provided', itab_output2-storeno, 'is not a number.'.
ELSEIF itab_output2-storeno >= 1 AND itab_output2-storeno <= 9.
CONCATENATE '1012'
'00000'
itab_output2-storeno
INTO wa1-storeno.
Store number came as 'IONS'.
Thanks,
Veni.
2008 Feb 11 7:31 PM
Check this example
report zars no standard page heading
line-size 170
line-count 65(4).
data : v_text(10) type c value 'IONS'.
if v_text CA sy-abcde.
write : 'Contains char'.
endif.
a®
2008 Feb 11 7:40 PM
Hi ARS,
The characters comming in to Store number is not constant. With the test data I have I saw 3(IONS, NYFL, ORES) different values for it. Is there any way I can catch this with out specifying the literal.
Thanks,
veni.
2008 Feb 11 7:44 PM
Check this example
report zars no standard page heading
line-size 170
line-count 65(4).
if i_output2-stroeno CA sy-abcde.
write : 'Contains char'.
endif.
2008 Feb 11 7:08 PM
Try this before all the IF statements
IF itab_output2-storeno CO '0123456789'.
Write all those IFs here
ELSE.
Write : "It is not a number".
ENDIF.
2008 Feb 11 7:29 PM
Hi Chandrasekhar,
I tried this logic also but it went into else condition when I have number also.
StoreNo provided 1795 is not a number.
StoreNo provided IONS is not a number.
Thanks,
Veni.
2008 Feb 11 7:17 PM
I would have used a case statement for this:
case itab_output2-storeno.
when 1 .......
when others.
raise message.
endcase.
2008 Feb 11 7:41 PM
Hi Jay,
How can I specify store num Ranges in CASE stmt?
Thanks,
Veni.
2008 Feb 11 7:51 PM
when GE '1' AND LE '9'.
CONCATENATE '1012' '00000' itab_output2-storeno INTO wa1-storeno.
when GR 9 AND LR 100.
CONCATENATE '1012' '0000' itab_output2-storeno INTO wa1-storeno.
.....
...
..
.
endcase.
to check if it had a character....
if itab-field ca sy-abcde.
2008 Feb 11 8:00 PM
Thank you ARS. IF itab_output2-storeno CA sy-abcde solved the problem.
Thank you Jay. I will implement CASE in my program.
Regards,
Veni.
2008 Feb 12 12:47 AM
Hi Jay,
Case stmt is not working as you mentioned. Can some one please help me, if can do this with ranges of values.
I am getting the error as 'Field "GE" is unknown. It is neither in one of the specified tables nor
defined by a "DATA" statement.'
CASE itab_output2-storeno.
when GE '1' AND LE '9'.
CONCATENATE '1012' '00000' itab_output2-storeno INTO wa1-storeno.
when GE 9 AND LE 100.
CONCATENATE '1012' '0000' itab_output2-storeno INTO wa1-storeno.
when GE 99 AND LE 1000.
CONCATENATE '1012' '000' itab_output2-storeno INTO wa1-storeno.
when GE 999 AND LE 10000.
CONCATENATE '1012' '00' itab_output2-storeno INTO wa1-storeno.
ENDCASE.
Thanks,
Veni.
2008 Feb 12 2:51 AM
Hi,
Just simplify the code
ifitab_output2-storeno GE '1' AND itab_output2-storeno LE '9'.
CONCATENATE '1012' '00000' itab_output2-storeno INTO wa1-storeno.
endif.
if itab_output2-storeno GE 9 AND itab_output2-storeno LE 100.
CONCATENATE '1012' '0000' itab_output2-storeno INTO wa1-storeno.
endif.
........
.......
......
.......
{code]
a®
2008 Feb 12 11:01 PM