Application Development 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: 

Copy from CHAR to CHAR

Former Member
0 Kudos

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?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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 valueshould get
77770000007777
444440000044444
9999990000999999


Former Member
0 Kudos

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.

0 Kudos

That's what I need! thank you!