cancel
Showing results for 
Search instead for 
Did you mean: 

long text in alv

Former Member
0 Kudos
239

Hi,

Iam trying to display alv list with one internal table(itab1).

I have another itab2 which is having very long text and which is appended as 4 lines.

Now i want to combine this itab2 into itab1 to dispaly long text.

Can any one explain me how to append this data.Here is the code.

My object is to put long text in the ALV list.Iam using QM02 transaction to get the data.

REPORT YQM_NOTIFICATION MESSAGE-ID ZM NO STANDARD PAGE HEADING

LINE-SIZE 255.

TYPE-POOLS: SLIS.

TABLES: QPCT,

QPGT,

QMEL,

QMMA,

IHPA.

DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

ITAB_EXTAB TYPE SLIS_T_EXTAB.

DATA: IT_FIELD TYPE SLIS_T_FIELDCAT_ALV,

W_LAYOUT TYPE SLIS_LAYOUT_ALV,

IT_EXCLU TYPE SLIS_T_EXTAB,

GS_EXTAB TYPE SLIS_EXTAB.

DATA : F_TDOBJECT LIKE THEAD-TDOBJECT,

F_TDNAME LIKE THEAD-TDNAME,

F_TDID LIKE THEAD-TDID,

ITAB_LINES LIKE tline OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF ITAB OCCURS 10,

DESC(72) TYPE C,

END OF ITAB.

DATA: BEGIN OF T_HDR OCCURS 0,

GROUP LIKE QPGT-CODEGRUPPE,

CODE LIKE QPCT-CODE,

TEXT LIKE QPCT-KURZTEXT,

NAME LIKE QPGT-KURZTEXT,

END OF T_HDR.

DATA: BEGIN OF T_DET OCCURS 0,

SNO TYPE I,

QMNUM LIKE QMEL-QMNUM, " NOTIFICATION NUMBER(REF NO)

REFNUM LIKE QMEL-REFNUM, " CONTRACT NO

PARNR LIKE IHPA-PARNR,

QMTXT LIKE QMEL-QMTXT,

QMGRP LIKE QMEL-QMGRP,

QMCOD LIKE QMEL-QMCOD,

OBJNR LIKE QMEL-OBJNR,

DESC(72),

END OF T_DET.

DATA: SNO TYPE I.

DATA: V_REPID TYPE SY-REPID.

SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_QMNUM FOR QMEL-QMNUM,

S_QMART FOR QMEL-QMART,

S_QMDAT FOR QMEL-QMDAT.

SELECTION-SCREEN END OF BLOCK A1.

START-OF-SELECTION.

PERFORM GET_DATA.

  • PERFORM 2000_GET_MAIN.

PERFORM DISPLAY_ALV.

END-OF-SELECTION.

&----


*& FORM DISPLAY_ALV

&----


  • TEXT

----


FORM DISPLAY_ALV.

PERFORM FIELD_CAT USING FIELDCAT.

V_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

IT_FIELDCAT = FIELDCAT

IT_EXCLUDING = ITAB_EXTAB

TABLES

T_OUTTAB = T_DET

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "DISPLAY_ALV

&----


*& FORM FIELD_CAT

&----


  • TEXT

----


  • -->P_FIELDCAT TEXT

----


FORM FIELD_CAT USING P_FIELDCAT.

  • FIELD CATELOG FOR ALV DISPLAY.

DATA: I_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR I_FIELDCAT.

I_FIELDCAT-FIELDNAME = 'SNO'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'S.NO'.

I_FIELDCAT-OUTPUTLEN = 4.

APPEND I_FIELDCAT TO FIELDCAT.

I_FIELDCAT-FIELDNAME = 'QMNUM'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'REF.NO'.

I_FIELDCAT-OUTPUTLEN = 18.

APPEND I_FIELDCAT TO FIELDCAT.

I_FIELDCAT-FIELDNAME = 'REFNUM'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'CONTRACT NO'.

I_FIELDCAT-OUTPUTLEN = 18.

APPEND I_FIELDCAT TO FIELDCAT.

I_FIELDCAT-FIELDNAME = 'PARNR'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'A-DIV'.

I_FIELDCAT-OUTPUTLEN = 10.

APPEND I_FIELDCAT TO FIELDCAT.

I_FIELDCAT-FIELDNAME = 'QMTXT'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'DESCRIPTION'.

I_FIELDCAT-OUTPUTLEN = 25.

APPEND I_FIELDCAT TO FIELDCAT.

I_FIELDCAT-FIELDNAME = 'DESC'.

I_FIELDCAT-TABNAME = 'T_DET'.

I_FIELDCAT-NO_OUT = ' '.

I_FIELDCAT-SELTEXT_L = 'DEFECT'.

I_FIELDCAT-OUTPUTLEN = 100.

APPEND I_FIELDCAT TO FIELDCAT.

ENDFORM. "FIED_CAT

&----


*& FORM GET_DATA

&----


  • TEXT

----


FORM GET_DATA.

*TO GET HEADER

SELECT CODEGRUPPE CODE KURZTEXT FROM QPCT INTO TABLE T_HDR.

LOOP AT T_HDR.

SELECT SINGLE * FROM QPGT WHERE CODEGRUPPE = T_HDR-GROUP.

IF SY-SUBRC = 0.

