Application Development 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: 

Type conversion

Tanishaa
Participant
0 Kudos

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

FredericGirod
Active Contributor

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 )

Tanishaa
Participant
0 Kudos

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

FredericGirod
Active Contributor
0 Kudos

Could you give us the detail of this TRUXS_T_TEXT_DATA

LaurensDeprost
Contributor

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.

0 Kudos

Thanks. Will try and see!!

ThorstenHoefer
Active Contributor

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

0 Kudos

Thank you. Will try this!

Tanishaa
Participant
0 Kudos

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.

matt
Active Contributor
0 Kudos

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.

VXLozano
Active Contributor
0 Kudos

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

matt
Active Contributor
0 Kudos

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?

Sandra_Rossi
Active Contributor
0 Kudos

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.