‎2008 Apr 11 8:38 AM
hi friends,
i want interactive object oriented alv report. i want some example program for that.
‎2008 Apr 11 8:40 AM
&----
*& Report Z8VM_N_PO_PRICING_CONDITION *
*& *
&----
*& *
*& *
&----
REPORT Z8VM_N_PO_PRICING_CONDITION NO STANDARD PAGE HEADING
MESSAGE-ID Z8VM.
************************************************************************
vivekanand meghmala
trial assignment
po with pricing condition interactive report with checkbox
************************************************************************
************************************************************************
data declaration
************************************************************************
TYPES : BEGIN OF STRUCT_EKKO, "po header
BUKRS LIKE T001-BUKRS,
EBELN LIKE EKKO-EBELN,
BSART LIKE EKKO-BSART,
BEDAT LIKE EKKO-BEDAT,
EKORG LIKE EKKO-EKORG,
WAERS LIKE EKKO-WAERS,
LIFNR LIKE EKKO-LIFNR,
KNUMV LIKE EKKO-KNUMV,
END OF STRUCT_EKKO.
TYPES : BEGIN OF STRUCT_EKPO, "po details
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
END OF STRUCT_EKPO.
TYPES : BEGIN OF STRUCT_KONV,
KNUMV LIKE KONV-KNUMV,
KPOSN LIKE KONV-KPOSN,
KSCHL LIKE KONV-KSCHL,
KAWRT LIKE KONV-KAWRT,
KBETR LIKE KONV-KBETR,
END OF STRUCT_KONV.
DATA : IT_EKKO TYPE STANDARD TABLE OF STRUCT_EKKO WITH HEADER LINE.
DATA : IT_EKPO TYPE STANDARD TABLE OF STRUCT_EKPO WITH HEADER LINE.
DATA : IT_KONV TYPE STANDARD TABLE OF STRUCT_KONV WITH HEADER LINE.
PARAMETERS : T_BUKRS LIKE EKKO-BUKRS .
SELECT-OPTIONS : S_BEDAT FOR IT_EKKO-BEDAT.
SELECT-OPTIONS : S_EKORG FOR IT_EKKO-EKORG.
************************************************************************
validations
************************************************************************
AT SELECTION-SCREEN.
IF T_BUKRS = ' '.
MESSAGE E009.
ENDIF.
SELECT BUKRS FROM T001
INTO CORRESPONDING FIELDS OF IT_EKKO
WHERE BUKRS = T_BUKRS.
EXIT.
ENDSELECT.
IF SY-SUBRC 0.
MESSAGE E001.
ENDIF.
************************************************************************
logic
************************************************************************
START-OF-SELECTION.
SELECT BUKRS
EBELN
BSART
BEDAT
EKORG
WAERS
LIFNR
KNUMV FROM EKKO INTO CORRESPONDING FIELDS OF TABLE IT_EKKO
WHERE BUKRS = T_BUKRS
AND BEDAT IN S_BEDAT
AND EKORG IN S_EKORG.
SELECT EBELN
EBELP
MATNR FROM EKPO INTO CORRESPONDING FIELDS OF IT_EKPO
FOR ALL ENTRIES IN IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
APPEND IT_EKPO.
ENDSELECT.
LOOP AT IT_EKPO.
SELECT KNUMV
KPOSN
KSCHL
KAWRT
KBETR FROM KONV INTO CORRESPONDING FIELDS OF IT_KONV
WHERE KPOSN = IT_EKPO-EBELP.
APPEND IT_KONV.
ENDSELECT.
ENDLOOP.
*************************************************************************
*data printing
*************************************************************************
LOOP AT IT_EKKO.
WRITE 😕 IT_EKKO-BUKRS,IT_EKKO-EBELN,IT_EKKO-BSART,IT_EKKO-BEDAT,
IT_EKKO-EKORG,IT_EKKO-WAERS,IT_EKKO-LIFNR,IT_EKKO-KNUMV.
LOOP AT IT_EKPO WHERE EBELN = IT_EKKO-EBELN.
WRITE 😕 IT_EKPO-EBELP,IT_EKPO-MATNR.
LOOP AT IT_KONV.
WHERE KPOSN = IT_EKPO-EBELN.
WRITE 😕 IT_KONV-KNUMV COLOR 3,IT_KONV-KPOSN COLOR 3,IT_KONV-KSCHL COLOR 3,IT_KONV-KAWRT COLOR 3,IT_KONV-KBETR COLOR 3.
ENDLOOP.
ENDLOOP.
ENDLOOP.[/code]
You may want to have a look at my ZUS_SDN_... sample reports in the following threads:
Event handling in alv oops With buttons
Event in ALV Grid
How to handle two hot spot clicks on one screen
thanks
reward if helpful
‎2008 Apr 11 8:41 AM
this is one sample program
just create that 100 and 200 screen s
REPORT ZCL_OOPS_INT_ALV_GRID .
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
*--END OF CLASS IMPL
start-of-selection.
set screen 100.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module status_0100 output.
set pf-status 'T111'.
set titlebar 'TITLE11' WITH 'PO HEADER DETAILS'.
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.
*--LAYOUT INFORMAITON
x_layout-grid_title = 'Posting Master Data'.
x_layout-keyhot = 'X'.
x_layout-ZEBRA = '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
----
form select_data .
select * from ekko
into table t_ekko
UP TO 10 ROWS.
endform. " select_data
&----
*& Form get_detail_data
&----
text
----
form get_detail_data .
select * from ekpo
into table t_ekpo
where ebeln = v_ebeln.
endform. " get_detail_data
&----
*& Form exit_program
&----
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 = 'ZCL_OOPS_INT_ALV_GRID'
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 'TITLE11' WITH '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
‎2008 Apr 11 8:41 AM
HI,
Refer to the following program:
BCALV_GRID_03 This program implements a function on event DOUBLE_CLICK. According to the selected line data
from table SBOOK is selected and displayed by a second ALV Control in a dialog dynpro.
Hope this helps.
Reward if helpful.
Regards,
Sipra
‎2008 Apr 11 8:43 AM
try like this
&----
*& Report ZALV_OOP
*&
&----
*&
*&
&----
REPORT zalv_oop.
----
CLASS lcl_event_handler DEFINITION
----
*
----
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*--Double-click control
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no.
PRIVATE SECTION.
ENDCLASS. "lcl_event_handler DEFINITION
----
CLASS lcl_event_handler IMPLEMENTATION
----
*
----
CLASS lcl_event_handler IMPLEMENTATION .
*--Handle Double Click
METHOD handle_double_click .
PERFORM handle_double_click USING e_row e_column es_row_no .
ENDMETHOD . "handle_double_click
ENDCLASS . "lcl_event_handler IMPLEMENTATION
TABLES : mseg.
DATA : BEGIN OF itab OCCURS 0,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
END OF itab.
DATA : gr_alvgrid TYPE REF TO cl_gui_alv_grid,
gr_ccontainer TYPE REF TO cl_gui_custom_container,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo.
DATA gr_event_handler TYPE REF TO lcl_event_handler .
DATA : ok_code LIKE sy-ucomm.
DATA : t_mat LIKE mara-matnr.
DATA: variant TYPE disvariant.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mblnr FOR mseg-mblnr.
SELECTION-SCREEN : END OF BLOCK blk1.
START-OF-SELECTION.
SET SCREEN 100.
CREATE OBJECT gr_event_handler .
PERFORM get_data.
PERFORM dis_data.
&----
*& Form get_data
&----
text
----
FORM get_data.
SELECT mblnr matnr menge FROM mseg INTO CORRESPONDING FIELDS OF TABLE itab
WHERE mblnr IN s_mblnr.
variant-report = sy-repid.
variant-username = sy-uname.
ENDFORM. "get_data
&----
*& Form dis_data
&----
text
----
FORM dis_data.
IF gr_alvgrid IS INITIAL.
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = 'CC_ALV'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
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 gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PERFORM create_fcat CHANGING gt_fcat.
PERFORM create_layout CHANGING gs_layo.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_variant = variant
i_save = 'A'
is_layout = gs_layo
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_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.
SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .
ENDIF.
ENDFORM. "dis_data
&----
*& Form create_fcat
&----
text
----
<--P_GT_FCAT text
----
FORM create_fcat CHANGING pt_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
ls_fcat-fieldname = 'MBLNR'.
ls_fcat-coltext = 'Material Doc.'.
APPEND ls_fcat TO pt_fcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-coltext = 'Material'.
APPEND ls_fcat TO pt_fcat.
ls_fcat-fieldname = 'MENGE'.
ls_fcat-coltext = 'Quantity'.
APPEND ls_fcat TO pt_fcat.
ENDFORM. " create_fcat
&----
*& Form create_layout
&----
text
----
<--P_GS_LAYO text
----
FORM create_layout CHANGING ps_layo TYPE lvc_s_layo.
ps_layo-zebra = 'X'.
ENDFORM. " create_layout
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZALV_OOP'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'BACK' OR 'UP' OR 'CANC'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form handle_double_click
&----
text
----
-->I_ROW text
-->I_COLUMN text
-->IS_ROW_NO text
----
FORM handle_double_click USING i_row TYPE lvc_s_row
i_column TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
READ TABLE itab INDEX is_row_no-row_id .
IF sy-subrc = 0 .
IF i_column = 'MATNR'.
t_mat = itab-matnr.
SET PARAMETER ID 'MAT' FIELD t_mat.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
SET PARAMETER ID 'MAT' FIELD space.
ELSEIF i_column = 'MBLNR'.
CALL TRANSACTION 'MIGO'.
ENDIF .
ENDIF.
ENDFORM . "handle_double_click
here in screen 100 i have taken one custom control with name cc_alv
‎2008 Apr 11 8:44 AM
Hi,
please check the fallowing code for interacive report
&----
*& Report ZVEN_INTERACTIVE_OBJ
*&
&----
*&
*&
&----
REPORT ZVEN_INTERACTIVE_OBJ.
*----type ref variables for custom container and alv
data:o_cost type ref to cl_gui_custom_container,
o_cost1 type ref to cl_gui_custom_container,
o_alv1 type ref to cl_gui_alv_grid,
o_alv type ref to cl_gui_alv_grid.
*-----Parameter declarations
parameters:p_vbeln like vbrk-vbeln.
tables:vbrk.
*selection-screen begin of block a with frame title text-001.
*select-options:s_vbeln for vbrk-vbeln.
*selection-screen end of block a.
*-----Internal table for vbrk and vbrp
data:it_vbrk like vbrk occurs 1 with header line,
it_vbrp like vbrp occurs 1 with header line.
data:it_index like LVC_S_ROW occurs 1 with header line,
wa_index like line of it_index.
data:wa_vbrk type vbrk.
*-----declaration for field catalog
data:it_fcat TYPE LVC_T_FCAT with header line.
*----class for handlling the event
class c1 definition.
public section.
methods:handler_HOTSPOT_CLICK for event HOTSPOT_CLICK
of cl_gui_alv_grid.
endclass.
*----implementaion for the enent
class c1 implementation.
method:handler_HOTSPOT_CLICK.
call screen 200.
endmethod.
endclass.
start-of-selection.
*---ref variable
data:obj type ref to c1.
create object obj.
*---Registering the event for the class c1
set handler obj->handler_HOTSPOT_CLICK for all instances.
*----populate the field catalog
perform populate_fieldcat.
set screen 100.
&----
*& Module STATUS_0100 OUTPUT
&----
text
-
module STATUS_0100 output.
SET PF-STATUS 'MENU'.
IF o_cost IS INITIAL.
*----Linking between screen to custom container class
CREATE OBJECT o_cost
EXPORTING
container_name = 'VBRK_COST'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Error while linking to custom container'.
ENDIF.
*-----Linking between custom container to alv grid class
CREATE OBJECT o_alv
EXPORTING
i_parent = o_cost
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Error while linging to alv frist grid'.
ENDIF.
*---Registering the event for the class c1
*set handler
*---get the data from vbrk
perform get_data_vbrk.
CALL METHOD o_alv->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME = 'VBRK'
CHANGING
it_outtab = it_vbrk[]
IT_FIELDCATALOG = IT_FCAT[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Data was not display in first alv'.
ENDIF.
endif.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
-
module USER_COMMAND_0100 input.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
&----
*& Form get_data_vbrk
&----
text
-
form get_data_vbrk .
select *
from vbrk
into table it_vbrk
where vbeln = p_vbeln.
endform. " get_data_vbrk
&----
*& Form populate_fieldcat
&----
text
-
form populate_fieldcat.
it_fcat-col_pos = 1.
it_fcat-FIELDNAME = 'VBELN'.
it_fcat-TABNAME = 'IT_VBRK'.
it_fcat-KEY = 'X'.
IT_FCAT-HOTSPOT = 'X'.
APPEND IT_FCAT.
CLEAR IT_FCAT.
endform. " populate_fieldcat
&----
*& Module STATUS_0200 OUTPUT
&----
text
-
module STATUS_0200 output.
SET PF-STATUS 'MENU'.
IF o_cost1 IS INITIAL.
*----Linking between screen to custom container class
CREATE OBJECT o_cost
EXPORTING
container_name = 'VBRP_COST'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Error while linking to custom container'.
ENDIF.
*-----Linking between custom container to alv grid class
CREATE OBJECT o_alv1
EXPORTING
i_parent = o_cost1
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Error while linging to alv Second grid'.
ENDIF.
*---get the data from vbrk
perform get_data_vbrp.
CALL METHOD o_alv1->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME = 'VBRP'
CHANGING
it_outtab = it_vbrp[]
IT_FIELDCATALOG = IT_FCAT[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF sy-subrc 0.
MESSAGE I000(Z00) WITH 'Data was not display in first alv'.
ENDIF.
endif.
endmodule. " STATUS_0200 OUTPUT
&----
*& Form get_data_vbrp
&----
text
-
form get_data_vbrp .
select *
from vbrp
into table it_vbrp
where vbeln = p_vbeln.
endform. " get_data_vbrp
&----
*& Module USER_COMMAND_0200 INPUT
&----
text
-
module USER_COMMAND_0200 input.
case sy-ucomm.
when 'BACK'.
LEAVE TO SCREEN 100.
endcase.
endmodule. " USER_COMMAND_0200 INPUT
Reward Points if found helpfull..
Cheers,
Chandra Sekhar.