Posted: Mon Nov 19, 2007 11:50 pm Post subject: Demo: BCALV_GRID_EDIT
Code:
program test.
parameters p_cell as checkbox default ' '.
parameters p_loce as checkbox default ' '.
parameters p_cedit as checkbox default ' '.
parameters p_f4 as checkbox default ' '.
parameters p_bforf4 as checkbox default ' '.
parameters p_aftrf4 as checkbox default 'X'.
parameters p_style as checkbox default ' '.
class cl_gui_object definition load.
class lcl_event_receiver definition deferred.
include <cl_alv_control>.
data: ok_code like sy-ucomm.
data: blubber2(30) type c.
data: blubber6(1) type c value 'X'.
data: blubber7(1) type c value ' '.
data: ls_cell type lvc_s_styl.
data: blubber9(1) type c value ' '.
data: gs_variant type disvariant.
data: gt_fieldcat type lvc_t_fcat.
data: gt_sort type lvc_t_sort.
data: gs_sort type lvc_s_sort.
data: gs_layout type lvc_s_layo.
data: gt_f4 type lvc_t_f4.
data: gs_f4 type lvc_s_f4.
data: gs_fieldcat type lvc_s_fcat.
data: begin of gt_sflight occurs 0.
include structure sflight.
data: carrname like scarr-carrname,
cell type lvc_t_styl,
end of gt_sflight.
data: begin of gt_sflight1 occurs 0.
include structure sflight.
data: carrname like scarr-carrname,
end of gt_sflight1,
g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
g_container2 type scrfname value 'BCALV_GRID_DEMO_0100_CONT2',
grid1 type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container.
data g_custom_container2 type ref to cl_gui_custom_container.
data: event_receiver type ref to lcl_event_receiver.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
start-of-selection.
if ( p_loce = ' ' and cl_gui_object=>www_active = 'X' ).
message i000(0K) with text-003.
p_loce = 'X'.
endif.
if ( cl_gui_control=>www_active = ' ' ).
select * into corresponding fields of table gt_sflight1 from
( sflight left join scarr
on sflight~carrid = scarr~carrid ) up to 50 rows.
else.
select * into corresponding fields of table gt_sflight1 from
( sflight left join scarr
on sflight~carrid = scarr~carrid ) up to 60 rows.
endif.
loop at gt_sflight1.
clear gt_sflight.
clear ls_cell.
move-corresponding gt_sflight1 to gt_sflight.
if p_cedit = 'X'.
if sy-tabix = 7.
ls_cell-style = cl_gui_alv_grid=>mc_style_disabled.
append ls_cell to gt_sflight-cell.
endif.
if sy-tabix = 9.
ls_cell-style = cl_gui_alv_grid=>mc_style_enabled.
ls_cell-maxlen = 4.
ls_cell-fieldname = 'PLANETYPE'.
append ls_cell to gt_sflight-cell.
endif.
if sy-tabix = 11.
ls_cell-style = cl_gui_alv_grid=>mc_style_enabled.
ls_cell-maxlen = 4.
ls_cell-fieldname = 'CARRNAME'.
append ls_cell to gt_sflight-cell.
endif.
endif.
append gt_sflight.
endloop.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
module pai input.
perform pai_input.
endmodule.
*&---------------------------------------------------------------------*
*& Form data_changed
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form data_changed using rr_data_changed type ref to
cl_alv_changed_data_protocol.
data: ls_mod_cells type lvc_s_modi.
data: ls_cells type lvc_s_modi.
data: l_carrid type sflight-carrid.
data: l_seats type sflight-seatsocc.
data: l_curr type sflight-currency.
data: l_seatsmax type sflight-seatsmax.
data: ls_sflight like gt_sflight1.
data: ls_tcurc like tcurc. "#EC NEEDED
loop at rr_data_changed->mt_good_cells into ls_mod_cells.
case ls_mod_cells-fieldname.
when 'CARRID'.
call method rr_data_changed->get_cell_value
exporting i_row_id = ls_mod_cells-row_id
i_fieldname = ls_mod_cells-fieldname
importing e_value = l_carrid.
select single * into corresponding fields
of ls_sflight from
( sflight left join scarr
on sflight~carrid = scarr~carrid )
where sflight~carrid = l_carrid.
if sy-subrc ne 0.
else.
call method rr_data_changed->modify_cell
exporting i_row_id = ls_mod_cells-row_id
i_fieldname = 'CARRNAME'
i_value = ls_sflight-carrname.
endif.
when 'CONNID'.
if p_style = 'X'.
call method rr_data_changed->modify_style
exporting i_fieldname = 'CURRENCY'
i_row_id = ls_mod_cells-row_id
i_style = cl_gui_alv_grid=>mc_style_disabled.
endif.
select single * from tcurc into ls_tcurc where waers = l_curr.
if sy-subrc ne 0.
call method rr_data_changed->add_protocol_entry
exporting i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = text-001
i_msgv2 = l_curr
i_msgv3 = text-006
i_fieldname = ls_mod_cells-fieldname
i_row_id = ls_mod_cells-row_id.
endif.
endcase.
endloop.
endform. " data_changed
*&---------------------------------------------------------------------*
*& Form change_planetype
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form change_planetype using rr_data_changed type ref to
cl_alv_changed_data_protocol
rs_mod_cells type lvc_s_modi.
data: l_planetype type sflight-planetype.
data: ls_saplane type saplane .
*&---------------------------------------------------------------------*
*& Form F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
form f4 using r_fieldname type lvc_fname
rs_row_no type lvc_s_roid
rr_event_data type ref to cl_alv_event_data
rt_bad_cells type lvc_t_modi. "#EC *
field-symbols: <lt_f4> type lvc_t_modi.
data: ls_f4 type lvc_s_modi.
assign rr_event_data->m_data->* to <lt_f4>.
ls_f4-fieldname = r_fieldname.
ls_f4-row_id = rs_row_no-row_id.
ls_f4-value = 'BLUBBER'.
append ls_f4 to <lt_f4>.
rr_event_data->m_event_handled = 'X'.
endform. " F4
*&---------------------------------------------------------------------*
*& Form pbo_output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pbo_output.
set pf-status 'MAIN100'.
if g_custom_container is initial.
if sy-batch is initial.
create object g_custom_container
exporting container_name = g_container.
if ( p_loce = 'X' ).
create object g_custom_container2
exporting container_name = g_container2.
endif.
endif.
create object grid1
exporting i_parent = g_custom_container
i_applogparent = g_custom_container2.
*&---------------------------------------------------------------------*
*& Form pai_input
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM pai_input.
data: l_valid(1) type c.
case ok_code.
when 'SAVE'.
call method grid1->check_changed_data importing e_valid = l_valid.
if l_valid = 'X'.
message i000(0k) with text-009.
else.
message i000(0k) with text-010.
endif.
when 'CHANGE'.
if grid1->is_ready_for_input( ) = 0.
call method grid1->set_ready_for_input exporting
i_ready_for_input = 1.
else.
call method grid1->check_changed_data
importing e_valid = l_valid.
if l_valid = 'X'.
call method grid1->set_ready_for_input exporting
i_ready_for_input = 0.
endif.
endif.
when 'EXIT'.
set screen 0.
leave screen.
endcase.
clear ok_code.
ENDFORM. " pai_input
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.