Application Development and Automation 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: 
Read only

packed decimal to character

0 Likes
787

Hi in this program i need to move data from type P to Char field.

Please suggest me how to handle this logic in ECC.

data: begin of itab

a(1) type c,

b(2) type c,

c type i,

end of itab.

data: d(13) TYPE c .

itab-a = 'a'.

itab-b = 'b'.

itab-c = '123456789'.

d = itab.

write:/ d.

Regards

Bhaskar

Hi in this program i need to move data from type P to Char field.

Please suggest me how to handle this logic in ECC.

data: begin of itab

a(1) type c,

b(2) type c,

c type i,

end of itab.

data: d(13) TYPE c .

itab-a = 'a'.

itab-b = 'b'.

itab-c = '123456789'.

d = itab.

write:/ d.

Regards

Bhaskar

2 REPLIES 2
Read only

karol_seman
Active Participant
0 Likes
628

Hi Bhaskar,

instead of


d = itab.

use


data: c type string.

c = itab-c.
concatenate itab-a itab-b c into d.
write: / d.

so the final code is:


data: begin of itab
a(1) type c,
b(2) type c,
c type i,
end of itab.

data: c type string.
data: d(13) TYPE c .

itab-a = 'a'.
itab-b = 'b'.
itab-c = '123456789'.

c = itab-c.
concatenate itab-a itab-b c into d.
write: / d.

Regards,

Karol

Read only

Former Member
0 Likes
628

I don't see any type P in your coding. If you have a packed decimal field, declare it as type P.

Then you can use the MOVE command to send it to a character field (and you will get a decimal point), or a WRITE ... TO command and you will get a dot or a comma comma as decimal point, depending on your profile.

You have also special FM like CURRENCY_AMOUNT_SAP_TO_IDOC or CURRENCY_AMOUNT_SAP_TO_BAPI.