Auto explode Bill of Materials when quote converted to order

hairyjimhairyjim Member Posts: 99
edited 2004-10-22 in Navision Attain
Hi all,

We have a situation where we wish to keep BOM's unexploded on quotes but wish to have them exploded on order screens.

Currently the Order Processor has to manually explode any BOMs that are on orders that have been created from quotes.

Could someone point me to the code unit that would require a mod to change this so any BOMs on quotes that are turned into orders are auto exploded on the order.
Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.

Comments

  • elenawelenaw Member Posts: 8
    Hi,
    One solution you may try is under the Codeunit 86 (Sales-Quote to Order) for sales or Codeunit 96 (Purch.-Quote to order) for purchases

    1) Create a new Function to call the Codeunit 63 Sales-Explode BOM (for sales) in CD 86; or call the Codeunit 73 Purch.-Explode BOM (for purchases) in CD 96. (requires record variable parameter passing)

    2)After the Quote is converted to Sales Order (At the end of OnRUN() function), add in code to called the function created in (1). (requires record variable parameter passing)
  • hairyjimhairyjim Member Posts: 99
    OK. I added at the bototm of the OnRUn function

    AutoExplodeBom;

    Inside this function I do the following:

    Item.GET(SalesOrderLine."No.");
    Item.CALCFIELDS("Bill of Materials");
    IF NOT Item."Bill of Materials" THEN
    EXIT;
    CODEUNIT.RUN(CODEUNIT::"Sales-Explode BOM",SalesOrderLine);

    Now what is happening is that it only works for the very last item added to the sales lines.

    Im not sure how or where I should loop through all the quote lines that are being converted to the order and check for being a BOM and explode or not.

    Do you have any further advice to offer?
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
  • elenawelenaw Member Posts: 8
    Inside the Function (AutoExplodeBom), you should take the Sales Order No. and declare a new record variable for Sales Order Line.

    SalesOrderLine.Reset;
    SalesOrderLine.Setrange("Document Type",SalesOrder."Document Type");
    SalesOrderLine.Setrange("Document NO.",SalesOrder."No.");
    SalesOrderLine.Setrange(Type,SalesOrderLine.Type::Item);
    If SalesOrderLine.FIND('-') THEN
    Repeat
    Item.GET(SalesOrderLine."No.");
    Item.CALCFIELDS("Bill of Materials");
    IF NOT Item."Bill of Materials" THEN
    EXIT;
    CODEUNIT.RUN(CODEUNIT::"Sales-Explode BOM",SalesOrderLine);
    Until SalesOrderLine.Next = 0;

    Remember to indent your codes properly.
  • hairyjimhairyjim Member Posts: 99
    Cheers for the help.

    I added the code as suggested.

    Now when a quote is converted to an order only the first line is exploded if it is a BOM or not, the loop does not seem to then go to the next line and check and explode or not.

    If the first line is a BOM then it does explode it but as above it does not then go to the next line and check.

    Any other thoughts?
    Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
Sign In or Register to comment.