on 07-29-2008 11:33 AM
hello abapers,
Cud nyone pls send me the code for an interactive alv reporting with al the events
Check the small code.. it is for Ineractive and Event user_command handled here..
REPORT ztest_alv.
TYPE-POOLS:slis.
DATA:it_fieldcat TYPE slis_t_fieldcat_alv,
wa_field LIKE LINE OF it_fieldcat.
DATA: BEGIN OF it_likp OCCURS 0,
vbeln TYPE likp-vbeln,
END OF it_likp.
DATA: layout TYPE slis_layout_alv.
wa_field-fieldname = 'VBELN'.
wa_field-tabname = 'IT_LIKP'.
wa_field-hotspot = 'X'.
wa_field-outputlen = 10.
wa_field-no_zero = 'X'.
wa_field-seltext_l = 'Sales'.
APPEND wa_field TO it_fieldcat.
SELECT vbeln FROM likp
UP TO 10 ROWS
INTO TABLE it_likp.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_likp
EXCEPTIONS
program_error = 1.
*&---------------------------------------------------------------------*
*& Form user_Command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING ucomm TYPE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
SET PARAMETER ID 'VL' FIELD selfield-value.
CALL TRANSACTION 'VL02N' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "user_Command
Regards
Vijay Babu Dudla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The following is code for interactive ALV
&----
*& Report ZALV_OOINTERACTIVE *
&----
*& AS : Simple Interactive ALV report developed using OOPS *
*& *
&----
CLASS event_class DEFINITION DEFERRED.*Internal table and work area declarations for dd02l and dd03l
DATA : it_dd02l TYPE TABLE OF dd02l,
wa_dd02l TYPE dd02l,
it_dd03l TYPE TABLE OF dd03l,
wa_dd03l TYPE dd03l.*data declarations for ALV Main list
DATA : ty_lay1 TYPE lvc_s_layo,
it_fieldcat TYPE lvc_t_fcat ,
ty_fieldcat TYPE lvc_s_fcat ,
c_alv1 TYPE REF TO cl_gui_alv_grid,
c_cont1 TYPE REF TO cl_gui_custom_container,
event_receiver TYPE REF TO event_class.*data declarations for ALV Interactive listDATA : ty_lay2 TYPE lvc_s_layo,
it_fcat TYPE lvc_t_fcat ,
ty_fcat TYPE lvc_s_fcat ,
c_alv2 TYPE REF TO cl_gui_alv_grid,
c_cont2 TYPE REF TO cl_gui_custom_container.
**Select options for multiple values and NOT ranges
SELECT-OPTIONS : s_table FOR wa_dd02l-tabname NO INTERVALS.
Initialization event
INITIALIZATION.*Start of selection event
START-OF-SELECTION.*fetch data into table and field characteristics
PERFORM fetch_data.*ALV display for output
PERFORM alv_output.&----
*& Form FETCH_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM fetch_data .*Select the table details
SELECT * FROM dd02l INTO CORRESPONDING FIELDS OF TABLE it_dd02l
WHERE tabname IN s_table
AND tabclass = 'TRANSP'.
ENDFORM. " FETCH_DATA----
PUBLIC SECTION. METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid IMPORTING e_row .ENDCLASS. "lcl_event_receiver DEFINITION
----
----
READ TABLE it_dd02l INDEX e_row-index INTO ls_dd02l.* *Select the field details of the selected table
SELECT * FROM dd03l INTO CORRESPONDING FIELDS OF TABLE it_dd03l
WHERE tabname EQ ls_dd02l-tabname.
*calling the ALV containing the field values
CALL SCREEN 101. ENDMETHOD. "handle_double_clickENDCLASS. "lcl_event_receiver IMPLEMENTATION&----
*MODULE pbo_100 OUTPUT.
*set pf-status 'XXX'.
*set titlebar 'XXX'.
ENDMODULE. " PBO_100 OUTPUT
&----
*& Module alv_100 OUTPUT
&----
IF c_cont1 IS INITIAL.*Creating object of container
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CCONT'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.*Creating object of alv
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.*alv layout
PERFORM alv_100_layout.*alv field catalogue
PERFORM alv_100_fieldcat.*Displaying the ALV grid
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
is_layout = ty_lay1
CHANGING
it_outtab = it_dd02l[]
it_fieldcatalog = it_fieldcat. IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.*Create object of the event class and setting handler for double click
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR c_alv1. ENDIF.ENDMODULE. " ALV_100 OUTPUT&----
*MODULE pai_100 INPUT.
ENDMODULE. " pai_100 INPUT----
SET PF-STATUS 'XXX'.
SET TITLEBAR 'XXX'.
ENDMODULE. " PBO_101 INPUT----
MODULE alv_101 OUTPUT.
*Check if the Custom container exists.
IF c_cont2 IS INITIAL.*Creating container object
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CDCONT'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.*creating ALV grid for interactive list
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.*ALV layout
PERFORM alv_101_layout.*ALV fieldcatalogue
PERFORM alv_101_fieldcat.*Sorting the output by field position
SORT it_dd03l BY position.*ALV for display field details
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
is_layout = ty_lay2
CHANGING
it_outtab = it_dd03l[]
it_fieldcatalog = it_fcat.
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.ENDMODULE. " ALV_101 OUTPUT
&----
*MODULE pai_101 INPUT.ENDMODULE. " PAI_101 INPUT
&----
*& Form ALV_OUTPUT
&----
text
----
--> p1 text
<-- p2 text
----
FORM alv_output .
CALL SCREEN 100.ENDFORM. " ALV_OUTPUT
&----
*& Form ALV_100_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
FORM alv_100_layout . ty_lay1-grid_title = 'TABLES'.
ty_lay1-zebra = 'X'.
ty_lay1-no_toolbar = 'X'.ENDFORM. " ALV_100_LAYOUT
&----
*& Form ALV_100_FIELDCAT
&----
text
----
--> p1 text
<-- p2 text
----
FORM alv_100_fieldcat .
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 1.
ty_fieldcat-fieldname = 'TABNAME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TableName'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat. ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 2.
ty_fieldcat-fieldname = 'TABCLASS'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CATEGORY'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat. ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 3.
ty_fieldcat-fieldname = 'AS4USER'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'CREATED'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat. ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 4.
ty_fieldcat-fieldname = 'AS4DATE'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'DATE'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.
ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 5.
ty_fieldcat-fieldname = 'AS4TIME'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'TIME'.
ty_fieldcat-outputlen = 10.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat. ty_fieldcat-row_pos = 1.
ty_fieldcat-col_pos = 6.
ty_fieldcat-fieldname = 'CONTFLAG'.
ty_fieldcat-tabname = 'GT_DD02L'.
ty_fieldcat-coltext = 'Delivery Class'.
ty_fieldcat-outputlen = 15.
APPEND ty_fieldcat TO it_fieldcat.
CLEAR ty_fieldcat.ENDFORM. " ALV_100_FIELDCAT
&----
*& Form ALV_101_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
FORM alv_101_layout . ty_lay2-grid_title = 'FIELDS'.
ty_lay2-zebra = 'X'.
ty_lay2-no_toolbar = 'X'.ENDFORM. " ALV_101_LAYOUT
&----
*& Form ALV_101_FIELDCAT
&----
text
----
--> p1 text
<-- p2 text
----
FORM alv_101_fieldcat . REFRESH it_fieldcat.
REFRESH it_fcat.
CLEAR ty_fcat. ty_fcat-row_pos = 1.
ty_fcat-col_pos = 1.
ty_fcat-fieldname = 'FIELDNAME'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Fieldname'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat.
ty_fcat-row_pos = 1.
ty_fcat-col_pos = 2.
ty_fcat-fieldname = 'CHECKTABLE'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'CHECKTABLE'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat. ty_fcat-row_pos = 1.
ty_fcat-col_pos = 3.
ty_fcat-fieldname = 'KEYFLAG'.
ty_fcat-tabname = 'GT_DD03L'.
ty_fcat-coltext = 'Key Flag'.
ty_fcat-outputlen = 10.
APPEND ty_fcat TO it_fcat.ENDFORM. " ALV_101_FIELDCAT
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Praveen,
Why don't you Search on sdn , or even on google .
Then you will see you were not the first to think of asking this question here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen
Refer to these links
[http://www.sapdevelopment.co.uk/reporting/alvhome.htm]
[http://help.sap.com/saphelp_nw04/helpdata/EN/66/bc7aab43c211d182b30000e829fbfe/frameset.htm]
[http://help.sap.com/saphelp_sm32/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/frameset.htm]
Regards,
Sravanthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Go through the below code:
check out the content of the structure it_event....
And also the functionality of ''REUSE_ALV_EVENTS_GET'
type-pools : slis.
data : it_vbak type STANDARD TABLE OF vbak,
WA_VBAK TYPE VBAK.
data : it_events type SLIS_T_EVENT,
wa_events type slis_alv_event.
PARAMETERS : P_VB TYPE VBELN.
END-OF-SELECTION
SELECT * FROM VBAK INTO TABLE IT_VBAK UP TO 10 ROWS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 4
IMPORTING
ET_EVENTS = it_events.
loop at it_events into wa_events.
if wa_events-name = 'USER_COMMAND'.
WA_EVENTS-FORM = 'NAVIGATE'.
MODIFY IT_EVENTS FROM WA_EVENTS.
ENDIF.
endloop.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_VBAK.
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
for the input parameter ..... goto table vbak...... and select a vbeln.
Source:https://forums.sdn.sap.com/click.jspa?searchID=14600652&messageID=5452639
SDN has lot of threads on the same issue, please make use of them.
With Sincere Regards,
Chaitanya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.