Re: [Axapta-Knowledge-Village] Re: Changing Units of Measure in AX2009

2010-09-02 Thread visti Sethna
Hi please ensure these are done with great care and will have an impact on
cost and quantity both. Forcefully updating the units of measure thought not
a best practise is possible and i have done the same through this code that
i have given you

On Wed, Aug 25, 2010 at 6:32 AM, george_spl <
george.burr...@solutionpartners.co.nz> wrote:

>
>
> Thank you for this Vishtaspa, I'll see if we can put these instructions to
> good use.
>
> Feedback from Microsoft is that changing Units of Measure, for items with
> open and/or closed transactions, has been blocked in AX2009. Suggestion is
> that we rename item number with wrong Units of Measure, and enter the old
> code as a new item.
>
> I can see the reason for the tightening of the logic here, but clients do
> mourn some lost features - even features which we'd see as being a bit
> loose!
>
> George
>
> --- In 
> Axapta-Knowledge-Village@yahoogroups.com,
> visti Sethna  wrote:
> >
> > static void TEC_UpdateInvent(Args _args)
> >
> > {
> >
> > InventTableModule inventTableModule;
> >
> > inventTable inventTable;
> >
> > ;
> >
> > ttsbegin;
> >
> >
> > select forupdate inventTable where inventTable.ItemId == 'XXX';
> > inventTable.BOMUnitId = 'YYY';
> > // instead of XXX enter item id
> > // instead of YYY enter Unit id
> >
> > inventTable.doUpdate();
> >
> >
> >
> > while select forupdate inventTableModule where inventTableModule.ItemId
> > == 'XXX'
> >
> > {
> > inventTableModule.UnitId = 'YYY';
> > // instead of XXX enter item id
> > // instead of YYY enter Unit id
> >
> > inventTableModule.doUpdate();
> >
> > }
> >
> >
> >
> > ttscommit;
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > }
> >
> >
> > On Tue, Aug 24, 2010 at 6:51 AM, George Burrell <
> > george.burr...@...> wrote:
> >
> > >
> > >
> > > Hello group
> > >
> > >
> > >
> > > In Version 3, and I think Version 4, it was always possible to change a
> > > Unit of Measure for an item, provided that there were no open
> transactions
> > > for the item.
> > >
> > >
> > >
> > > In AX2009, we are finding an obstacle here .. the error message is
> implying
> > > that there are open transactions when there are not.
> > >
> > >
> > >
> > > While this is an unusual thing for a client to be doing, I would still
> like
> > > to know more background if you have any.
> > >
> > > TIA
> > > George
> > >
> > >
> > >
> >
> >
> >
> > --
> >
> > *Thanks and Regards*
>
> >
> > **
> >
> > *Vishtaspa N. Sethna***
> >
> > *AX Functional Consultant**
> >
> > Tectura
> > **Level 8, Vibgyor Towers
> > C-62, G Block,
> > **Bandra Kurla Complex,
> > Bandra (E),
> > Mumbai, Maharashtra, 400051
> > INDIA**
> > Board Tel (+91) 22 **40907152
> > ** (+91) 22 4**0907153***
> >
> > *Fax Number (+91) 22 **40907070***
> >
> > *Mobile: (+91) 9833213532*
> >
> > *Email:
> > vishtaspananu.set...@...<
> https://owa.mytectura.com/owa/redir.aspx?C=c3ca3a2452714ee29cbcc3fbdee85241&URL=mailto%3arajesh.degaonkar%40tectura.com
> >
> > ***
> >
> > *Web:
> > www.tectura.com<
> https://owa.mytectura.com/owa/redir.aspx?C=c3ca3a2452714ee29cbcc3fbdee85241&URL=https%3a%2f%2fowa.mytectura.com%2fexchweb%2fbin%2fredir.asp%3fURL%3dhttp%3a%2f%2fwww.tectura.com%2f
> >
> > ***
> >
> >
> >
> > *Tectura | Your Business. Our Insight. *
>
> >
> > A worldwide provider of business consulting services.
> > www.tectura.com<
> https://owa.mytectura.com/owa/redir.aspx?C=c3ca3a2452714ee29cbcc3fbdee85241&URL=http%3a%2f%2fwww.tectura.com%2f>
>
>
> >
> > [image: Reseller_India_2010]
> >
> > [image: presidentsclubhorizontal_2010]
> >
>
>  
>



