Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

How to create a Reservation Entry using C/SIDE code?

Posted on by 543

Hi experts,

I'm using NAV 2015 and have created a purchase table with some purchase lines.

Now I need to register one or more Serial numbers and/or Lot numbers regarding one of the lines. How do I do that using C/SIDE code?

I have tried this, but it doesn't create anything:

// I have found the purchLine
doFullReserve := TRUE;
reservationManagement.SetPurchLine(purchLine);
reservationManagement.AutoReserve(doFullReserve, purchLine.Description, WORKDATE, purchLine."Outstanding Quantity", purchLine."Outstanding Qty. (Base)");

I think AutoReserve() cannot find my purchHeader.

It would be really great if someone can give an example where more Serial numbers or Lot numbers can be saved to the same purchase line.

  • Morten Steengaard Profile Picture
    Morten Steengaard 543 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hi Teddy,

    Thank you very much for your help. It is great.

    Best regards,

    Morten

  • Verified answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hi Morten,

    You don't need to follow it. The reservation entry is just there to put the serial number and lot number. If you don't need anything, just leave it blank. It could be as simple as:

    TempReservEntry.Init();

    TempReservEntry."Entry No." := 1;

    TempReservEntry."Lot No." := 'ABC';

    TempReservEntry.Quantity := 1;

    TempReservEntry."Expiration Date := Today();

    TempReservEntry.Insert();

    This is also based on BC, not older NAV. So the parameter may not be the same.

  • Morten Steengaard Profile Picture
    Morten Steengaard 543 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hi Teddy,

    The first time, you mention TempReservEntry in your code, it just uses the field "Expiration Date". Where is that field assigned?

    It is the same, when you call CreateReservEntryFor. You uses TempReservEntry, but never find it or assign values to it.

  • Suggested answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    It's a temporary record called Reservation Entry.

    TempReservEntry: Record "Reservation Entry" temporary;

  • Morten Steengaard Profile Picture
    Morten Steengaard 543 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hi Teddy,

    Thank you for your reply.

    In your code, there are a few things, I don't understand.

    I guess that "TempReservEntry" is a temporary version of the Reservation Entry table. But I don't have that record and in the "SetDates" function, I must use the field TempReservEntry."Expiration Date". And I use fields from the same record later also.

    How do I find/create the TempReservEntry before I use the code, you have given me?

    Best regards,

    Morten

  • Morten Steengaard Profile Picture
    Morten Steengaard 543 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hi Andy,

    Thank you.

    Best regards,

    Morten

  • Suggested answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: How to create a Reservation Entry using C/SIDE code?

    This is an example for Business Central, but you can modify it for NAV 2015.

    CreateReservEntry: Codeunit "Create Reserv. Entry";

    with PurchLine do begin

        CreateReservEntry.SetDates(0D, TempReservEntry."Expiration Date");

        CreateReservEntry.CreateReservEntryFor(

                         Database::"Purchase Line", "Document Type",

                         "Document No.", '', 0, "Line No.", "Qty. per Unit of Measure",

                         TempReservEntry.Quantity, TempReservEntry.Quantity * "Qty. per Unit of Measure", TempReservEntry);

        CreateReservEntry.CreateEntry(

                         "No.", "Variant Code", "Location Code", '', "Expected Receipt Date", 0D, 0, ReservStatus::Surplus);

    end;

  • Suggested answer
    Andy Sather Profile Picture
    Andy Sather on at
    RE: How to create a Reservation Entry using C/SIDE code?

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans