on ‎2006 Apr 29 10:11 AM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try to use FM CONVERT_STRING_TO_TABLE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.