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

Converting type P to type C

Former Member
0 Likes
1,480

I am having some trouble converting some data from type P to type C. I am only new to abap so please bear with me

I have two variables


DATA gv_shifttime TYPE p.
DATA lv_shifttime type c.

I do some calculations and put the result in gv_shifttime.

When I run the code


lv_shifttime = gv_shifttime.

all I get in lv_shifttime is *

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,073

Hi,

What is your requirement?

Thanks,

Archana

I am having some trouble converting some data from type P to type C. I am only new to abap so please bear with me

I have two variables


DATA gv_shifttime TYPE p.
DATA lv_shifttime type c.

I do some calculations and put the result in gv_shifttime.

When I run the code


lv_shifttime = gv_shifttime.

all I get in lv_shifttime is *

4 REPLIES 4
Read only

Former Member
0 Likes
1,074

Hi,

What is your requirement?

Thanks,

Archana

Read only

0 Likes
1,073

I am trying to build the Commentary for my ALV tree so that I can include the input values when it is printed. I want to include this value in the Commentary

Read only

0 Likes
1,073

Hi,

So why do you want to convert a packed type into character type? Can't you display directly, i mean to say, can't you directly add it to commentery directly?

Or is there any necessicity that you need to convert it in character format?

Also, when you define character type variable you need to spcify length, otherwise it takes default length which is 1 in this case.

You need to define your variable as

DATA lv_shifttime type char10.

It defines variable lv_shifttime with length 10.

Thanks,

Archana

Read only

0 Likes
1,073

I see what the problem was now. When I was adding it directly I could see no value in the print preview or when I paused the program and looked at the variable, this was because the commentary info field is 60 characters long.

I was converting it to a character format so I could try different things to get it working.

But your advice has solved my problem, thankyou.