Auto Purchase Order Posting Problem???

kishi_gkishi_g Member Posts: 162
Hi,
Iam facing one problem with purchase Orders posting. one of our client create the purchase orders and they want to post automatically. I created one Codeunit. i wrote the code below.

PurchHeader.INIT;
PurchLine.INIT;
IF PurchHeader.FIND('-') THEN
REPEAT
PurchHeader.Receive := TRUE;
PurchHeader.Invoice := TRUE;
PurchHeader.MODIFY;
PurchPost.RUN(PurchHeader);
UNTIL PurchHeader.NEXT = 0;

but iam facing one problem. suppose 10 PO's are created. In the 5th PO some Mandatory data was not given. if i run this codeunit 4 PO's will posted but after the 5th PO it was error. then it will not process the next 5 records. now i want if any records contain error it will skip that record and process the next record. it will not stop.

how can i do that????


Thanks & Regards,
kishore...

Comments

  • kinekine Member Posts: 12,562
    PurchHeader.INIT;
    PurchLine.INIT;
    IF PurchHeader.FIND('-') THEN
    REPEAT
      PurchHeader.Receive := TRUE;
      PurchHeader.Invoice := TRUE;
      //PurchHeader.MODIFY; //you do not need to save the record back, you canhave proiblems with DeadLocks on SQL...
      if PurchPost.RUN(PurchHeader) then begin
        //It was OK
      end else begin
        //There were error in this Order...
      end;
    UNTIL PurchHeader.NEXT = 0;
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kishi_gkishi_g Member Posts: 162
    hi Kine,
    Thanks for ur reply. I gave the same code but iam facing the same problem. I gave items must have lot Numbers. I created 3 PO's. first PO i gave lot number, 2nd PO i didnt gave lot and 3rd PO i gave Lot.

    i run this codeunit it will stop in the 2nd record. 3rd record was not posted.

    Lot number or Externall doc number details are mentioned in Codeunit-90.

    how can i do that??

    Thanks & regards,
    kishore...
Sign In or Register to comment.