Application Development and Automation 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: 
Read only

Need Help in Interactive ALV Report

Former Member
0 Likes
1,272

Hi guru's,

I need sample code of Interactive ALV when on selecting an particular field, it should open an another ALV windows or pop-up window. Please help me and points will be rewarded for the right code.

Regards

Rajiv Christopher

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,235

Hi

Plz refer the code BCALV_GRID_AND_POPUP.

This should solve the probelm.

Thanks

Vijay

PLZ reward points if helpful

Hi guru's,

I need sample code of Interactive ALV when on selecting an particular field, it should open an another ALV windows or pop-up window. Please help me and points will be rewarded for the right code.

Regards

Rajiv Christopher

10 REPLIES 10
Read only

ak_upadhyay
Contributor
0 Likes
1,235

hi,

may b it will b helpful 2 u.

INTERACTIVE ALV

REPORT Z50651_ALV_INTERACTIVE MESSAGE-ID ZMSG_50651

LINE-SIZE 100

LINE-COUNT 60

NO STANDARD PAGE HEADING.

******************TABLES DECLARATION*****************

TABLES : VBAP,MARA.

*****************TYPE POOLS**************************

TYPE-POOLS : SLIS.

****************INTERNAL TABLES**********************

DATA : BEGIN OF IT_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN, "SALES DOCUMENT

POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM

MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER

END OF IT_VBAP.

****************TEMPORARY VARIABLES******************

DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT

DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE

*****************FIELD CATALOG***********************

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

****************LAYOUT*******************************

DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

***************VARIANT*******************************

DATA : G_VARIANT LIKE DISVARIANT.

****************SAVE*********************************

DATA : G_SAVE(1) TYPE C.

*****************EVENTS******************************

DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,

G_EVENTS TYPE SLIS_T_EVENT.

******************PF STATUS**************************

DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.

******************USER COMMAND************************

DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',

R_UCOMM LIKE SY-UCOMM.

****************SELECTION SCREEN************************

SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.

***************AT SELECTION SCREEN*********************

AT SELECTION-SCREEN.

PERFORM VALIDATE.

**************START-OF-SELECTION**************************

START-OF-SELECTION.

PERFORM GET_DETAILS.

PERFORM FIELDCAT.

PERFORM LAYOUT.

PERFORM VARIANT.

PERFORM SAVE.

PERFORM EVENTS.

PERFORM ALV_DISPLAY.

*********************FORMS*******************************************

&----


*& Form validate

&----


text

-


--> p1 text

<-- p2 text

-


FORM VALIDATE .

SELECT SINGLE VBELN

FROM VBAP

INTO V_VBELN

WHERE VBELN IN S_VBELN.

IF SY-SUBRC <> 0.

MESSAGE E000 WITH 'enter valid vbeln'.

ENDIF.

ENDFORM. " validate

&----


*& Form get_details

&----


text

-


--> p1 text

<-- p2 text

-


FORM GET_DETAILS .

SELECT VBELN

POSNR

MATNR

FROM VBAP

INTO TABLE IT_VBAP

WHERE VBELN IN S_VBELN.

IF SY-SUBRC <> 0.

MESSAGE E000 WITH 'no details found'.

ENDIF.

ENDFORM. " get_details

&----


*& Form fieldcat

&----


text

-


--> p1 text

<-- p2 text

-


FORM FIELDCAT .

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'VBELN'.

WA_FIELDCAT-OUTPUTLEN = 10.

WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'POSNR'.

WA_FIELDCAT-OUTPUTLEN = 6.

WA_FIELDCAT-SELTEXT_L = 'ITEM'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-OUTPUTLEN = 18.

WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. " fieldcat

&----


*& Form LAYOUT

&----


text

-


--> p1 text

<-- p2 text

-


FORM LAYOUT .

WA_LAYOUT-ZEBRA = 'X'.

ENDFORM. " LAYOUT

&----


*& Form VARIANT

&----


text

-


--> p1 text

<-- p2 text

-


FORM VARIANT .

CLEAR G_VARIANT.

G_VARIANT-REPORT = SY-REPID.

ENDFORM. " VARIANT

&----


*& Form SAVE

&----


text

-


--> p1 text

<-- p2 text

-


FORM SAVE .

CLEAR G_SAVE.

G_SAVE = 'A'.

ENDFORM. " SAVE

&----


*& Form EVENTS

&----


text

-


--> p1 text

<-- p2 text

-


FORM EVENTS .

CLEAR XS_EVENTS.

XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.

XS_EVENTS-FORM = 'TOP_OF_PAGE'.

APPEND XS_EVENTS TO G_EVENTS.

