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

Add zero

Former Member
0 Likes
1,827

Hi Experts,

I have one field like MATNR. Its data type is char(18).

Now my problem is I wrote select querry based on matnr. if it is 100 means it didn't retrieve the data from the data base.

So I used to unpack command and adds 15 zero's to matnr and its working fine.

But if the Matnr is 'M-10' means its shows run time error. So how can I add zeros before to the parameter matnr at run time.

Thanks,

Points Assured.

1 ACCEPTED SOLUTION
Read only

harimanjesh_an
Active Participant
0 Likes
1,781

Hi Jasmine,

Use conversion exits. It will convert ur input data into format that is stored in database.

For example, Matnr = 2340 is stored as 000000000000002340.

So use conversion exit <b>'CONVERSION_EXIT_MATN1_INTPUT'</b>

check this sample code.....

PARAMETERS : p_matnr TYPE mara-matnr.

DATA : w_matnr TYPE mara-matnr,

t_mara TYPE STANDARD TABLE OF mara.

START-OF-SELECTION.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = p_matnr

IMPORTING

output = w_matnr.

.

SELECT * FROM mara INTO TABLE t_mara WHERE matnr = w_matnr.

IF sy-subrc = 0 .

WRITE : / sy-dbcnt.

  • process ur logic.

ENDIF.

Reward me if useful.........

Harimanjesh AN

11 REPLIES 11
Read only

Former Member
0 Likes
1,778

overlay matnr with '000000000000000000'.

Read only

Former Member
0 Likes
1,778

ALFA ALPHA conversion

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

Read only

asik_shameem
Active Contributor
0 Likes
1,778

use the FM <b>conversion_exit_alpha_input</b>

Read only

Former Member
0 Likes
1,778

Hi,

Use FM CONVERSION_EXIT_MATN1_INPUT & CONVERSION_EXIT_MATN1_OUTPUT on matnr field.

Reward Points if this helps,

Regards,

Satish

Read only

Former Member
0 Likes
1,778

Hi

use this fm

CONVERSION_EXIT_ALPHA_INPUT Conversion exit ALPHA, external->internal

CONVERSION_EXIT_ALPHA_OUTPUT Conversion exit ALPHA, internal->external

hope this helps you

Reward pts if useful..

Sreenivas

Read only

Former Member
0 Likes
1,778

Before the material is passed into the where clause of select

Use the conversion routine conversion_exit_matn1_input or

conversion_exit_matn1_output .

This u can see in the domain of the matnr field type .

apply this .

Regards,

Vijay.

Read only

Former Member
0 Likes
1,778

Hello

Please do this

DATA : L_MATNR(18).

write 'M-10' to L_MATNR right-justified.

overlay L_MATNR with '000000000000000000'. "18 zeros.

L_MATNR will now have data as per your format.

<b>Reward points if useful</b>

Regards

Saket Sharma

Read only

harimanjesh_an
Active Participant
0 Likes
1,782

Hi Jasmine,

Use conversion exits. It will convert ur input data into format that is stored in database.

For example, Matnr = 2340 is stored as 000000000000002340.

So use conversion exit <b>'CONVERSION_EXIT_MATN1_INTPUT'</b>

check this sample code.....

PARAMETERS : p_matnr TYPE mara-matnr.

DATA : w_matnr TYPE mara-matnr,

t_mara TYPE STANDARD TABLE OF mara.

START-OF-SELECTION.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = p_matnr

IMPORTING

output = w_matnr.

.

SELECT * FROM mara INTO TABLE t_mara WHERE matnr = w_matnr.

IF sy-subrc = 0 .

WRITE : / sy-dbcnt.

  • process ur logic.

ENDIF.

Reward me if useful.........

Harimanjesh AN

Read only

Former Member
0 Likes
1,778

Hi Jasmine,

Either u can use FM CONVERSION_EXIT_MATN1_INPUT

CONVERSION_EXIT_MATN1_OUTPUT to convert data in your required format.

or u use

ovelay l_matnr with '000000000000000000'.

write: l_matnr.

If it is usefull pls reward pts.

Regards

Srimanta

Read only

Former Member
0 Likes
1,778

I already checked with CONVERSION_EXIT_ALPHA_INPUT.

But its not working when the material number is m-10 (character means).

Any way thanks for the Effort.

Read only

0 Likes
1,778

I have a similar issue. Have you got any solution to this?