Wednesday 17 July 2019

Nav 365 C/AL create a purchase order

counter :=0;

PurchHeader.INIT;
//PurchHeader.INIT();
PurchHeader."Document Type":= PurchHeader."Document Type"::Order;
PurchHeader."Vendor Invoice No.":='123';
PurchHeader.VALIDATE("Posting Date",TODAY);
PurchHeader.VALIDATE("Buy-from Vendor No.",'10000');

PurchHeader.INSERT(TRUE);
COMMIT;

CurrPage.SETSELECTIONFILTER(SalesInvoiceLine);

 REPEAT
   PurchaseLine.INIT();
   PurchaseLine.CLEARMARKS;
   MESSAGE(FORMAT(PurchHeader."No."));
   counter := counter+1;
  PurchaseLine."Line No.":=counter;
  PurchaseLine."Document Type":=PurchHeader."Document Type";
  PurchaseLine."Document No.":=PurchHeader."No.";
  PurchaseLine.VALIDATE(Type,PurchaseLine.Type::Item);
  PurchaseLine.VALIDATE("No.",'70062');
  PurchaseLine.VALIDATE("Direct Unit Cost",90);
  //PurchaseLine.Quantity
  PurchaseLine.VALIDATE(Quantity,10);
  PurchaseLine.INSERT(TRUE);
  COMMIT;
 UNTIL SalesInvoiceLine.NEXT = 0;

No comments:

Post a Comment