2008 Nov 20 10:39 AM
Hi Friends,
I have a issue, i have two fields of char30 and the users enters numeric values in that and i have to added the data.
i have to validate the data enter by users before adding.
there are chances that users may enter values like'80 0' then i have to throug an error , how to do that. i am unable to capture that sapce between 80 and 0.
is there any Function module ?
regards
Kumar M
2008 Nov 20 12:55 PM
Hi try this code.
DATA : char03 TYPE char30 VALUE '1234567890.',
char04 TYPE char30,
len1 type i,
len2 type i.
PARAMETER: char01 TYPE char30,
char02 TYPE char30.
len1 = strlen( char01 ).
len2 = strlen( char02 ).
replace ' ' with '$' into char01.
replace ' ' with '$' into char02.
search char01 for '$'.
if sy-fdpos lt len1.
write 'space available'.
endif.
search char02 for '$'.
if sy-fdpos lt len2.
write 'space available'.
endif.
Regards,
vicky.
2008 Nov 20 10:45 AM
Hi ,
First find the string length using STRLEN.
Then check
If wf_field+0(strlen) CA space.
Raise error.
Endif.
Regards,
Sachin M M
Edited by: Sachin Mathapati on Nov 20, 2008 4:16 PM
2008 Nov 20 10:47 AM
Hello Kumar,
Try this simple code:
v_string = '80 80 80'.
V_LEN1 = STRLEN( V_STRING ). "V_LEN1 = 8
CONDENSE V_STRING. "Now V_STRING = '808080'.
V_LEN2 = STRLEN( V_STRING ). "V_LEN1 = 6
IF V_LEN1 NE V-LEN2.
* Throw Error Message
ENDIF.
Hope this helps.
BR,
Suhas
2008 Nov 20 10:48 AM
May we know why you are using character field to get numeric values?
If you use numeric or integer type then this will be taken care by the system itself.
Regards
Karthik D
2008 Nov 20 10:49 AM
Hi,
Try this
IF p_fname CO '1,2,3,4,5,6,7,8,9,0' .
ELSE.
Error MEssage.
ENDIF.
2008 Nov 20 10:49 AM
Hi,
Check this out...
constant : c_space type space.
search variable for C_space.
if sy-subrc = 0.
"throw error.
endif.
Hope it was helpful...
2008 Nov 20 10:52 AM
REPORT ZSRK_073 MESSAGE-ID ZMSG .
PARAMETERS : P_F1(30),
P_F2(30).
DATA : L_F(30),
L_F1 TYPE I,
L_F2 TYPE I.
AT SELECTION-SCREEN.
L_F1 = STRLEN( P_F1 ).
L_F2 = STRLEN( P_F2 ).
IF P_F1+0(L_F1) CA SPACE.
MESSAGE E999 WITH 'Space exist in P_F1'.
ENDIF.
IF P_F2+0(L_F2) CA SPACE.
MESSAGE E999 WITH 'Space exist in P_F2'.
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_F1
IMPORTING
OUTPUT = P_F1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_F2
IMPORTING
OUTPUT = P_F2.
L_F = P_F1 + P_F2.
WRITE : / L_F.
2008 Nov 20 12:55 PM
Hi try this code.
DATA : char03 TYPE char30 VALUE '1234567890.',
char04 TYPE char30,
len1 type i,
len2 type i.
PARAMETER: char01 TYPE char30,
char02 TYPE char30.
len1 = strlen( char01 ).
len2 = strlen( char02 ).
replace ' ' with '$' into char01.
replace ' ' with '$' into char02.
search char01 for '$'.
if sy-fdpos lt len1.
write 'space available'.
endif.
search char02 for '$'.
if sy-fdpos lt len2.
write 'space available'.
endif.
Regards,
vicky.
2008 Nov 20 12:56 PM
Hi Vicky,
I am really satisfied with your answer.
Edited by: Kumar M on Nov 20, 2008 1:57 PM
2008 Nov 20 1:21 PM
But i think at first you addressed him( vicky ) as Chandu, didnt you?
Is that his pet name or you know him personally?
>
> Hi Chandu,
>
> I am really satisfied with your answer.
Regards
Karthik D