Anda di halaman 1dari 18

TYPE-POOLS SLIS.

DATA: BEGIN OF ls_mara, check TYPE c, matnr TYPE mara-matnr, ersda TYPE mara-ersda, ernam TYPE mara-ernam, END OF ls_mara. DATA: lt_mara LIKE TABLE OF ls_mara. DATA: LS_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE. SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE lt_mara UP TO 10 ROWS. LS_FIELDCAT-FIELDNAME = 'CHECK'. LS_FIELDCAT-SELTEXT_M = 'Selection Field'. LS_FIELDCAT-CHECKBOX = 'X'. *LS_FIELDCAT-COMMAND = 'SELECT'. LS_FIELDCAT-edit = 'X'. LS_FIELDCAT-COL_POS = 1. LS_FIELDCAT-OUTPUTLEN = 15. APPEND LS_FIELDCAT . CLEAR LS_FIELDCAT. LS_FIELDCAT-FIELDNAME = 'MATNR'. LS_FIELDCAT-SELTEXT_M = 'Material Number'. LS_FIELDCAT-COL_POS = 2. LS_FIELDCAT-OUTPUTLEN = 20. APPEND LS_FIELDCAT . CLEAR LS_FIELDCAT. LS_FIELDCAT-FIELDNAME = 'ERSDA'. LS_FIELDCAT-SELTEXT_M = 'Creation Date'. LS_FIELDCAT-COL_POS = 3. LS_FIELDCAT-OUTPUTLEN = 20. APPEND LS_FIELDCAT . CLEAR LS_FIELDCAT. LS_FIELDCAT-FIELDNAME = 'ERNAM'. LS_FIELDCAT-SELTEXT_M = 'Creation By'. LS_FIELDCAT-COL_POS = 3. LS_FIELDCAT-OUTPUTLEN = 20. APPEND LS_FIELDCAT. CLEAR LS_FIELDCAT. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' * I_CALLBACK_PROGRAM = ' ' * I_CALLBACK_PF_STATUS_SET = ' '

* I_CALLBACK_USER_COMMAND = 'SELECT' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * I_STRUCTURE_NAME = * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = * IS_LAYOUT = IT_FIELDCAT = LS_FIELDCAT[] * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' * I_SAVE = ' ' * IS_VARIANT = * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * I_HTML_HEIGHT_TOP = 0 * I_HTML_HEIGHT_END = 0 * IT_ALV_GRAPHICS = * IT_HYPERLINK = * IT_ADD_FIELDCAT = * IT_EXCEPT_QINFO = * IR_SALV_FULLSCREEN_ADAPTER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = lt_mara * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.

Procedure

Coltext : Determines the column header of the column. You should assign a value to this field if it does not have a Data Dictionary reference. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'FULLTIMEEMPLOYEE'. <fs_fieldcat>-coltext = 'Fulltime'. ENDCASE. ENDLOOP. This will make the description of field FULLTIMEEMPLOYEE will appear as Fulltime in output. Checkbox: Making the particular field appear as checkbox in output if set. The checkbox cannot be modified by the user. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'FULLTIMEEMPLOYEE'. <fs_fieldcat>-checkbox = 'X'. ENDCASE. ENDLOOP. Edit: Making the particular field as editable if set. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'FULLTIMEEMPLOYEE'. <fs_fieldcat>-edit = 'X'. ENDCASE. ENDLOOP. Outputlen: Changing the particular field output length. Determines the column width of the field: ? If the field has a reference to the Data Dictionary, you can leave the field set to its initial value. In this case, the ALV adopts the output length of the relevant domain. ? For fields without reference to the DDIC, you must specify the desired field output length. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'FULLTIMEEMPLOYEE'. <fs_fieldcat>-outputlen = '8'. ENDCASE. ENDLOOP. Key: Making a field as key field if set or non-key field if not set. If this field is set, the ALV Grid Control color-codes the column as a key field and fixes this column during horizontal scrolling. The order of the key columns in the ALV Grid Control can be modified interactively. In contrast to the SAP List Viewer, the ALV Grid Control allows you to directly hide key columns with NO_OUT. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'ENO'. <fs_fieldcat>-key = ' '. ENDCASE. ENDLOOP. No_out: If you set this field, you hide the relevant column in the list. Nevertheless, the column is available in the field selection and can be interactively selected by the user as a display field. The ALV displays the contents of hidden fields on the detail screen for a row in the grid control.LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'AGE'. <fs_fieldcat>-no_out = 'X'.

