Application Development 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: 

checking for last digit change of material number

Former Member
0 Kudos

Hi friends,

I have a problem regaridng check for a material.

i have

*vbap-matnr = '000000000000000234

and now i will change material no

from 000000000000000234 to 000000000000000235

ie : only when the last digit of the number is change it should go into the if condition

code :

the old value will be there in the field

*vbap-matnr = '000000000000000234

and the change value will be in

vbap-matnr = 000000000000000235

if vbap-matnr17(1) = *vbap-matnr17(1)

Endif.

if iam writing in the above way its going ito the if condition even for the last 2 digits change also instead it shouild only when last digit of the material number is change.

How can i do that.

Reagrds

PRIYANKA.

1 ACCEPTED SOLUTION

JozsefSzikszai
Active Contributor
0 Kudos

hi,

IF vbap-matnr+17(1) NE *vbap-matnr+17(1) AND
IF vbap-matnr(17) EQ *vbap-matnr(17).
==> only the last digit changed
ENDIF

hope this helps

ec

6 REPLIES 6

Former Member
0 Kudos

Hi

try comparing both values.

i mean last digit should not match and other digits should match. like this. it will work.

if vbap-matnr17(1) <> mara-matnr17(1)

and vbap-matnr0(17) = mara-matnr0(17).

write:

/ vbap-matnr17(1), mara-matnr17(1).

else.

write: vbap-matnr.

endif.

JozsefSzikszai
Active Contributor
0 Kudos

hi,

IF vbap-matnr+17(1) NE *vbap-matnr+17(1) AND
IF vbap-matnr(17) EQ *vbap-matnr(17).
==> only the last digit changed
ENDIF

hope this helps

ec

Former Member
0 Kudos

while looping the data u need to take old VBAP-MATNR17(1) into one variable and compare that with current VBAP-MATNR17(1).

then only ur issue will be resolved.

VBAP-MATNR+17(1) always take recent value in VBAP-MATNR.

Regards,

Ajay kumar

Former Member
0 Kudos

Example code.

data: lv_matnr type mara-matnr.

loop.

If vbap-matnr17(1) = lv_matnr17(1).

-


-


endif.

clear lv_matnr.

lv_matnr = vbap-matnr.

endloop.

Former Member
0 Kudos

Hi,

you can try this:

DATA: MATNR0 LIKE MARA-MATNR VALUE '000000000000000591'.

DATA: MATNR1 LIKE MARA-MATNR VALUE '000000000100000590'.

DATA: I TYPE I.

*

I = ABS( MATNR0 - MATNR1 ).

*

IF I BETWEEN 1 AND 9.

WRITE: / 'last digit different'.

ELSE.

WRITE: / 'last digit NOT different'.

ENDIF.

Regards, Dieter

Former Member
0 Kudos

hi

the old value will be there in the field

*vbap-matnr = '000000000000000234

and the change value will be in

vbap-matnr = 000000000000000235

Create one more variable to store like

data wa_next_matnr type vbap-matnr.

wa_next_matnr = *vbap-matnr + 1.

Then use it in IF statement Like

if wa_new_matnr = vbap-matnr.

endif.

Take care of alphanumaric material number in prg. otherwise you will get short dump