how to convert from '2182 ' to '000000002182' BUT ALS

Question: how to easyest convert an char variable content from e.g. '2182 ' to '000000002182' BUT also e.g. '12182 ' to '000000012182'

Thank you
Brane

Answer:
Hi Brane,

See the answer to your last post. This is to do with conversion exits.
_________________
Regards

R


Abap KC
SFMDR

Answer:
Use Function module.

CONVERSION_EXIT_ALPHA_INPUT

Sanket
_________________
Sanket Kansal
SAP HR Techno-Functional Consultant

Answer:
Why don't you use the command 'unpack f to g'? However, be aware of the character case; it will result in short dump.

Answer:
Why don't you use the command 'unpack f to g'? However, be aware of the character case; it will result in short dump.

It may seem to be the simplest and easiest way, but SAP provide what are called conversion exits, and these exits are there for a reason. If you use SAP supplied methods, and SAP change these methods then your programs will continue to function.

However, if you do thinks like you suggest and SAP change the conversion exits, then your program will keep doing the conversion the old way and will probably fail.

The other reason why your method may fail is that if it is used on something like material numbers, customer or vendor codes, these can be alpha numeric in which case other rules are applied.

Have a look at the topic on conversion exits in the Abappers Knowledge Corner (you will have to regsiter to view thiis I'm afraid)
_________________
Regards

R


Abap KC
SFMDR

Answer:
Also check out type N

Answer:
To cover all the bases, how about looking into SHIFT and TRANSLATE?


_________________
The Doc
Magna Grand Docot of the Tuly Idiot Order

2007 Basic Rules

Answer:
do n times
concatenate '0' my_value into my_value.
enddo.

where n is size of data element - size of you value.

for second case just delete spaces and use the same trick.

or use conversion routine as it has been said.

I have used this method many times and it works well.

hope it helps.

how to easyest convert an char variable content from e.g. '2182 ' to '000000002182' BUT also e.g. '12182 ' to '000000012182'

Thank you
Brane
_________________
programming is not only coding

Answer:
Why do this?

do n times
concatenate '0' my_value into my_value.
enddo.

where n is size of data element - size of you value.

How about:

SHIFT field RIGHT DELETING TRAILING SPACE.
TRANSLATE field USING '0 '.

Or (expanding on angry_god's theme):

DATA field_n(12) TYPE N.
field_n = field.
_________________
The Doc
Magna Grand Docot of the Tuly Idiot Order

2007 Basic Rules

Answer:
Hey guys...stop confusing Brane with all these 'other options'!

Brane,
Though all these other options might do -- "convert from '2182 ' to '000000002182'", as R says, Conversion exits is what you are looking for.

br.
Copyright ?2007 - 2008 www.jt77.com