‎2006 Aug 30 11:18 AM
Hi,
I am using the following code to change the values in the output and update the database table.
TYPE-POOLS : SLIS.
TABLES : ZVCARE,
ZHR_VCARE.
DATA: BEGIN OF IT_ZVCARE OCCURS 0,
PERNR LIKE ZVCARE-PERNR,
CYEAR LIKE ZVCARE-CYEAR,
ENAME LIKE ZVCARE-ENAME,
END OF IT_ZVCARE.
DATA: BEGIN OF IT_ZVCARE1 OCCURS 0,
PERNR LIKE ZVCARE-PERNR,
CYEAR LIKE ZVCARE-CYEAR,
ENAME LIKE ZVCARE-ENAME,
END OF IT_ZVCARE1.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : IT_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA : V_REPID LIKE SY-REPID.
DATA : C_ZVCARE TYPE DD02L-TABNAME VALUE 'ZHR_VCARE'.
CONSTANTS: C_PF_STATUS1 TYPE SLIS_ALV_EVENT-FORM VALUE 'ZHR_MED',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
----
S E L E C T I O N S C R E E N *
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_CLAIM FOR ZVCARE-CLAIM,
S_PERNR FOR ZVCARE-PERNR,
S_CDATE FOR ZVCARE-CDATE.
SELECTION-SCREEN END OF BLOCK B1.
----
S T A R T O F S E L E C T I O N *
----
SET PF-STATUS 'ZHR_MED'.
PERFORM GET_DATA.
----
E N D O F S E L E C T I O N *
----
PERFORM BUILD_FIELDCATLOG.
PERFORM MODIFY_FIELD_CAT_BUILD.
PERFORM DISPLAY_ALV.
&----
*& Form GET_DATA
&----
text
----
FORM GET_DATA .
SELECT PERNR
CYEAR
ENAME
FROM ZVCARE
INTO TABLE IT_ZVCARE
WHERE CLAIM IN S_CLAIM
AND PERNR IN S_PERNR
AND CDATE IN S_CDATE.
MOVE : IT_ZVCARE[] TO IT_ZVCARE1[].
ENDFORM. " GET_DATA
&----
*& Form BUILD_FIELDCATLOG
&----
text
----
FORM BUILD_FIELDCATLOG .
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = C_ZVCARE
CHANGING
CT_FIELDCAT = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
ENDFORM. " BUILD_FIELDCATLOG
&----
*& Form DISPLAY_ALV
&----
text
----
FORM DISPLAY_ALV .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS1
I_CALLBACK_USER_COMMAND = C_USER_COMMAND
IS_LAYOUT = IT_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = IT_ZVCARE
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV
&----
*& Form MODIFY_FIELD_CAT_BUILD
&----
text
----
FORM MODIFY_FIELD_CAT_BUILD .
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
LOOP AT IT_FIELDCAT INTO X_FIELDCAT.
CASE X_FIELDCAT-FIELDNAME.
WHEN 'ENAME'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-INPUT = 'X'.
ENDCASE.
MODIFY IT_FIELDCAT FROM X_FIELDCAT.
ENDLOOP.
ENDFORM. " MODIFY_FIELD_CAT_BUILD
&----
*& Form user_command
&----
EXIT routine for user_command
----
-->R_UCOMM Checks for sy-ucomm for &IC1
-->RS_SELFIELD structure to store selected row
----
FORM USER_COMMAND USING IV_UCOMM TYPE SY-UCOMM
IV_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED
CASE IV_UCOMM.
WHEN 'SAVE1'.
LOOP AT IT_ZVCARE.
READ TABLE IT_ZVCARE1 INDEX SY-INDEX.
IF IT_ZVCARE-ENAME <> IT_ZVCARE1-ENAME.
UPDATE ZVCARE FROM IT_ZVCARE .
ENDIF.
ENDLOOP.
WHEN 'SETT'.
ENDCASE.
CLEAR IV_SELFIELD.
ENDFORM. "user_command
&----
*& Form set_pf_status
&----
this form is called by function module 'REUSE_ALV_GRID_DISPLAY'.
do not delete this form
----
FORM ZHR_MED USING RT_EXTAB TYPE SLIS_T_EXTAB. "#EC *
.
SET PF-STATUS C_PF_STATUS1 EXCLUDING RT_EXTAB. "#EC *
ENDFORM. " set_pf_status
In the PF-STATUS i have two buttons in the Application Tool Bar 'SAVE' and 'SETT'.
When i make changes in output and click on SAVE or SETT the changes made are not reflecting in the internal table IT_ZVCARE, but when i double click with the mouse changes are reflecting in the internal table.
I want the changes to be reflected when i click on SAVE or SETT.
Thank you,
Ramu N.
‎2006 Aug 30 11:22 AM
Proceed in the following lines:
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
when 'SAVE'.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
the internal table will now have updated data
endcase.
ENDFORM.
‎2006 Aug 30 11:21 AM
u are reading the table with Index ,So in that case u cannt UPDATE ,remove that line then check.
Regards
Prabhu
‎2006 Aug 30 11:22 AM
Proceed in the following lines:
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
case p_ucomm.
when 'SAVE'.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
the internal table will now have updated data
endcase.
ENDFORM.
‎2006 Aug 30 11:23 AM
Hi Ramu,
write this code after
CASE IV_UCOMM.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data.
WHEN 'SAVE'.
WHEN 'XYZ'.
ENDCASE.
‎2006 Aug 30 11:29 AM
HI,
check this program it is saving the data from internal table to database table using SAVE command in standard tool bar.
<b>REPORT ZALV_EDITABLE_FM .
type-pools: slis.
data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.
data: gs_layout type slis_layout_alv.
data v_repid like sy-repid.
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE CSKT.
DATA: end of itab.
START-OF-SELECTION.
v_repid = sy-repid.
*--- selection form cost center master table
SELECT * FROM CSKT
INTO TABLE itab.
PERFORM field_catalog.
gs_layout-edit = 'X'.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcat[]
is_layout = gs_layout
TABLES
t_outtab = itab.
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
form user_command using r_ucomm type sy-ucomm
rs_selfield type slis_selfield.
if r_ucomm = '&DATA_SAVE'.
message i000(SU) with 'saved'.
MODIFY CSKT FROM TABLE itab.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat[]
TABLES
t_outtab = itab.
endif.
endform.
*&---------------------------------------------------------------------*
*& Form field_catalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM field_catalog.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'ITAB'
i_inclname = v_repid
CHANGING
ct_fieldcat = it_fieldcat[].
ENDFORM. " field_catalog</b>Regards,
‎2006 Aug 30 11:48 AM
Hi Ramu,
I dont know if it possible using the functions. But if you use classes for ALV grid display (Class: CL_GUI_ALV_GRID) you can use the method CHECK_CHANGED_DATA. This transfers the data changed by the user in ALV grid to the internal table.
Regards,
Prabhas.