Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Counting

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

In the code below I need to Count the values of the Shipment line and Document Number. I then need to Look at the shipment Line Quantity then Count the Quantity in the batch. 

I'm thinking I then need to create 3 variables. 

3) intQtyBatch

2)intShipmentLine

1) intAssignQty. 

I then essentially need to state IF (1 + 3) > 2 

Error

IF 3 < 2 

ok... 

Any ideas on how to write this? Please ask if you need any other information 

3051.17.PNG

Here's how I've started although I'm assuming it's wrong

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    Ok ill start again. Im trying to basically say if the Current Batch "WhseSerialBatchList, Quantity' Is <> the quantity on the Posted Sales Shipment Line Quantity then produce an error.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    Try this.

    intShipmentLine := recSerialNoInformation.Quantity; //take the quantity

  • Suggested answer
    RE: Counting

    Hi,

    intShipmentLine := recSerialNoInformation."Shipment Line No",Quantity; is not accepted in C/AL.

    intShipmentLine := recSerialNoInformation.Quantity; is legal. But what is the table referred by recSerialNoInformation?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    6661.19.PNG

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    Try this code and let us know, if you face any specific error with this code.

    recWhseSerialBatchHeader.RESET;

    recWhseSerialBatchHeader.SETFILTER(Quantity, '>%1',0);

    frmWhseSerialBatchList.SETTABLEVIEW(recWhseSerialBatchHeader);

    frmWhseSerialBatchList.LOOKUPMODE(TRUE);

    IF frmWhseSerialBatchList.RUNMODAL = ACTION::LookupOK THEN BEGIN

     frmWhseSerialBatchList.GETRECORD(recWhseSerialBatchHeader);

     recSerialNoInformation.RESET;

     recSerialNoInformation.SETRANGE("Batch No.", recWhseSerialBatchHeader."No.");

     recSerialNoInformation.RESET;

     recSerialNoInformation3 := recSerialNoInformation;

     recSerialNoInformation3.SETRANGE("Shipment No.", recSalesShipmentLine."Document No.");

     recSerialNoInformation3.SETRANGE("Shipment Line No.", recSalesShipmentLine."Line No.");

     intQtyBatch := recWhseSerialBatchHeader.Quantity;      //This should  take the Quantity from the Whse Serial Batch List

     intShipmentLine := recSerialNoInformation."Shipment Line No",Quantity; //take the quantity from the Posted Sales Shipment

     intQtyAssign := recSalesShipmentLine.Quantity; //take the quantity from the Serial Number Information List

     recWhseSerialBatchHeader.Quantity.COUNT    //This should count the quanity

     recSalesShipmentLine.Qantity.COUNT  //This Should count the quantity

     IF recSerialNoInformation.COUNT <> recSalesShipmentLine.Quantity THEN

       IF (intAssignBatch + intQtyBatch) > intShipmentLine THEN

         ERROR('Error');                                                      //produce error message

     IF intQtyAssign < intShipmentLine THEN

       IF CONFIRM('Are you sure?',FALSE) = FALSE THEN

         EXIT;

      BEGIN

       IF recSerialNoInformation.FINDSET(FALSE,FALSE) THEN

         REPEAT

           recSerialNoInformation2 := recSerialNoInformation;

           recSerialNoInformation2."Shipment No." := recSalesShipmentLine."Document No.";

           recSerialNoInformation2."Shipment Line No." := recSalesShipmentLine."Line No.";

           recSerialNoInformation2."Batch No." := '';

           recSerialNoInformation2.MODIFY;

         UNTIL recSerialNoInformation.NEXT = 0;

         recWhseSerialBatchHeader.CALCFIELDS(Quantity);

         IF recWhseSerialBatchHeader.Quantity = 0 THEN;

           recWhseSerialBatchHeader.DELETE;

      END;

    END;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    3348.18.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    This is my code so far. I've commented what I want tot ry and achieve on the lines im having difficulty with.

    recWhseSerialBatchHeader.RESET;

    recWhseSerialBatchHeader.SETFILTER(Quantity, '>%1',0);

    frmWhseSerialBatchList.SETTABLEVIEW(recWhseSerialBatchHeader);

    frmWhseSerialBatchList.LOOKUPMODE(TRUE);

    IF frmWhseSerialBatchList.RUNMODAL = ACTION::LookupOK THEN BEGIN

     frmWhseSerialBatchList.GETRECORD(recWhseSerialBatchHeader);

     recSerialNoInformation.RESET;

     recSerialNoInformation.SETRANGE("Batch No.", recWhseSerialBatchHeader."No.");

     recSerialNoInformation.RESET;

     recSerialNoInformation3 := recSerialNoInformation;

     recSerialNoInformation3.SETRANGE("Shipment No.", recSalesShipmentLine."Document No.");

     recSerialNoInformation3.SETRANGE("Shipment Line No.", recSalesShipmentLine."Line No.");

     intQtyBatch := recWhseSerialBatchHeader.Quantity;      //This should  take the Quantity from the Whse Serial Batch List

     intShipmentLine := recSerialNoInformation."Shipment Line No",Quantity; //take the quantity from the Posted Sales Shipment

     intQtyAssign := recSalesShipmentLine.Quantity; //take the quantity from the Serial Number Information List

     recWhseSerialBatchHeader.Quantity.COUNT    //This should count the quanity

     recSalesShipmentLine.Qantity.COUNT  //This Should count the quantity

    IF recSerialNoInformation.COUNT <> recSalesShipmentLine.Quantity THEN

     IF (intAssignBatch + intQtyBatch) > intShipmentLine THEN

     ERROR                                                      //produce error mmessage

     IF intQtyAssign < intShipmentLine THEN

                                                                 //contineue code

       IF CONFIRM('Are you sure?',FALSE) = FALSE THEN

     EXIT;

      BEGIN

       IF recSerialNoInformation.FINDSET(FALSE,FALSE) THEN REPEAT

         recSerialNoInformation2 := recSerialNoInformation;

         recSerialNoInformation2."Shipment No." := recSalesShipmentLine."Document No.";

         recSerialNoInformation2."Shipment Line No." := recSalesShipmentLine."Line No.";

         recSerialNoInformation2."Batch No." := '';

         recSerialNoInformation2.MODIFY;

         UNTIL recSerialNoInformation.NEXT = 0;

         recWhseSerialBatchHeader.CALCFIELDS(Quantity);

         IF recWhseSerialBatchHeader.Quantity = 0 THEN;

             recWhseSerialBatchHeader.DELETE;

      END;

    END;

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    Pl. try to write some code based on the logic mentioned above.

    If you face any issue / error within same, copy your code here so that we can help you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    IntQtyBatch should take the Quantity from the Whse Serial Batch List

    IntShipmentLine is to take the quantity from the Posted Sales Shipment

    IntAssignQty is to take the quantity from the Serial Number Information List

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting

    Pl. write the logic of all the three fields and related conditions. If you face any error, we can help.

    As of now, we are not able to understand the logic of these fields.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans