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

ABAP Text format logic

Former Member
0 Likes
3,401

Hello,

I need a small logic to convert a text in a internal table so that the line length is restricted to 50 chars from existing  72 char.

Example :-

Currently internal table has the below data

I used TEXT_SPLIT and got the below output into a new IT with 50 char line length but the split line ( 2nd ) and the new line ( 3rd ) do not  continue and looks like a split data.

Pls provide me a logic so that I can convert the data to something like this and show continuous text .

Pls let me know.

Regards

Praneeth

1 ACCEPTED SOLUTION
Read only

Private_Member_7726
Active Contributor
0 Likes
2,455

Hi,

FORMAT_TEXTLINES with FORMATWIDTH = 50, especially if the source table is of type TLINE (ITF or SapScript text). Result you can move to your own internal table.

cheers

Janis

Hello,

I need a small logic to convert a text in a internal table so that the line length is restricted to 50 chars from existing  72 char.

Example :-

Currently internal table has the below data

I used TEXT_SPLIT and got the below output into a new IT with 50 char line length but the split line ( 2nd ) and the new line ( 3rd ) do not  continue and looks like a split data.

Pls provide me a logic so that I can convert the data to something like this and show continuous text .

Pls let me know.

Regards

Praneeth

6 REPLIES 6
Read only

Former Member
0 Likes
2,455

Hi,

i dont think there is any FM that provides a solution. as i had to do a split, i checked if the next word exceed 50 characters. If so, i did a split at SPACE, because i did not want to devide the words.

regards

Stefan Seeburger

Read only

Former Member
0 Likes
2,455

Hi Praneeth.

Why don't you concatenate all text lines inside a string variable and then split it using FM "SALP_POP_SPLIT_TEXT"?

As FM output uses string table, pay attention when some word exceeds line length on your work internal table or variable, because you have to break/split it manually!

Best regards from Brazil!

Alexandre B. Dambrowski

Read only

Private_Member_7726
Active Contributor
0 Likes
2,456

Hi,

FORMAT_TEXTLINES with FORMATWIDTH = 50, especially if the source table is of type TLINE (ITF or SapScript text). Result you can move to your own internal table.

cheers

Janis

Read only

0 Likes
2,455

Thank you.

Works perfectly.

Read only

0 Likes
2,455

For word lengths not exceeding 50 chars... Also, it may be useful to execute

CONDENSE_TEXTLINES after the format FM.

cheers

Janis


Read only

former_member201275
Active Contributor
0 Likes
2,455

Here we go:

   DATA: lv_text72(72),
      lv_text50(50),
      lv_len      TYPE int4,
      lt_split    TYPE TABLE OF char40,
      lr_split    TYPE REF TO char40,
      lt_char50  TYPE TABLE OF char50,
      lt_char72  TYPE TABLE OF char72.


LOOP AT lt_char72 INTO lv_text72.

  SPLIT lv_text72 AT space INTO TABLE lt_split.

  LOOP AT lt_split REFERENCE INTO lr_split.
    lv_len = STRLEN( lv_text50 ) + STRLEN( lr_split->* ).
    IF lv_len LT 50.
      CONCATENATE lv_text50 lr_split->* INTO lv_text50 SEPARATED BY space.
    ELSE.
      APPEND lv_text50 TO lt_char50.
      lv_text50 = lr_split->*.
    ENDIF.
  ENDLOOP.
  APPEND lv_text50 TO lt_char50.
ENDLOOP.