-- 

*Thanks and Regards*

**

*Vishtaspa N. Sethna***

*AX Functional Consultant**

Tectura
**Level 8, Vibgyor Towers
C-62, G Block,
**Bandra Kurla Complex,
Bandra (E),
Mumbai, Maharashtra, 400051
INDIA**
Board Tel   (+91) 22 **40907152
**   (+91) 22 4**0907153***

*Fax Number   (+91) 22 **40907070***

*Mobile:  (+91) 9833213532*

*Email:
vishtaspananu.set...@tectura.com
***

*Web:
www.tectura.com
***



*Tectura | Your Business. Our Insight. *

A worldwide provider of business consulting services.
www.tectura.com

[image: Reseller_India_2010]

[image: presidentsclubhorizontal_2010]


Re: [Axapta-Knowledge-Village] delete_from vs loop delete

2010-09-02 Thread Zainal Arifin
Hi Deshpande,

Thanks for the explanation and detail suggestion :)
The delete statement means I'd like to delete current record and all records
related to their parent, so that I used refId and linkRefId.
I've ever separated the delete refid and linkrefid, but it gave me more
locked error, so that I combined it in 1 query.
I'll try accommodate the second option in my behavior :)

Thanks and Regards,
Afin

On Thu, Sep 2, 2010 at 9:57 PM, Harry Deshpande wrote:

>
>
>  You have a problem L I suppose _refId in the first statement and
> _reqTrans.RefId in the second statement is same? (at least for some
> transactions?)
>
>
>
> You have a couple of options:
>
>
>
> 1.   Put the first delete statement in a separate transaction block.
> This has the side-effect that if your process crashes then the records will
> not be rolled back. But with master planning data consistency is not a big
> issue, if at all the process crashes (very rare) then the user will run it
> again any way.
>
> 2.   Create an isDeleted flag on xtrProdBreakDown table and instead of
> delete_from set this flag to true -> in the second statement add one more
> predicate isDeleted = false and then find a suitable place to issue a delete
> statement i.e. delete_from where isDeleted = true.
>
>
>
> Regards
>
>
>
> harry
>
>
>
> *From:* Axapta-Knowledge-Village@yahoogroups.com [mailto:
> axapta-knowledge-vill...@yahoogroups.com] *On Behalf Of *thomas 'znal'
> ramdhan
> *Sent:* Wednesday, September 01, 2010 6:21 PM
>
> *To:* Axapta-Knowledge-Village@yahoogroups.com
> *Subject:* Re: [Axapta-Knowledge-Village] delete_from vs loop delete
>
>
>
>
>
> Hi Deshpande,
>
> This is my code, I insert below code in Tables/ReqTrans/insertFromreqPO
>
> *delete_from xtsProdBreakDown
> where   xtsProdbreakDown.Type == _BreakDownType
>&&  (xtsProdBreakDown.RefId == _refId ||
>  xtsProdBreakDown.LinkRefId == _refId);*
>
> ..
> ...
> 
>
> *select forUpdate * from xtsProdBreakDown
> where   xtsProdBreakDown.RefId == _reqTrans.RefId
>&&  xtsProdBreakDown.ItemId == _reqTrans.ItemId
>&&  xtsProdBreakDown.RAFDate == UsedRAFDate
>&&  xtsProdBreakDown.Shift == xtsShift.Shift
>&&  xtsProdBreakDown.WrkCtrIdMachine ==
> WrkCtrCapResLoop.WrkCtrId;
>
>
> *The meaning of my above code is I like to refresh the xtsProdBreakDown
> table every master planning is generated, so that I need to delete it all
> first, and then regenerate it again.
> The most lock process that I found in SQL activity monitor is in delete
> codes. Do you have any suggestions ?
>
>
>  On Wed, Sep 1, 2010 at 9:55 PM, Harry Deshpande 
> wrote:
>
>
>
> Are u doing anything in the delete method for your customized table? Can
> you post the code? Another way would to find out which statement is getting
> blocked, you will find a lot of information on the net. I had posted some
> info long time back
> http://www.systomatics.com/Blog/010ExpensiveQueries/010_ExpensiveQueries.htmnot
>  sure if this is still valid.
>
>
>
> Regards
>
>
>
> harry
>
>
>
> *From:* Axapta-Knowledge-Village@yahoogroups.com [mailto:
> axapta-knowledge-vill...@yahoogroups.com] *On Behalf Of *thomas 'znal'
> ramdhan
> *Sent:* Wednesday, September 01, 2010 7:43 AM
>
>
> *To:* Axapta-Knowledge-Village@yahoogroups.com
> *Subject:* Re: [Axapta-Knowledge-Village] delete_from vs loop delete
>
>
>
>
>
> Hi Harry,
>
> I didn't delete reqTrans records. It's my own customized table, but the
> process is inside the master planning scheduler.
>
> On Wed, Sep 1, 2010 at 9:31 PM, Harry Deshpande 
> wrote:
>
>
>
> Hi
>
> From your reference to Batch helpers, it looks like you are trying to
> delete master planning records
>
> I further suspect that you are trying to delete reqTrans. Delete_from will
> still give you a lock error since deleting one record of reqTrans triggers
> another delete statement on another record.
>
> Say we have 2 record record no 1 and 2, which are related.
>
> You execute delete_from statement which will
>
> Delete record no 1 and
>
> Delete record no 2
>
> However, when record no 1 is deleted, it creates a delete statement on
> record no 2.
>
> Now delete_from will try to delete record no 2 which is next in sequence
> and you will get the lock error.
>
> You should you skipDataMethods and skipDeleteActions in such scenarios.
> However, you really need to know what you are doing J
>
> Seeing locks in activity monitor does not mean anything. What is the
> problem that you are facing (other than lock error while deleting)?
>
> Regards
>
> harry
>
>
>
> *From:* Axapta-Knowledge-Village@yahoogroups.com [mailto:
> axapta-knowledge-vill...@yahoogroups.com] *On Behalf Of *thomas 'znal'
> ramdhan
> *Sent:* 01 September 2010 10:34
>
>
> *To:* Axapta-Knowledge-Village@yahoogroups.com
>
> *Subject:* Re: [Axapta-Knowledge-Village] delete_from vs loop delete
>
>
>
>
>
> Hi Burtt,
>
> Thanks for brief

RE: [Axapta-Knowledge-Village] delete_from vs loop delete