ENDCASE. ENDLOOP. In change layout, the user can select the column and then make the field to appear in output. Just: Relevant only to fields of data type CHAR or NUMC. Justifications: ? 'R': right justified ? 'L': left justified ? 'C': centered How the column header is justified, depends on how the column contents are justified. You cannot justify the column header separately. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'AGE'. <fs_fieldcat>-just = 'R'. ENDCASE. ENDLOOP. Now in the output, Age field will come as Right-Justified. Tech: If this field is set, the relevant field is not displayed on the list and cannot be shown interactively. The field is only known in the field catalog. (For example, it must not be specified as a sorting criterion). LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'GENDER'. <fs_fieldcat>-tech = 'X'. ENDCASE. ENDLOOP. If tech is set for a field, the user cannot even select the field in change layout. Emphasize: If the field is set to 'X', the ALV uses a pre-defined color for highlighting the column. If it is set to 'Cxyz' (color code), the remaining numbers have the following meaning: ? x: color number ? y: intensified display on/off ? z: inverse display on/off LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'SALARY'. <fs_fieldcat>-emphasize = 'C411'. ENDCASE. ENDLOOP. Do_sum: If this field is set, the ALV uses this field to calculate the total (this corresponds to the generic totals function in the toolbar.) LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'SALARY'. <fs_fieldcat>-do_sum = 'X'. ENDCASE. ENDLOOP. Tooltip: Determines the text to be used as the tool tip for the column. You should assign a value to this field if it does not have a Data Dictionary reference. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'ENAME'. <fs_fieldcat>-TOOLTIP = 'Emp. Name'. ENDCASE.

ENDLOOP. Eventhough tooltip will appear other fields from field label/Coltext, if tooltip is set, it will override the other values. The database table structure is as follows.

Complete Code
Screen 9000, GUI Status ZSTATUS and GUI Title ZTITLE should be created and in Flow logic of the screen, PBO and PAI should be uncommented. REPORT zzz_jaytest message-id zz. * Data declarations DATA : itab TYPE STANDARD TABLE OF zzztable,"Output table i_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,"Field catalog wa TYPE zzztable, w_variant TYPE disvariant, o_docking TYPE REF TO cl_gui_docking_container,"Docking Container o_grid TYPE REF TO cl_gui_alv_grid."Grid FIELD-SYMBOLS : <fs_fieldcat> TYPE lvc_s_fcat. SELECT * FROM zzztable INTO TABLE itab. CALL SCREEN 9000. *&---------------------------------------------------------------------* *& Module STATUS_9000 OUTPUT *&---------------------------------------------------------------------* * PBO *----------------------------------------------------------------------* MODULE status_9000 OUTPUT. IF o_docking IS INITIAL. SET PF-STATUS 'ZSTATUS'. "GUI Status SET TITLEBAR 'ZTITLE'. "Title * Creating Docking Container and grid PERFORM create_object. * Filling the fieldcatalog table PERFORM create_fieldcat. * Modifying the fieldcatalog table PERFORM modify_fieldcat. * Displaying the output PERFORM display_output. ENDIF. ENDMODULE. " STATUS_9000 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_9000 INPUT

*&---------------------------------------------------------------------* * PAI *----------------------------------------------------------------------* MODULE user_command_9000 INPUT. DATA lv_ucomm TYPE sy-ucomm. lv_ucomm = sy-ucomm. CASE lv_ucomm. WHEN 'CANCEl' OR 'EXIT'. PERFORM free_objects. LEAVE PROGRAM. WHEN 'BACK'. PERFORM free_objects. SET SCREEN '0'. LEAVE SCREEN. ENDCASE. ENDMODULE. " USER_COMMAND_9000 INPUT *&---------------------------------------------------------------------* *& Form create_object *&---------------------------------------------------------------------* * Creating Docking Container and grid *----------------------------------------------------------------------* FORM create_object . * Creating Docking Container CREATE OBJECT o_docking EXPORTING ratio = '95'. IF sy-subrc EQ 0. * Creating Grid CREATE OBJECT o_grid EXPORTING i_parent = o_docking. ENDIF. ENDFORM. " create_object *&---------------------------------------------------------------------* *& Form create_fieldcat *&---------------------------------------------------------------------* * Filling the fieldcatalog table *----------------------------------------------------------------------* FORM create_fieldcat . * Filling the fieldcatalog table CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'ZZZTABLE' CHANGING ct_fieldcat = i_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error =2 OTHERS = 3. ENDFORM. " create_fieldcat

