05-08-2008 10:37 PM
Is there a FM, or a seriese of calls, which will allow me to take a string and put that into an internal table? Let me explain why.
I have a free-formated text box, on a webpage, and I need to include this text on a SmartForm. The issue is that I can't predict the length of the text and I can't have any of the text cutoff. My solution is to put the string into an internal table and then loop at that table. This will allow the node, in the SmartForm, to expand, thus keeping each and ever character (not cutting any of it off). I assume this will work but I don't know how to cut this string apart and put it in an internal table.
I could simply cut it at a certain length but that may cut words apart and I can't have that; I need the line breaks in between words.
Any ideas?
Thanks,
Aaron
05-09-2008 1:31 AM
Hi Aaron,
something like this might suit your needs. This example builds a string then puts it into an itab of CHAR128.
DATA: lv_string TYPE string,
lt_split TYPE TABLE OF char40,
lt_char128 TYPE TABLE OF char128,
lv_wa_str TYPE string,
lv_len TYPE int4,
lr_split TYPE REF TO char40,
lr_char128 TYPE REF TO char128.
DO 50 TIMES.
CONCATENATE lv_string
`The quick brown fox jumped over the lazy dog. `
INTO lv_string.
ENDDO.
SPLIT lv_string AT space INTO TABLE lt_split.
LOOP AT lt_split REFERENCE INTO lr_split.
lv_len = STRLEN( lv_wa_str ) + STRLEN( lr_split->* ).
IF lv_len LT 128.
CONCATENATE lv_wa_str lr_split->* INTO lv_wa_str SEPARATED BY space.
ELSE.
APPEND lv_wa_str TO lt_char128.
lv_wa_str = lr_split->*.
ENDIF.
ENDLOOP.
APPEND lv_wa_str TO lt_char128.
Cheers
Graham Robbo
05-08-2008 10:41 PM
try to use:
SPLIT string AT SPACE INTO ITAB
Or instead of SPACE use ' '.
02-09-2012 7:05 AM
i have split the string by ' | ' and the internal table is type of standard table name SFLIGHT.
05-09-2008 1:31 AM
Hi Aaron,
something like this might suit your needs. This example builds a string then puts it into an itab of CHAR128.
DATA: lv_string TYPE string,
lt_split TYPE TABLE OF char40,
lt_char128 TYPE TABLE OF char128,
lv_wa_str TYPE string,
lv_len TYPE int4,
lr_split TYPE REF TO char40,
lr_char128 TYPE REF TO char128.
DO 50 TIMES.
CONCATENATE lv_string
`The quick brown fox jumped over the lazy dog. `
INTO lv_string.
ENDDO.
SPLIT lv_string AT space INTO TABLE lt_split.
LOOP AT lt_split REFERENCE INTO lr_split.
lv_len = STRLEN( lv_wa_str ) + STRLEN( lr_split->* ).
IF lv_len LT 128.
CONCATENATE lv_wa_str lr_split->* INTO lv_wa_str SEPARATED BY space.
ELSE.
APPEND lv_wa_str TO lt_char128.
lv_wa_str = lr_split->*.
ENDIF.
ENDLOOP.
APPEND lv_wa_str TO lt_char128.
Cheers
Graham Robbo
05-09-2008 1:53 AM
Graham, that works like a charm! Now it is time to study this code.
Thank you so much!
Aaron
02-09-2012 7:10 AM
ya its useful.
one more doubt.
i want to assign that string to internal table fields(data: itab type table of sflight).
how we move the string indivudually to each field of internal table.
02-09-2012 7:40 AM
02-18-2014 10:19 AM
I know I'm late for this, but have you tried function module SCMS_STRING_TO_FTEXT?
If you search SCMS_* you have a lot of useful conversion function modules...
Regards,
03-18-2021 9:31 AM
09-06-2016 6:09 PM
Here is a way to implemnt what you want
DATA: BEGIN OF t_split OCCURS 0,
vkorg TYPE char4,
END OF t_split.
RANGES: r_vkorg FOR vbrk-vkorg.
"TYPE TABLE OF char4 WITH HEADER LINE.
REFRESH: t_split[] , r_vkorg[].
SPLIT 'OV01,OV02,OV07,' AT ',' INTO TABLE t_split.
LOOP AT t_split.
CLEAR r_vkorg.
r_vkorg-sign = 'I'.
r_vkorg-option = 'EQ'.
r_vkorg-low = t_split-vkorg.
APPEND r_vkorg.
ENDLOOP.