Skip to Content
author's profile photo Former Member
Former Member

Split string to put into Internal Table

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on May 09, 2008 at 12: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 08, 2008 at 09:41 PM

    try to use:

    SPLIT string AT SPACE INTO ITAB

    Or instead of SPACE use ' '.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2014 at 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,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 06, 2016 at 05: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.