[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Problem with InventTrans updating

Phan Trí Hùng

12/12/2005 11:21:00 AM

Hi everyone!

I'm trying to update field "Qty" in InventTrans table through X++ every time
I modify value in salesLine table. But it throws an error: "The reocord
already exists in....". I included my sample code for your examination:

ttsbegin;
select forupdate firstonly Qty
from inventTrans
where inventTrans.TransRefId == sca_ShipTable.ReleaseSalesId &&
inventTrans.ItemId == this.ShipItem;

inventTrans.Qty = -1 * salesQty;
inventTrans.update();
ttscommit;

Can anyone helps me?

Thanks in advance.
3 Answers

michael

12/12/2005 6:41:00 PM

0

I would think its because you only select the field Qty, but updating the
whole record. Try doing a select * on it

"Phan Trí Hùng" wrote:

> Hi everyone!
>
> I'm trying to update field "Qty" in InventTrans table through X++ every time
> I modify value in salesLine table. But it throws an error: "The reocord
> already exists in....". I included my sample code for your examination:
>
> ttsbegin;
> select forupdate firstonly Qty
> from inventTrans
> where inventTrans.TransRefId == sca_ShipTable.ReleaseSalesId &&
> inventTrans.ItemId == this.ShipItem;
>
> inventTrans.Qty = -1 * salesQty;
> inventTrans.update();
> ttscommit;
>
> Can anyone helps me?
>
> Thanks in advance.

Phan Trí Hùng

12/13/2005 1:08:00 AM

0

Thanks Michael, it works correctly.

"Michael" wrote:

> I would think its because you only select the field Qty, but updating the
> whole record. Try doing a select * on it
>
> "Phan Trí Hùng" wrote:
>
> > Hi everyone!
> >
> > I'm trying to update field "Qty" in InventTrans table through X++ every time
> > I modify value in salesLine table. But it throws an error: "The reocord
> > already exists in....". I included my sample code for your examination:
> >
> > ttsbegin;
> > select forupdate firstonly Qty
> > from inventTrans
> > where inventTrans.TransRefId == sca_ShipTable.ReleaseSalesId &&
> > inventTrans.ItemId == this.ShipItem;
> >
> > inventTrans.Qty = -1 * salesQty;
> > inventTrans.update();
> > ttscommit;
> >
> > Can anyone helps me?
> >
> > Thanks in advance.

Mike Frank

12/15/2005 3:45:00 PM

0

You should not directly update InventTrans like someone pointed out to you in your other post. There
sure should be some appropriate Axapta Framework class for your task.