‎2008 Mar 04 1:46 PM
Hi,
I have an ALV in which I am inserting a new row.
once new row is inserted , a value is given in the first cell. once the value is filled , rest of cells in that row should be grayed out i.e user can not enter values in the rest of cells.
This is working fine.
But when I have inserted one more row , the previous row is now turning into editable.
Could you please suggest me.
Regards,
Satya
‎2008 Mar 05 6:53 AM
Hi
set a variable g_flag = 'X', at the time u r filling editable row
and put alogic to make that new row greyed as it was done earlier for other rows.
I think problem is :
when u add on button to insert new row
first time : all the records which are greyed coming from database table into internal table.
but second time: logic may be differernt, thats why it is not making previous added row greyed.
I hope u understand bit,
otherwise pls explain ur problem in detail.
Dont forget to rewards points.
‎2008 Apr 08 12:54 PM
hi,
try this code for one field editable or for reference pls open object navigator (se80 , and refer BCALV_EDIT_02 )based on one condition only those rows are in edit mode , rest of the rows are in disable mode, just copy and paste the code in se38 and run
REPORT ZEDIT_ONE_CELL_OOPS.
*Essential steps (search for '§')
~~~~~~~~~~~~~~~
1.Extend your output table for a field, e.g., CELLTAB, that holds
information about the edit status of each cell for the
corresponding row (the table type is SORTED!).
2.After selecting data, set edit status for each row in a loop
according to field SEATSMAX.
2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
to status "editable".
2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
to status "non-editable".
2c.Copy your celltab to the celltab of the current row of gt_outtab.
3.Provide the fieldname of the celltab field by using field
STYLEFNAME of the layout structure.
*for reference BCALV_EDIT_02
TABLES: VBAK.
TYPE-POOLS: ICON.
*&----
*
*& Declaration Section for the Internal Tables *
*&----
*
DATA: BEGIN OF GT_OUTTAB OCCURS 0.
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
erzet TYPE vbak-erzet,
ernam TYPE vbak-ernam,
netwr TYPE vbak-netwr,
INCLUDE STRUCTURE ZVBAK_INTERNAL1.
DATA: CELLTAB TYPE LVC_T_STYL.
DATA: END OF GT_OUTTAB.
DATA: IT_VBAK TYPE TABLE OF ZVBAK_INTERNAL1 WITH HEADER LINE.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'GRID_CONTROL',
GRID1 TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GS_LAYOUT TYPE LVC_S_LAYO,
I_FCAT TYPE LVC_T_FCAT,
W_FCAT TYPE LVC_S_FCAT.
CALL SCREEN 200.
*&----
*
*& Module STATUS_0200 OUTPUT
*&----
*
text
*----
*
MODULE STATUS_0200 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING
CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING
I_PARENT = G_CUSTOM_CONTAINER.
PERFORM SELECT_DATA_AND_INIT_STYLE.
*§3.Provide the fieldname of the celltab field by using field
STYLEFNAME of the layout structure.
GS_LAYOUT-STYLEFNAME = 'CELLTAB'.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZVBAK_INTERNAL1'
IS_LAYOUT = GS_LAYOUT
ls_fieldcat = it_fieldcatalog
CHANGING
IT_OUTTAB = GT_OUTTAB[]
IT_FIELDCATALOG = I_FCAT.
ENDIF.
ENDMODULE. " STATUS_0200 OUTPUT
*&----
*
*& Module USER_COMMAND_0200 INPUT
*&----
*
text
*----
*
MODULE USER_COMMAND_0200 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN 'SWITCH'.
PERFORM SWITCH_EDIT_MODE.
WHEN OTHERS.
do nothing
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*&----
*
*& Form exit_program
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM EXIT_PROGRAM .
LEAVE PROGRAM.
ENDFORM. " exit_program
*&----
*
*& Form select_data_and_init_style
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM SELECT_DATA_AND_INIT_STYLE.
DATA: LT_CELLTAB TYPE LVC_T_STYL,
L_INDEX TYPE I.
SELECT VBELN
ERDAT
ERZET
ERNAM
NETWR UP TO 100 ROWS
FROM VBAK
INTO TABLE IT_VBAK.
move corresponding fields from lt_sflight to gt_outtab
LOOP AT IT_VBAK.
MOVE-CORRESPONDING IT_VBAK TO GT_OUTTAB.
APPEND GT_OUTTAB.
ENDLOOP.
*§2.After selecting data, set edit status for each row in a loop
according to field NETWR.
LOOP AT GT_OUTTAB.
L_INDEX = SY-TABIX.
REFRESH LT_CELLTAB.
IF GT_OUTTAB-VBELN EQ '0000000080'.
PERFORM FILL_CELLTAB USING 'RW'
CHANGING LT_CELLTAB.
ELSE.
PERFORM FILL_CELLTAB USING 'RO'
CHANGING LT_CELLTAB.
ENDIF.
*§2c.Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF LT_CELLTAB INTO TABLE GT_OUTTAB-CELLTAB.
MODIFY GT_OUTTAB INDEX L_INDEX.
ENDLOOP.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = input
IMPORTING
output = output.
*
ENDFORM. " select_data_and_init_style
*END-OF-SELECTION.
*&----
*
*& Form fill_celltab
*&----
*
text
*----
*
-->P_0194 text
<--P_LT_CELLTAB text
*----
*
FORM FILL_CELLTAB USING VALUE(P_MODE)
CHANGING P_LT_CELLTAB TYPE LVC_T_STYL.
DATA: LS_CELLTAB TYPE LVC_S_STYL,
L_MODE TYPE RAW4.
This forms sets the style of column 'PRICE' editable
according to 'p_mode' and the rest to read only either way.
IF P_MODE EQ 'RW'.
*§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
to status "editable".
L_MODE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
ELSE. "p_mode eq 'RO'
*§2b.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.
ENDIF.
LS_CELLTAB-FIELDNAME = 'VBELN'.
LS_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT LS_CELLTAB INTO TABLE P_LT_CELLTAB.
LS_CELLTAB-FIELDNAME = 'ERDAT'.
LS_CELLTAB-STYLE = L_MODE.
INSERT LS_CELLTAB INTO TABLE P_LT_CELLTAB.
LS_CELLTAB-FIELDNAME = 'ERZET'.
LS_CELLTAB-STYLE = L_MODE.
INSERT LS_CELLTAB INTO TABLE P_LT_CELLTAB.
LS_CELLTAB-FIELDNAME = 'ERNAM'.
LS_CELLTAB-STYLE = L_MODE.
INSERT LS_CELLTAB INTO TABLE P_LT_CELLTAB.
LS_CELLTAB-FIELDNAME = 'NETWR'.
LS_CELLTAB-STYLE = L_MODE.
INSERT LS_CELLTAB INTO TABLE P_LT_CELLTAB.
ENDFORM. " fill_celltab
*&----
*
*& Form switch_edit_mode
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM SWITCH_EDIT_MODE.
IF GRID1->IS_READY_FOR_INPUT( ) EQ 0.
set edit enabled cells ready for input
CALL METHOD GRID1->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ELSE.
lock edit enabled cells against input
CALL METHOD GRID1->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 0.
ENDIF.
ENDFORM. " switch_edit_mode
*&----
*
*& Form build_field_cat
*&----
*
FORM BUILD_FIELD_CAT.
CLEAR I_FCAT.
W_FCAT-COL_POS = '1'.
W_FCAT-FIELDNAME = 'VBELN'.
W_FCAT-REF_TABLE = 'VBAK'.
W_FCAT-SELTEXT = 'Sales and Distribution'.
APPEND W_FCAT TO I_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = '2'.
W_FCAT-FIELDNAME = 'ERDAT'.
W_FCAT-REF_TABLE = 'VBAK'.
W_FCAT-SELTEXT = 'Date'.
APPEND W_FCAT TO I_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = '3'.
W_FCAT-FIELDNAME = 'ERZET'.
W_FCAT-REF_TABLE = 'VBAK'.
W_FCAT-SELTEXT = 'Entry time'.
APPEND W_FCAT TO I_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = '4'.
W_FCAT-FIELDNAME = 'ERNAM'.
W_FCAT-REF_TABLE = 'VBAK'.
W_FCAT-SELTEXT = 'Name of Person'.
APPEND W_FCAT TO I_FCAT.
CLEAR W_FCAT.
W_FCAT-COL_POS = '5'.
W_FCAT-FIELDNAME = 'NETWR'.
W_FCAT-REF_TABLE = 'VBAK'.
W_FCAT-SELTEXT = 'Net Value'.
W_FCAT-CFIELDNAME = 'NETWR_AK'.
APPEND W_FCAT TO I_FCAT.
ENDFORM. " build_field_cat
Hope usefull to u, do reward points to me
Regards
Fareedas