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: 

Interactive alv

Former Member
0 Kudos

Hi,

I have developed an interactive alv in which the first list shows the details of customer(KUNRG) and its order number (AUFNR).

Now for one customer there are multiple AUFNR.

When the user clicks on any AUFNR, i should be able to select data on the basis of selected field of the first alv.

i.e the select query for my secondary alv should be :

select vbeln aufnr prctr 
from vbrp
where aufnr  .............????????

likewise i want to do it for KUNRG?

Thanks in Advance.

<b>Rohitaash</b>

5 REPLIES 5

p291102
Active Contributor
0 Kudos

Hi,

Herewith i am sending the sample report for interactive alv report.

Kindly go through it that.

REPORT YMS_ALVINTER.

&----


*& tables declaration

&----


TABLES: VBRK,VBRP.

&----


*& type-pools declaration

&----


TYPE-POOLS: SLIS.

&----


*& data declaration

&----


DATA: G_REPID TYPE SY-REPID.

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

WA_EVENT TYPE SLIS_ALV_EVENT,

T_EVENT TYPE SLIS_T_EVENT.

DATA: V_VBELN LIKE VBRK-VBELN,

V_MATNR LIKE VBRP-MATNR.

DATA: BEGIN OF IT_VBRK OCCURS 0,

VBELN LIKE VBRK-VBELN,

WAERK LIKE VBRK-WAERK,

VKORG LIKE VBRK-VKORG,

FKDAT LIKE VBRK-FKDAT,

BUKRS LIKE VBRK-BUKRS,

NETWR LIKE VBRK-NETWR,

END OF IT_VBRK.

DATA: BEGIN OF IT_VBRP OCCURS 0,

VBELN LIKE VBRP-VBELN,

POSNR LIKE VBRP-POSNR,

FKIMG LIKE VBRP-FKIMG,

VRKME LIKE VBRP-VRKME,

NETWR LIKE VBRP-NETWR,

MATNR LIKE VBRP-MATNR,

ARKTX LIKE VBRP-ARKTX,

END OF IT_VBRP.

&----


*& selection screen

&----


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

SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN,

S_FKDAT FOR VBRK-FKDAT,

S_MATNR FOR VBRP-MATNR.

SELECTION-SCREEN END OF BLOCK B.

**INITIALIZATION.

INITIALIZATION.

G_REPID = SY-REPID.

S_FKDAT-LOW = SY-DATUM - 200.

S_FKDAT-HIGH = SY-DATUM.

APPEND S_FKDAT.

***AT SELECTION-SCREEN.

AT SELECTION-SCREEN.

IF NOT S_VBELN IS INITIAL.

SELECT SINGLE VBELN FROM VBRK

INTO V_VBELN

WHERE VBELN IN S_VBELN.

IF SY-SUBRC <> 0.

MESSAGE E001(ZZ2).

ENDIF.

ENDIF.

IF NOT S_MATNR IS INITIAL.

SELECT SINGLE MATNR FROM MARA

INTO V_MATNR

WHERE MATNR IN S_MATNR.

IF SY-SUBRC <> 0.

MESSAGE E001(ZZ2).

ENDIF.

ENDIF.

***START-OF-SELECTION.

START-OF-SELECTION.

PERFORM GET_DATA_VBRK.

&----


*& Form GET_DATA_VBRK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA_VBRK .

SELECT VBELN

WAERK

VKORG

FKDAT

BUKRS

NETWR

INTO TABLE IT_VBRK

FROM VBRK

WHERE VBELN IN S_VBELN

AND FKDAT IN S_FKDAT.

ENDFORM. " GET_DATA_VBRK

&----


*& Form GET_DATA_VBRP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA_VBRP .

SELECT VBELN

POSNR

FKIMG

VRKME

NETWR

MATNR

ARKTX

FROM VBRP

INTO TABLE IT_VBRP

WHERE VBELN = IT_VBRK-VBELN.

ENDFORM. " GET_DATA_VBRP

***END-OF-SELECTION.

END-OF-SELECTION.

PERFORM EVENT_LIST.

PERFORM GET_FIELD_CATALOG.

PERFORM LIST_DISP .

&----


*& Form list_disp

&----


  • text

----


FORM LIST_DISP .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = G_REPID

  • I_CALLBACK_PF_STATUS_SET = 'POPUP'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = IT_FIELDCAT

  • 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

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_VBRK

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. " LIST_DISP

&----


*& Form GET_FIELD_CATALOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_FIELD_CATALOG .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = G_REPID

I_INTERNAL_TABNAME = 'IT_VBRK'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = G_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCAT

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.

ENDFORM. " GET_FIELD_CATALOG

&----


*& Form event_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM EVENT_LIST .

CLEAR WA_EVENT.

WA_EVENT-NAME = 'USER_COMMAND'.

WA_EVENT-FORM = 'USER_COMMAND'.

APPEND WA_EVENT TO T_EVENT.

CLEAR WA_EVENT.

ENDFORM. " event_list

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

READ TABLE IT_VBRK INDEX RS_SELFIELD-TABINDEX.

PERFORM GET_DATA_VBRP.

PERFORM BUILD_FIELDCATALOG_VBRP .

