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

Type conversion

Tanishaa
Participant
0 Likes
3,855

There is a data of type TRUXS_T_TEXT_DATA which needs to be converted into type string. How can it be done?

I've tried direct method, calling classes, but these methods aren't working.

Any suggestion as to how it can be converted into string type?

12 REPLIES 12
Read only

FredericGirod
Active Contributor
3,567

Don't know this TRUXS_T_TEXT_DATA

did you try :

data(my_string) = conv string( my_truxts_t_text_data )  ? 

(maybe it could be a table, in this case --> CL_BCS_CONVERT )

Read only

Tanishaa
Participant
0 Likes
3,567

I tried using this method but it didn't work.

Read only

FredericGirod
Active Contributor
0 Likes
3,567

Could you give us the detail of this TRUXS_T_TEXT_DATA

Read only

LaurensDeprost
Contributor
3,567

Hi Tanisha,

The data of type TRUXS_T_TEXT_DATA is an internal table consisting of one or more lines of 4096 characters.
There are different methods to 'flatten' the table (convert it to a single line/string).

A simple way is to loop over the table and concatenate each line into a separate variable.

DATA lv_concatenated_line TYPE string.<br>
LOOP AT lt_table ASSIGNING FIELD-SYMBOL(<line>).
 lv_concatenated_line = lv_concatenated_line && <line>.
ENDLOOP.
Read only

0 Likes
3,567

Thanks. Will try and see!!

Read only

ThorstenHoefer
Active Contributor
3,567

Hi Tanisha,

Function TEXT_CONVERT_TEX_TO_SAP convert TRUXS_T_TEXT_DATA to an internal table.

I hope following link will be helpful to find a solution.

https://answers.sap.com/questions/6552909/textconverttextosap.html

Best Regards
Thorsten

Read only

0 Likes
3,567

Thank you. Will try this!

Read only

Tanishaa
Participant
0 Likes
3,567

There is lv_data of type TRUXS_T_TEXT_DATA which contains some rows and columns filled with the data like field1, field2, field3, etc.

Now it has to be converted into string type.

Read only

matt
Active Contributor
0 Likes
3,567

Sounds like a job for the REDUCE operator.

DATA(as_a_string) = REDUCE string( INIT text = `` sep = ``
    FOR text_line IN lv_data 
    NEXT text = |{ text }{ sep }{ text_line }| sep = ` ` ).

This produces in as_a_string all the text, delimited at each line by space. Of course you can change that to, e.g. \n for newline.

Read only

VXLozano
Active Contributor
0 Likes
3,567

For Pete's Sake! You've really embraced the new syntax... and I'm still trying to figure the VALUE and NEW sentences *facepalm*

Read only

matt
Active Contributor
0 Likes
3,567

I have to look it up every time. And GROUP BY really baffles me. I never get it right on the first go. And Meshes? Say whut?

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,567

I'm not sure many people know the millions of DDIC types in the system. If you explain the context, people will be more inclined to help you.