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

using class's methods

Former Member
0 Likes
958

Dear All,

I have a question related to using a method of a class with parameters.

What is wrong with my code ?

DATA ref_Var TYPE REF TO CL_ABAP_STRING_UTILITIES.

Data sour(5) type c value 'First'.

Data dest type string.

CL_ABAP_STRING_UTILITIES->C2STR_PRESERVING_BLANKS( sour dest ).

Regards

Ilhan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
911

Hi Ertas,

If CL_ABAP_STRING_UTILITIES is a static class then use

<b>CL_ABAP_STRING_UTILITIES=>C2STR_PRESERVING_BLANKS</b>

otherwise

create object and call like this

<b>ref_var->C2STR_PRESERVING_BLANKS</b>

7 REPLIES 7
Read only

Former Member
0 Likes
911

It should be = not -

CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS( sour dest ).

and the code should be

<b>call method CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS

exporting

source = source

importing

DEST = dest.</b>

or

dest = CL_ABAP_STRING_UTILITIES<b>=></b>C2STR_PRESERVING_BLANKS( sour ).

Regards,

Ravi

Message was edited by:

Ravi Kanth Talagana

Read only

0 Likes
911

hello,

call method is running but the second way with

or

dest = CL_ABAP_STRING_UTILITIES=>C2STR_PRESERVING_BLANKS( sour ).

returns the error message:

C2STR_PRESERVING_BLANKS does not have a Returning Parameter.

You can not use it in expressions.

Does it mean the second way is worng or is there onother alternative.

Regards

Ilhan

Read only

0 Likes
911

Hi Ilhan,

What the error message says is right. You cannot use the second code. Sorry for that. It should have a return parameter instead of the exporting parameter to use it that way. YOu have to use it the other way only.

Regards,

Ravi

Read only

Former Member
0 Likes
911

It should be:

ref_Var->C2STR_PRESERVING_BLANKS( sour dest ).

Read only

0 Likes
911

sorry but it doesn' t help. I get still error message :

ref_Var->C2STR_PRESERVING_BLANKS("

is not defined please check your spelling

Read only

0 Likes
911

Hi Ilhan,

Try this code:

report ZRTTEST .

Data sour(5) type c value 'First'.

Data dest type string.

call method CL_ABAP_STRING_UTILITIES=>C2STR_PRESERVING_BLANKS

exporting

source = sour

importing

DEST = dest.

write: dest.

Regards,

Ravi

Read only

Former Member
0 Likes
912

Hi Ertas,

If CL_ABAP_STRING_UTILITIES is a static class then use

<b>CL_ABAP_STRING_UTILITIES=>C2STR_PRESERVING_BLANKS</b>

otherwise

create object and call like this

<b>ref_var->C2STR_PRESERVING_BLANKS</b>