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

Data Conversion

Former Member
0 Likes
732

I am selecting from a database table a field of type char and assigning

it to a data object of abap type c.

I want to process the data object further, but as an abap type n since

the function I am calling only operates on this data type.

How can I do this?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
696

Well, you can simply move it. Even if it would have some non-numeric it would work.




report zrich_0001 .

data: c(6) type c.
data: n(6) type n.

c = '12a'.

n = c.

write:/ n.

Regards,

RIch Heilman

7 REPLIES 7
Read only

Former Member
0 Likes
696

Hello,

Can u elaborate so that we can actually help u out ?

Regards,

Deepu.K

Read only

0 Likes
696

data: charvar type c.

data: numvar type n.

move charvar to numvar.

Message was edited by:

A. de Smidt

Read only

Former Member
0 Likes
696

You can move it type N ,but when you save the data into database table,please convert into original format after calculation.

Read only

Former Member
0 Likes
696

Hi

Use the function module CONVERSION_EXIT_ALPHA_OUTPUT.

Regards

Haritha.

Read only

Former Member
0 Likes
696

hi

For this u can use the FM CONVERSION_EXIT_ALPHA_INPUT.

In this FM , give ur source field as exporting and target field as imporitng.

Then u may get the required solution.

regards

sreeni

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
697

Well, you can simply move it. Even if it would have some non-numeric it would work.




report zrich_0001 .

data: c(6) type c.
data: n(6) type n.

c = '12a'.

n = c.

write:/ n.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
696

Sure. The data is processed further in preparing an ALV grid. I want

to set various attributes of the displayed columns, including hiding

any leading zeroes. The function below (set_leading_zero) requires

that the column (in my case the data object referred to above) be

of abap type n.

DATA: salv_column TYPE REF TO cl_salv_column.

TRY.

MOVE salv_columns->get_column( name ) TO salv_column.

salv_column->set_leading_zero( if_salv_c_bool_sap=>false ).

salv_column->set_alignment( alignment ).

salv_column->set_long_text( long_text ).

salv_column->set_tooltip( tooltip ).