Skip to Content
0
Former Member
Apr 02, 2009 at 05:56 AM

interactive report

24 Views

Hi all,

The following code is for interactive report. The Problem is that i amunable to get the screens.

here strucuture zitfinal11 corresponds to it_data internal table and zitfinal12 to it_final12.

Please help me in detecting the error.

start-of-selection.

set screen '100'.

perform getdata1.

************************************************************************************

form getdata1.

select spras mtart mtbez from t134t into wa_t134t where mtart = 'FERT' and spras = 'EN'.

wa_final-mtbez = wa_t134t-mtbez.

wa_final12-mtbez = wa_t134t-mtbez.

append wa_final to it_final.

append wa_final12 to it_final12.

endselect.

select spmon matnr werks from s031 into corresponding fields of table it_s031

where spmon in month and werks in plant.

loop at it_s031 into wa_s031.

wa_final-month = wa_s031-spmon.

append wa_final to it_final.

select matnr mtart from mara into corresponding fields of table it_mara

" FOR ALL ENTRIES IN it_s031

where matnr = wa_s031-matnr and mtart = 'FERT' .

select mblnr werks matnr menge dmbtr bwart erfme waers from mseg

into corresponding fields of table it_mseg "for all entries in it_s031

where matnr = wa_s031-matnr and ( bwart = '102' or bwart = '101' or bwart = '601' or

bwart = '602' ) and werks = wa_s031-werks." and erfme = 'M'.

" endloop.

loop at it_mara into wa_mara.

wa_final-matnr = wa_mara-matnr.

wa_final12-matnr = wa_mara-matnr.

append : wa_final to it_final,wa_final12 to it_final12.

endloop.

loop at it_mseg into wa_mseg.

wa_final-erfme = wa_mseg-erfme.

wa_final-dmbtr = wa_mseg-dmbtr.

wa_final-menge = wa_mseg-menge.

wa_final-waers = wa_mseg-waers.

wa_final-bwart = wa_mseg-bwart.

wa_final-mblnr = wa_mseg-mblnr.

append wa_final to it_final.

*************************************for individual display**********************************

wa_final12-erfme = wa_mseg-erfme.

wa_final12-dmbtr = wa_mseg-dmbtr.

wa_final12-menge = wa_mseg-menge.

wa_final12-waers = wa_mseg-waers.

append wa_final12 to it_final12.

endloop.

endloop.

sort it_final by month erfme.

delete it_final where erfme = space.

delete it_final where matnr = space.

loop at it_final into wa_final.

" write : / wa_final-month,wa_final-erfme,wa_final-matnr, wa_final-dmbtr, wa_final-menge,wa_final-bwart,wa_final-mblnr.

wa_temp_final = wa_final.

if wa_final-bwart = '101'.

flag = flag + wa_temp_final-dmbtr.

flag8 = flag8 + wa_temp_final-menge.

elseif wa_final-bwart = '102'.

flag1 = flag1 + wa_temp_final-dmbtr.

flag9 = flag9 + wa_temp_final-menge.

elseif wa_final-bwart = '601'.

flag4 = flag4 + wa_temp_final-dmbtr.

flag10 = flag10 + wa_temp_final-menge.

elseif wa_final-bwart = '602'.

flag5 = flag5 + wa_temp_final-dmbtr.

flag11 = flag11 + wa_temp_final-menge.

endif.

wa_temp_final-month = wa_final-month.

at end of month.

at end of erfme.

flag3 = flag - flag1. "101-102

flag6 = flag4 - flag5. "601-602

flag7 = flag3 - flag6.

flag12 = flag8 - flag9.

flag13 = flag10 - flag11.

flag14 = flag12 - flag13.

wa_temp_final-f3 = flag3.

wa_temp_final-f4 = flag6.

wa_temp_final-f5 = flag7.

wa_temp_final-f6 = flag12.

wa_temp_final-f7 = flag13.

wa_temp_final-f8 = flag14.

wa_data-month = wa_temp_final-month.

wa_data-menge = flag14.

wa_data-erfme = wa_final-erfme.

wa_data-dmbtr = flag7.

wa_data-waers = wa_final-waers.

append wa_data to it_data.

" skip.

" write : /1 wa_temp_final-month,25 wa_final-erfme, wa_temp_final-f5, wa_temp_final-f8,wa_temp_final-waers.

" skip.

flag = 0. flag1 = 0. flag3 = 0. flag4 = 0. flag5 = 0. flag6 = 0. flag7 = 0.

