面向對象(OO)的ALV
阿新 • • 發佈:2017-10-05
width div pan fields nging toolbar from false item
1 START-OF-SELECTION. 2 * Selection Screen 3 SELECTION-SCREEN BEGIN OF BLOCK 1. 4 SELECT-OPTIONS: so_pob FOR farr_d_defitem-pob_id. 5 SELECT-OPTIONS: so_con FOR farr_d_defitem-contract_id. 6 PARAMETERS: 7 p_test_r AS CHECKBOX DEFAULT ‘X‘, 8 p_new_li AS CHECKBOX DEFAULT ‘‘. 9 SELECTION-SCREENEND OF BLOCK 1. 10 11 *&---------------------------------------------------------------------* 12 *& END-OF-SELECTION 13 *&---------------------------------------------------------------------* 14 END-OF-SELECTION. 15 * In case of new lines no select is needed 16 IF p_new_li IS INITIAL. 17 * Select FARR_D_DEFITEM direct in output and changtab lt_ZFARR_D_DEFITEM 18 SELECT * FROM farr_d_defitem INTO CORRESPONDING FIELDS OF TABLE lt_zfarr_d_defitem 19 WHERE pob_id IN so_pob 20 AND contract_id IN so_con. 21 22 * Select original table lines in memory table23 SELECT * FROM farr_d_defitem INTO CORRESPONDING FIELDS OF TABLE lt_farr_d_defitem_org 24 WHERE pob_id IN so_pob 25 AND contract_id IN so_con. 26 ENDIF. 27 28 IF lt_zfarr_d_defitem IS INITIAL. 29 total_num = ‘0‘. 30 ELSE. 31 DESCRIBE TABLE lt_farr_d_defitem LINES total_num. 32 ENDIF. 33 34 *MESSAGE: ‘make sure the contract is consistence with RAI and Sales order as needed‘ TYPE ‘I‘. 35 MESSAGE: ‘Change all lines you like to change, mark the lines you need to change and press save‘ TYPE ‘S‘. 36 37 CALL SCREEN 999. 38 39 INCLUDE z_oo_test_james_status_0999o01. 40 41 INCLUDE z_oo_test_james_prepare_fief01.
1 PROCESS BEFORE OUTPUT. 2 MODULE ini_alv. 3 MODULE STATUS_0999. 4 5 * 6 PROCESS AFTER INPUT. 7 MODULE USER_COMMAND_0999.
1 &---------------------------------------------------------------------* 2 *& Module INI_ALV OUTPUT 3 *&---------------------------------------------------------------------* 4 * text 5 *----------------------------------------------------------------------* 6 MODULE ini_alv OUTPUT. 7 8 lw_layout-zebra = abap_true. 9 lw_layout-cwidth_opt = abap_true. 10 lw_layout-sel_mode = ‘D‘. 11 12 IF go_container is INITIAL. 13 create OBJECT go_container 14 EXPORTING 15 container_name = ‘CUS‘. " Name of the Screen CustCtrl 16 17 CREATE OBJECT go_alv_grid 18 EXPORTING 19 i_parent = go_container . " Parent Container 20 21 * CREATE OBJECT go_alv_toolbar 22 * EXPORTING 23 * IO_ALV_GRID = go_alv_grid 24 25 lw_layout-edit = abap_false. 26 lw_layout-zebra = abap_true. 27 * lw_layout-stylefname = ‘CT‘. 28 ls_variant-report = ‘ZFARR965‘. 29 30 PERFORM prepare_fieldcatalog. "make chekbox for insert and delete 31 32 * CALL METHOD go_alv_grid->set_toolbar_interactive. 33 CALL METHOD go_alv_grid->set_table_for_first_display 34 EXPORTING 35 i_structure_name = ‘ZFARR_D_DEFITEM‘ 36 is_layout = lw_layout 37 i_default = abap_true 38 i_save = ‘A‘ 39 * is_variant = ls_variant 40 CHANGING 41 it_fieldcatalog = gs_fieldcatalog 42 it_outtab = lt_zFARR_D_DEFITEM. " Output Table 43 * Set editable cells to ready for input initially 44 CALL METHOD go_alv_grid->set_ready_for_input 45 EXPORTING 46 i_ready_for_input = 1. 47 48 ELSE. 49 CALL METHOD go_alv_grid->refresh_table_display. 50 ENDIF. 51 52 ENDMODULE.
1 ***INCLUDE Z_OO_TEST_JAMES_STATUS_0999O01. 2 *----------------------------------------------------------------------* 3 *&---------------------------------------------------------------------* 4 *& Module STATUS_0999 OUTPUT 5 *&---------------------------------------------------------------------* 6 * text 7 *----------------------------------------------------------------------* 8 MODULE status_0999 OUTPUT. 9 SET PF-STATUS ‘STATUS_999‘. 10 SET TITLEBAR ‘TITLE_999‘. 11 ENDMODULE.
1 *&---------------------------------------------------------------------* 2 *& Module USER_COMMAND_0999 INPUT 3 *&---------------------------------------------------------------------* 4 * text 5 *----------------------------------------------------------------------* 6 MODULE user_command_0999 INPUT. 7 DATA ok_code TYPE ok_code. 8 CASE ok_code. 9 WHEN ‘BACK‘ OR ‘EXIT‘ OR ‘CANCEL‘. 10 * leave PROGRAM. 11 LEAVE to SCREEN 0. 12 WHEN ‘SAVE‘. 13 * PERFORM updat_FARR_D_DEFITEM_db. 14 WHEN OTHERS. 15 ENDCASE. 16 ENDMODULE.
1 *----------------------------------------------------------------------* 2 ***INCLUDE Z_OO_TEST_JAMES_STATUS_0999O01. 3 *----------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Module STATUS_0999 OUTPUT 6 *&---------------------------------------------------------------------* 7 * text 8 *----------------------------------------------------------------------* 9 MODULE status_0999 OUTPUT. 10 SET PF-STATUS ‘STATUS_999‘. 11 SET TITLEBAR ‘TITLE_999‘. 12 ENDMODULE.
1 ----------------------------------------------------------------------* 2 ***INCLUDE Z_OO_TEST_JAMES_PREPARE_FIEF01. 3 *----------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Form PREPARE_FIELDCATALOG 6 *&---------------------------------------------------------------------* 7 * text 8 *----------------------------------------------------------------------* 9 * --> p1 text 10 * <-- p2 text 11 *----------------------------------------------------------------------* 12 FORM prepare_fieldcatalog . 13 * Making feildcat 14 CLEAR gv_fcat. 15 gv_fcat-fieldname = ‘DELETE_LINE‘."fieldname 16 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 17 gv_fcat-checkbox = ‘X‘. 18 gv_fcat-coltext = ‘Delete line‘##NO_TEXT . 19 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 20 21 CLEAR gv_fcat. 22 gv_fcat-fieldname = ‘NEW_LINE‘."fieldname 23 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 24 gv_fcat-checkbox = ‘X‘. 25 gv_fcat-coltext = ‘Insert line‘##NO_TEXT . 26 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 27 28 CLEAR gv_fcat. 29 gv_fcat-fieldname = ‘CHANGE_USER‘."fieldname 30 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 31 gv_fcat-no_out = ‘X‘. 32 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 33 34 CLEAR gv_fcat. 35 gv_fcat-fieldname = ‘CHANGE_TIME‘."fieldname 36 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 37 gv_fcat-no_out = ‘X‘. 38 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 39 40 CLEAR gv_fcat. 41 gv_fcat-fieldname = ‘CHANGE_DAT‘."fieldname 42 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 43 gv_fcat-no_out = ‘X‘. 44 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 45 46 CLEAR gv_fcat. 47 gv_fcat-fieldname = ‘VERSION‘."fieldname 48 gv_fcat-tabname = ‘ZFARR_D_DEFITEM‘."tabname 49 gv_fcat-no_out = ‘X‘. 50 INSERT gv_fcat INTO TABLE gs_fieldcatalog. 51 52 ENDFORM.
1 *&---------------------------------------------------------------------* 2 *& Report Z_OO_TEST_JAMES 3 *&---------------------------------------------------------------------* 4 *&* (TEST FOR JAMES )Report to DISPLAY 5 *&---------------------------------------------------------------------* 6 REPORT Z_OO_TEST_JAMES. 7 8 TABLES: 9 farr_d_defitem. 10 *&---------------------------------------------------------------------* 11 *& DATA DEFINITION 12 *&---------------------------------------------------------------------* 13 DATA: 14 lt_farr_d_defitem TYPE SORTED TABLE OF farr_d_defitem 15 WITH UNIQUE KEY RECON_KEY POB_ID CONDITION_TYPE DEFERRAL_CAT, 16 ls_farr_d_defitem TYPE farr_d_defitem , 17 lt_zfarr_d_defitem TYPE STANDARD TABLE OF zfarr_d_defitem, 18 lt_farr_d_defitem_org TYPE STANDARD TABLE OF farr_d_defitem, 19 ls_farr_d_defitem_org TYPE farr_d_defitem. 20 21 * ALV 22 TYPE-POOLS: 23 slis. 24 *Class definition for ALV toolbar 25 *CLASS: lcl_alv_toolbar DEFINITION DEFERRED. 26 27 *Screen fields 28 DATA: 29 total_num TYPE i. 30 31 * OO DEFINITION 32 DATA: 33 go_container TYPE REF TO cl_gui_custom_container, 34 * go_alv_toolbar TYPE REF TO lcl_alv_toolbar, "Alv toolbar 35 go_alv_grid TYPE REF TO cl_gui_alv_grid. 36 37 * Workareas 38 DATA lt_fieldcat TYPE lvc_t_fcat. 39 DATA: 40 lw_fieldcat LIKE LINE OF lt_fieldcat, 41 lw_layout TYPE lvc_s_layo, 42 gs_fieldcatalog TYPE lvc_s_fcat OCCURS 0, 43 gv_fcat LIKE LINE OF gs_fieldcatalog. 44 45 DATA: ls_variant TYPE disvariant.
面向對象(OO)的ALV