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

Need logic to split a long text

Former Member
0 Likes
2,115

Hi ,

i will be getting a long text with varied length.

i need to split the text at the 60th position and send it to one record.

for ex : Text length is 60 ...........i will create one record.

if the text length is more that 60 .....................Lets say 120, i need to split the text at 60th and send it to 2 records.

as of now i am using this logic :

     IF NOT V_LINES IS INITIAL.

      V_TXTSQN = 1.

      LOOP AT IT_TLINE1.

            V_TABIX = SY-TABIX.

        V_TDLINE = IT_TLINE1-TDLINE.

        CONCATENATE V_TEXT4 V_TDLINE INTO V_LONGTEXT1.

        V_STRLEN = STRLEN( V_LONGTEXT1 ).

        IF V_STRLEN LE 60.

          V_TEXT1 = V_LONGTEXT1+0(60).
          MOVE: V_TEXT1  TO IT_FINAL1-TXT,
                V_TXTSQN TO IT_FINAL1-SQN.
          APPEND IT_FINAL1.

          V_TXTSQN = V_TXTSQN + 1.

        ELSEIF V_STRLEN LE 120.

          V_TEXT1 = V_LONGTEXT1+0(60).
          CLEAR IT_FINAL1-TXTDTA.
          MOVE: V_TEXT1  TO IT_FINAL1-TXT,
                V_TXTSQN TO IT_FINAL1-SQN.
          APPEND IT_FINAL1.
          V_TXTSQN = V_TXTSQN + 1.

          IF V_TABIX = V_LINES.
            V_TEXT2 = V_LONGTEXT1+60(60).
            CLEAR IT_FINAL1-TXTDTA.
            MOVE: V_TEXT2  TO IT_FINAL1-TXT,
                  V_TXTSQN TO IT_FINAL1-SQN.
            APPEND IT_FINAL1.
            V_TXTSQN = V_TXTSQN + 1.
          ELSE.
            V_TEXT3 = V_LONGTEXT+60(60).
          ENDIF.

        ELSEIF V_STRLEN > 120.

          V_TEXT1 = V_LONGTEXT1+0(60).
          CLEAR IT_FINAL1-TXT.
          MOVE: V_TEXT1  TO IT_FINAL1-TXT,
                V_TXTSQN TO IT_FINAL1-SQN.
          APPEND IT_FINAL1.
          V_TXTSQN = V_TXTSQN + 1.

          V_TEXT2 = V_LONGTEXT1+60(60).
          CLEAR IT_FINAL1-TXTDTA.
          MOVE: V_TEXT2  TO IT_FINAL1-TXT,
                V_TXTSQN TO IT_FINAL1-SQN.

          APPEND IT_FINAL1.
          V_TXTSQN = V_TXTSQN + 1.

          V_TEXT3 = V_LONGTEXT1+120(60).
          CLEAR IT_FINAL1-TXT.
          MOVE: V_TEXT3  TO IT_FINAL1-TXT,
                V_TXTSQN TO IT_FINAL1-SQN.

          APPEND IT_FINAL1.
          V_TXTSQN = V_TXT + 1.

          V_TEXT5 = V_LONGTEXT1+180(60).


        ENDIF.

        IF V_TABIX < V_LINES.
          V_TEXT4 = V_TEXT5.
        ENDIF.
     ENDLOOP.

this code handles only upto 240 length.

Is there any other way to do it , so that we can handle any length in TEXT.

Thanks in advance.

Vikki.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,320

Hello

Use FM 'RKD_WORD_WRAP'

Set 60 as parameter

3 REPLIES 3
Read only

Former Member
0 Likes
1,321

Hello

Use FM 'RKD_WORD_WRAP'

Set 60 as parameter

Read only

kamesh_g
Contributor
0 Likes
1,320

USe FM RKD_WORD_WRAP'

Edited by: KAMESH G on Jan 23, 2009 8:09 AM

Read only

Former Member
0 Likes
1,320

In case you don't have standard FM, you can use small ABAP code:

http://scn.sap.com/message/16534430#16534430