‎2010 Jan 13 7:52 AM
Hi all,
I want to restrict the user to enter the duplicate Purchase Items. Actually the end user fills the details for purchase items and after clicking save button, the data goes and sit in the ztable. If ztable already contains some purchase items and the end user is giving same purchase order to save in the ztable, it should restrict. Since ebelp (purch item) is the key field in ztable.
For this to achieve, iam looping the internal table and checking the condition. if itab-purchitem equals ztable-purchitem, iam displaying information message.
but for checking each purchitem of the ztable, should we should loop ztable also?
please provide your suggestions.
Thanking you,
Regards
Murali Krishna T
‎2010 Jan 20 10:34 AM
Please use proper subjects for your posts.
No need of loop.
Mark the field as primary key in your ztable.
While inserting the data intot your table use.
MODIFY DBTABLE from itab. " It updates the existing entries and inserts new entries.
‎2010 Jan 13 7:59 AM
Hi,
Where does the user enter the purchase order? Is it in a screen designed in SE51? Then you can select the field as dictionary field i.e. refer the field in the screen with the purchase order field in the table. You use INSERT insted of UPDATE then it will automatically check for duplicate enrty.
Thanks,
Sri.
‎2010 Jan 13 9:27 AM
Hi Sri,
Purchase order is from screen field from screen painter. After Checking for Duplicate Entry, it is going to short dump. So to avoid this, iam writing information message when the duplicate record entry takes place.
to check for duplicate records, we need to loop the internal table from where the user enters the purchase items.
In ztable there may be other purchase items. Here purch item (Ebelp) is key field. so after looping internal table, should we loop ztable also?
thanks
Murali
‎2010 Jan 13 10:11 AM
Hi,
In PAI under the save button write the following code.
SELECT SINGLE purchase_order
FROM ztable
INTO lv_purchase_order
WHERE purchase_order = ztable-purchase_order.
IF sy-subrc EQ 0.
MESSAGE 'purchase order already exists' type 'E'.
ENDIF.Thanks,
Sri.
‎2010 Jan 13 12:16 PM
Dear Murali,
Did you include purchase order no as a key field in your Ztable ?
If it is not yet done then do it.
My 2nd question : Is it a Z development for saving purchase order item details ?? or you are using standard transaction(ME21N / ME22N). Where do you get the dump ?
As per my understanding if you use INSERT statement then it might give you a short dump. Rather using INSERT statement use
MODIFY with key fields.
Thanks
Edited by: CONTACTSANKU on Jan 13, 2010 5:48 PM
‎2010 Jan 20 10:29 AM
Hi,
In PAI Event,
Chain
itab-po. no,
endchain.
module----<module name>
under this module
select po. no from ztable whnere po.no = itab-po,no,
if sy-subec = 0.
message ''purchase order already exists' type "E".
endif.
try to take po.no field, which u have put in screen, from dictionary.
This will help.
‎2010 Jan 20 10:34 AM
Please use proper subjects for your posts.
No need of loop.
Mark the field as primary key in your ztable.
While inserting the data intot your table use.
MODIFY DBTABLE from itab. " It updates the existing entries and inserts new entries.