Skip to Content
0
Former Member
Nov 16, 2013 at 07:51 AM

Change log for Z tables when logging in not by the system.

23 Views

the folowing are the steps tat i followed.

1) created CHANGE DOCUMENT OBJECT VIA SCDO. (OBJECT NAME : Z_test)

2) I have written the following code in Z-TABLE ( ZSC_TEST) i.e IN SM30 by creating a module in PAI.

problem : am i in the ryt direction for creating logs ? if yes? there is excution problem .

MODULE TEST INPUT.

DATA: OBJECTID TYPE CDHDR-OBJECTID,
TCODE TYPE CDHDR-TCODE,
PLANNED_CHANGE_NUMBER TYPE CDHDR-PLANCHNGNR,
UTIME TYPE CDHDR-UTIME,
UDATE TYPE CDHDR-UDATE,
USERNAME TYPE CDHDR-USERNAME,
CDOC_PLANNED_OR_REAL TYPE CDHDR-CHANGE_IND,
CDOC_UPD_OBJECT TYPE CDHDR-CHANGE_IND VALUE 'U',
CDOC_NO_CHANGE_POINTERS TYPE CDHDR-CHANGE_IND.


* declaration for the long text
DATA: BEGIN OF ICDTXT_Z_TEST OCCURS 20.
INCLUDE STRUCTURE CDTXT.
DATA: END OF ICDTXT_Z_TEST.
DATA: UPD_ICDTXT_Z_TEST TYPE C.

* table with the NEW content of: ZSC_TEST
DATA: BEGIN OF XZSC_TEST OCCURS 20.
INCLUDE STRUCTURE YZSC_TEST.
DATA: END OF XZSC_TEST.

* table with the OLD content of: ZSC_TEST
DATA: BEGIN OF YZSC_TEST OCCURS 20.
INCLUDE STRUCTURE YZSC_TEST.
DATA: END OF YZSC_TEST.

DATA: UPD_ZSC_TEST TYPE C.

DATA : FZ_EMP TYPE ZSC_TEST. " INTERNAL TABLE OF ZTABLE
DATA : FZ_CDTXT TYPE CDTXT. " INTERNAL TABLE OF CDTXT
DATA : T_CDTXT LIKE STANDARD TABLE OF FZ_CDTXT. "TABLE

BREAK-POINT.
FZ_EMP-EQUNR = ZSC_TEST-EQUNR .
FZ_EMP-LOEVM_KO = ZSC_TEST-LOEVM_KO .
FZ_EMP-KUNNR = ZSC_TEST-KUNNR .
* INSERT ZSC_TEST FROM FZ_EMP.
APPEND fz_emp to ICDTXT_Z_TEST .
* APPEND ICDTXT_Z_TEST .
APPEND fz_emp to XZSC_TEST.
APPEND fz_emp to YZSC_TEST.

UPD_ICDTXT_Z_TEST = 'I'.

BREAK-POINT.
* IF ( UPD_ZSC_TEST NE SPACE )
* OR ( UPD_ICDTXT_Z_TEST NE SPACE )
* .
* CALL FUNCTION 'SWE_REQUESTER_TO_UPDATE'.
CALL FUNCTION 'Z_TEST_WRITE_DOCUMENT' "IN UPDATE TASK
EXPORTING
OBJECTID = OBJECTID
TCODE = sy-TCODE
UTIME = sy-uzeit
UDATE = sy-datum
USERNAME = sy-uname
PLANNED_CHANGE_NUMBER = ' ' "PLANNED_CHANGE_NUMBER
OBJECT_CHANGE_INDICATOR = 'I' "CDOC_UPD_OBJECT
PLANNED_OR_REAL_CHANGES = ' ' "CDOC_PLANNED_OR_REAL
NO_CHANGE_POINTERS = ' '"CDOC_NO_CHANGE_POINTERS
* updateflag of ZSC_TEST
UPD_ZSC_TEST
= 'I'
UPD_ICDTXT_Z_TEST
= 'I ' "UPD_ICDTXT_Z_TEST
TABLES
ICDTXT_Z_TEST
= ICDTXT_Z_TEST
XZSC_TEST
= XZSC_TEST
YZSC_TEST
= YZSC_TEST
.
if sy-subrc eq 0.
message 'log created' type 'S'.
else.
message 'insert Error' type 'S'.
ENDIF.
CLEAR PLANNED_CHANGE_NUMBER.
ENDMODULE.