cancel
Showing results for 
Search instead for 
Did you mean: 

String conversion to Char

Former Member
0 Kudos

I have the particular requirement that I want to convert a String type to a char type. Are there any standard functions in ABAP for that?

Any help on the topic will be highly appreciated.

Thanks,

Pratibha

Accepted Solutions (0)

Answers (5)

Answers (5)

Clemenss
Active Contributor
0 Kudos

Hi Pratibha Gavurla,

this is a simple move opration:

charvar = stringvar.

If the defined length of charvar TYPE C variable is less than actual length of stringvar TYPE STRING variable, then it gets truncated.


The story about the C program is complete nonsense. Maybe Vijayendra Rao has a different understanding of your requirement.


Best way is give a small example with actual data and expected result.

Regards Clemens

pranay570708
Active Contributor
0 Kudos

Hi,

Try to use FM CONVERT_STRING_TO_TABLE.

Former Member
0 Kudos

Pratibha,

As String has no fixed length, your best bet is

CHAR_VAR = STRING_VAR+0(n).

n being the length of the CHAR Variable you have declared. There is a potential of data loss here.

regards,

Ravi

NOte :Please mark the helpful answers

Former Member
0 Kudos

Hi Pratibha,

My undersatnding is thats not supported in ABAP.

You can call a C program from ABAP and that can help you do that. In C and C++ you can convert a string into a char is very much possible.

Btw if you are going to convert a string into a char how would you define your Char variable? How will you come to know the length of the string and dynamically define your Char variable?

Rgds

VJ

0 Kudos

I don't think so  there is a need of calling of C or c++ program .

We can get string length using STRLEN. And declare char variable dynamically.

It will not result in loss of data.

Former Member
0 Kudos

Hi Pratibha,

I don't think you need to have a FUnction Module to convert string to char.

Check this code. This would work fine.

data: a type string,

b(5) type c.

a = 'Hello'.

b = a .

write b.

What is your exact requirement??

Regards,

SP.