04-22-2008 4:50 PM
Hi All,
I have a Z table, which stores PO number, Request Delivery date, condition values and Payer value from vbak and vbap table, when ever some fields in vbak or vbap table are changed using the tcode VA02, the same should be reflected in my Z table as well and date and time in the Z table should also be changed accordingly.
Please be aware that i am using change pointers (CDHDR and CDPOS, to find the required fields changed, not all) and my Z table contains only PO number, Request Delivery date, condition values and the payer fields, when ever the above fields are changed then only my Z table time should be changed with the new values and the old value are stored in other fields in the same Z table.
This is an urgent requirement.
Regards,
Venu.
04-23-2008 5:19 AM
Hi,
You must be having custom from where the ztable is upadated. You can have conditon over there. You can read the old values in one internal table and compare it with the new one. If its changed then update the fields accordingly.
REWARD IF USEFUL
04-23-2008 5:30 AM
Hi Venu,
Write your code to update the Ztable in userexit_save_document in a function module with update task in the include MV45AFZZ(se38)
You can use different logics to compare if the values in va02 were changed like we have the sales order number...so do a select from VBAK,VBAP into int_vbak,it_vbap and compare it with internal tables XVBAK,XBAP(these contains the values to be saved if any changes were made or not) in userexit_save_document like
if sy-ucomm = VA02.
if xvbap[ ] = int_vbap[ ].
else.
*call fxn module in update task and write code inside this function module to update the required fields in ztable
call function 'ZXXX' in update task
importing/exporting....
endif.
the purpose of writing it in update task is that only if a database commit occurs then only your ztable will update so it will prevent updation if there are any errors in standard tcode VA02...also note that the same exit is used by va01/02/03/41/42/43...pls code accordingly
Please note that things like text which are done usting read_text/save_text cannot be available from tables XVBAK/VBAK/VBAP/XVBAP..if you need to check if user has changed any text for header or item then a differtent logic must be used
Pls check and revert
Reward if helpful
Regards
Byju
04-23-2008 10:40 AM
Hi Byju,
When i call the FM with update task as below, the new sales document is not saved in my Z table,
call function 'ZXXX' in update task
importing/exporting....
endif.
but when i call my FM without update task then it is saving the record what could be the problem.
Thanks,
Venu.
04-23-2008 11:14 AM
Hi Venu,
Firstly there may not be a database commit...
imagine you took VA02 and did not change anything but saved it..then since no changes are recognised there may not be a database update and hence there will be no database commit and hence the function module in update task will not get triggered
if you write code outside the update task..everytime user press save ..irrespective of any change happened or not the update will happen and your code will trigger to update the database table
You test by doing the above case..change nothing..save it and see what happens with normal function module and function module in update task
Then change something and see what happens with both
Pls check and revert
Reward if helpful
Regards
Byju
04-23-2008 2:03 PM
Hi Byju,
Even when i create a sales document with VA01 and my FM with update task is not getting executed, i have even kept a breakpoint, but still it stopped there but did not go inside the FM.
Regards,
Venu.