‎2009 Sep 30 12:19 PM
Hi,
Could someone please give me the ABAP code to convert string table to Char table.
Thanks,
Subash M
‎2009 Sep 30 3:02 PM
Hi,
did you search in SDN?
I think you will get a lot of informations.
regards, Dieter
‎2009 Sep 30 12:25 PM
loop at the string table,
pass it to char structure.
append.
endlooop.
‎2009 Sep 30 12:29 PM
Hi,
Its not that simple, because string and the char would be different lengths and so data loss might be there.
Thanks,
Subash M
‎2009 Sep 30 1:13 PM
its simple.
take strlen of that string . it will give you the string length.
by the way dont you know the maximum length of text what you are going to get?
‎2009 Sep 30 12:48 PM
‎2009 Sep 30 12:53 PM
Hi,
Use SPLIT keyword. For example please type SPLIT in your abap editor and press F1 you will get sample examples.
Cheers!!
VEnk@
‎2009 Sep 30 1:25 PM
‎2009 Sep 30 2:59 PM
Below is an example converting to a binary string - this could be used for regular string as well with a couple of changes
data: lt_pdf type lvc_t_tlin,
ll_pdf like line of lt_pdf,
l_pdf_xstring type xstring,
convert the table into binary string
loop at lt_pdf into ll_pdf.
assign ll_pdf to <l_xline> casting.
concatenate l_pdf_xstring <l_xline> into l_pdf_xstring in byte mode.
endloop.
‎2009 Sep 30 3:02 PM
Hi,
did you search in SDN?
I think you will get a lot of informations.
regards, Dieter
‎2009 Oct 01 6:37 AM
HI
Thanks for your answers.
I still have one more query. Could you please help.
I need to store some text in ITF format.
But I get it as a string and using the funcation module 'CONVERT_STRING_TO_TABLE' I convert it to char table.
Now I need to convert this to stream so that I can use the funcation module CONVERT_STREAM_TO_ITF_TEXT
to finally convert it to ITF .
So could you tell me how to convert it to stream.
I tried various options but nothing is working.
Thanks,
Subash M
‎2009 Oct 01 6:39 AM
‎2009 Oct 01 6:49 AM
Hi Subhash,
As you got data into char table, Char table contains ASCII data only. You can directly pass char table to your CONVERT_STREAM_TO_ITF_TEXT directly like below.
<li>After that you can convert ITF to HTML
" Convert ASCII to ITF
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = l_char_tab "ascii
itf_text = l_itf_tab.
Thanks
Venkat.O
CALL FUNCTION 'CONVERT_ITF_TO_HTML'
EXPORTING
i_header = l_header
i_replace = space
i_html_header = space
TABLES
t_itf_text = l_itf_tab
t_html_text = l_char_tab
EXCEPTIONS
illegal_header = 1
OTHERS = 2.
‎2009 Oct 01 6:53 AM
Hi Subhash, <li>Check the method CONVERT_ASCII_TO_HTML in the class CL_BFW_WEBRESOURCE_POC @SE24 tcode.See the source code of the method. You will come to know many things. Thanks Venkat.O
‎2009 Oct 01 12:24 PM
Hi Venkat/All,
Using CONVERT_ASCII_TO_ITF this works. But the problem is , sometimes the alignment of the the text is not done properly.
For example when there are carriage returns in the text.
Thanks,
Subash M
‎2009 Oct 01 12:49 PM
‎2009 Oct 01 1:00 PM
Hi Subash,
although I don't no what you really want to do and why, this is what I would do to convert a table of STRINGs inro a table of CHAR elements:
FORM conv .
DATA:
lt_string TYPE TABLE OF string,
lv_maxl TYPE sy-linsz,
lr_clin TYPE REF TO data,
lr_ctab TYPE REF TO data.
FIELD-SYMBOLS:
<any> TYPE ANY,
<tab> TYPE table.
* get some test data into a string table
SELECT text
INTO TABLE lt_string
FROM t100
UP TO 100 ROWS.
* determine required maximum length
LOOP AT lt_string ASSIGNING <any>.
CHECK STRLEN( <any> ) > lv_maxl.
lv_maxl = STRLEN( <any> ).
ENDLOOP.
* create a CHASR object of that length
CREATE DATA lr_clin TYPE c LENGTH lv_maxl.
* Now we have a reference to the data, assign it to field-symbol for use
ASSIGN lr_clin->* TO <any>.
* create a table with records of this CHAR field
CREATE DATA lr_ctab LIKE TABLE OF <any>.
* Now we have a reference to the data, assign it to field-symbol for use
ASSIGN lr_ctab->* TO <tab>.
* transfer the STRING data to CHAR data
LOOP AT lt_string ASSIGNING <any>.
APPEND <any> TO <tab>.
ENDLOOP.
* That's it
BREAK-POINT. "See what we got
ENDFORM. " CONVRegards,
Clemens