*&---------------------------------------------------------------------* *& Form modify_fieldcat *&---------------------------------------------------------------------* * Making the column as ediable *----------------------------------------------------------------------* FORM modify_fieldcat . LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. when 'FULLTIMEEMPLOYEE'. <fs_fieldcat>-checkbox = 'X'. <fs_fieldcat>-coltext = 'Fulltime'. <fs_fieldcat>-edit = 'X'. <fs_fieldcat>-outputlen = '8'. when 'ENO'. <fs_fieldcat>-key = ' '. <fs_fieldcat>-coltext = 'Employee Number'. <fs_fieldcat>-edit = ' '. when 'AGE'. <fs_fieldcat>-no_out = 'X'. <fs_fieldcat>-coltext = 'Age'. <fs_fieldcat>-edit = 'X'. <fs_fieldcat>-just = 'R'. when 'GENDER'. <fs_fieldcat>-coltext = 'Gender'. <fs_fieldcat>-outputlen = '6'. <fs_fieldcat>-tech = 'X'. when 'SALARY'. <fs_fieldcat>-emphasize = 'C411'. <fs_fieldcat>-do_sum = 'X'. <fs_fieldcat>-coltext = 'Salary'. <fs_fieldcat>-edit = 'X'. when 'ENAME'. <fs_fieldcat>-coltext = 'Employee Name'. <fs_fieldcat>-edit = 'X'. <fs_fieldcat>-TOOLTIP = 'Emp. Name'. ENDCASE. ENDLOOP. ENDFORM. " modify_fieldcat *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form display_output *&---------------------------------------------------------------------* * Displaying the output *----------------------------------------------------------------------* FORM display_output . w_variant-report = sy-repid. * Displaying the output CALL METHOD o_grid->set_table_for_first_display EXPORTING is_variant = w_variant

i_save CHANGING

=''

it_outtab = itab it_fieldcatalog = i_fieldcat EXCEPTIONS invalid_parameter_combination = 1 program_error too_many_lines OTHERS IF sy-subrc <> 0. =2 =3 = 4.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. " display_output *&---------------------------------------------------------------------* *& Form free_objects *&---------------------------------------------------------------------* * Free Objects *----------------------------------------------------------------------* FORM free_objects . CALL METHOD o_grid->free EXCEPTIONS cntl_error =1 cntl_system_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. CALL METHOD o_docking->free EXCEPTIONS cntl_error =1 cntl_system_error = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDFORM. " free_objects

Output

Coltext makes the header of the output as described. Edit makes the employee no. to be non-editable whereas other fields are editable.

No_out makes the field AGE not appearing in layout. Whereas the user can select that field from change layout. Tech makes the field Gender not appearing in layout. The user cannot even select that field from change layout.

Outputlen extending the column length in output as mentioned. Do_sum calculates the total of salary as 188,000.00. Emphasize colors the Salary field. Checkbox makes the field Fulltime appear as Checkbox. Just = 'R' does the right Justification of field Age. Tooltip makes the Emp. Name to appear as tool tip for Employee Name. Key = ' ' makes the Employee no. field to appear as non-key column. Because of this, we cannot the see the default blue color for Key field. report radiobutton_alv_OOPS. class cl_alv definition deferred. type-pools: abap, icon. data: event_receiver type ref to cl_alv. data: v_okcode type sy-ucomm, alvgrid type ref to cl_gui_alv_grid, ccont type ref to cl_gui_custom_container, it_fcat type lvc_t_fcat , wa_fcat like line of it_fcat, wa_lout type lvc_s_layo , cont type scrfname value 'ZCUST'.

types: begin of ty_bsik, BUKRS type bsik-bukrs, LIFNR type bsik-lifnr, GJAHR type bsik-gjahr, BELNR type bsik-belnr, BUZEI type bsik-buzei, BUDAT type bsik-budat, BLDAT type bsik-bldat, XBLNR type bsik-xblnr, WRBTR type bsik-wrbtr, SGTXT type bsik-sgtxt, end of ty_bsik.

types: begin of ty_bkpf, BUKRS like bkpf-BUKRS, BELNR like bkpf-BELNR, GJAHR like bkpf-GJAHR, BLART like bkpf-BLART, BLDAT like bkpf-BLDAT, BUDAT like bkpf-BUDAT, XBLNR like bkpf-XBLNR, end of ty_bkpf. types: begin of ty_bseg, BUKRS TYPE BSEG-BUKRS, BELNR TYPE BSEG-BELNR, GJAHR TYPE BSEG-GJAHR, BUZEI TYPE BSEG-BUZEI, WRBTR TYPE BSEG-WRBTR, SGTXT TYPE BSEG-SGTXT, end of ty_BSEG. types: begin of ty_final, check type c, BUKRS like bkpf-BUKRS, BELNR like bkpf-BELNR, GJAHR like bkpf-GJAHR, BLART like bkpf-BLART, BLDAT like bkpf-BLDAT, BUDAT like bkpf-BUDAT, XBLNR like bkpf-XBLNR, BUZEI TYPE BSEG-BUZEI, radio1(4), radio2(4), WRBTR TYPE BSEG-WRBTR, WRBTR1 TYPE BSEG-WRBTR, SGTXT TYPE BSEG-SGTXT, handle_style type lvc_t_styl, end of ty_final. data: it_bsik type table of ty_bsik, it_bkpf type table of ty_bkpf, it_bseg type table of ty_bseg, it_final type table of ty_final, wa_bsik like line of it_bsik, wa_bkpf like line of it_bkpf, wa_besge like line of it_bkpf, wa_final like line of it_final. data: v_col type sy-index. data: v_lines type i, "Radio button

lt_selected_rows type LVC_T_ROW.

TABLES: BKPF, BSEG, BSIK. INCLUDE <icons>. selection-screen begin of block b1 with frame title text-001. SELECT-OPTIONS:s_lifnr for bseg-lifnr, S_BUKRS FOR BKPF-BUKRS. selection-screen end of block b1. selection-screen begin of block b2 with frame title text-002. parameters : p_date type sy-datum. selection-screen end of block b2. selection-screen begin of block b3 with frame title text-003. parameters : p_check1 as checkbox, p_check2 as checkbox, p_check3 as checkbox, p_check4 as checkbox, p_check5 as checkbox. selection-screen end of block b3. start-of-selection. call screen 101. *----------------------------------------------------------------------* * * *----------------------------------------------------------------------* class cl_alv definition. public section. methods: handle_double_click for event double_click of cl_gui_alv_grid importing e_row e_column, handle_hotspot_click for event hotspot_click of cl_gui_alv_grid importing e_row_id e_column_id es_row_no sender. endclass. "cl_alv DEFINITION CLASS cl_alv DEFINITION *----------------------------------------------------------------------*

*----------------------------------------------------------------------* * CLASS cl_alv IMPLEMENTATION *----------------------------------------------------------------------*

* *----------------------------------------------------------------------* class cl_alv implementation. method: handle_double_click. CALL METHOD ALVGRID->GET_SELECTED_ROWS IMPORTING ET_INDEX_ROWS = lt_selected_rows. endmethod. "handle_double_click

method: handle_hotspot_click. * define local data FIELD-SYMBOLS: <ls_entry> TYPE ty_final, <ld_fld> TYPE ANY. READ TABLE it_final ASSIGNING <ls_entry> INDEX es_row_no-row_id. CHECK ( <ls_entry> IS ASSIGNED ). * Set all radio buttons "unselected" <ls_entry>-radio1 = icon_wd_radio_button_empty. <ls_entry>-radio2 = icon_wd_radio_button_empty. ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry> TO <ld_fld>. IF ( <ld_fld> IS ASSIGNED ). * Set selected radio button "selected". <ld_fld> = icon_radiobutton. ENDIF. * Force PAI followed by refresh of table display in PBO CALL METHOD cl_gui_cfw=>set_new_ok_code EXPORTING new_code = 'REFRESH'. * IMPORTING * RC = CALL METHOD alvgrid->refresh_table_display. endmethod. endclass. *& * "handle_hotspot_click "cl_alv IMPLEMENTATION

*&---------------------------------------------------------------------* Module DISPLAY_ALV OUTPUT text *&---------------------------------------------------------------------* *----------------------------------------------------------------------* MODULE DISPLAY_ALV OUTPUT. if ccont is initial. select BUKRS LIFNR GJAHR BELNR

