Expand BOM for all rows in a sales invoice

jukkapalmujukkapalmu Member Posts: 2
edited 2005-07-21 in Navision Financials
Hello all.


Noob here, so go easy on me. I've a customer for whom I do mostly server and desktop support tasks, and they're using Financials 2.0 (yes, old, but it's working and they're on the cheap end of the scale so don't want to upgrade).

Now there's a new law here, stating that all household appliances must include a recycle fee, and it must be on a separate row on an invoice. They can do this by setting up BOM's for the items, but the usability is a bit so-so because the "Explode BOM" function in the invoice only works on one row at a time, and they regularly have dozens of different items on an invoice (they sell to resellers a bunch of items at a time).

I'd like to modify the invoice window by adding a button "Explode BOM for all rows", which would basically just call the explode bom codeunit for each row. Now, I have never done any Navision programming, but I could figure out how to add the button, how to make it execute a codeunit, and I even found the original "explode BOM" code which works for one row (I have 20+ years of programming experience under my belt), but I can't figure out how to loop through all the rows in an invoice - nor do I know for sure if I can call the original function in a loop for each row.

So, after long explanation here comes the question: Can I do it, and if it's doable could someone point me towards an example of selecting and looping the rows of a given invoice?

Thank you very much in advance,
Jukkapalmu

Comments

  • DenSterDenSter Member Posts: 8,307
    Going off the top of my head, but this should get you in the right direction.
    SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
    SalesLine.SETRANGE("Document No.",SalesHeader."No.");
    IF SalesLine.FIND('-') THEN BEGIN
      REPEAT
        Explode(SalesLine);
      UNTIL SalesLine.NEXT = 0;
    END;
    
    If it's a button on the Order form, the Sales Header is the Source Table, so you'd use Rec instead of SalesHeader, or even leave out the record altogether.
Sign In or Register to comment.