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

ABAP PROBLEM!!

Former Member
0 Likes
1,119

I am reading a table from a database into an internal table.

one of the fields in this table is MATNR and is displayed as ****( 4 to 8 character digit). I am comparing it agnist an other internal table field matnr which is '000000000000*****) 18 char field.

my problem is when i compare these fields they do not match because of the extra zero.

i.e 12345 <> 000000000000012345

how can i change the program to mach these fields..

VJ

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
956

Hi,

Use function module CONVERSION_EXIT_ALPHA_INPUT. And pass the material no to it before comapiring.

This will solve your problem.

Reward points if helpful answer.

Ashvender

Message was edited by:

Ashvender Kumar

7 REPLIES 7
Read only

ferry_lianto
Active Contributor
0 Likes
956

Hi,

You can use this FM CONVERSION_EXIT_MATN1_INPUT to add leading zeros for matnr or FM CONVERSION_EXIT_MATN1_OUTPUT to delete leading zeros for matnr.

Then you can compare both fields.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
956

Hi VJ,

Use Conversion exit on MATNR before doing comparision.

For this use FM 'CONVERSION_EXIT_MATN1_INPUT' to add leading zeros and compare this field with inerntal table field.

Thanks,

Vinay

Read only

Former Member
0 Likes
957

Hi,

Use function module CONVERSION_EXIT_ALPHA_INPUT. And pass the material no to it before comapiring.

This will solve your problem.

Reward points if helpful answer.

Ashvender

Message was edited by:

Ashvender Kumar

Read only

Former Member
0 Likes
956

Hi,

You can also use use SHIFT for the field MATNR which has the format "000000000000******".

Example

-


DATA: V_MATNR TYPE MATNR VALUE '000000000TEST'.

SHIFT V_MATNR LEFT DELETING LEADING '0'.

Thanks,

Naren

Read only

0 Likes
956

Hi,

this should solve your problem.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V_MATNR

IMPORTING

OUTPUT = V_MATNR.

Regards

Vara

Read only

Former Member
0 Likes
956

HI,

simple code...

<b>LOOP AT ITAB.

UNPACK ITAB-MATNR TO ITAB-MATNR.

MODIFY ITAB TRANSPORTING MATNR.

ENDLOOP.</b>

now u can compare...

or u can use those conversion exits also.

<b>LOOP AT ITAB.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = ITAB-MATNR

IMPORTING

output = ITAB-MATNR.

MODIFY ITAB TRANSPORTING MATNR.

ENDLOOP.</b>

now itab-matnr has also..000000000001234 = 0000000000001234 ( table field)

Regards

SAB

Read only

Former Member
0 Likes
956

"UNPACK ITAB-MATNR TO ITAB-MATNR" is the fast method rather then calling FM each time thru the loop.