BUZEI BUDAT BLDAT XBLNR WRBTR SGTXT from bsik into table it_bsik where bukrs in s_bukrs and lifnr in s_lifnr. select BUKRS BELNR GJAHR BLART BLDAT BUDAT XBLNR FROM BKPF INTO TABLE IT_BKPF for all entries in it_bsik WHERE BUKRS = it_bsik-bukrs and belnr = it_bsik-belnr and gjahr = it_bsik-gjahr and bldat = it_bsik-bldat and budat = it_bsik-budat and xblnr = it_bsik-xblnr. loop at it_bsik into wa_bsik. wa_final-buzei = wa_bsik-buzei. wa_final-sgtxt = wa_bsik-sgtxt. wa_final-wrbtr = wa_bsik-wrbtr. read table it_bkpf into wa_bkpf with key bukrs = wa_bsik-bukrs belnr = wa_bsik-belnr gjahr = wa_bsik-gjahr. if sy-subrc = 0. wa_final-bukrs = wa_bkpf-bukrs. wa_final-belnr = wa_bkpf-belnr. wa_final-blart = wa_bkpf-blart. wa_final-bldat = wa_bkpf-bldat. wa_final-budat = wa_bkpf-budat. wa_final-XBLNR = wa_bkpf-XBLNR. endif. wa_final-radio1 = icon_radiobutton. "Empty Radio Buttons wa_final-radio2 = icon_wd_radio_button_empty.. append wa_final to it_final. clear wa_final. endloop.

********************************************************** CREATE OBJECT CCONT EXPORTING CONTAINER_NAME REPID DYNNR EXCEPTIONS CNTL_ERROR CNTL_SYSTEM_ERROR CREATE_ERROR LIFETIME_ERROR others = 6. =3 =4 =1 =2 = cont = sy-repid = sy-dynnr

LIFETIME_DYNPRO_DYNPRO_LINK = 5

CREATE OBJECT ALVGRID EXPORTING I_PARENT EXCEPTIONS ERROR_CNTL_CREATE = 1 ERROR_CNTL_INIT = 2 ERROR_CNTL_LINK = 3 ERROR_DP_CREATE = 4 others = 5. '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . = ccont

perform fieldcat using 'CHECK' 'Check' perform fieldcat using 'BUKRS' 'Comp Code' perform fieldcat using 'BELNR' 'Accnt Doc No' perform fieldcat using 'BLART' 'Doc Type' perform fieldcat using 'BLDAT' 'Document Date' perform fieldcat using 'BUDAT' 'Posting Date' perform fieldcat using 'XBLNR' 'Ref. Doc NO' perform fieldcat using 'BUZEI' 'Item' perform fieldcat using 'SGTXT' 'Item Text' perform fieldcat using 'RADIO1' 'Full Amount' perform fieldcat using 'RADIO2' 'Partial Amount' perform fieldcat using 'WRBTR' 'Full Amount' perform fieldcat using 'WRBTR1' 'Partial Amount' wa_lout-SEL_MODE = 'A'. wa_lout-cwidth_opt = 'X'. wa_lout-zebra = 'X'. wa_lout-stylefname = 'HANDLE_STYLE'.

CALL METHOD ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING IS_LAYOUT CHANGING IT_OUTTAB IT_FIELDCATALOG EXCEPTIONS = it_final = it_fcat = wa_lout

INVALID_PARAMETER_COMBINATION = 1 PROGRAM_ERROR TOO_MANY_LINES others = 4. =2 =3

create object event_receiver. set handler event_receiver->handle_double_click for alvgrid. set handler event_receiver->handle_hotspot_click for alvgrid. else. CALL METHOD alvgrid->check_changed_data. call method alvgrid->refresh_table_display. endif. call method cl_gui_control=>set_focus EXPORTING control = alvgrid. ENDMODULE. *& * * * * Form FIELDCAT text -->P_0627 text -->P_0628 text -->P_0629 text VALUE(P_0627) " DISPLAY_ALV OUTPUT

*&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *----------------------------------------------------------------------*

*----------------------------------------------------------------------* FORM FIELDCAT USING VALUE(P_0628) VALUE(P_0629). v_col = v_col + 1. wa_fcat-fieldname wa_fcat-no_out wa_fcat-col_pos = p_0627. = p_0629. = v_col.

wa_fcat-reptext = p_0628.

wa_fcat-tabname = 'IT_FINAL'. if wa_fcat-fieldname = 'CHECK'. wa_fcat-checkbox = 'X'. wa_fcat-edit = 'X'. elseif wa_fcat-fieldname = 'RADIO1'. wa_fcat-tabname = 'IT_FINAL'. wa_fcat-seltext = 'Full Payment'. wa_fcat-outputlen = 6. wa_fcat-icon = 'X'. wa_fcat-hotspot = 'X'. "Icons "Interactive Handling

elseif wa_fcat-fieldname = 'RADIO2'.

wa_fcat-fieldname = 'RADIO2'. wa_fcat-seltext = 'Partial Payment'. wa_fcat-outputlen = 6. wa_fcat-icon = 'X'. wa_fcat-hotspot = 'X'. endif. append wa_fcat to it_fcat. clear wa_fcat. ENDFORM. *& * " FIELDCAT "Icons "Interactive Handling

*&---------------------------------------------------------------------* Module STATUS_0101 OUTPUT text *&---------------------------------------------------------------------* *----------------------------------------------------------------------* MODULE STATUS_0101 OUTPUT. SET PF-STATUS 'BBB'. * SET TITLEBAR 'xxx'. ENDMODULE. *& * " STATUS_0101 OUTPUT

*&---------------------------------------------------------------------* Module USER_COMMAND_0101 INPUT text *&---------------------------------------------------------------------* *----------------------------------------------------------------------* MODULE USER_COMMAND_0101 INPUT. case: sy-ucomm. when 'BACK' or 'CANCEL' or 'EXIT'. leave to screen 0. when '&IC1'. CALL METHOD alvgrid->check_changed_data. when 'REFRESH'. data: ls_edit type lvc_s_styl, lt_edit type lvc_t_styl, ls_field type lvc_fname, l_index type i. data: it_cells it_column wa_cells v_index type LVC_T_CELL, type LVC_T_COL, like line of it_cells, type sy-index.

it_selected_col type LVC_T_CENO,

CALL METHOD ALVGRID->GET_SELECTED_CELLS IMPORTING ET_CELL = it_cells.

CALL METHOD ALVGRID->GET_SELECTED_COLUMNS IMPORTING ET_INDEX_COLUMNS = it_column. CALL METHOD ALVGRID->GET_SELECTED_CELLS_ID IMPORTING ET_CELLS = it_selected_col. read table it_cells into wa_cells index 1. if sy-subrc = 0. v_index = wa_cells-row_id. endif. CALL METHOD alvgrid->check_changed_data. loop at IT_final into wa_final. l_index = sy-tabix. ls_edit-fieldname = 'WRBTR1'. if wa_final-radio1 = ' (R6)'. ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED. clear : wa_final-wrbtr1. elseif wa_final-radio1 = ' (SR)'. ls_edit-style = cl_gui_alv_grid=>MC_STYLE_ENABLED. endif. ls_edit-style2 ls_edit-style3 ls_edit-style4 ls_edit-maxlen = space. = space. = space. = 20.

insert ls_edit into table lt_edit. refresh: wa_final-handle_style. append lines of lt_edit to wa_final-handle_style. modify IT_final index l_index from wa_final. refresh: lt_edit,WA_FINAL-HANDLE_STYLE. clear :wa_final,ls_edit. endloop. * define local data DATA: ls_stable TYPE lvc_s_stbl. ls_stable-row = abap_true. ls_stable-col = abap_true. CALL METHOD alvgrid->refresh_table_display * * EXPORTING is_stable = ls_stable EXCEPTIONS finished = 1 OTHERS = 2.

When 'PRINT'. data: it_data type table of ZPAY_VOUCHER with header line. CALL METHOD alvgrid->check_changed_data. * --Process the selected check box data from the internal table loop at it_final into wa_final where check = 'X'.. it_data-bldat = wa_final-BLDAT. it_data-xblnr = wa_final-XBLNR.. it_data-buzei = wa_final-BUZEI. it_data-sgtxt = wa_final-SGTXT. if wa_final-WRBTR1 is not initial. it_data-wrbtr = wa_final-WRBTR1. else. it_data-wrbtr = wa_final-WRBTR. endif. append it_data. clear it_data. endloop. endcase. ENDMODULE. " USER_COMMAND_0101 INPUT

Anda mungkin juga menyukai