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

Length conversion in program

Former Member
0 Likes
2,733

Hi,

I am shyam. I am creating simple program.

parameter : p_matnr type mara-matnr.

Length of mara-matnr is 18.

During compile time-

i am giving value p_matnr=157.

it is working.

But if i am putting value in program means hard code

p_matnr=157.

i am facing run time error.

its show you gave value less than length.

Please provide me length conversion  code.

Thanks and Regrads,

SHYAM.

10 REPLIES 10
Read only

former_member214878
Active Participant
0 Likes
2,147

Read only

vinoth_aruldass
Contributor
0 Likes
2,147

hi,

in program you must satisfy the field length.

try p_matnr = '000000000000000157'.

because in some of the table entries it will be stored as the above . ex(MSEG)

try.

Regards,

Vinoth Aruldass.

Read only

vinoth_aruldass
Contributor
0 Likes
2,147

hi,

data : p_matnr type matnr.

p_matnr = '157'

pack p_matnr to p_matnr.

try it works,

regards,

Vinoth Aruldass s.

Read only

0 Likes
2,147

Read only

Former Member
0 Likes
2,147

Hi shyam,

if you do not put the value in quotes(' ') then it is treated as integer.

p_matnr = 157 is integer assignment to character. and integer length is 32 bytes which you are trying to assign to char field of 18 characters. So the dump.

As my friend told please put '000000000000000157'. or use statement. pack p_matnr to p_matnr.

thanks,

Read only

former_member193464
Contributor
0 Likes
2,147

put p_matnr = '157' , atleast it wont dump , but still you will not be able to fetch data from database tables . so you need to use CONVERSION_EXIT_MATN1_INPUT  to change your p_matnr.

You can always find conversion routine by going into the domain for that field , In definition tab you could see a field Convers. Routine. Hope it helps.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,147

Look for the domain MATNR definition -> There should be a conversion exit (like MATN1), double-click on this field; you get the FM name to convert a material number from external format to internal CONVERSION_EXIT_MATN1_INPUT and from internal to external (as WRITE statement implicitally do) CONVERSION_EXIT_MATN1_OUTPUT.

NB: The right justified, left padded with zero is only valid for ALPHA conversion exit and only if there are only space and a contiguous group of number. (better use CONVERSION_EXIT_ALPHA_INPUT FM in this case) In many SAP solutions, the ALPHA conversion exit is not suitable for material number.

Regards,

Raymond

Read only

Former Member
0 Likes
2,147

Hi Shyam,

  As other BI experts told, please preceed the value "157" with zeros and this will fix your issue.

Thanks,

Umashankar

Read only

Former Member
0 Likes
2,147

Hi,

      SHIFT p_matnr RIGHT DELETING TRAILING ' '.                        

      OVERLAY p_matnr WITH '000000000000000000'.           " 18 zero's 

Regard's

Smruti Ranjan

Read only

Former Member
0 Likes
2,147

thnks for giude me