‎2008 Jul 21 1:21 PM
Hi Gurus,
With following Code some record of RESB Table is being updated but some are not be updated. Could any one tell me Why?
data idx type sy-tabix.
check sy-tcode eq 'MB21'.
loop at ti_resb_new.
UPDATE resb SET sbter = sy-datum
bdztp = sy-uzeit
WHERE rsnum EQ ti_resb_new-rsnum AND
rspos EQ ti_resb_new-rspos AND
bdart eq 'MR'.
IF sy-subrc NE 0.
MESSAGE a000(zram) WITH 'Update failed'.
ENDIF.
endloop.
Regards
\[removed by moderator\]
Rajesh
Edited by: Jan Stallkamp on Jul 21, 2008 2:35 PM
‎2008 Jul 21 1:28 PM
hiiii
i dont find any thing wrong in your update query..you check with records..and check with exact time as you have given there as sy-uzeit..so little bit difference in time will not satisfy condition and updation will not be done ..otherwise code is fine..
regards
twinkal
‎2008 Jul 21 1:29 PM
Hi ,
RESB has RSNUM RSPOS RSART as primary keys..
But your update statement has only RSNUM and RSPOS . Include RSART in u r update statement and check,.
Update statement fails because either no line could be selected or the change would have generated lines with primary keys that already existed .
Regards,
Sachin M M
‎2008 Jul 21 1:45 PM
You really should NOT update standard SAP tables directly like this. You should find a BAPI or if you can't use a BDC to update the data via a transaction. It is very bad practice to directly update standard tables - if the data becomes corrupt because of incorrect coding (and you are already having problems getting your update to work correctly) potentially your SAP system can get very broken.
‎2008 Jul 22 9:56 AM
Yes it known to me that it is a bad practice. But thing is that I need to do this using update only. I am using this coding in a user exit:MBCF0007 . This exit is being used in transaction MB21. When user create a reservation mannualy then this exit will be called by transaction MB21. and then I update current RESB entry through this method.
Regards
rajesh
‎2008 Jul 22 10:15 AM
Rajesh,
It's not just bad practice - you simply shouldn't do it! Why do you need to do it via update only? There are usually alternate ways to achieve something - why not give us some more information about exactly what you are trying to do and maybe someone will have an alternative solution that means you won't need to use the direct update.
For what it's worth, based on a really quick look... I'm not sure why you are updating the RESB table directly in the user exit. The function module EXIT_SAPMM07R_001 is called for the user exit and drops into include program zxmbcu08. The function module has the parameters TI_RESB_NEW and TI_RESB_OLD. If you want to adjust values against a RESB entry you should modify the internal table TI_RESB_NEW to have your data. Then the transaction will continue as normal and save the entries along with your revised data.
By trying to update directly to the RESB table you are interupting the logic flow through the transaction - the transaction will perform it's own updates and commits later in the logic.
Does that make sense and help?
Gareth.
‎2008 Jul 22 11:24 AM
I have modified the both the internal table( TI_RESB_NEW and TI_RESB_OLD) but result as i expected could not be achieved. I explain my problem as :
A user create reservation using t code MB21 manually.. With manual method, MB21 transaction does not add current date(SBTER) and time(BDZTP) of RESB Table. So to add current date and time I used this USER EXIT. This USER EXIT is called by MB21 after saving data in RESB.
Could you suggest any other solution to update date and time in these fields.
Regards
rajesh
‎2008 Jul 22 11:32 AM
Hi,
You don't need to update TI_RESB_OLD, just TI_RESB_NEW. In the user exit, you need to loop at TI_RESB_NEW, update the two fields and then modify the internal table.
Based on what you are saying though, you may need to find a different user exit. The one you are using is called after the RESB entry has been saved - I think you need to find a different user exit or maybe an enhancement point or BADI within the MB21 transaction that allows you to change the date before it is saved to the database. I don't know of one specifically - maybe try searching.