2007 Nov 26 7:33 PM
Hi,
I've been going through all the article and threads in the this forum. I can;t seem to get the field populate VALUE NEW, VALUE OLD and also the FNAME field always shows as KEY.
My intersion is to update CDPOS everytime there is a value to a record in my z-table being changed.
Below is my trial code. but it does seem to work. I can INSERT into CDPOS but not UPDATE. Please review my code and let me know how can i get this problem solve please.
REPORT zvintest1.
TABLES: cdhdr, zvin_test.
DATA: objectclass LIKE cdhdr-objectclas,
objctid LIKE cdhdr-objectid,
stct_old TYPE zvin_test,
stct_new TYPE zvin_test,
tablename LIKE cdpos-tabname,
changenum LIKE cdhdr-changenr.
objectclass = 'ZVIN_ATT'.
objctid = '2711'.
tablename = 'ZVIN_TEST '.
CALL FUNCTION 'CHANGEDOCUMENT_OPEN'
EXPORTING
objectclass = objectclass
objectid = objctid
PLANNED_CHANGE_NUMBER = ' '
PLANNED_OR_REAL_CHANGES = 'R'
EXCEPTIONS
sequence_invalid = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
stct_old-vendor = '110'.
stct_old-assembly = 'position'.
stct_old-serialnum = '001'.
stct_old-status = '2'.
*modify zvin_test FROM stct_old.
stct_new-vendor = '110'.
stct_new-assembly = 'position'.
stct_new-serialnum = '001'.
stct_new-status = '1'.
*modify zvin_test FROM stct_old.
CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'
EXPORTING
change_indicator = 'U'
DOCU_DELETE = 'X'
REFAREA_NEW = STCT_NEW
REFAREA_OLD = stct_old
REFTABLENAME = 'ZVIN_TEST'
tablename = tablename
workarea_new = stct_new
workarea_old = stct_old
EXCEPTIONS
nametab_error = 1
open_missing = 2
position_insert_failed = 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.
CALL FUNCTION 'CHANGEDOCUMENT_CLOSE'
EXPORTING
date_of_change = sy-datum
objectclass = objectclass
objectid = objctid
tcode = 'MIGO'
time_of_change = sy-uzeit
username = sy-uname
object_change_indicator = 'U'
PLANNED_OR_REAL_CHANGES = 'R'
NO_CHANGE_POINTERS = 'X'
IMPORTING
changenumber = changenum
EXCEPTIONS
header_insert_failed = 1
no_position_inserted = 2
object_invalid = 3
open_missing = 4
position_insert_failed = 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.
the error i get is NO_POSITION_INSERTED.
Thank you.
Regards,
Vinod
2007 Nov 26 7:45 PM
Why don't you use the standard functionality of the record changes?
Go to SE11.. open your table.. go to Technical settings ..
here you can find the "Log data changes". Check this checkbox on.
Later on you can track changes by <b>SCU3</b> transaction code...
This the extract from the online help....
Log data changes
The logging flag defines whether changes to the data records of a table should be logged. If logging is activated, every change (with UPDATE, DELETE) to an existing data record by a user or an application program is recorded in a log table in the database.
Note: Activating logging slows down accesses that change the table. First of all, a record must be written in the log table for each change. Secondly, many users access this log table in parallel. This could cause lock situations even though the users are working with different application tables.
Dependencies
Logging only takes place if parameter rec/client in the system profile is set correctly. Setting the flag on its own does not cause the table changes to be logged.
The existing logs can be displayed with Transaction Table history (SCU3).
Regards,
Naimesh Patel
2007 Nov 26 7:45 PM
Why don't you use the standard functionality of the record changes?
Go to SE11.. open your table.. go to Technical settings ..
here you can find the "Log data changes". Check this checkbox on.
Later on you can track changes by <b>SCU3</b> transaction code...
This the extract from the online help....
Log data changes
The logging flag defines whether changes to the data records of a table should be logged. If logging is activated, every change (with UPDATE, DELETE) to an existing data record by a user or an application program is recorded in a log table in the database.
Note: Activating logging slows down accesses that change the table. First of all, a record must be written in the log table for each change. Secondly, many users access this log table in parallel. This could cause lock situations even though the users are working with different application tables.
Dependencies
Logging only takes place if parameter rec/client in the system profile is set correctly. Setting the flag on its own does not cause the table changes to be logged.
The existing logs can be displayed with Transaction Table history (SCU3).
Regards,
Naimesh Patel
2007 Nov 26 8:32 PM
Thanks for the reply Naimesh.
I am aware of tht method. but i was thinking of tryin the method i said earlier.
Any idea where have i made a mistake? or how is the correct procedure.
Thanks in advance.
Vinod
2007 Nov 26 8:44 PM
Ok...
You can look see the whereused list of this FM and figure out what they are putting as input and what you are missing..
What I see is, you are not passing the old and new vlaues
CALL FUNCTION 'CHANGEDOCUMENT_SINGLE_CASE'
EXPORTING
change_indicator = 'U'
DOCU_DELETE = 'X'
REFAREA_NEW = STCT_NEW " << you must pass new values
REFAREA_OLD = stct_old " << you must pass old values
* REFTABLENAME = 'ZVIN_TEST'
tablename = tablename
workarea_new = stct_new
workarea_old = stct_old
EXCEPTIONS
nametab_error = 1
open_missing = 2
position_insert_failed = 3
OTHERS = 4
Regards,
Naimesh Patel