X++ code for Project Item Requirement posting in Ax 2012

Below is the X++ code for Project Item Requirement posting in Ax 2012.

  SalesFormLetter salesFormLetter;  
   salesTable Salestablelocal;  
   str 200 msg;  
   if(this.parmSalesid())  
   {  
     changeCompany(_legalentity)  
     {  
       select Salestablelocal  
         where Salestablelocal.Salesid ==this.parmSalesid()  
           && Salestablelocal.salestype==SalesType::ItemReq  
           && Salestablelocal.SalesStatus==SalesStatus::Backorder;  
       if(Salestablelocal)  
       {  
         ttsBegin;  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);  
           salesFormLetter.update(Salestablelocal);  
           salesFormLetter = SalesFormLetter::construct(DocumentStatus::ProjectPackingSlip);  
           salesFormLetter.update(Salestablelocal);  
         ttsCommit;  
           msg = "Item Requirement with Sales order id : " + this.parmSalesid() + " Posted ";  
       }  
       else  
       {  
           msg = "Item Requirement with Sales order id: "+ this.parmSalesid() + " already posted";  
       }  
     }  
   }  
   else  
   {  
      msg = "Item Requirement with provided Sales order id does not exists";  
   }  

No comments: