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: 

HOW TO PRINT LONG TEXT OF 255 CHARACTER IN ALV GRID instead of132 Char's

0 Kudos

Hi sir/mam

i'm sreekar can any one help me on this please

"As I took a variable 'STR' with 255 length, But still ALV GRID DISPLAYS the same 132 characters, and

When I download the report into excel it is showing the 250 charactered text"

how can i print it in alv grid

FORM BUID_CATALOG .

DATA : COL_POS TYPE I.

COL_POS = COL_POS + 1.

*--DECLARING FIELDCATALOG FOR HEADER

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'EBELN'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Purch.doc.no.'(002).

LT_FCAT-REF_FIELDNAME = 'EBELN'.

LT_FCAT-REF_TABNAME = 'EKKO'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'BEDAT'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Po Date'(003).

LT_FCAT-REF_FIELDNAME = 'EBDAT'.

LT_FCAT-EDIT_MASK = '__.__.____'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'EKGRP'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Purch.Grp'(004).

LT_FCAT-REF_FIELDNAME = 'BKGRP'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'EKNAM'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Purch.Grp. Name'(005).

LT_FCAT-REF_FIELDNAME = 'EKNAM'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'LIFNR'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Vendor No.'(006).

LT_FCAT-REF_FIELDNAME = 'ELIFN'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'NAME1'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Vendor Name'(007).

LT_FCAT-REF_FIELDNAME = 'NAME1_GP'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'ZTERM'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Pay.Code'(008).

LT_FCAT-REF_FIELDNAME = 'ZTERM'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'TEXT1'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Own explanation'(009).

LT_FCAT-REF_FIELDNAME = 'DZTERM'.

LT_FCAT-OUTPUTLEN = '30'.

LT_FCAT-DDICTXT = 'L'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'WAERS'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Curr'(010).

LT_FCAT-REF_FIELDNAME = 'WAERS'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

LT_FCAT-COL_POS = COL_POS.

LT_FCAT-FIELDNAME = 'NETWR'.

LT_FCAT-TABNAME = 'LT_FINAL'.

LT_FCAT-SELTEXT_L = 'Net Value'(011).

LT_FCAT-REF_FIELDNAME = 'BWERT'.

APPEND LT_FCAT.

CLEAR LT_FCAT.

ENDFORM. " BUID_CATALOG

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_BUFFER_ACTIVE = 'X'

I_BACKGROUND_ID = 'ALV_BACKGROUND'

IS_LAYOUT = GS_LAYOUT

IT_FIELDCAT = LT_FCAT[]

I_SAVE = G_SAVE

IS_VARIANT = GS_VARIANT

IMPORTING

E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER

ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER

TABLES

T_OUTTAB = LT_FINAL[]

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC = 0.

IF G_EXIT_CAUSED_BY_CALLER = 'X'.

ELSE.

IF GS_EXIT_CAUSED_BY_USER-BACK = 'X'. "F3

EXIT.

ELSE.

IF GS_EXIT_CAUSED_BY_USER-EXIT = 'X'. "F15

LEAVE TO SCREEN 1000.

ELSE.

IF GS_EXIT_CAUSED_BY_USER-CANCEL = 'X'. "F12

LEAVE TO SCREEN 1000.

ELSE.

EXIT.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ELSE.

ENDIF.

ENDFORM. " DISPLAY_DATA

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'F15' "ls_thead-tdid PAYMENT TERMS

LANGUAGE = SY-LANGU "ls_thead-tdspras "CURRENT LANGUAGE 'E'

NAME = NAME "ls_thead-tdname PO NUMBER LW_EKKO-EBELN

OBJECT = 'EKKO' "ls_thead-tdobject TABLE NAME EKKO

IMPORTING

HEADER = HTEXT

TABLES

LINES = LTEXT

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.

LOOP AT LTEXT.

IF LTEXT-TDLINE NE ''.

MOVE LTEXT-TDLINE TO WA_WORD-TEXT.

APPEND WA_WORD TO LT_SENTENCE.

ENDIF.

ENDLOOP.

ENDIF.

LOOP AT LT_SENTENCE INTO WA_WORD.

COUNT = COUNT + 1.

IF COUNT = 1.

STR = WA_WORD-TEXT.

LW_FINAL-TEXT1 = STR.

ELSEIF COUNT = 2 OR COUNT = 3 OR COUNT = 4 OR COUNT = 5 OR COUNT = 6 OR COUNT = 7 OR COUNT = 8.

CONCATENATE STR WA_WORD-TEXT INTO STR SEPARATED BY SPACE.

LW_FINAL-TEXT1 = STR.

ENDIF.

ENDLOOP.

6 REPLIES 6

Former Member
0 Kudos

Hi,

I think you ll have to use word wrap functionality for that particular column to achieve this functionality. As such i dont think a column in ALV can hold more than 132 characters.

You will have to use word wrap to extend this particular column over two lines so that the whole text is displayed.

Use function module 'RKD_WORD_WRAP' to split your field which has length more than 132 characters into two. In Reuse_alv_grid_display display only first line.

Use event AFTER_LINE_OUTPUT to display the second line. Hope this helps

Regards,

Arun

Former Member
0 Kudos

Hi,

I think you ll have to use word wrap functionality for that particular column to achieve this functionality. As such i dont think a column in ALV can hold more than 132 characters.

You will have to use word wrap to extend this particular column over two lines so that the whole text is displayed.

Use function module 'RKD_WORD_WRAP' to split your field which has length more than 132 characters into two. In Reuse_alv_grid_display display only first line.

