ALV Editable

March 18, 2018 | Author: Abbu Sandeep | Category: Computing, Technology, Software, Computer Data, Areas Of Computer Science


Comments



Description

Hi, Guest   Log On  Join Us  Getting Started  Newsletters  Store Search for:  Products  Services & Support  About SCN  Downloads  Industries  Training & Education  Partnership  Developer Center  Lines of Business  University Alliances  Events & Webinars  Innovation  Activity  Communications  Actions  BrowseMore More discussions in ABAP DevelopmentWhere is this place located? 11 Replies Latest reply: 08-Jul-2013 15:59 by Viswanathan s inShare Editting a cell in ALV Grid Control This question is Assumed Answered. T Aswani Kalyan 21-Jun-2005 12:03 Hello, Can anybody please tell me how to make a cell "EDITABLE" in alv grid control. When i use the EDIT option of field catalog, complete column gets editable. But I want only one column to get editable. Regards Kalyan  15325 Views  Topics: abap Average User Rating (0 ratings)  Re: Editting a cell in ALV Grid Control Guest 21-Jun-2005 12:14 (in response to T Aswani Kalyan) Hi kalyan, ls_fcat-scrtext_s = 'CURRENCY'. Regards.When u want to do edit only for particular column and not for the entire grid then you need to perform fieldcat in that particular column only. loop at pt_fieldcat into ls_fcat.</b> modify pt_fieldcat from ls_fcat. if ls_fcat-fieldname EQ 'Curr'. Ls_fcat-seltext = 'CURRENCY'. endloop. ls_fcat-scrtext_m = 'CURRENCY'. data ls_fcat type lvc_s_fcat. endif. . <b>ls_fcat-edit = 'X'. ls_fcat-reptext = 'CURRENCY'. ls_fcat-scrtext_l = 'CURRENCY'. in this way you can give editable option to that particular column only. for example form build_fieldcat changing pt_fieldcat type lvc_t_fcat. don't set the edit property for the field. . 2. Regards Kalyan  Alert Moderator  Like (0)  Re: Editting a cell in ALV Grid Control Sandeep Jha 21-Jun-2005 12:36 (in response to T Aswani Kalyan) This is taken from a reference doc which was here on SDN few months back. 1. In the fieldcatalogue .venu. add a table to your list data table. o Like (0) o Re: Editting a cell in ALV Grid Control T Aswani Kalyan 21-Jun-2005 12:21 (in response to Guest ) Hello Venu. But as I specified earlier. I want to make a single cell editable not the complete column editable. Thanks for you answer. ls_style-style = cl_gui_alv_grid=>mc_style_enabled. data end of gt_grid. . append ls_style to lt_style. endif. data: ls_grid like line of pt_grid. lt_style type lvc_t_styl.data begin of gt_grid occurs 0. data cellstyles type lvc_t_styl. . loop at pt_grid into ls_grid. modify pt_grid from ls_grid. form make_field_edit using pt_grid like gt_grid[]. . 'your condition for the row ls_style-fieldname = 'CURR'. 3.. ls_style type lvc_s_styl. Then now the logic . if ls_grid-curr = xyz. insert lines of lt_style into ls_grid-celltyles. (See BCALV_EDIT_01 for an overview  of possible states). *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&  Purpose:  ~~~~~~~~  This report illustrates how to set chosen cells of an  ALV Grid Control editable. here is the right example for your requirement. PROGRAM BCALV_EDIT_02. see BCALV_EDIT_03.endloop.  Remark: You may set the states for chosen columns using field  *---- EDIT of the fieldcatalog. . endform.   Alert Moderator  Like (0) Re: Editting a cell in ALV Grid Control Guest 29-Feb-2012 08:49 (in response to T Aswani Kalyan) hi kalyan. -  To check program behavior  ~~~~~~~~~~~~~~~~~~~~~~~~~  Switch to the state editable activated. set edit status for each row in a loop according to field SEATSMAX.  2c.       2. e.g. that holds  information about the edit status of each cell for the  corresponding row (the table type is SORTED!).Copy your celltab to the celltab of the current row of gt_outtab.. 2a.After selecting data.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell to status "non-editable".Provide the fieldname of the celltab field by using field .Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell to status "editable". CELLTAB. 2b.  3. *----  Essential steps (search for '§')  ~~~~~~~~~~~~~~~  1.Extend your output table for a field. You may then change the  price of flights where the capacity of a plane is greater or equal  than 300 seats. DATA: BEGIN OF gt_outtab occurs 0.. e. *---- *  *---- MAIN * . g_max type i value 100. g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1'.g. that holds  information about the edit status of each cell for the  corresponding row (the table type is SORTED!).Extend your output table for a field. CELLTAB. save_ok like sy-ucomm. STYLEFNAME of the layout structure. grid1 TYPE REF TO cl_gui_alv_grid. *§1. g_custom_container TYPE REF TO cl_gui_custom_container. DATA: celltab type LVC_T_STYL. DATA: END OF gt_outtab. *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&& DATA: ok_code LIKE sy-ucomm. "with header line include structure sflight. gs_layout TYPE lvc_s_layo. IF g_custom_container IS INITIAL.Provide the fieldname of the celltab field by using field  STYLEFNAME of the layout structure. CREATE OBJECT grid1 EXPORTING i_parent = g_custom_container.* CALL SCREEN 100. *§3. *---- *  MODULE PBO OUTPUT *---- * MODULE pbo OUTPUT. gs_layout-stylefname = 'CELLTAB'. SET TITLEBAR 'MAIN100'. * . CREATE OBJECT g_custom_container EXPORTING container_name = g_container. SET PF-STATUS 'MAIN100'. PERFORM select_data_and_init_style. CASE save_ok. CALL METHOD grid1->set_table_for_first_display EXPORTING i_structure_name = 'SFLIGHT' is_layout = gs_layout CHANGING it_outtab = gt_outtab[]. ENDMODULE. ENDIF. *---- *  MODULE PAI INPUT *---- * MODULE pai INPUT. clear ok_code. set substate of editable cells to deactivated CALL METHOD grid1->set_ready_for_input EXPORTING i_ready_for_input = 0. WHEN 'EXIT'. save_ok = ok_code. * . PERFORM exit_program. WHEN 'SWITCH'. *---- * FORM EXIT_PROGRAM  *---- * FORM exit_program. LEAVE PROGRAM.PERFORM switch_edit_mode.  do nothing ENDCASE. *&---- * *& Form SELECT_DATA_AND_INIT_STYLE *&---- *  *---- text * . ENDMODULE. ENDFORM. WHEN OTHERS. DATA: lt_sflight TYPE TABLE OF sflight WITH HEADER LINE. . *§2. lt_celltab TYPE lvc_t_styl.p2 text *---- * FORM select_data_and_init_style. l_index TYPE i. LOOP AT gt_outtab.After selecting data. refresh lt_celltab. l_index = sy-tabix. SELECT * FROM sflight INTO TABLE lt_sflight UP TO g_max ROWS. ENDLOOP.  move corresponding fields from lt_sflight to gt_outtab LOOP AT lt_sflight. MOVE-CORRESPONDING lt_sflight TO gt_outtab. APPEND gt_outtab. if gt_outtab-seatsmax ge 300. set edit status for each row in a loop  according to field SEATSMAX.*  --> p1 text  <-. *§2c. ENDFORM. else. " SELECT_DATA_AND_INIT_STYLE *&---- * *& Form FILL_CELLTAB *&---- *  text *---- *  *---- <--P_PT_CELLTAB text . ENDLOOP.Copy your celltab to the celltab of the current row of gt_outtab. perform fill_celltab using 'RO' changing lt_celltab.perform fill_celltab using 'RW' changing lt_celltab. MODIFY gt_outtab INDEX l_index. endif. INSERT LINES OF lt_celltab INTO TABLE gt_outtab-celltab. l_mode = cl_gui_alv_grid=>mc_style_enabled.  This forms sets the style of column 'PRICE' editable  according to 'p_mode' and the rest to read only either way.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell  to status "editable". l_mode type raw4. ENDIF. "p_mode eq 'RO' *§2b.* FORM fill_celltab using value(p_mode) CHANGING pt_celltab TYPE lvc_t_styl. ls_celltab-fieldname = 'CONNID'. . INSERT ls_celltab INTO TABLE pt_celltab.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell  to status "non-editable". l_mode = cl_gui_alv_grid=>mc_style_disabled. DATA: ls_celltab TYPE lvc_s_styl. ls_celltab-fieldname = 'CARRID'. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. *§2a. ELSE. IF p_mode EQ 'RW'. INSERT ls_celltab INTO TABLE pt_celltab. ls_celltab-fieldname = 'SEATSOCC'. ENDFORM. INSERT ls_celltab INTO TABLE pt_celltab. INSERT ls_celltab INTO TABLE pt_celltab. *&---- " FILL_CELLTAB .ls_celltab-fieldname = 'FLDATE'. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. INSERT ls_celltab INTO TABLE pt_celltab. ls_celltab-fieldname = 'CURRENCY'. INSERT ls_celltab INTO TABLE pt_celltab. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. INSERT ls_celltab INTO TABLE pt_celltab. ls_celltab-fieldname = 'PRICE'. ls_celltab-style = l_mode. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. INSERT ls_celltab INTO TABLE pt_celltab. ls_celltab-fieldname = 'PLANETYPE'. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled. ls_celltab-fieldname = 'PAYMENTSUM'. ls_celltab-fieldname = 'SEATSMAX'. INSERT ls_celltab INTO TABLE pt_celltab. . ELSE. IF grid1->is_ready_for_input( ) eq 0.p2 text *---- * FORM switch_edit_mode.  lock edit enabled cells against input CALL METHOD grid1->set_ready_for_input EXPORTING i_ready_for_input = 0.* *& Form SWITCH_EDIT_MODE *&---- *  text *---- *  --> p1 text  <-.  set edit enabled cells ready for input CALL METHOD grid1->set_ready_for_input EXPORTING i_ready_for_input = 1. sdn.com/irj/se rvlet/prt/portal/prtroot/com. " SWITCH_EDIT_MODE You can make use of the tutorial <a href="https://www.sdn.sap.com:443http://www.com/i rj/servlet/prt/portal/prtroot/com.cm. it is just only apply 1 style for a cell. On the example show by the others here before. like below: <b>ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.</b> .sap.comhttp://www.sap.sap.sdn.sdn.comhttp://www.km.sap. ENDFORM.sap.pdf">"An Easy eference for ALV Grid Control"</a>.sdn.sdn.sap.ENDIF. Regards *--Serdar <a href="https://www.docs/documents/a1-8-4/an%20easy %20reference%20for%20alv%20grid%20control.sap.sdnbusinesscard?u=qbk %2bsag%2bjiw%3d">[ BC ]</a>  o Alert Moderator o Like (0) Re: Editting a cell in ALV Grid Control FS CHU 28-Jul-2006 04:21 (in response to T Aswani Kalyan) Hi Guys.comhttp://www.businesscard.sdn. .But im having a requirement to have more than 1 style need to apply to a cell.. thank you all.. and I don't wanna to change all the program to use control. But now the user want to change this.. The author put the all the collum editable (using fieldcat) and if the value can be change. i need to apply the hotspot for the same cell in addition.. For my case.. Thanks in advance.  o Alert Moderator o Like (0) Re: Editting a cell in ALV Grid Control André Fogagnoli 07-Dec-2007 16:38 (in response to T Aswani Kalyan) Can I use this in ALV Function (REUSE_ALV_GRID_DISPLAY)?? I have a program that was done a long time ago for another person. he show a message.. Meaning system will only recognize value from ls_celltab-style but <b>NOT</b> for ls_celltab-style2/style3/style4 Pls comment if i missed out any steps. o Alert Moderator o Like (0) . and only enable to edit what can be edited. But system will <b>NOT</b> have any effects on the value assigned in ls_celltabstyle<b>2</b>. where i put in the code like this: ls_celltab-style<b>2</b> = cl_gui_alv_grid=>mc_style_hotspot. statu TYPE ekpo-statu. peinh TYPE ekpo-peinh. TYPE-POOLS: slis. In this am doing coloring the filed and edit the field. Re: Editting a cell in ALV Grid Control Vijayaraghavan Narayanan 05-Jul-2013 17:10 (in response to T Aswani Kalyan) Hi Priya. matnr TYPE ekpo-matnr. ebeln TYPE ekpo-ebeln. menge TYPE ekpo-menge. TABLES: ekko. "ALV Declarations *Data Declaration *---------------TYPES: BEGIN OF t_ekko. "Used to store row color attributes . meins TYPE ekpo-meins. line_color(4) TYPE c. ebelp TYPE ekpo-ebelp. aedat TYPE ekpo-aedat. netpr TYPE ekpo-netpr.without header line. END OF t_ekko. DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0. gd_layout TYPE slis_layout_alv. START-OF-SELECTION. *ALV data declarations DATA: fieldcatalog TYPE LINE OF slis_t_fieldcat_alv. PERFORM build_layout. wa_ekko TYPE t_ekko. PERFORM build_fieldcatalog . ************************************************************************ *Start-of-selection."CHANGING fieldcatalog. *&---------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG *&---------------------------------------------------------------------* . gd_repid LIKE sy-repid. PERFORM display_alv_report. t_fieldcatalog TYPE slis_t_fieldcat_alv. gd_tab_group TYPE slis_t_sp_group_alv. PERFORM data_retrieval. "CHANGING fieldcatalog TYPE slis_t_fieldcat_alv. gd_layout-totals_text = 'Totals'(201). ENDLOOP. . MODIFY t_fieldcatalog FROM fieldcatalog. gd_layout-colwidth_optimize = 'X'. gd_layout-no_input = 'X'. ENDFORM. fieldcatalog-edit = 'X'. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name * = sy-repid I_INTERNAL_TABNAME i_structure_name = = 'ZALV_VIJAY' * I_CLIENT_NEVER_DISPLAY * I_INCLNAME * I_BYPASSING_BUFFER * I_BUFFER_ACTIVE = 'X' = = = CHANGING ct_fieldcat = t_fieldcatalog LOOP AT t_fieldcatalog INTO fieldcatalog WHERE fieldname = 'EBELN'. FORM build_layout.* Build Fieldcatalog for ALV Report *----------------------------------------------------------------------* FORM build_fieldcatalog . gd_repid = sy-repid. ENDFORM. .e. FORM data_retrieval. FORM display_alv_report. IF sy-subrc <> 0.* Set layout field for row attributes(i. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program is_layout = gd_repid = gd_layout it_fieldcat = t_fieldcatalog i_save = 'X' TABLES t_outtab = it_ekko EXCEPTIONS program_error OTHERS =1 = 2. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. color) gd_layout-info_fieldname = 'LINE_COLOR'. ENDFORM. IF ld_color = 8. LOOP AT it_ekko INTO wa_ekko. ld_color = ld_color + 1. ENDIF. * wa_ekko-line_color = 'C410'.DATA: ld_color(1) TYPE c. CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color. ld_color = 1. . SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh UP TO 10 ROWS FROM ekpo INTO TABLE it_ekko. MODIFY it_ekko FROM wa_ekko. ENDLOOP. ENDFORM. by using the following code we can edit single row.(By using the condition iam editing single row) . IF wa_makt-indcat NE 'H'. *&---------------------------------------------------------------------* *& Form set_specific_field_attributes *&---------------------------------------------------------------------* * populate FIELD_STYLE table with s pecific field attributes *----------------------------------------------------------------------* FORM set_specific_field_attributes.  o Alert Moderator o Like (0) Re: Editting a cell in ALV Grid Control sivajyothi yellamelli 08-Jul-2013 13:40 (in response to T Aswani Kalyan) Hai priya. o Alert Moderator o Like (0) Re: Editting a cell in ALV Grid Control Clemens Li 05-Jul-2013 14:05 (in response to T Aswani Kalyan) ask google. I also faced the same Pbm. LOOP AT it_makt INTO wa_makt. PERFORM field_attributes USING 'ERDAT' 'X'. PERFORM field_attributes USING 'DISPR' 'X'. PERFORM field_attributes USING 'STPRS' 'X'. PERFORM field_attributes USING 'MSEHI' 'X'. PERFORM field_attributes USING 'RAUBE' 'X'. PERFORM field_attributes USING 'ZMRDAT' 'X'. PERFORM field_attributes USING 'MVGR2' 'X'. PERFORM field_attributes USING 'SPART' 'X'. PERFORM field_attributes USING 'PRFRQ' 'X'. PERFORM field_attributes USING 'EKGRP' 'X'. PERFORM field_attributes USING 'MATNR' 'X'.PERFORM field_attributes USING 'INDCAT' 'X'. PERFORM field_attributes USING 'EMPID' 'X'. PERFORM field_attributes USING 'VPRSV' 'X'. PERFORM field_attributes USING 'PRCTR' 'X'. PERFORM field_attributes USING 'VKORG' 'X'. PERFORM field_attributes USING 'LGORT' 'X'. PERFORM field_attributes USING 'EXTWG' 'X'. PERFORM field_attributes USING 'BEHVO' 'X'. PERFORM field_attributes USING 'MINO' 'X'. PERFORM field_attributes USING 'MATKL' 'X'. PERFORM field_attributes USING 'VTWEG' 'X'. PERFORM field_attributes USING 'ERNAM' 'X'. PERFORM field_attributes USING 'VERPR' 'X'. . PERFORM field_attributes USING 'BKLAS' 'X'. PERFORM field_attributes USING 'MTART' 'X'. PERFORM field_attributes USING 'KZECH' 'X'. PERFORM field_attributes USING 'LGPBE' 'X'. ENDFORM. PERFORM field_attributes USING 'ZMCDAT' 'X'. ENDLOOP. INSERT ls_stylerow INTO TABLE wa_makt-field_style. o Alert Moderator . CLEAR: ls_stylerow. ls_stylerow-fieldname = p_field. * ******* ENDFORM. DATA lt_styletab TYPE lvc_t_styl.PERFORM field_attributes USING 'WERKS' 'X'. PERFORM field_attributes USING 'LONGTX' 'X'. ENDIF. PERFORM field_attributes USING 'MAKTX' 'X'. DATA ls_stylerow TYPE lvc_s_styl. ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled. MODIFY it_makt FROM wa_makt. " DISPLAY_ALV *&---------------------------------------------------------------------* *& Form FIELD_ATTRIBUTES *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_0952 text * -->P_0953 text *----------------------------------------------------------------------* FORM field_attributes USING p_field p_name. gs_fieldcat-edit = 'X'. i1 = i1 + 1. my code assign three filed catlog in 2 filed is editable filed: i1 = i1 + 1. when build a field catlog assign "X" to particular one column gs_fieldcat-input = 'X'. PERFORM fieldcat USING i1 'GT_SMY_ALV' 'PROJECT' text-008 '30' '' '' 'X' 'X' '' '' '' ''. Am using Form and perform easy to assign a filedcatlog . PERFORM fieldcat USING i1 'GT_SMY_ALV' 'PROJECT_MANAGER' text-009 '30' '' '' '' '' '' '' '' ''. i1 = i1 + 1.o  Like (0) Re: Editting a cell in ALV Grid Control Viswanathan s 08-Jul-2013 15:59 (in response to T Aswani Kalyan) Hi priya. PERFORM fieldcat USING i1 'GT_SMY_ALV' 'DEVELOPED_BY' text-006 '25' '' '' '' '' '' '' '' ''. FORM fieldcat USING value(col_pos) value(tabname) value(fieldname) value(reptext) value(len) value(no_out) value(sum) value(nozero) value(edit) value(no_chk) value(dtype) value(tdropdown) value(tfieldname). gs_fieldcat-reptext_ddic = reptext. gs_fieldcat-input = nozero. gs_fieldcat-no_out = no_out. . gs_fieldcat-outputlen = len. gs_fieldcat-do_sum = sum. gs_fieldcat-tabname = tabname. gs_fieldcat-datatype = dtype. gs_fieldcat-col_pos = col_pos. gs_fieldcat-fieldname = fieldname. gs_fieldcat-edit = edit. gs_fieldcat-checkbox = no_chk. CLEAR gs_fieldcat. gs_fieldcat-ref_fieldname = tfieldname. APPEND gs_fieldcat TO gt_fieldcat. ENDFORM. .gs_fieldcat-ref_tabname = tdropdown.
Copyright © 2024 DOKUMEN.SITE Inc.