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: 

Multiple line selection in ALV

Former Member
0 Kudos
332

Hi,

I am tring to use multiple selection in ALV.

i am creating fieldcatalog like this

WA_FIELDCAT-COL_POS = A.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-SELTEXT_M = 'PO NO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

A = A + 1.

WA_FIELDCAT-COL_POS = A.

WA_FIELDCAT-FIELDNAME = 'AEDAT'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-SELTEXT_M = 'CREATE DATE'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

A = A + 1.

WA_FIELDCAT-COL_POS = A.

WA_FIELDCAT-FIELDNAME = 'BEDAT'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-SELTEXT_M = 'CHANGE DATE'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

A = A + 1.

and then i am using the below code for multiple selection:

GS_LAYOUT-SEL_MODE = 'A'.

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = GS_LAYOUT

CHANGING

IT_OUTTAB = IT_EKKO[].

IT_FIELDCATALOG = IT_FIELDCAT.

this is giving an error saying that it_fieldcatalog is not compatable to it_fielcat.

Regards,

Himanshu

4 REPLIES 4

Vijay
Active Contributor
0 Kudos
92

hi

it should not give error and one more thing you need not explictly do anything to activate multiple selection as alv has inbuilt property of multiple selection.

you can select multiple row by presing ctrl and selecting rows.

regards

vijay

<b>reward points if helpful</b>

Former Member
0 Kudos
92

<b>You should define FIELDCAT globally during the start of a report.</b>

Check this example,

TYPE-POOLS: SLIS.

*&----


TYPES:

BEGIN OF TY_KNA1,

KUNNR TYPE KUNNR,

NAME1 TYPE NAME1,

ORT01 TYPE ORT01,

END OF TY_KNA1.

TYPES: BEGIN OF TY_VBAK,

VBELN TYPE VBELN,

ERNAM TYPE ERNAM,

ERDAT TYPE ERDAT,

NETWR TYPE NETWR,

WAERK TYPE WAERK,

END OF TY_VBAK.

*&--


WORK AREA & TABLE DECLARATION--


DATA: W_KNA1 TYPE TY_KNA1.

DATA: T_KNA1 TYPE STANDARD TABLE OF TY_KNA1 INITIAL SIZE 1.

DATA: W_VBAK TYPE TY_VBAK.

DATA: T_VBAK TYPE STANDARD TABLE OF TY_VBAK INITIAL SIZE 1.

*&--


FIELDCAT TABLE & WORK AREA--


DATA: W_FCAT TYPE SLIS_FIELDCAT_ALV.

DATA: T_FCAT TYPE SLIS_T_FIELDCAT_ALV.

*&----


DATA: W_FCAT1 TYPE SLIS_FIELDCAT_ALV.

DATA: T_FCAT1 TYPE SLIS_T_FIELDCAT_ALV.

*&--


EVENT TABLE AND WORK AREA--


DATA: W_EVENTS TYPE SLIS_ALV_EVENT.

DATA: T_EVENTS TYPE SLIS_T_EVENT.

*&----


DATA: W_EVENTS1 TYPE SLIS_ALV_EVENT.

DATA: T_EVENTS1 TYPE SLIS_T_EVENT.

*&--


COMMENT TABLE & WORK AREA--


DATA: W_COMMENT TYPE SLIS_LISTHEADER.

DATA: T_COMMENT TYPE SLIS_T_LISTHEADER.

*&----


DATA: W_COMMENT1 TYPE SLIS_LISTHEADER.

DATA: T_COMMENT1 TYPE SLIS_T_LISTHEADER.

*&----


APPENDING FCAT -


W_FCAT-COL_POS = 1.

W_FCAT-FIELDNAME = 'KUNNR'.

W_FCAT-SELTEXT_M = 'CUST. NO'.

W_FCAT-HOTSPOT = 'X'. " HOT SPOT HAND SYMBOL

W_FCAT-EMPHASIZE = 'C119'. " FOR COLORING THE COLUMN 1

APPEND W_FCAT TO T_FCAT.

CLEAR W_FCAT.

W_FCAT-COL_POS = 2.

W_FCAT-FIELDNAME = 'NAME1'.

W_FCAT-SELTEXT_M = 'CUST. NAME'.

APPEND W_FCAT TO T_FCAT.

W_FCAT-COL_POS = 3.

W_FCAT-FIELDNAME = 'ORT01'.

W_FCAT-SELTEXT_M = 'CITY'.

APPEND W_FCAT TO T_FCAT.

*&----


W_FCAT1-COL_POS = 1.

W_FCAT1-FIELDNAME = 'VBELN'.

W_FCAT1-SELTEXT_M = 'ORDER NO'.

W_FCAT1-EMPHASIZE = 'C519'.

APPEND W_FCAT1 TO T_FCAT1.

CLEAR W_FCAT.

W_FCAT1-COL_POS = 2.

W_FCAT1-FIELDNAME = 'ERNAM'.

W_FCAT1-SELTEXT_M = 'NAME OF PARTY'.

APPEND W_FCAT1 TO T_FCAT1.

W_FCAT1-COL_POS = 3.

W_FCAT1-FIELDNAME = 'ERDAT'.

W_FCAT1-SELTEXT_M = 'DATE'.

APPEND W_FCAT1 TO T_FCAT1.