PERFORM DISPLAY_ALV_VBRP.

ENDCASE.

ENDFORM. "user_command

&----


*& Form BUILD_FIELDCATALOG_VBRP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELDCATALOG_VBRP .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = G_REPID

I_INTERNAL_TABNAME = 'IT_VBRP'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = G_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCAT

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.

ENDFORM. " BUILD_FIELDCATALOG_VBRP

&----


*& Form DISPLAY_ALV_VBRP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_ALV_VBRP .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = G_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = IT_FIELDCAT

  • 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

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_VBRP

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_VBRP

Thanks,

Sankar M

Former Member
0 Kudos

See the following ex:

&----


*& Form USER_COMMAND_REPL

&----


  • text

----


  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

----


FORM user_command_repl USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

CLEAR: wa_out_replan,

g_rs_selfield.

READ TABLE it_out_replan INTO wa_out_replan INDEX

rs_selfield-tabindex.

MOVE rs_selfield TO g_rs_selfield.

PERFORM sub_data_retriev_repl_det.

IF NOT it_repl_final[] IS INITIAL.

PERFORM sub_build_fieldcat_repl_det.

PERFORM sub_event_call USING v_events_final.

PERFORM display_alv_repl_det.

ENDIF.

ENDCASE.

ENDFORM. "user_command

&----


*& Form sub_data_retriev_repl_det

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sub_data_retriev_repl_det.

DATA: l_qmnum LIKE viqmel-qmnum,

l_qmnum1 LIKE viqmel-qmnum,

l_tabix like sy-tabix,

l_flag TYPE c.

REFRESH: it_final, it_repl_final.

CLEAR: it_final, it_repl_final.

CASE g_rs_selfield-fieldname.

WHEN 'INITREP'.

**Display SAP Initiated Replan

**if activity code group is 'REPLAN'

*and code R001,R002,R003,R004 & BA then it SAP initiated replan.

IF wa_out_replan-initrep GT 0.

CLEAR: wa_rec_temp.

SORT it_rec BY qmart mngrp mncod.

READ TABLE it_rec WITH KEY qmart = wa_out_replan-qmart

mngrp = wa_out_replan-mngrp

mncod = wa_out_replan-mncod BINARY SEARCH.

IF sy-subrc = 0.

LOOP AT it_rec FROM sy-tabix.

IF ( it_rec-qmart <> wa_out_replan-qmart

OR it_rec-mngrp <> wa_out_replan-mngrp

OR it_rec-mncod <> wa_out_replan-mncod ).

EXIT.

ELSE.

**Move data to final internal table

PERFORM sub_move_repl_detail_data.

ENDIF.

ENDLOOP.

ENDIF.

ELSE.

MESSAGE s013(zmamin) WITH 'Records not found for the selection'.

ENDIF.

WHEN 'REP_NOTF'.

IF wa_out_replan-rep_notf GT 0.

SORT it_rec BY qmart mngrp mncod qmnum.

CLEAR l_flag.

READ TABLE it_rec WITH KEY qmart = wa_out_replan-qmart

mngrp = wa_out_replan-mngrp

mncod = wa_out_replan-mncod BINARY SEARCH.

IF sy-subrc = 0.

LOOP AT it_rec FROM sy-tabix.

IF ( it_rec-qmart <> wa_out_replan-qmart

OR it_rec-mngrp <> wa_out_replan-mngrp

OR it_rec-mncod <> wa_out_replan-mncod ).

EXIT.

ENDIF.

AT NEW qmnum.

l_flag = 'X'.

ENDAT.

IF l_flag = 'X'.

**Move data to final internal table

PERFORM sub_move_repl_detail_data.

CLEAR l_flag.

ENDIF.

ENDLOOP.

ENDIF.

ELSE.

MESSAGE s013(zmamin) WITH 'Records not found for the selection'.

ENDIF.

Former Member
0 Kudos

use at line selection event..

and the double click will get the row into "sy-lisel" sysytem field...

then using offset..position..u can get the value into the variable say "w_val".

then u can use that in select query...

select vbeln aufnr prctr

from vbrp

where aufnr = w_val.

Former Member
0 Kudos

Hi...Check this...and reward points if helpful

EVENT-FORM = 'SECOND_LIST'.

EVENT-NAME = 'USER_COMMAND'.

APPEND EVENT.

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

*END-OF-SELECTION

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

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • IS_LAYOUT =

IT_FIELDCAT = FCAT[]

IT_EVENTS = EVENT[]

TABLES

t_outtab = IT_FINAL[]

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

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

**********SECONDARY LIST

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

FORM SECOND_LIST USING UCOMM1 LIKE SY-UCOMM FIELD TYPE SLIS_SELFIELD .

select vbeln aufnr prctr

from vbrp

where aufnr = field-value.

Former Member
0 Kudos

in reuse alv display just give the form name in I call back user command = 'USERCOM'

form usercom using pucom like sy-ucomm selfield type slis_selfield.

case pucom.

when '&IC1'.

if selfield-fieldname = 'AUFNR'.

<you may have to use conversion exit alpha input fm for leading zeroes>

select vbeln aufnr prctr

from vbrp

where aufnr = selfield-value.

endif.

endcase.

endform.

regards

shiba dutta