T_HDR-NAME = QPGT-KURZTEXT.

MODIFY T_HDR.

CLEAR T_HDR.

ENDIF.

ENDLOOP.

*TO GET DETAILS

SELECT QMNUM REFNUM QMDAT QMTXT OBJNR QMGRP QMCOD FROM QMEL

INTO CORRESPONDING FIELDS OF TABLE T_DET

WHERE QMNUM IN S_QMNUM AND

QMART IN S_QMART AND

QMDAT IN S_QMDAT.

LOOP AT T_DET.

SELECT SINGLE * FROM IHPA WHERE OBJNR = T_DET-OBJNR.

IF SY-SUBRC = 0.

T_DET-PARNR = IHPA-PARNR.

MODIFY T_DET.

CLEAR T_DET.

ENDIF.

ENDLOOP.

LOOP AT T_DET.

DELETE T_HDR WHERE GROUP NE T_DET-QMGRP.

ENDLOOP.

LOOP AT T_DET.

SNO = SNO + 1.

T_DET-SNO = SNO.

MODIFY T_DET.

CLEAR T_DET.

ENDLOOP.

CLEAR : ITAB.

REFRESH : ITAB.

LOOP AT T_DET.

F_TDID = 'LTQM'.

F_TDNAME = T_DET-QMNUM.

F_TDOBJECT = 'QMEL'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = F_TDID

LANGUAGE = SY-LANGU

NAME = F_TDNAME

OBJECT = F_TDOBJECT

TABLES

LINES = ITAB_LINES.

DESCRIBE TABLE ITAB_LINES LINES SY-TFILL.

IF SY-TFILL > 0.

LOOP AT ITAB_LINES.

ITAB-DESC = ITAB_LINES-TDLINE.

<b>APPEND ITAB</b>. "itab2

CLEAR ITAB.

ENDLOOP.

ENDIF.

ENDLOOP.

  • <b>LOOP AT ITAB.</b>

  • T_DET-DESC = ITAB-DESC.

  • MODIFY T_DET.

  • CLEAR T_DET. "itab1

  • <b>ENDLOOP.</b>

ENDFORM. "GET_DATA<b></b><b></b><b></b>

points guaranteed

cheers

kaki

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi again,

1. the code/logic should be something like this

2. it will use TWO LOOPS.

3 X 5 = 15

3 [notifitab]

5 [descitab] -- for each notifitab

15 [alvitab]

3. Loop at NOTIFITAB. [3 times]

ALVITAB-NOTN = NOTIFITAB-NOTN.

Read Text in DescITAB.

Loop at DESCITAB. [5 times - for each notif]

ALVITAB-DESC = DESCITAB-DESC.

APPEND ALVITAB.

ENDLOOP.

ENDLOOP.

4. The above will get the desired output.

Hope it helps.

regards,

amit m.

Message was edited by: Amit Mittal

Message was edited by: Amit Mittal

Former Member
0 Kudos

Hi,

Have you thought about using TEXT EDIT control? However, if you want it to be a part of the row of the ALV, it will not be possible.

regards,

Ravi

Former Member
0 Kudos

Hi again,

1. I don't think it is directly possible in alv.

2. bcos Notification is a simple field

3. But Description ?

This is fetched into an INTERNAL Table

having many rows.

3. One option is :

The internal table which uare displaying

in alv (lets say ITAB)

Populate it with some home-grown logic.

4. lets say u have 3 Notifications

each having Descriptions of 5 lines.

ie 3 x 5 = 15 lines

5. So loop thru all descriptions

and populate both fields one by one.

-


itab should something like this -


-


make the notification field blank

for lines starting from 2 (for each notification)

6. NOT001 line1

line2

lin3

line4

NOT002 line 1

line 2

line 3

line 4

NOT0003 line1

line2

etc etc.

I hope it helps.

Regards,

Amit M.

Former Member
0 Kudos

Hi,

While combining itab2 into itab1 use Concatenate.

Regards,

Amey

Former Member
0 Kudos

Hi kaki,

(I don't know whether i understood

ur query properly or not.)

1. as far as i know,

we cannot display long text

in alv

in multiple lines (with line feed character)

just like as it appears on the screen

having text control.

2. at the most only 1 line will be displayed(only half text)

3. And even if we manage to show it in 3-5 lines,

it will affect the whole row

(ie the full row and other fields will be in 3-5 lines)

4. Moreover the description text will be of

3 lines, 5 lines, 10 lines,

nobody knows.

If anything i get, i surely will get back to you.

Or lets wait for some other answers.

regards,

amit m.

former_member188685
Active Contributor
0 Kudos

Hi,

In the Below code you are Doing the same i guess..

But what is your exact requirement..

regards

vijay

Former Member
0 Kudos

Hi Amit,

What you have understood is correct. Iam trying to display multiple lines in ALV.If not possible in ALV, how to display in normal report.

At the end of the line it should break and continue into second line in particular column.

My requirement is to display output something like this.

NUmber----description

12345-----aaaaaaaaaa

-


bbbbbbbbbb

-


cccccccccc

67890-----xxxxxxxxxx

-


yyyyyyyyy

-


zzzzzzzzzz

former_member188685
Active Contributor
0 Kudos

Hi Can you explain bit clear what is exactly you need...

Regards

vijay