2014 Jan 08 4:59 AM
Hello,
there is a standard internal table, but I don't know how this internal table look like, could be any standard table.
My propose is to store this standard table in a field of flat structure(need to be converted back to standard table later), it could be stored in a reference field, but in my case, i cannot use reference.
so I want to store standard table in a xstring, but i don't know how to convert a standard table to a xstring and convert back.
Please give some samples.
Thanks in advance and best regards,
Kevin
Hello,
there is a standard internal table, but I don't know how this internal table look like, could be any standard table.
My propose is to store this standard table in a field of flat structure(need to be converted back to standard table later), it could be stored in a reference field, but in my case, i cannot use reference.
so I want to store standard table in a xstring, but i don't know how to convert a standard table to a xstring and convert back.
Please give some samples.
Thanks in advance and best regards,
Kevin
2014 Jan 08 5:34 AM
hi Kevin
standard table to xstring:1 step using FM 'SCMS_TEXT_TO_BINARY', 2 step using FM 'SCMS_BINARY_TO_XSTRING''
xstring to standard table: 1 step using FM 'SCMS_XSTRING_TO_BINARY', 2 step using 'SCMS_BINARY_TO_TEXT'.
regards,
Archer
2014 Jan 08 5:39 AM
HI kevin,
Please try this combination FM.
SOTR_SERV_TABLE_TO_STRING
SCMS_STRING_TO_XSTRING or SCMS_FTEXT_TO_XSTRING
At the end of this data would be in xstring.
For reverse process :
HR_KR_XSTRING_TO_STRING - converting to string
for converting from string to internal table. You can code it like
This is a sample code of mine
CONSTANTS:
max TYPE i VALUE 15.
DATA:
lv_string TYPE string,
lv_sum TYPE i,
lv_txt1(co_max) TYPE c,
lt_txt1 LIKE TABLE OF lv_txt1,
lv_len1 TYPE i,
lv_txt2(co_max) TYPE c,
lt_txt2 LIKE TABLE OF lv_txt2,
lv_len2 TYPE i.
lv_string = 'WHERE BNAME = ''SFLIGHT*'' AND CONNID = ''AA'''.
SPLIT lv_string AT ' ' INTO TABLE lt_txt1.
LOOP AT lt_txt1 INTO lv_txt1.
lv_len1 = strlen( lv_txt1 ).
ASSERT lv_len1 <= max.
lv_len2 = strlen( lv_txt2 ).
lv_sum = lv_len1 + lv_len2 + 1.
IF lv_sum <= max.
CONCATENATE lv_txt2 lv_txt1 INTO lv_txt2 SEPARATED BY ' '.
CONDENSE lv_txt2.
ELSE.
APPEND lv_txt2 TO lt_txt2.
lv_txt2 = lv_txt1.
ENDIF.
ENDLOOP.
APPEND lv_txt2 TO lt_txt2.
LOOP AT lt_txt2 INTO lv_txt2.
WRITE: / lv_txt2.
ENDLOOP.
Regards,
Sivaganesh
2014 Jan 08 7:11 AM
Declare a variable of type String and transfer the entire contents of your internal table to that variable.
Than call the FM below.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = html_string
* MIMETYPE = ' '
* ENCODING =
IMPORTING
buffer = xhtml_string
EXCEPTIONS
failed = 1
OTHERS = 2.
Thanks
Abhinab
2015 Apr 13 7:37 PM
the problem is not from string to xstring. this piece we can just do
data(l_xstirng) = CL_ABAP_CODEPAGE=>convert_to(source = l_string)
or
data(l_string) = CL_ABAP_CODEPAGE=>convert_from(source = l_xstring)
Dr.Horst Keller has an example here in sdn.
the problem is, the internal table you have, may have mixed data types.
types: begin of ty_line,
a type c,
b type p,
end of ty_line.
data: ls_line type ty_line,
lt_tab type standard table of ty_line.
here you can't simply write lt_tab to string because component b is a number.
you have to move b to data(l_string)
then concatenate your work with l_string to the final string.
George
2015 Apr 14 2:59 AM
Thank you for your answers, they are really helpful, this discussion is closed.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |