You can not post lines ... Strange error

kamranshehzadkamranshehzad Member Posts: 165
Hi All,

I am trying to do the following
1- Modify line items on a PO ( working)
2- Converting PO to PR (work when I manually set the quantity) and gives the following errorr when i set it through modify line items on a PO method and process it.

Microsoft Dynamics NAV Classic
You cannot post these lines because you have not entered a quantity on one or more of the lines.
OK

When I modify the line item quantity manually then posting to PR works.

PS: I know quantity etc are decimal in system. I am using them as integer for testing.

Code follows.
ModifyPurchaseLine(VAR DocumentNo : Text[50];VAR DocumentType : Text[30];VAR ItemNo : Text[30];VAR OrderedQty : Integer;VAR QtyToReceiv

      IF DocumentType = 'Order' THEN BEGIN
        // record initialisation
        recPurchaseRecord.INIT;
        recPurchaseLine.INIT;

        // filtering header record
        recPurchaseRecord.SETFILTER(recPurchaseRecord."No.",DocumentNo);
        recPurchaseRecord.SETFILTER(recPurchaseRecord."Document Type", 'Order');

        // filtering line items
        recPurchaseLine.SETFILTER(recPurchaseLine."Document No.",DocumentNo);
        recPurchaseLine.SETFILTER(recPurchaseLine."Document Type",  'Order');
        recPurchaseLine.SETFILTER(recPurchaseLine."Line No.",'<>0');

        IF recPurchaseLine.FINDSET THEN BEGIN
         // if rows exists
         recPurchaseLine.SETFILTER(recPurchaseLine."No.", ItemNo); //filter the item no
         IF(recPurchaseLine.COUNT>0) THEN BEGIN
           REPEAT
             // calculating the quantity that can be received
             QtyThatCanBeReceived := recPurchaseLine.Quantity - recPurchaseLine."Quantity Received";
             // new received qty , should be eixsting qty to recieve and new incoming qty
             NewReceivedQty := recPurchaseLine."Qty. to Receive" + QtyToReceive;

             IF QtyThatCanBeReceived >=  NewReceivedQty THEN BEGIN
               recPurchaseLine."Qty. to Receive" := NewReceivedQty; // set new qty
               recPurchaseLine.MODIFY;                   // modify record set.
               //Commit;
               clear( recPurchaseLine);
               clear( recPurchaseRecord);
              EXIT;
             END;

             // clearing the calculated fields for line
             QtyThatCanBeReceived := 0;
             NewReceivedQty := 0;

           UNTIL recPurchaseLine.NEXT = 0;
         END;
           END ELSE BEGIN
               MESSAGE('NOT IMPLEMENTED');
       END;
      END;




ProcessPoToReceipt(VAR DocumentNo : Text[50];VAR DocumentType : Text[30]) status : Boolean
         IF DocumentType = 'Order' THEN BEGIN

            recPurchaseRecord.SETFILTER("No.",DocumentNo);
            recPurchaseRecord.SETFILTER("Document Type",DocumentType);
            recPurchaseRecord.INIT;

           IF recPurchaseRecord.FIND('-') THEN  BEGIN
             recPurchaseRecord.Receive := TRUE;   // SETTING PROPERTY TO RECEIVE
              IF cuPurchPost.RUN(recPurchaseRecord) THEN BEGIN
                message('processed');
                status := TRUE;
              END ELSE BEGIN
                message('not processed');
                status := FALSE;
              END;
           END;
         END;

KS

Answers

Sign In or Register to comment.