‎2007 Jun 21 8:27 AM
Can anyone explain me
1. How to add leading zeros to a field in abap objects.
For eg:
data: dmb(6) type c value '123456',
actually the output value of c should have leading zeros added to it for length 16.
i.e '0000000000123456' . If the length of dmb is less than 16 then leading zeros should be added to that value to make it 16 as length.
Please tell me how to do it in ABAP Objects.
‎2007 Jun 21 8:30 AM
Hi,
U can use the FM "CONVERSION_EXIT_ALPHA_INPUT"
Passing the dmb
Just make sure that ur variabl should be of char(16) in ur case.
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>
‎2007 Jun 21 8:30 AM
Hi,
Take another character variable of length 16 and assign this dmb to that variable.
Regards,
Suruchi
Message was edited by:
Suruchi Mahajan
‎2007 Jun 21 8:31 AM
Hi
Declare a TYPE N field with 16 length
data: dmb(6) type c value '123456',
dmb1(16) type N.
Move dmb to dmb1.
use DMB1 in your code
Reward points for useful Answers
Regards
Anji
‎2007 Jun 21 8:32 AM
Hi Camila ,
You can use the unpack command.
Here is a sample program for the same
DATA : v1(16),
v2(6) TYPE c VALUE '123456'.
unpack v2 to v1.
write /: v1 , v2Regards
Arun
‎2007 Jun 21 8:33 AM
U can try this .
data: dmb(16) type c value '123456',
i_value(16) type n .
i_value = dmb .
write i_value .
~ Laxmi
Reward helpful answers
‎2007 Jun 21 9:10 AM
Hi laxmi,
If the dmb value has decimal points like '123456.20' then the
i_value should have '0000000123456.20'. How this can be done. if i apply
the logic which u told then it is removing the decimal places. Could u please help
me in this.
‎2016 Jan 06 11:07 AM
Hi Laxmi,
It perfectly works, if you integer type data type.
Thanks for your suggestion.
Regards,
Naveen
‎2007 Jun 21 8:40 AM
hi,
use Fm 'CONVERSION_EXIT_ALPHA_OUTPUT'
EX:
Data: Dat(16) type c. -> how much length u want while creating a variable itself.
Dat = '9999999'.
CALL FUNCTION 'CONVERTION_EXIT_ALPHA_OUTPUT'.
Exporitng
FIELD = Dat
Importing
FIELD = Dat.
Write: Dat.
if useful reward some points.
with regards,
suresh.
‎2007 Jun 21 8:49 AM
Hi Camila
Try to use the statement
DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ',
M1(4) VALUE 'ABCD',
M2(6) VALUE 'BJJCA '.
SHIFT ALPHABET LEFT DELETING LEADING M1.The field
ALPHABET
remains unchanged.
SHIFT ALPHABET LEFT DELETING LEADING SPACE.The field ALPHABET now has the following contents:
'ABCDEFGHIJ '.SHIFT ALPHABET RIGHT DELETING TRAILING M2.<b>ALPHABET</b> now has the following contents:
' ABCDEFGHI'.<u><b>IN CHARACTER MODE</b></u>
<b>Effect</b>
This is the default setting (see above), and the addition is therefore optional.
<b>Note
Performance:</b>
For performance reasons, you should avoid using SHIFT in WHILE loops.
The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ...
LEFT DELETING LEADING
... variant is around 3.5 msn, for ...
RIGHT DELETING TRAILING
... around 4.5 msn.
Reward all helpfull answers
Regards
Pavan
‎2016 Jan 06 11:40 AM
Hi Camila,
Use FM "CONVERSION_EXIT_ALPHA_INPUT" like below:-
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = V1
IMPORTING
OUTPUT = V1
If it is integer type say "1234" , leading zeros will be added to it, if it is some character or string type say "ABCD", it will remain same.
The data type of both INPUT and OUTPUT should be same, it can be any, this is the mandatory condition. Whether you use same variable for both or different.
Hope this may help you.
Regards,
Swati
‎2016 Jan 06 11:53 AM
What is DMB ?
If it is something that already exists in SAP such as a material number (but with a different use in the same way that you have 'Material Number' and 'Old Material Number'), then define a custom data element with a domain of MATNR.
If however, it is totally custom and does not appear anywhere in SAP then create a domain with the relevant characteristics (ie C with a length of 16), and define the conversion exit as 'ALPHA'. Make sure you document the domain.
Then create a data element based upon the domain you have created. Document this data element since it is this documentation that will appear when the user presses the F1 key.
Use the data element to define your fields. When you use it as a parameter the zeroes will be added automatically. When you write it out to a report the zeroes will be removed. ie it will work in exactly the same way as a material number.
This avoids the need to keep calling the relevant conversion exits.
Regards
Rich
‎2016 Jan 06 12:01 PM
Hi,
Kindly use the fm "CONVERSION_EXIT_ALPHA_INPUT".
Pass the input field and it will add the leading zero.
‎2016 Jan 06 3:27 PM
Old post resurrected for no good reason - locked. People - please check the date of the start of the thread before posting.
‎2021 Feb 08 5:26 PM
first of all... please check fields domain routine..if there is any FM mention for converion then use it..
for example for field matnr you must use "CONVERSION_EXIT_MATN1_INPUT" .
if there no routine mention in the domain then you can use "CONVERSION_EXIT_ALPHA_INPUT" .
Thank You .