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

Validation for last 2 places in coding

Former Member
0 Likes
1,113

hi all , i have a field g_aufk-zz_pmf_key it is 7 char

i need to pass it to t_aufk if the last 2 char are numbers

so i wrote

IF g_aufk-zz_pmf_key+5(2) CA '0123456789'.

t_aufk = g_aufk-zz_pmf_key.

ELSE.

WRITE:/'error'.

ENDIF.

but when i see i debugging i can see the value in g_aufk-zz_pmf_key+5(2) is blank .

can anynody suggest me a better way ?

Regards

hi all , i have a field g_aufk-zz_pmf_key it is 7 char

i need to pass it to t_aufk if the last 2 char are numbers

so i wrote

IF g_aufk-zz_pmf_key+5(2) CA '0123456789'.

t_aufk = g_aufk-zz_pmf_key.

ELSE.

WRITE:/'error'.

ENDIF.

but when i see i debugging i can see the value in g_aufk-zz_pmf_key+5(2) is blank .

can anynody suggest me a better way ?

Regards

10 REPLIES 10
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,088

Hello ,

The code you have written should work fine.

The only reason i can see is that the last 2 fields are blank in g_aufk-zz_pmf_key . So it will not give any results. You need to check this.

Rgds,

sandeep

Read only

0 Likes
1,088

hello sandeep the value in g_pmkey+5(2) is blank

but i g_pnkey there is a value .

Can you please help me with ths

Read only

0 Likes
1,088

But you are c hecking g_pmkey+5(2) and not g_pnkey.

Please paste ur code here.

Read only

0 Likes
1,088

Hi Bhanu,

You can use the below logic.

Declare a variable of length 7 say namely ld_var.

ld_var = g_aufk-zz_pmf_key

Use FM CONVERSION_EXIT_ALPHA_INPUT on ld_var.

IF ld_var+5(2) CA '0123456789'.

t_aufk = g_aufk-zz_pmf_key.

ELSE.

WRITE:/'error'.

ENDIF.

Read only

Former Member
0 Likes
1,088

Hey Bhanu,

According to your logic, even if one of the characters turns out to be a number, data will be passed to t_ausk, which I think is not according to your requirement. for eg: wot if last 2 characters are 'a2' ?

Using your logic, data will be passed.

Why don't you see for each character..

ie,


IF g_aufk-zz_pmf_key+5(1) CA '0123456789' and 
    g_aufk-zz_pmf_key+6(1) CA '0123456789'.
    t_aufk = g_aufk-zz_pmf_key.
ELSE.
  WRITE:/'error'.
ENDIF.

cheers,

Vishnu

Read only

Former Member
0 Likes
1,088

Hello,

It is working fine for me if not you can use this logic.

I tested just now it is working fine.

DATA: y_v_char TYPE char7 VALUE 'ABCDE89'.

DATA: y_v_char1 TYPE char2.

IF y_v_char+5(2) CA 'ABCDE89'.

y_v_char1 = y_v_char+5(2).

ELSE.

WRITE:/'error'.

ENDIF.

Read only

Former Member
0 Likes
1,088

Check if g_aufk-zz_pmf_key have any value and is not empty.

regards,

Advait

Read only

Former Member
0 Likes
1,088

hi,

i tried like this. it's getting value... just check it once...

data: zz_pmf_key(7)  type c value 'abcde45'.
data: t_aufk(2) type c.

IF zz_pmf_key+5(2) CA '0123456789'.
t_aufk = zz_pmf_key+5(2).
*move zz_pmf_key+5(2) TO t_aufk.
ELSE.
WRITE:/'error'.
ENDIF.

Regards,

Shankar.

Read only

Former Member
0 Likes
1,088

Hi,

DATA : LEN TYPE I,

IND1 TYPE I,

IND2 TYPE I.

LEN = STRLEN( G_AUFK-ZZ_PMF_KEY ).

IND1 = LEN - 2.

IND2 = LEN - 1.

IF G_AUFK-ZZ_PMF_KEYIND1(1) CA '0123456789' AND G_AUFK-ZZ_PMF_KEYIND2(1) CA '0123456789'.

T_AUFK = G_AUFK-ZZ_PMF_KEY.

ELSE.

WRITE:/'error'.

ENDIF.

Read only

Former Member
0 Likes
1,088

If you want to check that BOTH characters are numbers, you must code

 CO '0123456789'. 

and NOT

 CA '0123456789'.