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

Convert string table to Char table

Former Member
0 Likes
5,969

Hi,

Could someone please give me the ABAP code to convert string table to Char table.

Thanks,

Subash M

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,937

Hi,

did you search in SDN?

I think you will get a lot of informations.

regards, Dieter

15 REPLIES 15
Read only

Former Member
0 Likes
2,937

loop at the string table,

pass it to char structure.

append.

endlooop.

Read only

0 Likes
2,937

Hi,

Its not that simple, because string and the char would be different lengths and so data loss might be there.

Thanks,

Subash M

Read only

0 Likes
2,937

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?

Read only

Former Member
0 Likes
2,937

Try to use FM CONVERT_STRING_TO_TABLE

Read only

Former Member
0 Likes
2,937

Hi,

Use SPLIT keyword. For example please type SPLIT in your abap editor and press F1 you will get sample examples.

Cheers!!

VEnk@

Read only

Former Member
0 Likes
2,937

Try FM RKD_WORD_WRAP.

Read only

Former Member
0 Likes
2,937

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.

Read only

Former Member
0 Likes
2,938

Hi,

did you search in SDN?

I think you will get a lot of informations.

regards, Dieter

Read only

0 Likes
2,936

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

Read only

0 Likes
2,936

CONVERT_ASCII_TO_ITF

try this

Read only

0 Likes
2,936

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.

" Convert ASCII to ITF
  CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
       TABLES
            text_stream = l_char_tab   "ascii
            itf_text    = l_itf_tab.
<li>After that you can convert ITF to HTML

  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.
Thanks Venkat.O

Read only

0 Likes
2,936

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

Read only

0 Likes
2,936

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

Read only

0 Likes
2,936

you can use format is before you call the FM

Read only

Clemenss
Active Contributor
0 Likes
2,936

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.                    " CONV

Regards,

Clemens