flag8 = 0. flag9 = 0. flag10 = 0. flag11 = 0. flag12 = 0. flag13 = 0. flag14 = 0.

endat.

endat.

endloop.

endform.

class lcl_event_receiver definition.

public section.

methods:

handle_double_click

for event double_click of cl_gui_alv_grid

importing e_row e_column.

private section.

endclass.

class lcl_event_receiver implementation.

method handle_double_click.

data: ls_it_data like line of gt_it_data.

read table gt_it_data index e_row-index into ls_it_data.

perform select_table_it_final12 using ls_it_data

changing gt_it_final12.

call screen 101 starting at 10 5.

endmethod. "handle_double_click

endclass.

form exit_program.

call method custom_container1->free.

if not custom_container2 is initial.

call method custom_container2->free.

endif.

call method cl_gui_cfw=>flush.

if sy-subrc ne 0.

  • add your handling, for example

call function 'POPUP_TO_INFORM'

exporting

titel = g_repid

txt2 = sy-subrc

txt1 = 'Error in FLush'(500).

endif.

leave program.

endform.

module status_0100 output.

g_repid = sy-repid.

if custom_container1 is initial.

perform select_table_it_data changing gt_it_data.

create object custom_container1

exporting

container_name = cont_on_main

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc ne 0.

call function 'POPUP_TO_INFORM'

exporting

titel = g_repid

txt2 = sy-subrc

txt1 = 'The control could not be created'(510).

endif.

  • create an instance of alv control

create object grid1

exporting i_parent = custom_container1.

gs_layout-grid_title = 'Materials'."(100).

call method grid1->set_table_for_first_display

exporting i_structure_name = 'ZITFINAL11'

is_layout = gs_layout

changing

it_outtab = gt_it_data.

create object event_receiver.

set handler event_receiver->handle_double_click for grid1.

endif. "IF grid1 IS INITIAL

call method cl_gui_control=>set_focus exporting control = grid1.

endmodule. " PBO_100 OUTPUT

&----


*& Module PAI_100 INPUT

&----


  • text

----


module user_command_0100 input.

case sy-ucomm.

when 'EXIT'.

perform exit_program.

when 'RETURN' .

leave to screen '0000' .

endcase.

clear ok_code.

endmodule. " PAI_100 INPUT

&----


*& Module PBO_0101 OUTPUT

&----


  • text

----


module status_0101 output.

if custom_container2 is initial.

create object custom_container2

exporting

container_name = cont_on_dialog

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

if sy-subrc ne 0.

call function 'POPUP_TO_INFORM'

exporting

titel = g_repid

txt2 = sy-subrc

txt1 = 'The control could not be created'(510).

endif.

create object grid2

exporting i_parent = custom_container2.

gs_layout-grid_title = 'Materials'(101).

perform mask_columns tables gt_fieldcat.

call method grid2->set_table_for_first_display

exporting

is_layout = gs_layout

changing it_fieldcatalog = gt_fieldcat[]

it_outtab = gt_it_final12.

else.

call method grid2->refresh_table_display.

endif. "IF grid2 IS INITIAL.

call method cl_gui_control=>set_focus exporting control = grid2.

call method cl_gui_cfw=>flush.

if sy-subrc ne 0.

  • add your handling, for example

call function 'POPUP_TO_INFORM'

exporting

titel = g_repid

txt2 = sy-subrc

txt1 = 'Error in FLush'(500).

endif.

endmodule. " PBO_0101 OUTPUT

&----


*& Form SELECT_TABLE_mara

&----


  • text

----


  • <--P_GT_mara text

----


form select_table_it_data changing p_gt_it_data like gt_it_data[].

p_gt_it_data[] = it_data[].

endform. " SELECT_TABLE_mara

&----


*& Form SELECT_TABLE_mseg

&----


  • text

----


form select_table_it_final12 using p_ls_it_data like line of gt_it_data

changing p_gt_it_final12 like gt_it_final12[].

p_gt_it_final12[] = it_final12[].

endform. " SELECT_TABLE_mseg

&----


*& Module PAI_0101 INPUT

&----


  • text

----


module user_command_0101 input.

case ok_code.

when 'RETURN'.

leave to screen '0000'.

endcase.

clear ok_code.

endmodule. " PAI_0101 INPUT

&----


*& Form MASK_COLUMNS

&----


  • text

----


  • <--P_GT_FIELDCAT text

----


form mask_columns tables p_gt_fieldcat type lvc_t_fcat.

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = 'ZITFINAL12'

changing

ct_fieldcat = p_gt_fieldcat[].

endform.