2010-09-02 Thread Harry Deshpande
You have a problem :( I suppose _refId in the first statement and 
_reqTrans.RefId in the second statement is same? (at least for some 
transactions?)

You have a couple of options:


1.   Put the first delete statement in a separate transaction block. This 
has the side-effect that if your process crashes then the records will not be 
rolled back. But with master planning data consistency is not a big issue, if 
at all the process crashes (very rare) then the user will run it again any way.

2.   Create an isDeleted flag on xtrProdBreakDown table and instead of 
delete_from set this flag to true -> in the second statement add one more 
predicate isDeleted = false and then find a suitable place to issue a delete 
statement i.e. delete_from where isDeleted = true.

Regards

harry

From: Axapta-Knowledge-Village@yahoogroups.com 
[mailto:axapta-knowledge-vill...@yahoogroups.com] On Behalf Of thomas 'znal' 
ramdhan
Sent: Wednesday, September 01, 2010 6:21 PM
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: Re: [Axapta-Knowledge-Village] delete_from vs loop delete



Hi Deshpande,

This is my code, I insert below code in Tables/ReqTrans/insertFromreqPO

delete_from xtsProdBreakDown
where   xtsProdbreakDown.Type == _BreakDownType
   &&  (xtsProdBreakDown.RefId == _refId ||
 xtsProdBreakDown.LinkRefId == _refId);

..
...


select forUpdate * from xtsProdBreakDown
where   xtsProdBreakDown.RefId == _reqTrans.RefId
   &&  xtsProdBreakDown.ItemId == _reqTrans.ItemId
   &&  xtsProdBreakDown.RAFDate == UsedRAFDate
   &&  xtsProdBreakDown.Shift == xtsShift.Shift
   &&  xtsProdBreakDown.WrkCtrIdMachine == WrkCtrCapResLoop.WrkCtrId;


The meaning of my above code is I like to refresh the xtsProdBreakDown table 
every master planning is generated, so that I need to delete it all first, and 
then regenerate it again.
The most lock process that I found in SQL activity monitor is in delete codes. 
Do you have any suggestions ?


On Wed, Sep 1, 2010 at 9:55 PM, Harry Deshpande 
mailto:har...@microsoft.com>> wrote:

Are u doing anything in the delete method for your customized table? Can you 
post the code? Another way would to find out which statement is getting 
blocked, you will find a lot of information on the net. I had posted some info 
long time back 
http://www.systomatics.com/Blog/010ExpensiveQueries/010_ExpensiveQueries.htm 
not sure if this is still valid.

Regards

harry

From: 
Axapta-Knowledge-Village@yahoogroups.com
 
[mailto:Axapta-Knowledge-Village@yahoogroups.com]
 On Behalf Of thomas 'znal' ramdhan
Sent: Wednesday, September 01, 2010 7:43 AM

To: 
Axapta-Knowledge-Village@yahoogroups.com
Subject: Re: [Axapta-Knowledge-Village] delete_from vs loop delete



Hi Harry,

I didn't delete reqTrans records. It's my own customized table, but the process 
is inside the master planning scheduler.
On Wed, Sep 1, 2010 at 9:31 PM, Harry Deshpande 
mailto:har...@microsoft.com>> wrote:

Hi
>From your reference to Batch helpers, it looks like you are trying to delete 
>master planning records
I further suspect that you are trying to delete reqTrans. Delete_from will 
still give you a lock error since deleting one record of reqTrans triggers 
another delete statement on another record.
Say we have 2 record record no 1 and 2, which are related.
You execute delete_from statement which will
Delete record no 1 and
Delete record no 2
However, when record no 1 is deleted, it creates a delete statement on record 
no 2.
Now delete_from will try to delete record no 2 which is next in sequence and 
you will get the lock error.
You should you skipDataMethods and skipDeleteActions in such scenarios. 
However, you really need to know what you are doing :)
Seeing locks in activity monitor does not mean anything. What is the problem 
that you are facing (other than lock error while deleting)?
Regards
harry

From: 
Axapta-Knowledge-Village@yahoogroups.com
 
[mailto:Axapta-Knowledge-Village@yahoogroups.com]
 On Behalf Of thomas 'znal' ramdhan
Sent: 01 September 2010 10:34

To: 
Axapta-Knowledge-Village@yahoogroups.com
Subject: Re: [Axapta-Knowledge-Village] delete_from vs loop delete



Hi Burtt,

Thanks for brief explanation :)
I have declare all suitable index for my table, but sometimes still returns me 
lock error. If I use batch helpers, for sure I get more lock issue in activity 
monitor. If this is the case, is loop delete the righteous solution ?

Thanks and Regards,
Afin
On Wed, Sep 1, 2010 at 4:07 PM, Malcolm Burtt 
mailto:malcolm.bu...@touchstone.co.uk>> wrote:

Hi

The difference between the two approaches is in