Enter serial no. through code

new_to_calnew_to_cal Member Posts: 21
Hi folks,

I would like to enter given serial numbers for a purchase order through code. Could anybody tell me, how this is done?

Answers

  • vijay_gvijay_g Member Posts: 884
    Then insert the reservation entry by code with required field detail. You can also search the forum for same.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    I believe ara3n posted some code on here that works wonderfully. Search!
  • ara3nara3n Member Posts: 9,255
    Here is an example
    SalesLine.get(SalesLine."Document type"::Order,'1532',20000);
    SalesHeader.get(SalesHeader."Document type"::Order,'1532');
    
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.CreateReservEntryFor(
      DATABASE::"Sales Line",
      SalesLine."Document type",
      SalesLine."document No.",
      '',
      0,
      SalesLine."Line No.",
      SalesLine."Qty. per Unit of Measure",
      1,
      'YOURSERIALNO',
      '');
    
    CreateReservEntry.CreateEntry(
      SalesLine."No.",
      SalesLine."Variant Code",
      SalesLine."Location Code",
      SalesLine.Description,
      SalesHeader."Posting date",
      SalesHeader."Document Date",
      0,
      2);
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ara3nara3n Member Posts: 9,255
    CreateReservEntry is cu Create Reserv. Entry
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • new_to_calnew_to_cal Member Posts: 21
    Amongst others I found this post. The Code
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.CreateReservEntryFor(
      DATABASE::"Sales Line",
      SalesLine."Document Type",
      SalesLine."Document No.",
      '',
      0,
      SalesLine."Line No.",
      SalesLine."Qty. per Unit of Measure",
      ABS(SalesLine.Quantity),
      'RANDOMSNR',
      '');
    
    CreateReservEntry.CreateEntry(
      SalesLine."No.",
      '',
      SalesLine."Location Code",
      SalesLine.Description,
      0D,
      SalesLine."Shipment Date",
      0,
      3);
    
    does create a reservation entry with the correct serial no. but the reservation status is Prospect instead of Reservation. Is that correct?
  • gerrykistlergerrykistler Member Posts: 149
    It should be Surplus. If you manually create a Purchase Order for a Serial Tracked item and manually create the tracking line - you can then go to the Reservation Entry table and see how the reservation entry should be populated.
    Gerry Kistler
    KCP Consultores
  • new_to_calnew_to_cal Member Posts: 21
    It should be Surplus. If you manually create a Purchase Order for a Serial Tracked item and manually create the tracking line - you can then go to the Reservation Entry table and see how the reservation entry should be populated.

    I don't want to be seen near a Purchase Order :P
    I was talking about Sales Orders!
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    new_to_cal wrote:
    I was talking about Sales Orders!
    Reread your first posting.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • gerrykistlergerrykistler Member Posts: 149
    new_to_cal wrote:
    It should be Surplus. If you manually create a Purchase Order for a Serial Tracked item and manually create the tracking line - you can then go to the Reservation Entry table and see how the reservation entry should be populated.

    I don't want to be seen near a Purchase Order :P
    I was talking about Sales Orders!

    It is the same for Sales Orders as it is for Purchase Orders - the only difference is the sign on the quantity. Just take my response above and replace Purchase with Sales.
    Gerry Kistler
    KCP Consultores
  • vijay_gvijay_g Member Posts: 884
    It is the same for Sales Orders as it is for Purchase Orders - the only difference is the sign on the quantity. Just take my response above and replace Purchase with Sales.

    what about "Source type" and Positive field? both are also differ for sale/purchase.
  • dansdans Member Posts: 148
    vijay_g wrote:
    what about "Source type" and Positive field? both are also differ for sale/purchase.

    there should be no problem. the codeunit will handle it.
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • ara3nara3n Member Posts: 9,255
    new_to_cal wrote:
    Amongst others I found this post. The Code
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.CreateReservEntryFor(
      DATABASE::"Sales Line",
      SalesLine."Document Type",
      SalesLine."Document No.",
      '',
      0,
      SalesLine."Line No.",
      SalesLine."Qty. per Unit of Measure",
      ABS(SalesLine.Quantity),
      'RANDOMSNR',
      '');
    
    CreateReservEntry.CreateEntry(
      SalesLine."No.",
      '',
      SalesLine."Location Code",
      SalesLine.Description,
      0D,
      SalesLine."Shipment Date",
      0,
      3);
    
    does create a reservation entry with the correct serial no. but the reservation status is Prospect instead of Reservation. Is that correct?

    Yes. try and insert through ui manually and then compare the records
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • new_to_calnew_to_cal Member Posts: 21
    Reread your first posting.
    Aaw crap. That's what you get from trying to do multitasking :roll:

    Nevertheless - Thanks @all for the support.
Sign In or Register to comment.