01-17-2006 4:51 PM
Hi.
I am using an editable ALV grid using Oops Concepts.
Using field catalog, i have disabled certain columns.
How do i disable certain rows depending upon a field condition ( For eg. If Certain field is filled, disable that row for editing purpose- Grey it out) ?
here are my declarations.
gs_layout TYPE lvc_s_layo, "Layout declaration
go_grid TYPE REF TO cl_gui_alv_grid, "Grid
go_custom_container TYPE REF TO cl_gui_custom_container,"Container
go_fieldcat type lvc_t_fcat, "Field Catalog
Thanks,
Shareen
01-18-2006 10:49 AM
Hi shareen,
you can use following method and update each and every cell.
ls_alv_style TYPE lvc_s_styl,
get the Field name of internal table into work area and to disable a row
ls_alv_style-style = go_grid=>mc_style_disabled
i hope i understood your question correctly.
regards,
kinshuk
01-18-2006 10:52 AM
Hi Shareen,
Please check the <b>BCALV_EDIT*</b> programs will sove
your problem. See the the below sample code
* Output table
types : BEGIN OF I_FINAL,
YHPPROJ LIKE YHPTPRHP-YHPPROJ,
YHPCORR LIKE YHPTPRHP-YHPCORR,
YHPDATE LIKE YHPTPRHP-YHPDATE,
YHPTIME LIKE YHPTPRHP-YHPTIME,
YHPOTYPE LIKE YHPTIMPM-YHPOTYPE,
YHPOBJ LIKE YHPTIMPM-YHPOBJ,
MDLENAME LIKE YHPTIMPM-MDLENAME,
YHPDEVC LIKE YHPTIMPM-YHPDEVC,
YHPTLTYP LIKE YHPTIMPM-YHPTLTYP,
YHPSOBTYP LIKE YHPTIMPM-YHPSOBTYP,
YHPFUNC LIKE YHPTIMPM-YHPFUNC,
YHPTECH LIKE YHPTIMPM-YHPTECH,
YHPOWNER LIKE YHPTIMPM-YHPOWNER,
YHPCONTN LIKE YHPTIMPM-YHPCONTN,
YHPESTHRS LIKE YHPTIMPM-YHPESTHRS,
YHPACTHRS LIKE YHPTIMPM-YHPACTHRS,
YHPSTRTDA LIKE YHPTIMPM-YHPSTRTDA,
YHPENDATE LIKE YHPTIMPM-YHPENDATE,
YHPACTSDT LIKE YHPTIMPM-YHPACTSDT,
YHPACTEDT LIKE YHPTIMPM-YHPACTEDT,
YHPASSIGN LIKE YHPTIMPM-YHPASSIGN,
YHPCOMPLT LIKE YHPTIMPM-YHPCOMPLT,
YHPLOCAT LIKE YHPTIMPM-YHPLOCAT,
YHPCOMMENT LIKE YHPTIMPM-YHPCOMMENT,
YHPPDES LIKE YHPTPROJ-YHPPDES,
types, : handle_style type lvc_t_styl,
END OF I_FINAL.
DATA : IT_PROJC TYPE TABLE OF I_FINAL.
data: ls_edit type lvc_s_styl,
lt_edit type lvc_t_styl,
ls_field type lvc_fname,
l_index type i.
gs_layout-stylefname = 'HANDLE_STYLE'.
* Fill ALV Control: Style Table for columns
loop at IT_PROJC into ls_outtab.
l_index = sy-tabix.
ls_edit-fieldname = 'YHPPROJ'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPCORR'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPOBJ'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'MDLENAME'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPDEVC'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPTLTYP'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPSOBTYP'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPFUNC'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPTECH'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPOWNER'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPCONTN'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPESTHRS'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPACTHRS'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPSTRTDA'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPENDATE'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPACTSDT'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPACTEDT'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPASSIGN'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPCOMPLT'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPLOCAT'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
ls_edit-fieldname = 'YHPCOMMENT'.
ls_edit-style = cl_gui_alv_grid=>MC_STYLE_DISABLED.
ls_edit-style2 = space.
ls_edit-style3 = space.
ls_edit-style4 = space.
ls_edit-maxlen = 8.
insert ls_edit into table lt_edit.
insert lines of lt_edit into table ls_outtab-handle_style.
modify IT_PROJC index l_index from ls_outtab
transporting handle_style.
endloop.
Lopp at your output table and depending on the condition you can enable or disable the rows.
Thanks&Regards,
Siri.
Message was edited by: Srilatha T
01-19-2006 5:51 AM
Hi Srilatha, I went through your program.I want to disable whole rows for input wherever advsr_time_dt field has some entry.Thats the criteria.Also at the same time, some field columns should be disabled at all times.Here is the code, can you pls guide me or correct my code.After editing the grid, I am saving this in the database.Now, if i modify the internal table to accomodate styl, how will i save the internal table..These 2 interal tables will differ in structure.Anyways, the my code is as below.Your help is greatly appreciated.Also there are 2 internal tables i use.gi_zswt_rckdvols is the internal table after modification to the grid and gi_zwt_rckdvols_before holds data before grid entries were changed.I only update rows which were modified.
REPORT Zmaintain.
TABLES: ZSWT_RCKDVOLS,
sscrfields .
DATA: gi_ZSWT_RCKDVOLS1 TYPE STANDARD TABLE OF ZSWT_RCKDVOLS,
ok_code LIKE sy-ucomm, "Global Data
gs_layout TYPE lvc_s_layo, "Layout declaration
wa_ZSWT_RCKDVOLS1 type ZSWT_RCKDVOLS,
go_grid TYPE REF TO cl_gui_alv_grid, "Grid
go_custom_container TYPE REF TO cl_gui_custom_container,"Container
go_fieldcat type lvc_t_fcat, "Field Catalog
v_repid like sy-repid,
i_ucomm like sy-ucomm .
Internal Table and Work area to hold data before Maintainance
Types: BEGIN OF typ_ZSWT_RCKDVOLS, "no header line
daily_vol_key type ZSWT_RCKDVOLS-daily_vol_key,
locid type ZSWT_RCKDVOLS-locid,
matnr type ZSWT_RCKDVOLS-matnr,
DAILY_DATE type ZSWT_RCKDVOLS-daily_date,
START_TIME type ZSWT_RCKDVOLS-start_time,
STOP_TIME type ZSWT_RCKDVOLS-stop_time,
NET_VOL type ZSWT_RCKDVOLS-net_vol,
MEINS type ZSWT_RCKDVOLS-meins,
DAILY_TEXT type ZSWT_RCKDVOLS-daily_text,
TEST_API_GRAVITY type ZSWT_RCKDVOLS-test_api_gravity,
ADVSR_ADJ_FLG type ZSWT_RCKDVOLS-advsr_adj_flg,
SOURCE_ID type ZSWT_RCKDVOLS-source_id,
DEST_ID type ZSWT_RCKDVOLS-dest_id,
SUPPLIER_NAME type ZSWT_RCKDVOLS-supplier_name,
CUSTOMER_NAME type ZSWT_RCKDVOLS-customer_name,
ADVSR_TIME_DT type ZSWT_RCKDVOLS-advsr_time_dt,
ERDAT type ZSWT_RCKDVOLS-erdat,
ERZEIT type ZSWT_RCKDVOLS-erzeit,
ERNAM type ZSWT_RCKDVOLS-ernam,
AEDAT type ZSWT_RCKDVOLS-aedat,
AEZEIT type ZSWT_RCKDVOLS-aezeit,
AENAM type ZSWT_RCKDVOLS-aenam,
SESSION_UPLOAD type ZSWT_RCKDVOLS-session_upload,
Add styl field
celltab type LVC_T_STYL,
END OF typ_ZSWT_RCKDVOLS.
data: gi_ZSWT_RCKDVOLS type standard table of typ_ZSWT_RCKDVOLS.
data: gi_ZSWT_RCKDVOLS_before type standard table of typ_ZSWT_RCKDVOLS.
data : wa_ZSWT_RCKDVOLS like line of gi_ZSWT_RCKDVOLS. "Work Area
data : wa_ZSWT_RCKDVOLS_before like line of gi_ZSWT_RCKDVOLS_before.
"Work Area
data: fcode(20),
i_result .
*SELECTION SCREEN BLOCK
selection-screen : begin of block blk1 with frame title text-001.
parameters p_rows(10) type n.
selection-screen : end of block blk1.
selection-screen : begin of block blk2 with frame title text-002.
select-options : s_VOLKEY for ZSWT_RCKDVOLS-DAILY_VOL_KEY,"Daily VolKey
s_LOCID for ZSWT_RCKDVOLS-LOCID, "Location ID
s_MATNR for ZSWT_RCKDVOLS-MATNR, "Material No.
s_DLYDT for ZSWT_RCKDVOLS-DAILY_DATE, "Daily Date
s_STRTME for ZSWT_RCKDVOLS-START_TIME,"TicketStartTime
s_STPTME for ZSWT_RCKDVOLS-STOP_TIME,"TicketStopTime
s_NETVOL for ZSWT_RCKDVOLS-NET_VOL,"Net Volume
s_MEINS for ZSWT_RCKDVOLS-MEINS,"UOM
s_srcid for ZSWT_RCKDVOLS-SOURCE_ID,"SouceID-Adv-Master
s_destid for ZSWT_RCKDVOLS-DEST_ID,
s_supnam for ZSWT_RCKDVOLS-SUPPLIER_NAME,"SupplierName
s_cusnam for ZSWT_RCKDVOLS-CUSTOMER_NAME,"CustomerName
s_adtmdt for ZSWT_RCKDVOLS-ADVSR_TIME_DT,"Advisory
s_aedat for ZSWT_RCKDVOLS-AEDAT,"Last update date
s_aezeit for ZSWT_RCKDVOLS-AEZEIT."Last update time
selection-screen: end of block blk2.
initialization.
sscrfields-functxt_01 = 'New Entries' .
selection-screen function key 1. "Actual creation of buttons
at selection-screen .
if sscrfields-ucomm eq 'FC01' .
call transaction 'ZDLYVOL_A' .
endif .
start-of-selection .
Fill the internal table.
perform fill_internal_table. " Fill gi_ZSWT_RCKDVOLS
gi_ZSWT_RCKDVOLS_before -- stores grid before changes
gi_ZSWT_RCKDVOLS_before[] = gi_ZSWT_RCKDVOLS[] .
set screen 100 .
&----
*& Module STATUS_0100 OUTPUT --- PBO EVENT
&----
MODULE status_0100 OUTPUT.
SET PF-STATUS '100' excluding 'ZDLYVOL_M' .
SET TITLEBAR '100'.
fill the fieldcat
perform fill_fieldcat.
Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
ENDIF.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'ZSWT_RCKDVOLS'
is_layout = gs_layout
CHANGING
it_fieldcatalog = go_fieldcat
it_outtab = gi_ZSWT_RCKDVOLS[].
CALL METHOD go_grid->set_ready_for_input
EXPORTING i_ready_for_input = 1.
ENDMODULE. " STATUS_0100 OUTPUT
----
FORM get_data_from_db *
----
........ *
----
FORM fill_internal_table.
DATA: lt_ZSWT_RCKDVOLS TYPE TABLE OF ZSWT_RCKDVOLS,
lt_celltab TYPE lvc_t_styl,
l_index TYPE i.
SELECT * up to p_rows rows
FROM ZSWT_RCKDVOLS
INTO TABLE lt_ZSWT_RCKDVOLS
WHERE DAILY_VOL_KEY in s_VOLKEY
AND LOCID in s_LOCID
AND MATNR in s_MATNR
AND DAILY_DATE in s_DLYDT
AND START_TIME in s_STRTME
AND STOP_TIME in s_STPTME
AND NET_VOL in s_NETVOL
AND MEINS in s_MEINS
AND SOURCE_ID in s_srcid
AND DEST_ID in s_destid
AND SUPPLIER_NAME in s_supnam
AND CUSTOMER_NAME in s_cusnam
AND ADVSR_TIME_DT in s_adtmdt
AND AEDAT in s_aedat
AND AEZEIT in s_aezeit.
Modify internal table - when checkbox checked save as Y,otherwise as N
loop at lt_ZSWT_RCKDVOLS into wa_ZSWT_RCKDVOLS1 .
if wa_ZSWT_RCKDVOLS1-ADVSR_ADJ_FLG eq 'Y' .
wa_ZSWT_RCKDVOLS1-ADVSR_ADJ_FLG = 'X' .
elseif wa_ZSWT_RCKDVOLS1-ADVSR_ADJ_FLG eq 'N' .
clear: wa_ZSWT_RCKDVOLS1-ADVSR_ADJ_FLG .
endif .
modify lt_ZSWT_RCKDVOLS from wa_ZSWT_RCKDVOLS1
transporting ADVSR_ADJ_FLG .
endloop .
*Override lt_ZSWT_RCKDVOLS onto gi_ZST_RCKDVOLS. gi_ZST_RCKSVOLS has an
*extra styl field
LOOP AT lt_ZSWT_RCKDVOLS into wa_ZSWT_RCKDVOLS1 ..
MOVE-CORRESPONDING lt_ZSWT_RCKDVOLS TO gi_ZSWT_RCKDVOLS.
APPEND gi_ZSWT_RCKDVOLS.
ENDLOOP.
Row Enable-Disable Critera
If advsr_time_dt field is blank, enable row except daily_vol_key and
last 8 field colums on zswt_rckdvols.Fieldcat must have taken care
of it
If advsr_time_dt field is filled, disable whole row.
LOOP AT gi_ZSWT_RCKDVOLS.
l_index = sy-tabix.
refresh lt_celltab.
if gi_ZSWT_RCKDVOLS-ADVSR_TIME_DT is initial.
perform fill_celltab using 'RW'
changing lt_celltab.
else.
perform fill_celltab using 'RO'
changing lt_celltab.
endif.
*Copy your celltab to the celltab of the current row of gt_outtab.
INSERT LINES OF lt_celltab INTO TABLE gi_ZSWT_RCKDVOLS-celltab.
MODIFY gi_ZSWT_RCKDVOLS INDEX l_index.
ENDLOOP.
ENDFORM. " get_data_from_db
FORM save_data.
Save only if there is a modification done to a row.
data v_index like sy-tabix.
move-corresponding gi_ZSWT_RCKDVOLS to gi_ZSWT_RCKDVOLS1.
loop at gi_ZSWT_RCKDVOLS1 into wa_ZSWT_RCKDVOLS1 .
read table gi_ZSWT_RCKDVOLS_before into wa_ZSWT_RCKDVOLS_before with key
DAILY_VOL_KEY = wa_ZSWT_RCKDVOLS-DAILY_VOL_KEY.
if wa_ZSWT_RCKDVOLS_before ne wa_ZSWT_RCKDVOLS.
If ADVSR Flag is checked, it is saved as Y else stored as N
if wa_ZSWT_RCKDVOLS-ADVSR_ADJ_FLG eq 'X' .
wa_ZSWT_RCKDVOLS-ADVSR_ADJ_FLG = 'Y' .
elseif wa_ZSWT_RCKDVOLS-ADVSR_ADJ_FLG eq ' ' .
wa_ZSWT_RCKDVOLS-ADVSR_ADJ_FLG = 'N' .
endif .
Modification date,time and person involved in the modification.
wa_zswt_rckdvols-aedat = sy-datum .
wa_zswt_rckdvols-aezeit = sy-uzeit .
wa_zswt_rckdvols-aenam = sy-uname .
v_index = sy-tabix.
modify gi_ZSWT_RCKDVOLS from wa_ZSWT_RCKDVOLS index v_index
transporting ADVSR_ADJ_FLG aedat aezeit aenam .
modify zswt_rckdvols from wa_zswt_rckdvols .
endif.
endloop .
commit work .
refresh gi_zswt_rckdvols .
message s041(zsw) .
submit zswr_rckdvols_a .
ENDFORM. " save_data
&----
*& Module Screen_modify OUTPUT
&----
Modify the Screen Internal tables
----
MODULE Screen_modify OUTPUT.
ENDMODULE. " Screen_modify OUTPUT
&----
*& Form fill_fieldcat
&----
FORM fill_fieldcat.
data : wa_fieldcat type LVC_S_FCAT.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'DAILY_VOL_KEY'.
wa_fieldcat-SCRTEXT_M = 'Daily Vol Key'.
wa_fieldcat-SCRTEXT_S = 'Dly Vol Ky'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'LOCID'.
wa_fieldcat-SCRTEXT_M = 'Location ID'.
wa_fieldcat-SCRTEXT_S = 'Location ID'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-SCRTEXT_M = 'Material #'.
wa_fieldcat-SCRTEXT_S = 'Material #'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'DAILY_DATE'.
wa_fieldcat-SCRTEXT_M = 'Daily Date'.
wa_fieldcat-SCRTEXT_S = 'Daily Date'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'START_TIME'.
wa_fieldcat-SCRTEXT_M = 'Start Time'.
wa_fieldcat-SCRTEXT_S = 'Start Time'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'STOP_TIME'.
wa_fieldcat-SCRTEXT_M = 'Stop Time'.
wa_fieldcat-SCRTEXT_S = 'Stop Time'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'NET_VOL'.
wa_fieldcat-SCRTEXT_M = 'Net Vol'.
wa_fieldcat-SCRTEXT_S = 'Net Vol'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-SCRTEXT_M = 'UoM'.
wa_fieldcat-SCRTEXT_S = 'UoM'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'DAILY_TEXT'.
wa_fieldcat-SCRTEXT_M = 'Comment'.
wa_fieldcat-SCRTEXT_S = 'Comment'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'TEST_API_GRAVITY'.
wa_fieldcat-SCRTEXT_M = 'Test API Gvty'.
wa_fieldcat-SCRTEXT_S = 'Test API Gvty'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'ADVSR_ADJ_FLG'.
wa_fieldcat-SCRTEXT_M = 'Adj Indicator'.
wa_fieldcat-SCRTEXT_S = 'Adj Indicator'.
wa_fieldcat-checkbox = 'X'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'SOURCE_ID'.
wa_fieldcat-SCRTEXT_M = 'Source ID'.
wa_fieldcat-SCRTEXT_S = 'Source ID'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'DEST_ID'.
wa_fieldcat-SCRTEXT_M = 'Dest ID'.
wa_fieldcat-SCRTEXT_S = 'Dest ID'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'SUPPLIER_NAME'.
wa_fieldcat-SCRTEXT_M = 'Supplier Name'.
wa_fieldcat-SCRTEXT_S = 'Supplier Name'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'CUSTOMER_NAME'.
wa_fieldcat-SCRTEXT_M = 'Customer Name'.
wa_fieldcat-SCRTEXT_S = 'Customer Name'.
wa_fieldcat-EDIT = 'X'.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'ADVSR_TIME_DT'.
wa_fieldcat-SCRTEXT_M = 'Advisory Time-Date'.
wa_fieldcat-SCRTEXT_S = 'Advisory Time-Date'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'ERDAT'.
wa_fieldcat-SCRTEXT_M = 'Creation Dt'.
wa_fieldcat-SCRTEXT_S = 'Creation Dt'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'ERZEIT'.
wa_fieldcat-SCRTEXT_M = 'Creation Time'.
wa_fieldcat-SCRTEXT_S = 'Creation Time'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-SCRTEXT_M = 'Created by'.
wa_fieldcat-SCRTEXT_S = 'Created by'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-SCRTEXT_M = 'Last Changed Dt'.
wa_fieldcat-SCRTEXT_S = 'Last Changed Dt'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'AEZEIT'.
wa_fieldcat-SCRTEXT_M = 'Last Changed Time'.
wa_fieldcat-SCRTEXT_S = 'Last Changed Time'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'AENAM'.
wa_fieldcat-SCRTEXT_M = 'Last Changed by'.
wa_fieldcat-SCRTEXT_S = 'Last Changed by'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'gi_ZSWT_RCKDVOLS'.
wa_fieldcat-fieldname = 'SESSION_UPLOAD'.
wa_fieldcat-SCRTEXT_M = 'Session Upload'.
wa_fieldcat-SCRTEXT_S = 'Session Upload'.
wa_fieldcat-EDIT = ' '.
append wa_fieldcat to go_fieldcat.
ENDFORM. " fill_fieldcat
&----
*& PAI --- EVENT
&----
MODULE user_command_0100 INPUT.
call method go_grid->check_changed_data.
case fcode .
when 'ZDLYVOL_A' .
submit ZSWR_RCKDVOLS and return .
when 'ZDLYVOL_D' .
submit ZSWR_RCKDVOLS_B via selection-screen and return .
when 'SAVE' .
perform save_data.
when 'EXIT' or 'CANC'.
refresh gi_zswt_rckdvols .
set screen 0 . leave screen .
when 'BACK' .
if gi_ZSWT_RCKDVOLS_before[] ne gi_zswt_rckdvols[] .
clear: i_result .
CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
EXPORTING
DEFAULTOPTION = 'Y'
DIAGNOSETEXT1 = text-003
TEXTLINE1 = text-004
TITEL = text-005
CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = i_result .
case i_result .
leave to list-processing.
when 'J' .
perform save_data.
when 'N'.
refresh gi_zswt_rckdvols .
set screen 0 . leave screen .
when others .
refresh gi_zswt_rckdvols .
leave to transaction sy-tcode . "Stay there
endcase .
else .
refresh gi_zswt_rckdvols .
call transaction 'ZDLYVOL_M'.
endif .
endcase .
ENDMODULE. " USER_COMMAND_0100 INPUT
Perform routine to enable and disable rows.
FORM fill_celltab using value(p_mode)
CHANGING pt_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'.
*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'
*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 = 'DAILY_VOL_KEY'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'LOCID'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'MATNR'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'DAILY_DATE'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'START_TIME'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'STOP_TIME'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'NET_VOL'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'MEINS'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'DAILY_TEXT'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'TEST_API_GRAVITY'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'MEINS'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'ADVSR_ADJ_FLG'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SOURCE_ID'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'DEST_ID'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SUPPLIER_NAME'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'CUSTOMER_NAME'.
ls_celltab-style = l_mode.
INSERT ls_celltab INTO TABLE pt_celltab.
The next 8 columns are disabled at all times.The above columns
depends on the fiel ADVSR_TIME_DT.
ls_celltab-fieldname = 'ADVSR_TIME_DT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'ERDAT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'ERZEIT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'ERNAM'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'AEDAT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'AEZEIT'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'AENAM'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
ls_celltab-fieldname = 'SESSION_UPLOAD'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_celltab INTO TABLE pt_celltab.
01-19-2006 6:00 AM
hi,
before display the output take the backup and then after editing the grid compare with the backup ,if you find any difference in that then you can update the database.
and then repopulate the internal table ,and refresh the output.
regards
vijay
01-19-2006 7:10 AM
hi u can do like this,
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
now
read lt_fiedlcat into ls_fieldcat index LS_MOD_CELL-row_id.
if ls_fieldcat-fieldname = 'xxx'.
ls_fieldcat-edit = ''.
modify fieldcat.