Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

interactive reports in ALV GRID

Dear gurus,

can we have interactive list in ALV ?

Regards

R.Rajendran

Tags:
Former Member
Former Member replied

Hi,

Hope this will help You

&----


*& Report ZAlv

*&

&----


*&

*&

&----


REPORT ZAlv.

TYPE-POOLS : SLIS.

TABLES : KNA1,VBAK.

DATA : BEGIN OF ITAB OCCURS 0 ,

KUNNR LIKE KNA1-KUNNR,

NAME1 LIKE KNA1-NAME1,

LAND1 LIKE KNA1-LAND1,

ORT01 LIKE KNA1-ORT01,

END OF ITAB.

DATA : BEGIN OF JTAB OCCURS 0,

VBELN LIKE VBAK-VBELN ,

ERNAM LIKE VBAK-ERNAM ,

ERDAT LIKE VBAK-ERDAT,

KUNNR LIKE VBAK-KUNNR,

END OF JTAB .

DATA : BEGIN OF JTAB1 OCCURS 0,

VBELN LIKE VBAK-VBELN ,

ERNAM LIKE VBAK-ERNAM ,

ERDAT LIKE VBAK-ERDAT,

KUNNR LIKE VBAK-KUNNR,

END OF JTAB1.

DATA : V_REPID LIKE SY-REPID,

V_LAYOUT TYPE SLIS_LAYOUT_ALV,

V_EVENTS TYPE SLIS_T_EVENT,

V_PRINT TYPE SLIS_PRINT_ALV,

L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA : FIELD1 TYPE SLIS_FIELDCAT_ALV.

DATA : FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.

DATA : FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV.

SELECT-OPTIONS : CNO FOR KNA1-KUNNR.

START-OF-SELECTION.

V_REPID = SY-REPID .

SELECT KUNNR NAME1 LAND1 ORT01 FROM KNA1 INTO CORRESPONDING FIELDS OF

TABLE ITAB WHERE KUNNR IN CNO .

SELECT VBELN ERNAM ERDAT KUNNR FROM VBAK INTO CORRESPONDING FIELDS OF

TABLE JTAB FOR ALL ENTRIES IN ITAB WHERE KUNNR = ITAB-KUNNR.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = V_REPID

  • I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE = ' '

CHANGING

CT_FIELDCAT = FIELDCAT1

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 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.

  • LOOP AT FIELDCAT1 INTO l_fieldcat.

  • CASE l_fieldcat-fieldname.

  • WHEN 'KUNNR'.

  • l_fieldcaT-hotspot = 'X'.

  • MODIFY FIELDCAT1 FROM l_fieldcat.

  • ENDCASE.

  • ENDLOOP.

*

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

IT_FIELDCAT = FIELDCAT1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = ITAB

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.

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELD text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

IF RS_SELFIELD-FIELDNAME EQ 'KUNNR'.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.

REFRESH JTAB1.

  • CLEAR JTAB1.

LOOP AT JTAB WHERE KUNNR = ITAB-KUNNR.

APPEND JTAB TO JTAB1.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'JTAB1'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = V_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT2

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 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.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = 'X'

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

IT_FIELDCAT = FIELDCAT2

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = JTAB1

  • 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.

ENDCASE.

ENDIF.

ENDFORM. "user_command

Regards,

Sravanthi

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question