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

Issue with Displaying Long Text in Module pool

former_member185978
Active Participant
0 Likes
2,171

Hi Experts,

I am facing problem in displaying long text which I will retrieve from SAP IW23 ( Using READ_TEXT) and display using SET_TEXT_AS_R3TABLE method.

If I give 40 in WORDWRAP MODE  : its breaking @ 40 Characters. But I need to display as it appears in internal table. Say for eg. Internal table contains 10 lines ( Each line has ranges between 10 to 90 Chars .. ) , First Line has 10 chars , 2line has 45 char or 50 or 60...

Whatever the line size , this code is displaying @ 40 Chars .

My requirement is to display as it appears in Internal table.

Here is the sample code:

   CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
        WORDWRAP_POSITION          = 40 "LINE_LENGTH
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>FALSE.

After READ TEXT

   CALL METHOD TEXT_EDITOR1->SET_TEXT_AS_R3TABLE
      EXPORTING
        TABLE           = lt_txt[].

CALL METHOD TEXT_EDITOR1->AUTO_REDRAW
                EXPORTING ENABLE_REDRAW = 1.
CALL METHOD CL_GUI_CFW=>FLUSH.
* set mode
  CALL METHOD TEXT_EDITOR1->set_readonly_mode
    EXPORTING
      readonly_mode          = readonly
    EXCEPTIONS
      error_cntl_call_method = 1
      invalid_parameter      = 2
      OTHERS                 = 3.

I also tried FM   CONVERT_ITF_TO_STREAM_TEXT , didn't work.

I also tried SET_SELECTED_TEXT_AS_R3TABLE , didn't work.

Please help.

With Regards,

Bala

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,538

Hi Bala,

You can pass CL_GUI_TEXTEDIT=>WORDWRAP_OFF or CL_GUI_TEXTEDIT=>WORDWRAP_AT_WINDOWBORDER for the parameter WORDWRAP_MODE.

Thanks,

Ajay Bose

10 REPLIES 10
Read only

Former Member
0 Likes
1,539

Hi Bala,

You can pass CL_GUI_TEXTEDIT=>WORDWRAP_OFF or CL_GUI_TEXTEDIT=>WORDWRAP_AT_WINDOWBORDER for the parameter WORDWRAP_MODE.

Thanks,

Ajay Bose

Read only

0 Likes
1,538

Hi Ajay,

Thanks for your reply. Here are my trails: But no use.

Currently I am using

   CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
        WORDWRAP_POSITION          = 40 "LINE_LENGTH
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>FALSE.

My previous Trails:

   CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
        WORDWRAP_POSITION          = 40 "LINE_LENGTH
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE

   CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>WORDWRAP_OFF

        WORDWRAP_POSITION          = 40 "LINE_LENGTH
        WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>T
RUE

If we use WORDWRAP off. its coming in 1 line.

Read only

0 Likes
1,538

Hi Bala,

You can pass maximum value for WORDWRAP_POSITION instead of value 40. What is the output you are getting in this case?

Thanks,

Ajay

Read only

0 Likes
1,538

Hi Ajay,

I passed

       WORDWRAP_POSITION          = LINE_LENGTH ( 254 Char) its coming in one line.

Here is my requirement.

Suppose I have Long standard text SE78 as :

1st Line --> "THis is my first Line and want to be as in First Line "

2nd Line --> "THis is my sec Line and want to be as in Sec Line  and some more text adding my"

3rd Line --> "THis is my Third Line  "...

But my READ_TEXT is pulling these 3 lines into 3 lines in Internal table, but when displayed it is showing as below when use 40.

THis is my first Line and want to be as in First Line THis is   (40 )

my sec Line and want to be as in Sec Line  and some more (40)

text adding THis is my Third Line  (Remaining).

If I use 50 it divides @ 50. but not as it appears in Internal table ( 3 Lines as it is ).

Read only

0 Likes
1,538

Hi Bala,

Can you paste the complete source code.

Thanks,

Ajay Bose

Read only

0 Likes
1,538

Hi Bala

Can you please comment this and check. Just comment this reste everything remains same

        WORDWRAP_POSITION          = 40 "LINE_LENGTH

Thanks

Nabheet

Read only

0 Likes
1,538

Hi Nabheet,

Thanks for your reply and I tried today by commenting the above said line and it appears like this

I entered while creation :

 

1234567890

0987654321

1234567890

000000000000000000000

99999999999999999999999

77777777777777777

66666666666666666666666666

It appears when displays:

1234567890 0987654321 1234567890 000000000000000000000 99999999999999999999999 77777777777777777 66666666666666666666666666

Hi Jagraj Singh,

Let me try your answer and I will get back to you ASAP.

Read only

0 Likes
1,538

Hi Ajay,

Here is the Full Code @ PBO.

I am able to see 7 lines which comes out from READ_TEXT.

MODULE STATUS_0100 OUTPUT.

data readonly type I value '1'.
data name     type THEAD-TDNAME.

data :lt_tlines   TYPE TABLE OF tline,
      ls_tlines   TYPE tline,
      texthdr     TYPE thead.

DATA: BEGIN OF LT_TXT OCCURS 0,
        LINE(200),
      END OF LT_TXT.

