Application Development 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: 

Handling long text display

former_member367551
Participant
0 Kudos

Dear forumers,

I have a bit of an issue with a long text display for a smartform in CRM. Hope you can help me out.

Here's what I've done so far:-

A sample text input is initially in a string data type as shown above – in this example, it has 808 characters of length in total.

Next, this text input is passed to the FM, CONV_TEXTSTRING_TO_ITF.

(I had earlier used the FM, G_SPLIT_LINE, but this didn't work well because it had a limitation of 500 characters of length for the text input.)

The text input is broken down into multiple lines as shown above after it is processed by the FM, CONV_TEXTSTRING_TO_ITF.

The text lines here have a maximum length of 132 characters per line.

Next, these text lines will processed by the FM, FORMAT_TEXTLINES.

The text lines are finally formatted as above after it is processed by the FM, FORMAT_TEXTLINES (this is meant to limit the length of text up to 100 characters per line, solely for the smartform display purposes).

These text lines now have a maximum length of 100 characters per line.

How may I resolve the issues as highlighted in the red bubbles?

Appreciate any of your help here.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You should collect string in to internal table then make a loop.

  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

    `This is hello world program`

    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.

3 REPLIES 3

former_member184158
Active Contributor
0 Kudos

Hi,

could you provide the code before using FM /converting,


thanks

Former Member
0 Kudos

You should collect string in to internal table then make a loop.

  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

    `This is hello world program`

    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.

0 Kudos

Thanks much, Avirat. But after populating LT_CHAR128, any idea on how I should convert this data to the internal table of the type, TLINE?