W_FCAT1-COL_POS = 4.

W_FCAT1-FIELDNAME = 'NETWR'.

W_FCAT1-SELTEXT_M = 'ORDER VALUE'.

APPEND W_FCAT1 TO T_FCAT1.

W_FCAT1-COL_POS = 5.

W_FCAT1-FIELDNAME = 'WAERK'.

W_FCAT1-SELTEXT_M = 'CURRENCY'.

APPEND W_FCAT1 TO T_FCAT1.

*&--


APPEND COMMENTRY--


W_COMMENT-TYP = 'H'.

W_COMMENT-INFO = 'CUSTOMER DETAILS'.

APPEND W_COMMENT TO T_COMMENT.

CLEAR W_COMMENT.

*&--


APPEND EVENTS TABLE--


W_EVENTS-NAME = 'TOP_OF_PAGE'.

W_EVENTS-FORM = 'TOPPAGE'.

APPEND W_EVENTS TO T_EVENTS.

W_EVENTS-NAME = 'USER_COMMAND'.

W_EVENTS-FORM = 'SUB2'.

APPEND W_EVENTS TO T_EVENTS.

W_EVENTS1-NAME = 'TOP_OF_PAGE'.

W_EVENTS1-FORM = 'TOPPAGE1'.

APPEND W_EVENTS1 TO T_EVENTS1.

CLEAR W_EVENTS1.

W_EVENTS1-NAME = 'USER_COMMAND'.

W_EVENTS1-FORM = 'SUB3'.

APPEND W_EVENTS1 TO T_EVENTS1.

*&----


SELECT-OPTIONS: CUSTNO FOR W_KNA1-KUNNR.

*&----


SELECT KUNNR

NAME1

ORT01

FROM KNA1

INTO TABLE T_KNA1

WHERE KUNNR IN CUSTNO.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZKAL_ALV_INTERACTIVE_12'

I_BACKGROUND_ID = 'BIKE'

I_GRID_TITLE = 'CUSTOMER DETAILS'

IT_FIELDCAT = T_FCAT

IT_EVENTS = T_EVENTS

TABLES

T_OUTTAB = T_KNA1.

*&----


FORM TOPPAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_COMMENT

I_LOGO = 'LOGO_ALV'.

ENDFORM. " END OF TOPPAGE SUB.

*&----


FORM SUB2 USING UCOMM LIKE SY-UCOMM FIELDS1 TYPE SLIS_SELFIELD.

READ TABLE T_KNA1 INTO W_KNA1 INDEX FIELDS1-TABINDEX.

SELECT VBELN

ERNAM

ERDAT

NETWR

WAERK

FROM VBAK

INTO TABLE T_VBAK

WHERE KUNNR = W_KNA1-KUNNR.

*&----


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZKAL_ALV_INTERACTIVE_12'

I_BACKGROUND_ID = 'KALEEM'

I_GRID_TITLE = 'LIST OF ORDERS'

IT_FIELDCAT = T_FCAT1

IT_EVENTS = T_EVENTS1

TABLES

T_OUTTAB = T_VBAK.

ENDFORM. "END OF SUB2.

*&----


FORM TOPPAGE1.

*&--


APPEND COMMENTRYOF SECONDRY SCREEN--


W_COMMENT1-TYP = 'H'.

W_COMMENT1-INFO = 'LIST OF ORDERS'.

APPEND W_COMMENT1 TO T_COMMENT1.

W_COMMENT1-TYP = 'S'.

W_COMMENT1-KEY = 'CUSTOMER'.

W_COMMENT1-INFO = W_KNA1-KUNNR.

APPEND W_COMMENT1 TO T_COMMENT1.

CLEAR W_COMMENT.

W_COMMENT1-TYP = 'A'.

W_COMMENT1-INFO = W_KNA1-NAME1.

APPEND W_COMMENT1 TO T_COMMENT1.

CLEAR W_COMMENT1.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = T_COMMENT1

I_LOGO = 'LOGO_ALV'.

REFRESH T_COMMENT1.

ENDFORM. " END OF TOPPAGE1

*&----


FORM SUB3 USING UCOMM LIKE SY-UCOMM FIELDS1 TYPE SLIS_SELFIELD.

READ TABLE T_VBAK INTO W_VBAK INDEX FIELDS1-TABINDEX.

SET PARAMETER ID 'AUN' FIELD W_VBAK-VBELN.

CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.

ENDFORM. ":

*&----


*

Regards,

Pavan

Former Member
0 Kudos
92

Hi

See the below where you can give different

option to GS_LAYOUT-SEL_MODE to provide option to

select rows/columns..etc.


  Data : GS_LAYOUT   TYPE LVC_S_LAYO.
 
  IF Cell selection.
    GS_LAYOUT-SEL_MODE = 'D'.
  ENDIF.
  IF Column/line selection.
    GS_LAYOUT-SEL_MODE = 'A'.
  ENDIF.
  IF Listbox (SingleSelection).
    GS_LAYOUT-SEL_MODE = 'B'.
  ENDIF.
  IF Listbox (MultiSelection).
    GS_LAYOUT-SEL_MODE = 'C'.
  ENDIF.

Check this link

http://www.abap4.it/download/ALV.pdf

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

Former Member
0 Kudos
92

Go thru the program <b>bcalv_grid_05</b>

u may get some idea