Hello Experts,
This might be a simple question but still, I couldn't figure out the solution.
Here's the requirement: I have a custom ztable which has fields changed by user name and changed on date along with the other fields. Now I am pulling the data from this database table using ALV grid report. This output of this ALV grid report has two editable fields. When I edit a existing editable field cell or add new data into my editable field cell and click on SAVE then my database table should get updated only for these edited fields changing the changed by user name to sy-uname and changed on date to sy-datum.
But, currently when I am doing a SAVE it updates all the records with sy-uname and sy-datum which is not supposed to do that. Can anybody suggest me an idea for doing this?
Below is my code.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE SY-UCOMM.
WHEN '&DATA_SAVE'.
LOOP AT ITAB INTO WA.
CLEAR: GV_NAM, GV_NAM1, GV_MESS, GV_MESS1.
SELECT SINGLE BNAME FROM USR21 INTO GV_NAM WHERE BNAME = WA-NAME.
SELECT SINGLE ZGR FROM ZTABLE INTO GV_NAM1 WHERE ZGR = WA-ZGR.
IF GV_NAM = WA-NAME AND GV_NAM1 = WA-ZGR.
UPDATE ZTABLE2 SET NAME = WA-NAME
NOTE = WA-NOTE
ZCHANGE_DATE = SY-DATUM
ZCHANGE_USER = SY-UNAME
WHERE TEXT = WA-TEXT.
ELSEIF GV_NAM NE WA-NAME.
CONCATENATE TEXT-067 WA-NAME TEXT-069 INTO GV_MESS SEPARATED BY SPACE.
MESSAGE GV_MESS TYPE GC_E.
ELSEIF GV_NAM1 NE WA-ZGR.
CONCATENATE TEXT-068 WA-ZGR TEXT-069 INTO GV_MESS1 SEPARATED BY SPACE.
MESSAGE GV_MESS1 TYPE GC_E.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM. "USER_COMMAND
Thanks,
Nani