‎2006 Nov 19 11:41 PM
Hi,
In user-exit i am changing the plant status .Example - 'P1' is the intial value and then on certain condition it has been changed to 'SO' and later on to 'CC' , at the end of the process i want to assign the orginal value 'P1' to the status.
how can i get the original value , i think the maximum changenr logic in cdhdr cannot be applied here .
Thanks & Regards.
Syed
‎2006 Nov 20 12:13 AM
Hi,
another way of achieving this requirement is,
1) turn on tabble logging for the table whichis having plant status field.
2) when this field value is changed, then entries will be created in DBTABPRT r/3 table.
3) based on table name, key (sy-mandt concatenated with other key elements of the table to whcih tabble logging is turned on), change dt (AS4DATE) fields, you can retrieve data from DBTABPRT r/3 table.
4) sort records retrieved by table name, key, date and time fields. The first record will be having the original value for plant status before change.
Note: Some time you maybe getting more than one records with same value specified in point 4. in this situation you have to considar counter field value also.
best way is after reading first record, loop the internal table with the index and compare the current plant status value with dbtab prt records value.
hope this will help.
regards,
sundaramj
‎2006 Nov 20 12:24 AM
Hi,
thanks for ur reply , how can i turn on the table logging , i am using mstae field in mara , i am using 4.6 c .
Regards
Syed
‎2006 Nov 20 12:27 AM
‎2006 Nov 20 12:35 AM
hi ,
i think in the technical setting there is log data changes , if the flag is set , will this work or other settings are required ?
Regards
Syed
‎2006 Nov 20 12:42 AM
‎2006 Nov 20 1:03 AM
Yes sayed.
we have check table logging checl box intechnical settings. This will be done by basis (access key is required to change r/3 table technical settings).
tegards,
sundaramj
‎2006 Nov 20 1:05 AM
you might be able to use an import/export approach to save and restore the initial value. On the first time the exit is entered, ie. when a save variable is initial, set the variable to the value of the field you are dealing with (mara-mstae) and then 'export' it.
eg,
data l_old_status type mara-mstae.
*... retrieve status
IMPORT l_old_status FROM MEMORY ID 'mara-mstae'.
*... if there is already a non-blank one - keep it
CHECK l_old_status IS INITIAL.
*... save status for later use
EXPORT l_old_status FROM mara-mstae TO MEMORY ID 'mara-mstae'.
In your code when you want to restore the mara-mstae:
*... restore original status
IMPORT l_old_status = mara-mstae FROM MEMORY ID 'mara-mstae'.