Copy document functionality - ignore blocked items

hairyjim
Member Posts: 99
When you use the copy document functionality can it:
1) Copy the quote description
2) Tell you that there are blocked items (but skip them) but still bring over the rest of the document.
Anyone know where in Report 292 I need to change to make this happen?
Cheers
Jim
1) Copy the quote description
2) Tell you that there are blocked items (but skip them) but still bring over the rest of the document.
Anyone know where in Report 292 I need to change to make this happen?
Cheers
Jim
Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.
0
Answers
-
In Report 292 the quote document number has to be copied in a new field in the Sales Header table (after the TRANSFERFIELDS statement) , the rest must be done in Codeunit 6620 "Copy Document Mgt" ( to find the quote sales lines and to skip the blocked items).Kai Kowalewski0
-
Can I use CurrReport.SKIP in code units or is there a better way of skipping a line item?Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0
-
I found this in codeunit 6620:
IF FromSalesLine.FIND('-') THEN REPEAT IF FromSalesLine.Quantity > 0 THEN BEGIN ToSalesLine."No." := FromSalesLine."No."; ToSalesLine."Variant Code" := FromSalesLine."Variant Code"; ToSalesLine."Location Code" := FromSalesLine."Location Code"; ToSalesLine."Bin Code" := FromSalesLine."Bin Code"; ToSalesLine."Unit of Measure Code" := FromSalesLine."Unit of Measure Code"; ToSalesLine."Qty. per Unit of Measure" := FromSalesLine."Qty. per Unit of Measure"; ToSalesLine."Outstanding Quantity" := FromSalesLine.Quantity; CheckItemAvailable(ToSalesHeader,ToSalesLine); END; UNTIL FromSalesLine.NEXT = 0;
This I believe to be the code that does the copying of sales lines to the new sales quote.
The function call of: CheckItemAvailable(ToSalesHeader,ToSalesLine); I think I need to put in the IF statement just after the repeat so I can check before trying to copy, and if it comes back true then skip that record.
I am not sure how to achieve this. Could someone please advise.
ThanksGive a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0 -
Create an local Item record variable.
After the REPEAT something like this:
If FromSalesLine."Type" = FromSalesLine."Type"::Item then begin
Item.get(FromSalesLine."No.");
IF Item.Blocked THEN
IF confirm('Item %1 is blocked and will not be copied',TRUE,FromSalesLine."No.") THEN;
End;
IF ((FromSalesLine."Type" = FromSalesLine."Type"::Item) AND NOT Item.Blocked) OR (FromSalesLine."Type" <> FromSalesLine."Type"::Item) then
IF FromSalesLine.Quantity > 0 THEN BEGIN
....
The confirm YES / NO buttons can both be used, as this is used only for display purposes here.Kai Kowalewski0 -
Hmmm - actually I now realise the check happens on the sales line table.
In the code there is the following lines:Type::Item: BEGIN GetItem; Item.TESTFIELD(Blocked, FALSE); //This is where it would check and fail blocked items Item.TESTFIELD("Inventory Posting Group"); Item.TESTFIELD("Gen. Prod. Posting Group"); Description := Item.Description; "Description 2" := Item."Description 2"; GetUnitCost; "Allow Invoice Disc." := Item."Allow Invoice Disc."; "Units per Parcel" := Item."Units per Parcel"; "Gen. Prod. Posting Group" := Item."Gen. Prod. Posting Group"; "VAT Prod. Posting Group" := Item."VAT Prod. Posting Group"; "Tax Group Code" := Item."Tax Group Code"; "Item Category Code" := Item."Item Category Code"; "Product Group Code" := Item."Product Group Code"; Nonstock := Item."Created From Nonstock Item"; "Profit %" := Item."Profit %"; "Allow Item Charge Assignment" := TRUE; IF SalesHeader."Language Code" <> '' THEN GetItemTranslation; IF (Item.Reserve = Item.Reserve::Optional) THEN Reserve := SalesHeader.Reserve ELSE Reserve := Item.Reserve; VALIDATE("Unit of Measure Code",Item."Sales Unit of Measure"); END;
Now from what I have researched the copy document functionality works thus (ignoring Include header option):
If you 'recalculate lines' any line that is blocked will stop the process. The error gets thrown from the sales line table, in the code posted above.
If you do not 'recalculate lines' then all lines including blocked get copied to the new sales quote.
Now I think I have two options.
a) I modify the sales line table so that it respects the blocked items check but throws a friendly error which would allow the process to continue.
b) I somehow manage to figure out which bit of code is used for not recalculating lines and modify it so that bit of code is fired for recalculating lines but throws a friendly error which would allow the process to continue.
Which option do people think will work best in the grand scheme of things, or is there a much better and simpler way of doing this.Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0 -
Hi,
I would not change the salesline table.
You should try to not have the blocked items in your copies salesorder.
Navision does this for G/L accounts that have direct posting.
Have a look in the function CopySalesLine in the Codeunit 6620.
You wil find the following piece of code there:IF ToSalesLine.Type = ToSalesLine.Type::"G/L Account" THEN BEGIN ToSalesLine."No." := FromSalesLine."No."; IF GLAcc."No." <> FromSalesLine."No." THEN GLAcc.GET(FromSalesLine."No."); CopyThisLine := GLAcc."Direct Posting"; IF CopyThisLine THEN ToSalesLine.VALIDATE("No.",FromSalesLine."No."); END ELSE ToSalesLine.VALIDATE("No.",FromSalesLine."No.");
Notice that the boolean CopyThisLine is set to false is directposting if false.
You need to program a similar thing if the item is blocked.
If you need help with this, just ask.0 -
Thanks for the reply.
Yeah I could do with a little extra explaining as to how I can use this to allow quotes to be copied to another quote without copying blocked items but to continue processing if it does find a blocked recordGive a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0 -
Try:
IF ToSalesLine.Type = ToSalesLine.Type::"G/L Account" THEN BEGIN ToSalesLine."No." := FromSalesLine."No."; IF GLAcc."No." <> FromSalesLine."No." THEN GLAcc.GET(FromSalesLine."No."); CopyThisLine := GLAcc."Direct Posting"; IF CopyThisLine THEN ToSalesLine.VALIDATE("No.",FromSalesLine."No."); END ELSE if ToSalesLine.Type = ToSalesLine.Type::"ITEM" THEN BEGIN ToSalesLine."No." := FromSalesLine."No."; IF Item."No." <> FromSalesLine."No." THEN Item.GET(FromSalesLine."No."); CopyThisLine := NOT Item."Blocked"; IF CopyThisLine THEN ToSalesLine.VALIDATE("No.",FromSalesLine."No."); end else ToSalesLine.VALIDATE("No.",FromSalesLine."No.");
I hope it works, it should, but I have not tested.
If you want realy neat programming you should do a case statement.0 -
After a little bit of modifications this works a treat.
When it does come across a line that is 'blocked' it does skip and carry n copying but it shows the following error after the batch copy has finished.
"The document line(s) with a G/L account where direct posting is not allowed have not been copied ot the new document by the copy document batch job."
Do you know where this message is thrown from, I would like to change it to say something more friendly such as "Certain items were not copied because they are blocked".
Thanks for your help, I have really learned some nwe things while trying to do this over the last few days.Give a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0 -
Change variable Text004 in Codeunit 6620.
It is raised in the Function CopySalesDocIF LinesNotCopied > 0 THEN MESSAGE(Text004);
Better is to create a new message, and leave the Text004 as it is, for future upgrading.0 -
=D>
Most excellent.
You and others in this thread have helped a great deal!
Thankyou all.
JimGive a man a fish and he will eat for a day, teach a man to fish and he will drink beer allday.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions