Update statement in job

Hi

I have SQL updates which has to be written in X++ .

--Update Inventory Item Name ------------------------------------------------------------------

Update #P0000 set #P0000.Txt = Name

from #P0000, InventTable, EcoResProductTranslation ERPT where

InventTable.Product = ERPT.Product and

#P0000.EmplItemId = InventTable.ItemId and InventTable.DataAreaId = @Entity and

ProjTransType = 4

--Update Employee Name ------------------------------------------------------------------------

Update #P0000 set #P0000.Txt = HWCD.Name, EmplItemId = PersonnelNumber

from #P0000, HcmWorkerCubeDimension HWCD where

#P0000.Worker = HWCD.RecId and --HWCD.DataAreaId = @Entity and

ProjTransType = 2

I wrote a job as follows:

while select * from _ecoresproductranslation join product from _inventtable

join EmplItemId from caeprojtransposting

where _ecoresproductranslation.Product == _inventtable.Product && _inventtable.ItemId ==

 caeprojtransposting.EmplItemId && caeprojtransposting.ProjTransType == 4

{

while select forupdate caeprojtransposting join ItemId from _inventtable where _inventtable.ItemId ==

 caeprojtransposting.EmplItemId && caeprojtransposting.ProjTransType == 4 && caeprojtransposting.Txt ==''

{

ttsBegin;

caeprojtransposting.Txt = _ecoresproductranslation.Name;

caeprojtransposting.update();

ttsCommit;

}

}

//Update Employee Name

ttsBegin;

while select forupdate caeprojtransposting join RecId from _HcmWorkerCubeDimension where _HcmWorkerCubeDimension.RecId ==

caeprojtransposting.Worker && caeprojtransposting.Txt=='' && caeprojtransposting.Worker != 0 && caeprojtransposting.ProjTransType == 2

{


caeprojtransposting.Txt = _HcmWorkerCubeDimension.Name;

caeprojtransposting.EmplItemId = _HcmWorkerCubeDimension.PersonnelNumber;

caeprojtransposting.update();


}

ttsCommit


}

First update works but the second update doesn't works. I am not sure whether the above code is correct.;  

Thanks

 

Related
Recommended