2006 Dec 06 4:44 PM
Hello friends,
I have written a ALV grid display report, and its working fine.
However I need to modify it to an Intreactive report in ALV Grid format.
what are the additions that go into this program and what would be the function modules i need to use.
Thanks in advance,
Shejal.
2006 Dec 06 8:58 PM
Hi,
Good..Please close the thread if the issue is solved..
Thanks,
Naren
Hello friends,
I have written a ALV grid display report, and its working fine.
However I need to modify it to an Intreactive report in ALV Grid format.
what are the additions that go into this program and what would be the function modules i need to use.
Thanks in advance,
Shejal.
2006 Dec 06 4:46 PM
Here is a example
http://www.sap-img.com/abap/an-interactive-alv-report.htm
Bottom line
1. You need to add & register the events you want to handle
2. You need to handle when the events are fired.
Regards,
Ravi
2006 Dec 06 5:01 PM
Thanks Ravi,
I had the program before that u have specified and have some questions releated ti it.
1 - I see a form statement without a perform ( form user_command).
Can u explain in brief about FM - REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE.
Thanks for the help,
Shejal.
2006 Dec 06 5:07 PM
1. You don't see a PERFORM for USER_COMMAND because what will happen is the RESUE* function module will dynamically call the perform depending on the subroutine name that you are passing as the parameter.
2. EVENT_GET function will get all the events pertaining to the events of the ALV report.
3. COMMENTARY_WRITE - If you want to write a header of the ALV report you will have to use this function module.
Regards,
Ravi
2006 Dec 06 5:32 PM
2006 Dec 06 5:47 PM
I am using Hotspot. So when I click the required field where does the data gets stored.
For eg - in my primary list when i click the customer number, i need to display results based on customer number on the second screen, So where is the customer number store.
Shejal.
2006 Dec 06 5:54 PM
Hi Shejal,
Suggets you to <b>search in SDN with key - HOTSPOT.</b> Will get many post on the same.
Hope this will help and give an idea.
Reward points if this Helps.
Manish
Message was edited by:
Manish Kumar
2006 Dec 06 5:54 PM
Hi,
Check this example fo interactive ALV..Initially the sales orders will be displayed..There will be a hotspot for the sales order number..If you press it , the sales order line items will be displayed..
The hotspot related code is marked in bold..
TYPE-POOLS: slis.
DATA: BEGIN OF itab1 OCCURS 0,
vbeln TYPE vbeln,
bstnk TYPE vbak-bstnk,
erdat TYPE vbak-erdat,
kunnr TYPE vbak-kunnr,
END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0,
vbeln TYPE vbeln,
matnr TYPE vbap-matnr,
netpr TYPE vbap-netpr,
kwmeng TYPE vbap-kwmeng,
END OF itab2.
DATA: t_fieldcatalog1 TYPE slis_t_fieldcat_alv.
DATA: t_fieldcatalog2 TYPE slis_t_fieldcat_alv.
DATA: v_repid TYPE syrepid.
v_repid = sy-repid.
Get the fieldcatalog1
PERFORM get_fieldcat1.
Get the fieldcatalog2
PERFORM get_fieldcat2.
SELECT vbeln bstnk erdat kunnr UP TO 10 ROWS
INTO TABLE itab1
FROM vbak.
IF NOT itab1[] IS INITIAL.
SELECT vbeln matnr netpr kwmeng UP TO 10 ROWS
INTO TABLE itab2
FROM vbap
FOR ALL ENTRIES IN itab1
WHERE vbeln = itab1-vbeln.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'DISPLAY_DETAIL'
it_fieldcat = t_fieldcatalog1
TABLES
t_outtab = itab1.
----
FORM display_detail *
----
........ *
----
--> UCOMM *
--> SELFIELD *
----
FORM display_detail USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA: itab2_temp LIKE itab2 OCCURS 0 WITH HEADER LINE.
<b> IF ucomm = '&IC1'.
READ TABLE itab1 INDEX selfield-tabindex.
IF sy-subrc = 0.
LOOP AT itab2 WHERE vbeln = itab1-vbeln.
MOVE itab2 TO itab2_temp.
APPEND itab2_temp.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = t_fieldcatalog2
TABLES
t_outtab = itab2_temp.
ENDIF.
ENDIF.</b>
ENDFORM.
----
FORM GET_FIELDCAT1 *
----
........ *
----
FORM get_fieldcat1.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'VBELN'.
<b> s_fieldcatalog-hotspot = 'X'.</b>
APPEND s_fieldcatalog TO t_fieldcatalog1.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BSTNK'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'BSTNK'.
APPEND s_fieldcatalog TO t_fieldcatalog1.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog1.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog1.
CLEAR s_fieldcatalog.
ENDFORM.
*
----
FORM GET_FIELDCAT2 *
----
........ *
----
FORM get_fieldcat2.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB2'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog2.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'ITAB2'.
s_fieldcatalog-rollname = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog2.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB2'.
s_fieldcatalog-rollname = 'NETPR'.
APPEND s_fieldcatalog TO t_fieldcatalog2.
CLEAR s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'KWMENG'.
s_fieldcatalog-tabname = 'ITAB2'.
s_fieldcatalog-rollname = 'KWMENG'.
APPEND s_fieldcatalog TO t_fieldcatalog2.
CLEAR s_fieldcatalog.
ENDFORM.
Thanks,
Naren
2006 Dec 06 6:05 PM
Thanks Naren,
I looked at the program and it looks like I will get it done.
Shejal.
2006 Dec 06 7:52 PM
Naren,
In your code why are you passing
i_callback_user_command = 'DISPLAY_DETAIL'
in the FM - CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY the first time and no passing it the second time.
Shejal.
2007 Apr 10 10:25 PM
Hi Muttu,
I have seen ur code here and tried to slove my problem. Your code here looks very simple but when I tried to implement it on my program it doesnt work. I am trying to display a message when user clicks on the hotspot column. It would be really helpful if u could tell me what is worng with my code.
type-pools: slis.
tables kna1.
types: begin of tp_data,
ktokd like kna1-ktokd,
kunnr like kna1-kunnr,
name1 like kna1-name1,
name2 like kna1-name2,
ort01 like kna1-ort01,
end of tp_data,
tp_tbl_data type standard table of tp_data. "data type defination
Report data to be shown.
data: it_data type standard table of tp_data.
ALV required data objects.
data: t_fieldcat type slis_t_fieldcat_alv,
t_event type slis_t_event.
refresh: t_fieldcat, t_event.
*code to get user input
Selection-screen begin of block Enter_data with frame title text-001.
PARAMETERS p_ktokd like KNA1-ktokd OBLIGATORY.
SELECT-OPTIONS s_kunnr FOR KNA1-kunnr.
Selection-screen end of block Enter_data.
START-OF-SELECTION.
*get data into the internal table it_data
PERFORM get_data USING it_data.
*prepare the field catalog
PERFORM prepare_fieldcat using:
1 'KTOKD' 'KNA1' t_fieldcat,
2 'KUNNR' 'KNA1' t_fieldcat,
3 'NAME1' 'KNA1' t_fieldcat,
4 'NAME2' 'KNA1' t_fieldcat,
5 'ORT01' 'KNA1' t_fieldcat.
Displays the ALV grid
PERFORM display_alv USING t_fieldcat it_data.
*deleting the internal table it_data from memory
free it_data.
----
*definations of sub-routines called in the program
*function to get the data from the database table KNA1 to internal table it_data
form get_data USING t_data type tp_tbl_data.
SELECT ktokd kunnr name1 name2 ort01
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM kna1
WHERE ktokd = p_ktokd
and kunnr in s_kunnr.
ENDFORM.
*function to set the field catalog
FORM prepare_fieldcat USING t_colpos t_fieldname t_ref_tabname t_fieldcat type slis_t_fieldcat_alv.
data tmp_fcat type slis_fieldcat_alv.
clear tmp_fcat.
tmp_fcat-col_pos = t_colpos.
tmp_fcat-ref_fieldname = tmp_fcat-fieldname = t_fieldname.
tmp_fcat-ref_tabname = t_ref_tabname.
if t_fieldname = 'KTOKD'.
tmp_fcat-hotspot = 'X'.
ELSE.
tmp_fcat-hotspot = ' '.
endif.
append tmp_fcat to t_fieldcat.
ENDFORM.
*function to display the alvgrid on the screen
form display_alv using t_fc type slis_t_fieldcat_alv
it_d type tp_tbl_data.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = t_fc
i_callback_user_command = 'USER_COMMAND'
tables
t_outtab = it_d[]
exceptions
program_error = 1
others = 2.
ENDFORM.
form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield.
data msg type string.
if ucomm = '&IC1'.
CONCATENATE 'you pressed on ' selfield-value into msg.
MESSAGE msg type 'S'.
endif.
ENDFORM.
Thanks,
Pushpa
2007 Apr 10 10:28 PM
Pushpa,
open a new thread, because it is already closed.. so most of the people willnot check the closed threads.. so open a new thread and post u r quesiton there....
2006 Dec 06 7:55 PM
Hi,
Since I am using HOTSPOT in my first ALV (REUSE_ALV_GRID_DISPLAY)..I need to handle when the user presses the hotspot..
The DISPLAY_DETAIL is the subroutine will be invoked when the user presses the hotspot.
For the ALV to know the subroutine name we are passing it in the parameter..
<b>i_callback_user_command = 'DISPLAY_DETAIL'</b>
Where as for the second ALV, I don't have any HOTSPOT...That is the reason I am not passing this parameter..
Hope this is clear..
Thanks,
Naren
2006 Dec 06 8:25 PM
2006 Dec 06 8:35 PM
Naren,
In the below code I am having problems with errors. It givinf=g me an error because i am using a form end form in another form endform.
ANy suggestions.
<b>FORM 4210_list .</b>
PERFORM f9200_get_fieldcat1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'DISPLAY_DETAIL'
i_grid_title = 'Company Code - 5400'
it_fieldcat = i_fieldcat1
TABLES
t_outtab = it_output1
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.
PERFORM f9200_get_fieldcat2.
&----
*& Form display_detail
&----
text
----
-->UCOMM text
-->SELFIELD text
----
<b>FORM display_detail USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.</b>
IF ucomm = '&IC1'.
READ TABLE it_output1 INDEX selfield-tabindex.
IF sy-subrc = 0.
LOOP AT it_output WHERE hkont = it_output1-hkont.
MOVE it_output TO it_output2.
APPEND it_output2.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_grid_title = 'Company Code - 5400'
it_fieldcat = i_fieldcat2
TABLES
t_outtab = it_output2
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.
ENDIF.
ENDIF.
<b>ENDFORM. "display_detail
ENDFORM. " 4210_list</b>
2006 Dec 06 8:51 PM
2006 Dec 06 8:58 PM
Hi,
Good..Please close the thread if the issue is solved..
Thanks,
Naren
2006 Dec 06 9:15 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |