‎2013 Dec 10 7:29 AM
Hi Experts,
I developed a demo ALV program using OOPS. But after executing, the ALV is not displayed.
I am not able to figure out where am i wrong or am I missing something.
PFA code file "DEMO_ALV using OOPS.txt".
Regards,
Ramiz
‎2013 Dec 10 7:56 AM
Ramiz Inamdar wrote:
Hi Experts,
I developed a demo ALV program using OOPS. But after executing, the ALV is not displayed.
I am not able to figure out where am i wrong or am I missing something.
PFA code file "DEMO_ALV using OOPS.txt".
Regards,
Ramiz
Hello Ramiz,
You cannot use the sap default selection screen ( 1000) to show the ALV.
You need to create a separate custom screen ( say 9000) and call the ALV logic in the PBO of the custom screen:
START-OF-SELECTION.
DATA : obj TYPE REF TO cldata.
CREATE OBJECT obj.om
CALL METHOD obj->get_data.
* CALL METHOD obj->process_data.
CALL METHOD obj->fill_fcat.
CALL SCREEN 9000. " Call new custom screen
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* Call the ALV in the PBO of the custom screen
*----------------------------------------------------------------------*
module STATUS_9000 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
CALL METHOD obj->display_alv.
endmodule. " STATUS_9000 OUTPUT
‎2013 Dec 10 7:37 AM
Hi,
you didn't create a screen, you didn't create the minimum PBO PAI
regards
Fred
‎2013 Dec 10 7:41 AM
Hi Ramiz,
I did not find the CALL Screen statement in your program.
Unless you call the screen, where can you display the ALV?
Refer to sample programs on module pool.
You can refer this link
‎2013 Dec 10 7:45 AM
create screen using CALL SCREEN <screen number>
& call the required methods in PBO & PAI.
check this code as a sample code sample ALV-OOPS program - Code Gallery - SCN Wiki
‎2013 Dec 10 7:51 AM
You don't need a screen mandatory....
you can do like this...
CREATE OBJECT lo_grid
EXPORTING
i_parent = cl_gui_custom_container=>screen0.
This will do it.
‎2013 Dec 10 7:56 AM
Ramiz Inamdar wrote:
Hi Experts,
I developed a demo ALV program using OOPS. But after executing, the ALV is not displayed.
I am not able to figure out where am i wrong or am I missing something.
PFA code file "DEMO_ALV using OOPS.txt".
Regards,
Ramiz
Hello Ramiz,
You cannot use the sap default selection screen ( 1000) to show the ALV.
You need to create a separate custom screen ( say 9000) and call the ALV logic in the PBO of the custom screen:
START-OF-SELECTION.
DATA : obj TYPE REF TO cldata.
CREATE OBJECT obj.om
CALL METHOD obj->get_data.
* CALL METHOD obj->process_data.
CALL METHOD obj->fill_fcat.
CALL SCREEN 9000. " Call new custom screen
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* Call the ALV in the PBO of the custom screen
*----------------------------------------------------------------------*
module STATUS_9000 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
CALL METHOD obj->display_alv.
endmodule. " STATUS_9000 OUTPUT
‎2013 Dec 10 3:36 PM
‎2013 Dec 11 5:07 AM
Thanks Raymond for your valuable inputs.
I will surely try using CL_GUI_DOCKING_CONTAINER or CL_GUI_DIALOGBOX_CONTAINER in my code.
On this note closing the thread.
Regards,
Ramiz
‎2013 Dec 10 8:23 AM
Hii Ramiz,
You have to call screen other wise it will not work.
I have brought some changes in your code .Just try with this.
*&---------------------------------------------------------------------*
*& Report YRAIN1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT yrain1.
*----------------------------------------------------------------------*
* CLASS declaration DEFINITION
*----------------------------------------------------------------------*
CLASS declaration DEFINITION.
PUBLIC SECTION.
TYPES : BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr,
land1 TYPE kna1-land1,
name1 TYPE kna1-name1,
name2 TYPE kna1-name2,
END OF ty_kna1.
ENDCLASS. "declaration DEFINITION
*----------------------------------------------------------------------*
* CLASS data DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cldata DEFINITION INHERITING FROM declaration.
PUBLIC SECTION.
DATA : alv_container TYPE REF TO cl_gui_docking_container.
DATA : alv_grid TYPE REF TO cl_gui_alv_grid.
DATA : layout TYPE lvc_s_layo.
DATA : fieldcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
DATA : variant TYPE disvariant.
DATA : repid TYPE sy-repid.
DATA : counter TYPE i.
DATA : itcl_kna1 TYPE TABLE OF ty_kna1,
wacl_kna1 TYPE ty_kna1.
METHODS : get_data,
process_data,
fill_fcat,
display_alv.
ENDCLASS. "data DEFINITION
*----------------------------------------------------------------------*
* CLASS data IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cldata IMPLEMENTATION.
METHOD : get_data.
SELECT kunnr
land1
name1
name2
FROM kna1
INTO TABLE itcl_kna1
UP TO 10 ROWS.
ENDMETHOD. ":
METHOD : process_data.
IF itcl_kna1[] IS NOT INITIAL.
LOOP AT itcl_kna1[] INTO wacl_kna1.
WRITE : wacl_kna1-kunnr ,' ' , wacl_kna1-land1,' ' , wacl_kna1-name1,' ' , wacl_kna1-name2 ,/.
ENDLOOP.
ENDIF.
ENDMETHOD. ":
METHOD : fill_fcat.
REFRESH: fieldcat.
CLEAR: ls_fcat.
counter = counter + 1.
ls_fcat-reptext = 'Customer'.
ls_fcat-fieldname = 'KUNNR'.
ls_fcat-tabname = 'ITCL_KNA1'.
ls_fcat-outputlen = '12'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = counter.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
counter = counter + 1.
ls_fcat-reptext = 'Country'.
ls_fcat-fieldname = 'LAND1'.
ls_fcat-tabname = 'ITCL_KNA1'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = counter.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
counter = counter + 1.
ls_fcat-reptext = 'Name1'.
ls_fcat-fieldname = 'NAME1'.
ls_fcat-tabname = 'ITCL_KNA1'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = counter.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
counter = counter + 1.
ls_fcat-reptext = 'Name2'.
ls_fcat-fieldname = 'NAME2'.
ls_fcat-tabname = 'ITCL_KNA1'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = counter.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ENDMETHOD. ":
METHOD : display_alv.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
layout-edit_mode = 'X'.
IF alv_container IS INITIAL.
CREATE OBJECT alv_container
EXPORTING
repid = repid
dynnr = sy-dynnr
ratio = 69
side = alv_container->dock_at_bottom
extension = 1500.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'WACL_KNA1'
CHANGING
it_outtab = itcl_kna1[]
it_fieldcatalog = fieldcat[].
ELSE.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'WACL_KNA1'
CHANGING
it_outtab = itcl_kna1[]
it_fieldcatalog = fieldcat[].
CALL METHOD alv_grid->refresh_table_display.
ENDIF.
ENDMETHOD. ":
ENDCLASS. "alv IMPLEMENTATION
START-OF-SELECTION.
DATA : obj TYPE REF TO cldata.
CREATE OBJECT obj.
CALL METHOD obj->get_data. "Double click and create a normal screen and uncomment the PBO AND PAI and activate the screen..
IF sy-subrc EQ 0.
CALL SCREEN 9000.
ENDIF.
MODULE status_9000 OUTPUT.
SET PF-STATUS 'ZSTATUS'. "Double click and create status and set BACK, EXIT AND CANCEL button under Function Key and activate it.
SET TITLEBAR 'TITLE'.
CALL METHOD: obj->fill_fcat,
obj->display_alv.
ENDMODULE. " STATUS_9000 OUTPUT
MODULE user_command_9000 INPUT.
CASE sy-ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK' OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
regards
Syed
‎2013 Dec 10 8:39 AM
please you modify your display_alv like the following code:
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
.....
ENDIF.
G_CONTAINER is your container name in your screen.
‎2013 Dec 10 10:53 AM
Issue resolved.
Resolution : I had to create a screen in order to display my ALV.
Thanks all for your helpful answers.
Regards,
Ramiz