‎2008 Jan 21 8:42 AM
i have written code for interative report but secondary list is not displayed, i have just change the existing program given in sdn forum, but it not working, therefore i would like to know what is wrong in my coding using latest classes.
types : begin of itab1,
lifnr type ekko-lifnr,
netwr type ekpo-netwr,
name1 type lfa1-name1,
end of itab1.
data : itab type standard table of itab1 with header line.
data : itab2 type standard table of itab1.
types : begin of mat_det1,
ebeln type ekko-ebeln,
lifnr type ekko-lifnr,
bedat type ekko-bedat,
matnr type ekpo-matnr,
menge type ekpo-menge,
netpr type ekpo-netpr,
NETWR type EKPO-NETWR,
maktx type makt-maktx,
end of mat_det1.
data : mat_det type standard table of mat_det1 with header line.
data : mat_det2 type standard table of mat_det1.
data : ispfli type table of spfli.
data : xspfli type spfli.
data : gr_table type ref to cl_salv_table.
data : gr_functions type ref to cl_salv_functions_list.
data : gr_events type ref to cl_salv_events_table.
data : gr_selections type ref to cl_salv_selections.
tables : ekko,ekpo,lfa1.
select-options: s_bedat for ekko-bedat.
class lcl_handle_events definition.
public section.
methods: on_user_command for event added_function of cl_salv_events
importing e_salv_function,
on_double_click for event double_click of cl_salv_events_table
importing row column.
endclass.
data : event_handler type ref to lcl_handle_events.
start-of-selection.
*select * into corresponding fields of table ispfli from spfli up to 100 rows .
select alifnr " sum( bnetwr ) as netwr
into corresponding fields of itab
from ekko as a inner join ekpo as b on bebeln = aebeln
where abedat in s_bedat group by alifnr.
select single name1 from lfa1 into itab-name1
where lifnr = itab-lifnr.
append itab to itab2.
endselect.
call method cl_salv_table=>factory
importing
r_salv_table = gr_table
changing
t_table = itab2.
gr_table->set_screen_status(
pfstatus = 'SALV_TABLE_STANDARD'
report = sy-repid
set_functions = gr_table->c_functions_all ).
gr_events = gr_table->get_event( ).
create object event_handler.
set handler event_handler->on_user_command for gr_events.
set handler event_handler->on_double_click for gr_events.
gr_selections = gr_table->get_selections( ).
gr_selections->set_selection_mode( 1 ).
gr_table->display( ).
class lcl_handle_events implementation.
method on_user_command.
Get the selection rows
data: lr_selections type ref to cl_salv_selections.
data: lt_rows type salv_t_row.
data: ls_rows type i.
data: message type string.
case e_salv_function.
when 'MYFUNCTION' .
lr_selections = gr_table->get_selections( ).
lt_rows = lr_selections->get_selected_rows( ).
*****read table lt_rows into ls_rows index 1.
*****read table ispfli into xspfli index ls_rows.
*****concatenate xspfli-carrid xspfli-connid xspfli-cityfrom xspfli-cityto into message separated by space.
****
*****message i001(00) with 'You pushed the button!' message .
endcase.
Endmethod.
method on_double_click.
data: message type string.
data: row_c(4) type c.
row_c = row.
data: lr_selections type ref to cl_salv_selections.
data: lt_rows type salv_t_row.
data: ls_rows type i.
lr_selections = gr_table->get_selections( ).
lt_rows = lr_selections->get_selected_rows( ).
read table lt_rows into ls_rows index 1.
read table itab2 into itab index ls_rows.
select ebeln bedat lifnr from ekko into corresponding fields of mat_det
where ebeln = p_itab2-ebeln and bedat = p_itab2-bedat
where lifnr = itab-lifnr..
select matnr menge netpr NETWR from ekpo
into corresponding fields of mat_det
where ebeln = mat_det-ebeln.
select single maktx from makt into corresponding fields of mat_det
where matnr = mat_det-matnr.
append mat_DET to mat_DET2.
endselect.
endselect.
****call method cl_salv_table=>factory
****importing
****r_salv_table = gr_table
****changing
****t_table = mat_DET2.
gr_table->set_screen_status(
pfstatus = 'SALV_TABLE_STANDARD'
report = sy-repid
set_functions = gr_table->c_functions_all ).
gr_events = gr_table->get_event( ).
create object event_handler.
set handler event_handler->on_user_command for gr_events.
set handler event_handler->on_double_click for gr_events.
gr_selections = gr_table->get_selections( ).
gr_selections->set_selection_mode( 1 ).
gr_table->display( ).
*****concatenate 'Row' row_c 'Column' column into message separated by space.
*****message i001(00) with 'You double-clicked on ' message.
endmethod.
endclass.
thanx
rocky
‎2008 Jan 21 1:27 PM
Hi Rocky, check this for some sample code.
pls find the docu for interactive reporting..
________________________________________________________________
When the system processes event blocks that are not assigned to interactive list events, and when processing dialog modules, the ABAP program writes its list output to the basic list.
The ABAP system field SY-LSIND contains the index of the list currently being created. While the basic list is being created, SY-LSIND is zero.
By default, the basic list has a standard list status and a standard page header. The TOP-OF-PAGE and END-OF-PAGE events can occur while the basic list is being created. All output in these events is placed in the page header or footer of the basic list. In executable programs, the basic list is automatically sent to the list processor and displayed at the end of the END-OF-SELECTION event. Otherwise, it is displayed after the PAI processing block on the screen from which the LEAVE TO LIST-PROCESSING statement occurred.
Creating Detail Lists
Each time the user executes an action on a list, the runtime environment checks whether there is an event block defined that corresponds to the function code. If there is, SY-LSIND is automatically increased by one, and the relevant event block is executed. Any list output arising during this event block places its data into a new list (list level) with the index SY-LSIND. In order to create a new list level, the GUI status of the basic list must allow user actions, and the relevant event blocks must be defined in the program.
All lists created during an interactive list event are detail lists. Each interactive list event creates a new detail list. With one ABAP program, you can maintain one basic list and up to 20 detail lists. If the user creates a list on the next level (that is, SY-LSIND increases), the system stores the previous list and displays the new one. The user can interact with whichever list is currently displayed.
The system displays this list after processing the entire processing block of the event keyword or after leaving the processing block due to EXIT or CHECK. By default, the new list overlays the previous list completely. However, you can display a list in a dialog box. If no other dialog status is set in the event block for the detail list, the system uses the status from the previous list level. However, there is no standard page header for detail lists (see below).
Consequences of Event Control
The fact that you program detail lists in event blocks has important consequences. You cannot nest processing blocks (see Structure of an ABAP Program). Therefore, you cannot process other events within the processing blocks of interactive lists.
Especially, you cannot
• use separate processing blocks to process further interactive events. A certain user action always triggers the same processing block in your program. You must use control statements (IF, CASE) within the processing block to make sure that the system processes the desired statements. There is a range of system field that you can use for this.
• use the event TOP-OF-PAGE to influence the list structure of secondary lists. To layout the page headers of the secondary lists, you must use the event TOP-OF-PAGE DURING LINE-SELECTION (see below). However, the system does process the event END-OF-PAGE in secondary lists.
• use events such as GET and GET LATE to retrieve data for secondary lists, but must use SELECT statements. You can use the logical database assigned to the executable program (report) only for the basic list. If you want to use a logical database during interactive events, you must either call another executable program using SUMIT, or (better) call the logical database using a function module.
Navigating in Lists:
To return from a high list level to the next-lower level (SY-LSIND), the user can choose back from a detail list. The system releases the last list to have been displayed, and returns to the previous list level. The system deletes the contents of the released list.
To determine the list level in which the output from an event block will be displayed, you can change the value of the system fields SY-LSIND. This is one of the few exceptions to the rule that states that you must never overwrite ABAP system fields. The system accepts only index values which correspond to existing list levels. It then deletes all existing list levels whose index is greater or equal to the index you specify. For example, if you set SY-LSIND to 0, the system deletes all secondary lists and overwrites the basic list with the current secondary list.
When you change SY-LSIND, the change only takes effect at the end of the corresponding event. If you work with statements that access the list with index SY-LSIND (using the INDEX addition - for example, SCROLL), you should set the new value of SY-LISND after these statements. The best place to set it is in the last statement of the event block.
System Fields for Details Lists
After each user action on a list, the following ABAP system fields will be set in the corresponding event block:
System field
SY-LSIND Index of the list created during the current event (basic list = 0)SY-LISTI Index of the list level from which the event was triggered
SY-LILLI Absolute number of the line from which the event was triggered
SY-LISEL Contents of the line from which the event was triggered
SY-CUROW Position of the line in the window from which the event was triggered (counting starts with 1)
SY-CUCOL Position of the column in the window from which the event was triggered (counting starts with 2)
SY-CPAGE Page number of the first displayed page of the list from which the event was triggered
SY-STARO Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1). This line may contain the page header.
SY-STACO Number of the first column displayed in the list from which the event was triggered (counting starts with 1)
SY-UCOMM Function code that triggered the event
SY-PFKEY Status of the list currently being displayed.
Page Headers for Detail Lists
On detail lists, the system does not display a standard page header and it does not trigger the event TOP-OF-PAGE. To create page headers for detail list, you must use a different TOP-OF-PAGE event:
TOP-OF-PAGE DURING LINE-SELECTION.
The system triggers this event for each detail list. If you want to create different page headers for different list levels, you must program the processing block of this event accordingly, for example by using system fields such as SY-LSIND or SY-PFKEY in control statements (IF, CASE).
As on the basic list, the page header of a detail list remains displayed even when you scroll vertically.
Messages on Detail Lists
ABAP allows you to react to incorrect or possibly-incorrect user input by displaying messages. The seriousness of the error determines how program processing continues.
In list processing, the message processing for the individual message types is as follows:
A (=Abend): Termination
The system displays the message in a dialog box. After the user confirms the message using ENTER , the system terminates the entire transaction (for example SE38).
E (=Error) or W (=Warning):
The system displays the message in the status bar. Once the user has confirmed the error by pressing ENTER, the current event block is terminated and the previous list level remains displayed. If you use an error or warning message while creating the basic list, the entire program is terminated.
I (=Information):
The system displays the message in a dialog box. Once the user has confirmed the message (ENTER), the program continues processing after the MESSAGE statement.
S (= status)
The system displays the message in the status bar of the current list.
X (= Exit) Runtime error:
This message type triggers a runtime error and generates a short dump.
Using Detail Lists
A classic report is a program that generates a single list, which must contain all of the required detail information. This procedure may result in extensive lists from which the user has to pick the relevant data. For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program. The desired selections must be made beforehand and the list must provide detailed information.
For dialog sessions, there are no such restrictions. The user is present during the execution of the program and can control and manipulate the program flow directly. To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.
Interactive reporting allows the user to participate actively in retrieving and presenting data during the session. Instead of one extensive and detailed list, with interactive reporting you create a condensed basic list from which the user can call detailed information by positioning the cursor and entering commands. Interactive reporting thus reduces information retrieval to the data actually required. Detailed information is presented in detail lists.
Apart from creating detail lists, interactive reporting also allows you to call transactions or other executable programs (reports) from lists. These programs then use values displayed in the list as input values. The user can, for example, call a transaction from within a list to change the database table whose data is displayed in the list.
EXAMPLES
Creating Detail Lists
REPORT demo_list_interactive_1.
START-OF-SELECTION.
WRITE: 'Basic List, SY-LSIND =', sy-lsind.
AT LINE-SELECTION.
WRITE: 'Secondary List, SY-LSIND =', sy-lsind.
When you run the program, the basic list appears. The GUI status automatically permits the function Choose (F2). When you choose a list line, the system triggers the AT LINE-SELECTION event, and the first detail list overlays the basic list. This list has no standard page header. It also inherits the GUI status of the basic list. By choosing Choose, the user can now create up to 19 of these lists. Trying to produce more than 19 lists results in a runtime error. Using Back , the user can return to previous lists.
Navigation in detail lists.
REPORT demo_list_interactive_2.
START-OF-SELECTION.
WRITE: 'Basic List, SY-LSIND =', sy-lsind.
AT LINE-SELECTION.
IF sy-lsind = 3.
sy-lsind = 0.
ENDIF.
WRITE: 'Secondary List, SY-LSIND =', sy-lsind.
When you run the program, the basic list appears:
Basic List, SY-LSIND = 0
The GUI status automatically permits the function Choose (F2). If the user positions the cursor on the list line and chooses Choose to trigger the AT LINE-SELECTION event, the system displays a detail list that contains the following line:
Secondary List, SY-LSIND = 1
Choosing Choose again produces:
Secondary List, SY-LSIND = 2
Back leads to the previous list level. Choosing Choose for the third time produces a detail list that contains the following line (because of the IF condition):
Secondary List, SY-LSIND = 0
The system deletes list levels 1 and 2. Choosing Back returns to the point at which the list processing started. If you choose Choose, the system creates a detail list with index 1. However, the list on level 0 is no longer a basic list (no page header), but is itself a detail list.
Page Headers for Detail Lists
REPORT demo_list_interactive_3.
START-OF-SELECTION.
WRITE 'Basic List'.
AT LINE-SELECTION.
WRITE 'Secondary List'.
TOP-OF-PAGE DURING LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
WRITE 'First Secondary List'.
WHEN 2.
WRITE 'Second Secondary List'.
WHEN OTHERS.
WRITE: 'Secondary List, Level:', sy-lsind.
ENDCASE.
ULINE.
When you run the program, the basic list appears. The user can choose Choose to create detail lists. The detail lists have page headers that are set according to the value of SY-LSIND.
Messages on Detail Lists
REPORT demo_list_interactive_4 NO STANDARD PAGE HEADING.
AT LINE-SELECTION.
WRITE 'Basic List'.
MESSAGE s888(sabapdocu) WITH text-001.
AT LINE-SELECTION.
IF sy-lsind = 1.
MESSAGE i888(sabapdocu) WITH text-002.
ENDIF.
IF sy-lsind = 2.
MESSAGE e888(sabapdocu) WITH text-003 sy-lsind text-004.
ENDIF.
WRITE: 'Secondary List, SY-LSIND:', sy-lsind.
When the program runs, the system displays the basic list and the success message 100 in the status line. A single click triggers the AT-LINE-SELECTION event. When the system creates the first detail list, it displays a dialog box with the information message 100. You cannot create the second detail list, because the message 200 has message type E:
kindly reward if found helpful.
cheers,
Hema.
‎2008 Jan 22 4:42 AM
Hi
see this example this is for ALV interactive report
you can understand very easily
report znaresh_class_asgn.
type-pools : slis.
data : t_ekko type table of ekko.
data : t_ekpo type table of ekpo.
data : v_ebeln like ekko-ebeln.
data : x_ekko like ekko.
data : x_layout type lvc_s_layo,
x_layout_dtl type lvc_s_layo.
data : grid_ekko type ref to cl_gui_alv_grid,
grid_ekpo type ref to cl_gui_alv_grid,
cont_ekko type ref to cl_gui_custom_container,
cont_ekpo type ref to cl_gui_custom_container.
----
INTERFACE lintf_handler
----
*
----
interface lintf_handler.
class-methods : handle_hotspot_click for event hotspot_click of
cl_gui_alv_grid
importing e_row_id.
endinterface. "lintf_handler
class lcl_event_receiver definition.
public section.
interfaces lintf_handler.
aliases handler1 for lintf_handler~handle_hotspot_click.
endclass. "lcl_event_receiver DEFINITION
----
CLASS lcl_event_receiver IMPLEMENTATION
----
*
----
class lcl_event_receiver implementation.
method lintf_handler~handle_hotspot_click.
if not e_row_id is initial.
clear x_ekko.
read table t_ekko into x_ekko index e_row_id-index.
v_ebeln = x_ekko-ebeln.
if not v_ebeln is initial.
perform get_detail_data.
if not t_ekpo[] is initial.
call screen 200.
endif.
endif.
endif.
endmethod. "lintf_handler~handle_hotspot_click
endclass. "lcl_event_receiver IMPLEMENTATION
start-of-selection.
set screen 100.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module status_0100 output.
set pf-status 'T111'.
set titlebar 'TITLE11'.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
module user_command_0100 input.
case sy-ucomm.
when 'EXIT'.
perform exit_program.
when 'BACK'.
perform exit_program.
when others.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
&----
*& Module set_pbo OUTPUT
&----
text
----
module set_pbo output.
if cont_ekko is initial.
perform select_data.
create object cont_ekko
exporting container_name = 'CUST_CONT1'.
create object grid_ekko
exporting i_parent = cont_ekko.
x_layout-grid_title = 'Posting Master Data'.
x_layout-keyhot = 'X'.
call method grid_ekko->set_table_for_first_display
exporting
i_structure_name = 'EKKO'
is_layout = x_layout
changing
it_outtab = t_ekko.
set handler lcl_event_receiver=>handler1 for all instances.
call method grid_ekko->set_toolbar_interactive.
else.
call method grid_ekko->refresh_table_display.
endif.
call method cl_gui_control=>set_focus
exporting
control = grid_ekko.
endmodule. " set_pbo OUTPUT
&----
*& Form select_data
&----
text
----
--> p1 text
<-- p2 text
----
form select_data .
select *
into table t_ekko
from ekko.
endform. " select_data
&----
*& Form get_detail_data
&----
text
----
--> p1 text
<-- p2 text
----
form get_detail_data .
select *
into table t_ekpo
from ekpo where
ebeln = v_ebeln.
endform. " get_detail_data
&----
*& Form exit_program
&----
text
----
--> p1 text
<-- p2 text
----
form exit_program .
call method cont_ekko->free.
if not cont_ekpo is initial.
call method cont_ekpo->free.
endif.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = sy-repid
txt1 = 'Error in Flush'
txt2 = sy-subrc.
endif.
leave program.
endform. " exit_program
&----
*& Module STATUS_0200 OUTPUT
&----
text
----
module status_0200 output.
set pf-status 'T111'.
set titlebar 'Posting Details'.
endmodule. " STATUS_0200 OUTPUT
&----
*& Module pbo_200 OUTPUT
&----
text
----
module pbo_200 output.
if cont_ekpo is initial.
create object cont_ekpo
exporting container_name = 'CUST_CONT2'.
create object grid_ekpo
exporting i_parent = cont_ekpo.
x_layout_dtl-grid_title = 'Posting Detail Data'.
call method grid_ekpo->set_table_for_first_display
exporting
i_structure_name = 'EKPO'
is_layout = x_layout_dtl
changing
it_outtab = t_ekpo.
else.
call method grid_ekpo->refresh_table_display.
endif.
call method cl_gui_control=>set_focus
exporting
control = grid_ekpo.
endmodule. " pbo_200 OUTPUT
&----
*& Module USER_COMMAND_0200 INPUT
&----
text
----
module user_command_0200 input.
case sy-ucomm.
when 'BACK'.
leave to screen 100.
when others.
endcase.
endmodule. " USER_COMMAND_0200 INPUT