ENDFORM. " EVENTS

&----


*& Form TOP_OF_PAGE

&----


text

-


FORM TOP_OF_PAGE.

WRITE 😕 ' INTELLI GROUP'.

ENDFORM. "TOP_OF_PAGE

&----


*& Form ALV_DISPLAY

&----


text

-


--> p1 text

<-- p2 text

-


FORM ALV_DISPLAY .

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = ' '

I_BYPASSING_BUFFER =

I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_PF_STATUS_SET = PF_STATUS

I_CALLBACK_USER_COMMAND = USER_COMMAND

I_STRUCTURE_NAME =

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 = G_SAVE

IS_VARIANT = G_VARIANT

IT_EVENTS = G_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

IMPORTING

E_EXIT_CAUSED_BY_CALLER =

ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_VBAP

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

&----


*& Form SET_PF_STATUS

&----


text

-


FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'Z50651_PFSTATUS' EXCLUDING EXTAB.

ENDFORM. "SET_PF_STATUS

&----


*& Form SET_USER_COMMAND

&----


text

-


FORM SET_USER_COMMAND USING R_UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN 'DC'.

READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.

IF SY-SUBRC = 0.

SELECT SINGLE MTART

FROM MARA

INTO V_MTART

WHERE MATNR = IT_VBAP-MATNR.

IF SY-SUBRC 0.

MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.

ELSE.

WRITE 😕 'MATERIAL NO :',IT_VBAP-MATNR.

WRITE 😕 'MATERIAL TYPE :' , V_MTART.

ENDIF.

ENDIF.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'CLOSE'.

CALL TRANSACTION 'SE38'.

ENDCASE.

ENDFORM. "SET_USER_COMMAND

Reward if useful...

Read only

Former Member
Read only

Former Member
0 Likes
1,235

Hi, this code will work for u.

report yh645_secndry_alv.

type-pools: slis.

data: fieldcat type slis_t_fieldcat_alv,
fieldcat_ln like line of fieldcat,
fs_layout type slis_layout_alv,
t_layoout like standard table
of fs_layout.

data: begin of fs_spfli,
carrid type spfli-carrid,
connid type spfli-connid,
countryfr type spfli-countryfr,
cityfrom type spfli-cityfrom,
airpfrom type spfli-airpfrom,
countryto type spfli-countryto,
cityto type spfli-cityto,
airpto type spfli-airpto,
fltime type spfli-fltime,
deptime type spfli-deptime,
arrtime type spfli-arrtime,
distance type spfli-distance,
distid type spfli-distid,
fltype type spfli-fltype,
period type spfli-period,
checkbox,
color(3),
end of fs_spfli.
data:
begin of fs_table,
carrid type spfli-carrid,
connid type spfli-connid,
end of fs_table.

data: begin of fs_sflight,
check,
color(3).
include type sflight.
data:end of fs_sflight.

data:
begin of fs_table1,
carrid type sflight-carrid,
connid type sflight-connid,
fldate type sflight-fldate,
end of fs_table1.

data:
t_spfli like standard table
of fs_spfli.

data:
t_table like standard table
of fs_table.

data:
t_table1 like standard table
of fs_table1.

data:
t_sflight like standard table
of fs_sflight.

data:
t_sbook like standard table
of sbook.


data t_layout type slis_layout_alv.

select *
into corresponding fields of table t_spfli
from spfli.

perform start_list_viewer.
perform get_spfli_details.

&--------------------------------------------------------------------
*& Form SUB1
&--------------------------------------------------------------------


text 
---------------------------------------------------------------------

-->RT_EXTAB text 
---------------------------------------------------------------------

form sub1 using rt_extab type slis_t_extab.

data: flight type slis_extab.
flight-fcode = 'SFLIGHT'.
append flight to rt_extab.
set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

endform. "SUB1

&---------------------------------------------------------------------
*& Form START_LIST_VIEWER
&---------------------------------------------------------------------

text 
----------------------------------------------------------------------

--> p1 text 
<-- p2 text 
----------------------------------------------------------------------

form start_list_viewer .

data: pgm like sy-repid.
pgm = sy-repid.

fs_layout-box_fieldname = 'CHECKBOX'.
fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB1'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SPFLI'
is_layout = fs_layout
tables
t_outtab = t_spfli
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. " START_LIST_VIEWER

********Process Call Back Events (Begin)***************************

form user_command using ucomm like sy-ucomm
selfield type slis_selfield.

case ucomm.
when 'SFLIGHT'.
selfield-refresh = 'X'.
perform get_spfli_details.
select *
from sflight
into corresponding fields of table t_sflight
for all entries in t_table
where carrid eq t_table-carrid
and connid eq t_table-connid.

