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: 

select statment

Former Member
0 Kudos

Hi..

I am doing a select statement on a database table based on a material number from a legacy file.

The MATNR in SAP is char 18. If the legacy file material number has complete 18 chars like '000000000000100010' , then the select works fine.

but if the legacy file has just '100010' for material number without leading zero's then the select fails.

any idea how to approach this issue .

Thanks and will reward helpful answers.

6 REPLIES 6

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please use this FM CONVERSION_EXIT_MATN1_INPUT to convert legacy material number prior to use in select statement.

Regards,

Ferry Lianto

Former Member
0 Kudos

Hi,

Use Conversion_exit_alpha_input.

reward points if helpful.

kesavadas_thekkillath
Active Contributor
0 Kudos

first add leading zeros to the value and pass it in the select atatement.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

EXPORTING

input = it_mseg_cst-kostl

IMPORTING

OUTPUT = it_mseg_cst-kostl

.

it_alv-kostl = it_mseg_cst-kostl.

modify it_alv.

this function module adds leading zeros to the value.

the zeros will be added to the maximum size of that data type.

reward if useful

Former Member
0 Kudos

hi Kanti,

Before your select statement use CONVERSION_EXIT_MATN1_INPUT FM


DATA : lv_matnr LIKE mard-matnr,


CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = itab-matnr
IMPORTING
output = lv_matnr.

Former Member
0 Kudos

DATA: mat(18).

DATA: matr(18) TYPE n.

mat = '1222140011'.

matr = mat.

DATA: BEGIN OF itab OCCURS 1,

matnr LIKE mara-matnr,

END OF itab.

SELECT matnr FROM mara INTO TABLE itab WHERE matnr = matr.

WRITE:/ mat.

WRITE:/ matr.

LOOP AT itab.

WRITE:/ itab-matnr.

ENDLOOP.

and the result is :

1222140011

000000001222140011

1222140011

if useful reward points.

anju

Former Member
0 Kudos

use conversion exit alpha input function module.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = itab-matnr

IMPORTING

output = itab_matnr.

Hope this answers your curiosity,

Award points if useful else getbk,

Aleem.