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

Initial(Prefix) zero gets truncated while saving data in table

Former Member
0 Likes
4,788

Hi,

Through module pool, I am updating a custom table with field Doc_no whose domain has type CHAR(10) with Conversion Routine ALPHA applied on it.

What I need is incase user puts a single digit in DOC_NO, it should get stored with prefix zero i.e "0000000001". I have used function CONVERSION_EXIT_ALPHA_INPUT to convert single digit to "0000000001" in the module-pool. It gets converted at the interface level but while storing in table all the initial zero's get truncated.

Same functionality is also implemented in table VBAK & MARA for field VBELN & MATNR.

Any help would be appreciated.

Regards

Randhir Jha

7 REPLIES 7
Read only

Former Member
0 Likes
1,862

Hi, Randhir.

Data stores as "0000000001" at database level, but in SE11 transaction you see it without leading zeroes by default (because of system conversion exit).

To see real values (with leading zeroes) go to:

SE11 transaction -> Menu -> Utilities -> Settings -> Function builder -> Switch off conversion exit while testing.

Hope it will be helpful for you.

Best regards,

George Shlyahov.

Read only

0 Likes
1,862

Hi George,

Thanks for the prompt response.

I checked in debugger, it gets converted to "0000000001" but while updating the table it saves only 1. I tried with the setting you provided but it is not working. Actually after changing Setting, I changed one record in SE11 itself and saved it.

Again it truncated all the leading zero's.

Regards

Randhir Jha

Read only

0 Likes
1,862

Hi

Why dont you try to use NUMC if you are so keen on having the leading Zeros.This will store the document with leading Zeros.

Regards

Vijay V

Read only

0 Likes
1,862

The values of such fields as VBELN & MATNR will always be saved to database table with leading zeroes.

That's why it is impossible to create two records with "1" and "001" values.

For database these two records are identical.

If the field has type char10, then values "1" and "001" are considered as the different by database.

In your case, an automatic transformation of types could take place before saving. When you specified "001" actually registered "1". Maybe you should choose another variable type (numeric).

Best regards,

George Shlyahov.

Read only

0 Likes
1,862

Hi All,

Thanks for your reply. My problem is resolved.

Using NUMC although it was accepting leading zeros, but within the table if I double click on the record again it would show

document no without leading zeros.

Actually problem was Conversion Routine. As I have mentioned earlier the data element which I was using has domain with conversion routine ALPHA assigned to it. This was truncating the leading zeros. I used same data type CHAR(10) without conversion routine and it worked.

Anyway thanks everyone for your valuable contribution.

Regards

Randhir Jha

Read only

former_member215575
Active Participant
0 Likes
1,862

Hi Randhir,

In debug at INSERT stmt, what value did you see? with zero's or without?

If it is with zero's it should apparently update the table well.

Just to make sure of the issue, where are you checking the table entries, SE11 or SE16N.

If it is in SE16N, Doubleclick on the record to see value unconverted.

Regards,

SG.

Read only

vijaymanikandan
Contributor
0 Likes
1,862

HI

Refer to the link [http://forums.sdn.sap.com/thread.jspa?threadID=402427]

'

Extract is here.

Then go to SE51

Give the program name -> SAPL + "Function group used to generate the screen".

Give the screen number..

Press change..

Go to the layout..

In the input field attributes for that NUMC field...Set the flag "LEADING ZEROES".

Activate the screen..

Then go to SM30..

Give 1 in the numc field and then press enter..You will see 0001

Let me know if you still need help.

Regards

Vijay V