CREATE OBJECT EDITOR_CONTAINER
      EXPORTING
        CONTAINER_NAME              = 'TEXTEDITOR1'
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5.

CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION
         WORDWRAP_POSITION = 80.

if sy-tcode = 'IW23' or
   sy-tcode = 'IW22'.

CONCATENATE VIQMEL-QMNUM 'LONG1' into name.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
     CLIENT                        = SY-MANDT
      ID                            = 'ST'
      LANGUAGE                      = sy-langu
      NAME                          = name
      OBJECT                        = 'TEXT'
*     ARCHIVE_HANDLE                = 0
*     LOCAL_CAT                     = ' '
   IMPORTING
     HEADER                        = texthdr
    TABLES
      LINES                         = lt_tlines
   EXCEPTIONS
     ID                            = 1
     LANGUAGE                      = 2
     NAME                          = 3
     NOT_FOUND                     = 4
     OBJECT                        = 5
     REFERENCE_CHECK               = 6
     WRONG_ACCESS_TO_ARCHIVE       = 7
     OTHERS                        = 8
            .
  IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  loop at lt_tlines into ls_tlines.
    move ls_tlines-TDLINE to lt_txt-line.
    APPEND lt_txt.
  ENDLOOP.

CALL METHOD TEXT_EDITOR1->SET_TEXT_AS_R3TABLE
      EXPORTING
        TABLE           = lt_txt[].

CALL METHOD TEXT_EDITOR1->AUTO_REDRAW
                EXPORTING ENABLE_REDRAW = 1.
CALL METHOD CL_GUI_CFW=>FLUSH.

if sy-tcode = 'IW23'.

  CALL METHOD TEXT_EDITOR1->set_readonly_mode
    EXPORTING
      readonly_mode          = readonly
    EXCEPTIONS
      error_cntl_call_method = 1
      invalid_parameter      = 2
      OTHERS                 = 3.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
endif.
endif.

ENDMODULE. "STATUS_0100 OUTPUT.

Read only

Former Member
0 Likes
1,538

Hi Bala,

I am pasting the code here. Hope you get to use it according to your wish.

**--------Data Declaration for the Text---------**

CONSTANTS:

      co_max TYPE i VALUE 60.

  DATA:

    lv_string       TYPE string,

    lv_sum          TYPE i,

    lv_txt1(co_max) TYPE c,

    lt_txt1         LIKE TABLE OF lv_txt1,

    lv_len1         TYPE i,

    lt_txt2         LIKE TABLE OF lv_txt2,

    lv_len2         TYPE i.

  wa-typ = 'S'.

  wa-key = 'Documentation'(h10).

  CLEAR wa-info.

  APPEND wa TO et_header.

**----------Select the reason text in table---------**

  SELECT * FROM table1 INTO TABLE lt_texts WHERE transid =

  gt_sessions-transid.

  SORT lt_texts BY line.

  LOOP AT lt_texts.

    wa-typ = 'A'.

    lv_string = lt_texts-text.

    IF lv_string IS INITIAL.

      CLEAR : lv_txt2.

    ENDIF.

**----------Splitting the Text into single words and adding them into table----------**

    SPLIT lv_string AT ' ' INTO TABLE lt_txt1.

    IF sy-subrc EQ 0.

      CLEAR : lv_txt2.

    ENDIF.

**---------Adding the text into 40 character long internal table et_header----------**

    LOOP AT lt_txt1 INTO lv_txt1.

      lv_len1 = strlen( lv_txt1 ).

      CHECK lv_len1 <= co_max.

      lv_len2 = strlen( lv_txt2 ).

      lv_sum = lv_len1 + lv_len2 + 1.

      IF lv_sum <= co_max.

        CONCATENATE lv_txt2 lv_txt1 INTO lv_txt2 SEPARATED BY ' '.

        CONDENSE lv_txt2.

      ELSE.

        wa-info = lv_txt2.

        APPEND wa TO et_header.

        CLEAR : lv_txt2, wa.

        CONCATENATE lv_txt2 lv_txt1 INTO lv_txt2 SEPARATED BY ' '.

        CONDENSE lv_txt2.

      ENDIF.

    ENDLOOP.

    wa-info = lv_txt2.

    APPEND wa TO et_header.

  ENDLOOP.

*---------------------------------------------------------------------------------------------------------*

Hope this helps.  You might have to debug and tweak the code according to your needs.

Reward points if helpful.

Best Regards,

Jagraj Singh.

Read only

former_member185978
Active Participant
0 Likes
1,538

Hi All,

Thanks for all your help and Efforts. I got what I was looking..

With this lines are appearing as it shows in Internal table, but differs when you exceed the border on right. In this case , 6666666666666 ... exceed the border and thatz the reason one 6 appears in next line.

 

1234567890

0987654321

1234567890

000000000000000000000

99999999999999999999999

77777777777777777

6666666666666666666666666

6

   CREATE OBJECT TEXT_EDITOR1
      EXPORTING
        PARENT           = EDITOR_CONTAINER
        WORDWRAP_MODE    = CL_GUI_TEXTEDIT=>wordwrap_at_windowborder .