05-29-2014 4:02 PM
Hi, help me please.
I copy data from one internal table (1_table) in another internal table (2_table).
Copy number "7777" from the field of CHAR (10) in "1_table" in the CHAR (10) in "2_table".
In the second table I have to get the value "0000007777".
How can I do this in ABAP?
05-29-2014 4:14 PM
You didn't give all the details but you should be able to adapt this code to your needs.
loop at 1_table into w_table.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
importing
input = w_table-field
exporting
output = w_table-field.
append w_table to 2_table.
endloop.
This will add leading zeros to any value that is all numeric, but leave it unchanged if it is not all numeric.
So, your 7777 will convert to 0000007777 but 77.77 will not pad with leading zeros.
I does not matter how many leading zeros you need, the FM will figure it out.
05-29-2014 4:12 PM
and in 2_table table I will copy different numbers and I need to add up to 10 characters in front of the number zero...
Ie I have to copy as follows:
initial value | should get |
7777 | 0000007777 |
44444 | 0000044444 |
999999 | 0000999999 |
05-29-2014 4:14 PM
You didn't give all the details but you should be able to adapt this code to your needs.
loop at 1_table into w_table.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
importing
input = w_table-field
exporting
output = w_table-field.
append w_table to 2_table.
endloop.
This will add leading zeros to any value that is all numeric, but leave it unchanged if it is not all numeric.
So, your 7777 will convert to 0000007777 but 77.77 will not pad with leading zeros.
I does not matter how many leading zeros you need, the FM will figure it out.
05-29-2014 4:53 PM