cancel
Showing results for 
Search instead for 
Did you mean: 

Need zeros infront of a number

Former Member
0 Kudos

HI Experts,

I have a 2 Infoobjects

1. EMPNumber Nchar (8)

2. PNumber Char (20)

now my question is i need to include zeros if there is less than 8 characters for the no.1 and 9 characters for No.2

1. 987656 should be 00987656

2. i.e; 98765 should be 000098765

I am getting No.2 from R/3 so i cant even chgange the length of it to 9 characters

Any ideas Please.

Thanks,

john

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Siggi,

If possible can you please give me a step by step procedure.

john.

Former Member
0 Kudos

John,

imagine you create a routine in the update rules to a object called zperson. In the routine you need to enter the following code:

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting input = comm_structure-zperson

importing output = result.

Hope this helps!

regards

Siggi

Answers (7)

Answers (7)

Former Member
0 Kudos

You can use a function module called 'conversion_exit_alpha_input'.

Former Member
0 Kudos

Hi John

If it is so you can use the standard object as a template to a Z-info object and then now u can check the alpha conversion routine in the General tab of Z-info object.

Cheers

Chaks

Former Member
0 Kudos

Hi John,

You van use the "NUMCV Conversion Routine". Document "Conversion Routines in BW" says the next about this routine:

<i>When converting from an external into an internal format this checks whether the entry in the

INPUT field is wholly numerical, whether it consists of digits only, possibly with blank spaces

before and/or after. If yes, the sequence of digits is copied to the OUTPUT field, right-aligned,

and the space on the left is filled with zeros (‘0’). Otherwise the blank characters are removed

from the sequence of digits, the result is transferred, left-aligned, into the output field, and this is

then filled from the right with blank characters.</i>

Hope this helps.

Regards,

Harald

Former Member
0 Kudos

Hello experts,

But if i am taking the Business content which dosent have Alpha in it, lets say (0person)which is of 8 Ncharacters, can you let me know how to include zeros for it befor.

Thank You,

John.

Former Member
0 Kudos

Hi John,

in a routine call the function 'CONVERSION_EXIT_ALPHA_INPUT'. Pass the value as input parameter to it and you get the value back with leading zeroes.

regards

Siggi

Former Member
0 Kudos

Hi John

If the object is already created and now you would like to include the aplha conversion use the T-code RSMDCNVEXIT.Click "enable the activation of conversion routine icon" next to the refresh icon.Give the Basic characteristic, the type of conversion routine (ALPHA) and then click the activate conversion routine tab.

Regards

Chaks

edwin_harpino
Active Contributor
0 Kudos

hi john,

if your infoobject has convers. routine ALPHA,

you can tick the 'conversion' checkbox in transfer rules maintenance, last column.

or you can use following sample routine

data : lv_material(18) type c value '000000000000000000',

lv_length type i.

RESULT = TRAN_STRUCTURE-[fieldname].

lv_length = 18 - strlen( RESULT ).

if lv_length > 0 and lv_length < 18.

shift RESULT right by lv_length places.

RESULT(lv_length) = lv_material(lv_length).

endif.

hope this helps.

Former Member
0 Kudos

Hi John,

I dont know why you would like to get the "leading zeroes" as SAP would insert them internally for you.

Bye

Dinesh