02-07-2008 5:23 AM
Hi All ABAPers,
I have a question in Advanced ALV using ABAP objects.Can we display the output ie., ALV Grid without defining the custom cointainer?ie., just as we do in the classical ALV without defining any screens.Can we do that as a normal executable program ie., without using module pool programming.Please give me a solution.
Thanks & Regards,
Chaitanya.
02-07-2008 7:02 AM
You need a custom container or some container wherein you display the ALV grid while using ABAP objects. Creation of ALV grid itself requires you to pass a container object to it.
Without using PAI, PBO modules, you can probably display an ALV Grid inside a container, but how would you track the events (like a button press, selection change etc) on the ALV Grid? So, you would require PBO and PAI module programming similar to any screen programming.
You can refer to the following link for displaying a simple ALV grid.[http://www.erpgenie.com/abap/controls/alvgrid.htm]
02-07-2008 8:02 AM
Hello Chaitanya
Of course you can display ALV grids without custom containers. Using the new ALV object model (CL_SALV_TABLE) you do not even need a screen which is still mandatory for classical ALV (CL_GUI_ALV_GRID).
For sample reports have a look at .
If you do not require additional elements on your screen besides the ALV list then I would always recommend to use the following approach:
" Create grid instance using docking container as parent
CREATE OBJECT go_docking " cl_gui_docking_container
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
" Link docking container to target screen (NOTE: screen contains no elements)
gd_repid = syst-repid
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
Regards
Uwe
02-07-2008 8:29 AM
02-07-2008 10:12 AM
If you want editable grids then the cl_salv_table method won't unfortunately be of use since (currently) there's no editable facility / method.
So if you are using cl_gui_alv_grid here's how to "get round" the problem.
I'm essentially using my own alv class which is a reference to cl_gui_alv_grid but the methodology shown here is quite simple.
What you can do is to create a method which calls a function module for example ZZ_CALL_SCREEN so you only have to code a Screen and a GUI in ONE function module and not in every ALV report.
for example you could create something like this
My version has the option of 2 screens - so when I double click on a cell in one grid I can perform some actions and then display a 2nd grid before returning back to the ist grid.You can easily modify this to suit your applications.
The parameters are fairly self evident from the code. You can just use this as a model for your own applications.
I agree that having to code a separate screen and GUI for OO ALV GRID reports was for some people a "show stopper" in switching from the old SLIS to OO ALV reports.
I Hope if any SAP development guys are reading this PLEASE PROVIDE EDITABLE FUNCTIONALITY IN THE NEW CL_SALV_TABLE class. Thanks in advance.
method display_data.
call function 'ZZ_CALL_SCREEN'
exporting
screen_number = screen_number
program = program
title_text = title_text
i_gridtitle = i_gridtitle
i_zebra = i_zebra
i_edit = i_edit
i_opt = i_opt
i_object = z_object
changing
e_ucomm = e_ucomm
it_fldcat = it_fldcat
gt_outtab = gt_outtab.
e_ucomm = sy-ucomm.
endmethod.
* ...
function zz_call_screen .
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(SCREEN_NUMBER) TYPE SY-DYNNR
*" REFERENCE(PROGRAM) TYPE SY-REPID
*" REFERENCE(TITLE_TEXT) TYPE CHAR50
*" REFERENCE(I_GRIDTITLE) TYPE LVC_TITLE
*" REFERENCE(I_ZEBRA) TYPE LVC_ZEBRA
*" REFERENCE(I_EDIT) TYPE LVC_EDIT
*" REFERENCE(I_OPT) TYPE LVC_CWO
*" REFERENCE(I_OBJECT) TYPE REF TO ZZHR_ALV_GRID
*" CHANGING
*" REFERENCE(E_UCOMM) TYPE SY-UCOMM
*" REFERENCE(IT_FLDCAT) TYPE LVC_T_FCAT
*" REFERENCE(GT_OUTTAB) TYPE STANDARD TABLE
*"----------------------------------------------------------------------
*
assign gt_outtab to <dyn_table>.
move title_text to screen_title.
assign i_object to <zogzilla>.
export <dyn_table> to memory id 'dawggs'.
export i_gridtitle to memory id 'i_gridtitle'.
export i_edit to memory id 'i_edit'.
export i_zebra to memory id 'i_zebra'.
export i_opt to memory id 'í_opt'.
export it_fldcat to memory id 'it_fldcat'.
case screen_number.
when '100'.
call screen 100.
when '200'.
call screen 200.
endcase.
endfunction.
process before output.
module status_0100.
*
process after input.
module user_command_0100.
rocess before output.
module status_0200.
*
process after input.
module user_command_0200.
*----------------------------------------------------------------------*
* INCLUDE LZHR_MISCO01 *
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
import <dyn_table> from memory id 'dawggs'.
import i_gridtitle from memory id 'i_gridtitle'.
import i_edit from memory id 'i_edit'.
import i_opt from memory id 'í_opt'.
import it_fldcat from memory id 'it_fldcat'.
i_object = <zogzilla>.
call method i_object->display_grid
exporting
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
i_opt = i_opt
g_fldcat = it_fldcat
g_outtab = <dyn_table>
changing
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
set pf-status '001'.
set titlebar '000' with screen_title.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0200 output.
import <dyn_table> from memory id 'dawggs'.
import i_gridtitle from memory id 'i_gridtitle'.
import i_edit from memory id 'i_edit'.
import i_opt from memory id 'í_opt'.
import it_fldcat from memory id 'it_fldcat'.
i_object = <zogzilla>.
call method i_object->display_grid
exporting
i_gridtitle = i_gridtitle
i_edit = i_edit
i_zebra = i_zebra
i_opt = i_opt
g_fldcat = it_fldcat
g_outtab = <dyn_table>
changing
it_fldcat = it_fldcat
gt_outtab = <dyn_table>.
set pf-status '001'.
set titlebar '000' with screen_title.
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. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& 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
Cheers
jimbo