Use event AFTER_LINE_OUTPUT to display the second line. Hope this helps

Regards,

Arun

0 Kudos

can you provide an example of how to wrap the text i have like this please see the below code and correct if any errors

FORM GET_TEXT_LINES .

DATA :NAME TYPE THEAD-TDNAME.

NAME = LW_EKKO-EBELN.

V_TABIX = SY-TABIX.

*********************************************************************

  • CALLING FUNCTION READ_TEXT FOR PAYMENT TEXTS

*********************************************************************

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT "CLIENT ID 200/600/400

ID = 'F15' "ls_thead-tdid "PAYMENT TERMS TEXT ID 'F15'

LANGUAGE = SY-LANGU "ls_thead-tdspras "CURRENT LANGUAGE 'E'

NAME = NAME "ls_thead-tdname "PO NUMBER LW_EKKO-EBELN

OBJECT = 'EKKO' "ls_thead-tdobject "TABLE NAME EKKO

IMPORTING

HEADER = HTEXT "LS_THEAD

TABLES

LINES = LTEXT "LT_LINES[]

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.

LOOP AT LTEXT.

IF LTEXT-TDLINE NE ''.

MOVE LTEXT-TDLINE TO WA_WORD-TEXT.

APPEND WA_WORD TO LT_SENTENCE.

ENDIF.

ENDLOOP.

ENDIF.

  • Word Wrap the text in multiple lines

LOOP AT LT_SENTENCE INTO WA_WORD.

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING

TEXTLINE = WA_WORD-TEXT

OUTPUTLEN = 100

TABLES

OUT_LINES = LT_SENTENCE

EXCEPTIONS

OUTPUTLEN_TOO_LARGE = 1

OTHERS = 2.

IF SY-SUBRC EQ 0.

    • IF not LT_SENTENCE IS INITIAL.

READ TABLE LT_SENTENCE INTO WA_WORD INDEX v_tabix.

LW_FINAL-TEXT1 = WA_WORD_TEXT.

MODIFY LT_FINAL FROM LW_FINAL INDEX V_TABIX.

ENDLOOP.

CLEAR: LT_SENTENCE.

ENDFORM. " GET_TEXT_LINES

&----


*& Form LAYOUT_INIT

&----


  • text

----


  • -->P_GS_LAYOUT text

----


FORM LAYOUT_INIT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.

*"Build layout for list display

RS_LAYOUT-DETAIL_POPUP = 'X'.

ENDFORM. " LAYOUT_INIT

&----


*& Form EVENTTAB_BUILD

&----


  • text

----


  • -->P_GT_EVENTS[] text

----


FORM EVENTTAB_BUILD USING RT_EVENTS TYPE SLIS_T_EVENT.

*"Registration of events to happen during list display

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = RT_EVENTS.

READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_AFTER_LINE_OUTPUT

INTO LS_EVENT.

IF SY-SUBRC = 0.

APPEND LS_EVENT TO RT_EVENTS.

ENDIF.

ENDFORM. " EVENTTAB_BUILD

&----


*& Form AFTER_LINE_OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM AFTER_LINE_OUTPUT.

  • CLEAR :COUNT,LT_SENTENCE.

LOOP AT LT_SENTENCE INTO WA_WORD.

READ TABLE LT_SENTENCE INTO WA_WORD INDEX V_TABIX.

CHECK SY-SUBRC = 0.

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING

TEXTLINE = WA_WORD-TEXT

OUTPUTLEN = 20

TABLES

OUT_LINES = LT_SENTENCE.

DESCRIBE TABLE LT_SENTENCE LINES V_TABIX.

CHECK V_TABIX > 1.

COUNT = COUNT + 1.

IF COUNT = 1.

STR = WA_WORD-TEXT.

LW_FINAL-TEXT1 = STR.

ELSEIF COUNT = 2 OR COUNT = 3 OR COUNT = 4 OR COUNT = 5 OR COUNT = 6 OR COUNT = 7 OR COUNT = 8.

CONCATENATE STR WA_WORD-TEXT INTO STR SEPARATED BY SPACE.

LW_FINAL-TEXT1 = STR.

ENDIF.

ENDLOOP.

ENDFORM. " AFTER_LINE_OUTPUT

Former Member
0 Kudos

I utilize function module RKD_WORD_WRAP and then insert the rows into the table to be displayed in the ALV, duplicating the "key" fields into the new text rows....Then call the ALV with cell merging on, sorted, etc.

presents one row with all values, then additional rows with only the additional text displayed.

0 Kudos

Hi,

Breakpoint s suggestion is much simpler and i guess you should follow it.

Use RKD_WORD_WRAP to break long text into two or three lines. Then while filling the Internal table, duplicate the key fields for all subsequent lines

For eg , let fields be MATNR , PLANT and LONG TEXT. This is how the internal table should be populated

first row - 1000 100 abcdefgh

second row 1000 100 ijklmnopq

third row 1000 100 rstuvwxyz

Hope you got the drift. Then populate IT_SORT table and make use of Merge cells option also ( I think default is Merge , so maybe nothing needs to be done just check it up once. )

Once this is done , during actual display of ALV the report will be displayed as follows:

first row - 1000 100 abcdefgh

second row (blank) (blank) ijklmnopq

third row (blank) (blank) rstuvwxyz

Regards,

Arun

0 Kudos

Thanks for the good ideas guys it really helped me to pitch my graph towards output but still there is a problem in that

i'm getting output of single line only and not the remaining lines, is it really possible to word wrap in alv grid.