10-10-2007 10:40 AM
hi Experts!!
I am working on a ALV Grids which are on a Tabstrip Sub screen area.I have done the ALV in Edit mode and :
> <b>when we enter the values in the editing colums i want it to be updateted in the DB table.
>But when we enter values it is not comming in the internal table also and not updateing in DB table.
>Plz suggest waht needs to be done to catch the edited valuse and update the same into DB table</b>.
10-10-2007 10:52 AM
Hi Mahesh,
Use the handle_data_changed event.
1. This will help you to capture the changes done in the ALV grid.
2. The table that you use for displaying the Alv grid , you can have a column to mark the changed lines.
3. then in the PAI, write the logic for Updating the same inthe DB table.
Reward if helpful.
Regards,
Chitra
10-10-2007 10:47 AM
u have to do this in ooalv.
invoking the data_changed method
CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_DATA_CHANGED
FOR EVENT DATA_CHANGED OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED E_ONF4 E_UCOMM.
ENDCLASS
----
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
----
*
----
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DATA_CHANGED.
PERFORM DATA_CHANGED USING ER_DATA_CHANGED E_ONF4 E_UCOMM.
ENDCLASS.
SET HANDLER EVENT_RECEIVER->HANDLE_DATA_CHANGED FOR GO_GRID.
<b>CALL METHOD GO_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD GO_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = cl_gui_alv_grid=>mc_evt_enter.</b>
&----
*& Form DATA_CHANGED
&----
text
----
-->P_ER_DATA_CHANGED text
-->P_E_ONF4 text
----
FORM DATA_CHANGED USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
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 write logic to update the internal table with the l_value using the particular row and fieldname
using the itab u can update dbtab.
ENDLOOP.
NOTE: WHAT I HAVE BOLDED IS VERY IMPORTANT. WE HAVE TO REGISTER
Message was edited by:
Hymavathi Oruganti
10-11-2007 12:34 PM
hi,
this is with regrds to the asn which u relpyed me for my quition.
i did as u told for updation in ALv but getting only 1 colume updated n other soem invalid entries.
can u plz help me in this.
mahesh
10-18-2007 11:14 AM
hii
thanku..
this is with reg to AL:V edit,
i did the same way as u suggested but its giing the dump when i call the data_changes_method.
plz suggest me if any other way or how to do the same
plz help me
mahesh
10-10-2007 10:52 AM
Hi Mahesh,
Use the handle_data_changed event.
1. This will help you to capture the changes done in the ALV grid.
2. The table that you use for displaying the Alv grid , you can have a column to mark the changed lines.
3. then in the PAI, write the logic for Updating the same inthe DB table.
Reward if helpful.
Regards,
Chitra
10-10-2007 10:55 AM
thanks for you replye.
the defnition of the data do we need to define and implement in top include..
plz send me if u have any example of the same.
mahesh
10-10-2007 11:00 AM
Hi Mahesh,
The following declaration should be done in top include.
&----
Event Handler Declarations
&----
----
CLASS lcl_event_receiver DEFINITION
----
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
ENDCLASS. "lcl_event_receiver DEFINITION
----
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
----
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed. " <u><b>write the code to get the rows that is changed</b></u>
ENDMETHOD. "handle_data_changed
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
10-10-2007 11:07 AM
10-10-2007 10:53 AM
hi,
Check this might help you...
Regard points if helpful....
DATA: G_CONTROL TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA: T_FCAT TYPE LVC_T_FCAT,
WA_FCAT TYPE LVC_S_FCAT.
DATA: I_ZAMIT TYPE TABLE OF ZAMIT_SHIP_TAB WITH HEADER LINE.
DATA: I_INDEX TYPE I.
DATA: G_OK_CODE TYPE SY-UCOMM.
DATA: G_OK_CODE1 TYPE SY-UCOMM.
SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
CALL SCREEN 9000.
SCREEN FORMS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
&----
*& Module STATUS_9000 OUTPUT
&----
text
----
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'PF9001'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
&----
*& Module CREATE_CONTROL OUTPUT
&----
text
----
MODULE CREATE_CONTROL OUTPUT.
CREATE OBJECT G_CONTROL
EXPORTING
PARENT =
CONTAINER_NAME = 'G_CUSTOM_CONTROL'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " CREATE_CONTROL OUTPUT
&----
*& Module CREATE_ALV OUTPUT
&----
text
----
MODULE CREATE_ALV OUTPUT.
CREATE OBJECT G_ALV
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = G_CONTROL
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " CREATE_ALV OUTPUT
&----
*& Module DISPLAY_ALV OUTPUT
&----
text
----
MODULE DISPLAY_ALV OUTPUT.
PERFORM PREPARE_FIELD_CATALOG.
CALL METHOD G_ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'SFLIGHT'
IS_VARIANT =
I_SAVE = 'X'
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = T_TOOLBAR[]
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = I_ZAMIT[]
IT_FIELDCATALOG = T_FCAT
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " DISPLAY_ALV OUTPUT
&----
*& Form PREPARE_FIELD_CATALOG
&----
text
----
--> p1 text
<-- p2 text
----
FORM PREPARE_FIELD_CATALOG .
REFRESH T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 1.
WA_FCAT-COLTEXT = 'SHIPMENT NO.'.
WA_FCAT-FIELDNAME = 'ZSHIP_NO'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-edit = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-COLTEXT = 'DOC TYPE'.
WA_FCAT-FIELDNAME = 'ZDOC_TYP'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 3.
WA_FCAT-COLTEXT = 'NAME_CR'.
WA_FCAT-FIELDNAME = 'ZNAME_CR'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 4.
WA_FCAT-COLTEXT = 'SHIP_TYP'.
WA_FCAT-FIELDNAME = 'ZSHIP_TYP'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 5.
WA_FCAT-COLTEXT = 'LEG_IND'.
WA_FCAT-FIELDNAME = 'ZLEG_IND'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
ENDFORM. " PREPARE_FIELD_CATALOG
&----
*& Module LEAVE INPUT
&----
text
----
MODULE LEAVE INPUT.
LEAVE PROGRAM.
ENDMODULE. " LEAVE INPUT
&----
*& Module USER_COMMAND_9000 INPUT
&----
text
----
MODULE USER_COMMAND_9000 INPUT.
IF G_OK_CODE = 'CHANGE'.
DATA: VALUE TYPE C,
COL TYPE I ,
ROW TYPE LVC_S_ROW,
COLNO TYPE LVC_S_COL,
ROWNO TYPE LVC_S_ROID.
CALL METHOD G_ALV->GET_CURRENT_CELL
IMPORTING
E_ROW = I_INDEX
CALL METHOD G_ALV->GET_CURRENT_CELL
IMPORTING
E_ROW =
E_VALUE = VALUE
E_COL = COL
ES_ROW_ID = ROW
ES_COL_ID = COLNO
ES_ROW_NO = ROWNO.
.
READ TABLE I_ZAMIT INDEX I_INDEX.
CALL SCREEN 9001 STARTING AT 10 10 .
ENDIF.
ENDMODULE. " USER_COMMAND_9000 INPUT
&----
*& Module STATUS_9001 OUTPUT
&----
text
----
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'PF9002'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9001 OUTPUT
&----
*& Module USER_COMMAND_9001 INPUT
&----
text
----
MODULE USER_COMMAND_9001 INPUT.
IF G_OK_CODE1 = 'SAVE'.
MODIFY ZAMIT_SHIP_TAB FROM I_ZAMIT.
SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
CALL METHOD G_ALV->REFRESH_TABLE_DISPLAY.
CALL SCREEN 9000.
ENDIF.
ENDMODULE. " USER_COMMAND_9001 INPUT
10-12-2007 11:11 AM
hi experts!!!
i am editing the ALv grid and want to read the changed Values in grid.
i am using
<b>CALL METHOD G_grid_102->GET_CURRENT_cell
*IMPORTING</b>
method and getting only a single cell valuse and the other cells some unknown valuse but i want to get all edited valuse in that row. so is tehre any method which i can use to canth the edited row valuse in grid.plz send me some expmlles.
plz help me