perform display_sflight.

when 'SBOOK'.
selfield-refresh = 'X'.
perform get_sflight_details.
select *
from sbook
into corresponding fields of table t_sbook
for all entries in t_table1
where carrid eq t_table1-carrid
and connid eq t_table1-connid
and fldate eq t_table1-fldate.

perform display_sbook.

endcase.
endform. "USER_COMMAND

&--------------------------------------------------------------------
*& Form SUB2
&--------------------------------------------------------------------


text 
---------------------------------------------------------------------

-->RT_EXTAB text 
---------------------------------------------------------------------

form sub2 using rt_extab type slis_t_extab.

data: flight type slis_extab.
flight-fcode = 'SBOOK'.
append flight to rt_extab.
set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

endform. "SUB2

&---------------------------------------------------------------------
*& Form DISPLAY_SFLIGHT
&---------------------------------------------------------------------

text 
----------------------------------------------------------------------

--> p1 text 
<-- p2 text 
----------------------------------------------------------------------

form display_sflight .

data: pgm like sy-repid.
pgm = sy-repid.

clear t_layout.
fs_layout-box_fieldname = 'CHECK'.
fs_layout-info_fieldname = 'COLOR'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_callback_pf_status_set = 'SUB2'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
tables
t_outtab = t_sflight
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_SFLIGHT

&---------------------------------------------------------------------
*& Form GET_SPFLI_DETAILS
&---------------------------------------------------------------------

text 
----------------------------------------------------------------------

--> p1 text 
<-- p2 text 
----------------------------------------------------------------------

form get_spfli_details .

loop at t_spfli into fs_spfli.
if fs_spfli-checkbox = 'X'.
fs_spfli-color = 'C51'.
fs_spfli-checkbox = '1'.
fs_table-carrid = fs_spfli-carrid.
fs_table-connid = fs_spfli-connid.
append fs_table to t_table.
modify t_spfli from fs_spfli.
endif.
endloop.
endform. " GET_SFLIGHT_DETAILS

&---------------------------------------------------------------------
*& Form GET_SFLIGHT_DETAILS
&---------------------------------------------------------------------

text 
----------------------------------------------------------------------

--> p1 text 
<-- p2 text 
----------------------------------------------------------------------

form get_sflight_details .

loop at t_sflight into fs_sflight.
if fs_sflight-check = 'X'.
fs_sflight-color = 'C71'.
fs_sflight-check = '1'.
fs_table1-carrid = fs_sflight-carrid.
fs_table1-connid = fs_sflight-connid.
fs_table1-fldate = fs_sflight-fldate.
append fs_table1 to t_table1.
modify t_sflight from fs_sflight.
endif.
endloop.

endform. " GET_SFLIGHT_DETAILS

&---------------------------------------------------------------------
*& Form DISPLAY_SBOOK
&---------------------------------------------------------------------

text 
----------------------------------------------------------------------

--> p1 text 
<-- p2 text 
----------------------------------------------------------------------

form display_sbook .

data: pgm like sy-repid.
pgm = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = pgm
i_structure_name = 'SBOOK'
tables
t_outtab = t_sbook
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_SBOOK.

Reward points if helpful

Read only

Former Member
0 Likes
1,236

Hi

Plz refer the code BCALV_GRID_AND_POPUP.

This should solve the probelm.

Thanks

Vijay

PLZ reward points if helpful

Read only

Former Member
0 Likes
1,235

Rajiv,

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ws_repid

i_callback_user_command = 'USER_COMMAND'

is_layout = gs_layout

it_fieldcat = i_fcat

TABLES

t_outtab = i_final.

&----


*& Form USER_COMMAND

&----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE i_final INTO i_final INDEX rs_selfield-tabindex.

***Setting parameter id for Notification

SET PARAMETER ID 'IQM' FIELD rs_selfield-value.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

text_question = text-008

text_button_1 = 'YES'

text_button_2 = 'NO'

IMPORTING

answer = l_answer

EXCEPTIONS

text_not_found = 1

OTHERS = 2.

IF l_answer = '1'.

ENDIF.

ENDCASE.

ENDFORM. "user_command

Read only

Former Member
0 Likes
1,235

Hi,

Interactive report is all about making the ALV report to interact with another alv report.

I think you can do ALV report.After getting the first ALV report int the "USER COMMAND" form statement.

Write some PERFORM statements for building out fieldcat,layout,data retrieval and call function alv for grd output.

Such as Shown below,

Use the form of user command of the first ALV to generate the another alv such as interactive.

