‎2008 Jan 22 4:24 PM
Hi everybody
one of the problems in using CL_GUI_ALV_GRID in programs as opposed to the old fashioned SLIS function modules is that each separate program normally requires its own screen (and a status).
A really easy way to avoid this problem is to define a number of screens (I usually ever want 2 at the most) in a function module and call it instead of having a call screen in the program.
call function 'ZZ_CALL_SCREEN'
exporting
screen_number = '100'
form = 'DISPLAY_GRID1'
Program = invoker.
* call screen 100.
if sy-ucomm = 'BACK'.
leave program.
form display_grid1.
call method dog->inhibit_input.
CALL METHOD dog->display_grid
EXPORTING
g_outtab = <dyn_table>
g_fldcat = it_fldcat
i_gridtitle = 'Jimbos test - entry 1'
i_edit = ' '
i_zebra = ' '
CHANGING
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
endform.
The function module is simply
function zz_call_screen.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(SCREEN_NUMBER) TYPE SY-DYNNR
*" REFERENCE(FORM) TYPE CHAR30
*" REFERENCE(PROGRAM) TYPE SY-REPID
*"----------------------------------------------------------------------
perform (form) in program (program).
case screen_number.
when '100'.
call screen 100.
when '200'.
call screen 200.
endcase.
endfunction.
* the screen logic
process before output.
module status_0100.
*
process after input.
module user_command_0100.
process before output.
module status_0200.
*
process after input.
module user_command_0200.
*----------------------------------------------------------------------*
***INCLUDE LZHR_MISCO01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
set pf-status '001'.
set titlebar '000'.
endmodule.
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0200 output.
set pf-status '001'.
set titlebar '000'.
endmodule. " STATUS_0200 OUTPUT
*----------------------------------------------------------------------*
***INCLUDE LZHR_MISCI01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
when 'RETURN'.
leave program.
when others.
endcase.
endmodule.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0200 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0200 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
when 'RETURN'.
leave program.
when others.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
SY-UCOMM is available to the calling program after PAI executed .
You just need dummy screens with a custom container on each CCONTAINER1, CCONTAINER2 and a standard status (SE41) with BACK, EXIT and CANCEL buttons on it.
The custom container names are dependent on what you call your custom container(s) when calling the ALV GRID handling class. I use CCONTAINER1, CCONTAINER2).
Having this in the Function Module code means your cl_gui_alv_grid class call programs now no longer need their own screens.
Hope this is of help
(you could incorporate this into an ALV GRID calling class itself but you would still need the function module so this (IMO) is the simplest way to do it.
Cheers
jimbo
‎2008 Jan 22 4:50 PM
Hi. If the idea here is to be able to create a simply ALV output display, without using the REUSE function, and using OO concepts, and without creating a screen, I would suggest using the ALV Object Model, basically it allows you to use OO concepts and create an ALV without creating a screen, but the option is always there. Check this.
http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
An easy implementation of this would be something like this.
REPORT rich_0001.
DATA: ispfli TYPE TABLE OF spfli.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_functions TYPE REF TO cl_salv_functions.
START-OF-SELECTION.
SELECT * INTO TABLE ispfli FROM spfli.
cl_salv_table=>factory(
* EXPORTING
* list_display = IF_SALV_C_BOOL_SAP=>FALSE
* r_container =
* container_name =
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_table->display( ).
Notice in the IMPORTING parameters, you could implement this in a container within a screen, but it is not required, if you don't pass these parameters, it will implement as fullscreen. And yes, it will use the REUSE function underneath to do this. This functionality was introduced in NetWeaver 2004. So Jimbo, your approach would be VERY useful to people who are working pre-NetWeaver. Very nice and thanks for sharing.
Regards,
Rich heilman
‎2008 Jan 22 8:36 PM
Hi Rich
Nice Idea but I,d already rejected this approach as the cl_salv_table class doesn't have any editable functionality.
However thanks for the reply
cheers
jimbo