FORM USER_COMMAND USING WF_UCOMM TYPE SY-UCOMM

WF_SEL_FIELD TYPE SLIS_SELFIELD.

READ TABLE ITAB INTO WA_tab INDEX WF_SEL_FIELD-TABINDEX.

PERFORM FIELDCAT.

PERFORM FIELDCAT_LAYOUT.

PERFORM DATA_RETRIEVAL.

PERFORM CALL_FUNC_DISPLAY.

ENDFORM. " USER_COMMAND

You can use the above codings for developing alv.

Thanks,

Sakthi C

Read only

Former Member
0 Likes
1,235

hi please refer to the follwing code

rs_selfield TYPE slis_selfield . "#EC CALLED

*&-- cases on user command click

CASE r_ucomm.

*&-- when hotspot is clicked

WHEN c_click. "&IC1 [double click]

IF rs_selfield-fieldname = text-014. "Field-werks

READ TABLE i_final INTO wa_final WITH KEY werks =

rs_selfield-value. "#EC *

IF sy-subrc = 0. "if succesful

*&--PERFORM FOR PRINTING THE PLANT AND STORAGE DESCRIPTION

PERFORM zf_data_popualtion_2.

ELSE. "if unsuccesful

MESSAGE e004. "Error- Record does not exist

ENDIF.

*&--PERFORM TO CALL ALV GRID IN POPUP LIKE WINDOW

PERFORM zf_alv_grid_popup.

*&--refreshing the table and clearinf workarea.

CLEAR: wa_final_2.

REFRESH: i_final_2.

ENDIF.

&----


*

*& Form ZF_DATA_POPUALTION_2

*&----


FORM zf_data_popualtion_2.

LOOP AT i_final INTO wa_final_2 WHERE matnr = wa_final-matnr AND werks

= wa_final-werks.

APPEND wa_final_2 TO i_final_2.

CLEAR wa_final_2.

ENDLOOP.

CLEAR wa_final_2.

ENDFORM. " ZF_DATA_POPUALTION_2

&----


*& Form ZF_ALV_GRID_POPUP

&----


FORM zf_alv_grid_popup .

*&-- calling FM to call ALV grid in a POPUP like window

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = i_fieldcat2

  • i_screen_start_column = 10*

i_screen_start_line = 1

i_screen_end_column = 95

i_screen_end_line = 10

TABLES

t_outtab = i_final_2

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

these lines will open ALV GRID in a popup like window

if you want exact popup window, then use 'REUSE_ALV_POPUP_TO_SELECT'..this will display

output in ALV LIST FORMAT..not GRID

reward if helpful

Rohan

Read only

Former Member
0 Likes
1,235

Hi ,

I tried the sample ALV program it is not working because I am not able to select any field and not moving to another window? .

How to create an Z-Customized PF - Status and add it to the ALV output ?. Can anyone give the step-by-step procedure for creating z customized PF-Status.

Rajiv Christopher

Read only

0 Likes
1,235

hi rajiv,

follow these steps to create he customized menu in alv

here are the steps..

1) OPEN SE41

2) TYPE IN YOUR PROGRAM NAME FOR WHICH YOU NEED ALV MENU

3) on the application tolbar you would see a button named 'STATUS', click it

4) now it would say copy status FROM AND TO....

type:

FROM:

PROGRAM: SAPLSLVC_FULLSCREEN

STATUS: STANDARD_FULLSCREEN

TO

PROGRAM: TYPE YOuR PROGRAM NAME

STATUS : TYPE YOUR CUSTOM MENU NAME

5) PRESS COPY..and again till it says a message 'COPIED SUCCESSFULLY

6)in you ALV PROGRAM IN EVENT SET_PF_STATUS,

TYPE THIS ALV STATUS AND DOUBLE CLICK UR MENU NAME

AND THEN YOU WILL HAVE YOUR ALV STANDARD MENU..AND

YOU CAN HAVE YOUR BUTTON ON IT, BY MAKING YOU OWN COMMAND SAY ''&UP1' name it as update info

6) ACTIVATE IT

AND YOUR ALV MENU IS MADE

reward if helpful

ROhan

Read only

Former Member
0 Likes
1,235

hi Rajiv,

take help of this code

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = I_FIELDCAT

I_GRID_TITLE = 'Pricing Routine : '

I_SCREEN_START_COLUMN = 10

I_SCREEN_START_LINE = 1

I_SCREEN_END_COLUMN = 95

I_SCREEN_END_LINE = 10

TABLES

T_OUTTAB = IT_KONV1

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.

mentioning starting and ending column will show alv like a pop up alv.

you can also use function modules.

reward if helpful,

kushagra