Listing out item from BOM in Item Reclass Journal

lavanyaballurgi
Member Posts: 235
Hey Experts,
I created a button in ITEM RECLASS where the user will fill the prod. order & when press this button it will list out the items present in the Prod. Order Component table of that prod order. But I am getting some error. Kindly help
CODE -
line:=10000;
ItemJournal.RESET;
ItemJournal.SETRANGE("Journal Template Name",'Transfer');
ItemJournal.SETRANGE("Journal Batch Name",'ISSUE');
ItemJournal.SETRANGE("Document No.","Document No.");
ItemJournal.SETRANGE("Posting Date","Posting Date");
ItemJournal.SETRANGE("Entry Type",4);
Prodordercomponent.SETRANGE("Prod. Order No.","Prod. Order No.");
IF Prodordercomponent.FINDFIRST THEN BEGIN
REPEAT
ItemJournal."Journal Template Name" := 'Transfer';
ItemJournal."Journal Batch Name" := 'ISSUE';
ItemJournal."Line No." := line;
ItemJournal."Document No." := "Document No.";
ItemJournal."Document Date" := "Document Date";
ItemJournal."Posting Date" := "Posting Date";
ItemJournal."External Document No." := "External Document No.";
ItemJournal."Entry Type" := "Entry Type";
ItemJournal."Location Code" := "Location Code";
ItemJournal.VALIDATE("Item No.",POC."Item No.");
ItemJournal.VALIDATE("Unit of Measure Code",POC."Unit of Measure Code");
ItemJournal.VALIDATE(Quantity,POC."Remaining Quantity");
ItemJournal.Description := POC.Description;
ItemJournal.MODIFY;
ItemJournal.INSERT;
line := line+10000;
UNTIL Prodordercomponent.NEXT = 0;
END;
And the error is
"The Item Journal Line already exists.
Identification fields and values:
Journal Template Name='TRANSFER',Journal Batch Name='ISSUE',Line No.='10000'"
I created a button in ITEM RECLASS where the user will fill the prod. order & when press this button it will list out the items present in the Prod. Order Component table of that prod order. But I am getting some error. Kindly help
CODE -
line:=10000;
ItemJournal.RESET;
ItemJournal.SETRANGE("Journal Template Name",'Transfer');
ItemJournal.SETRANGE("Journal Batch Name",'ISSUE');
ItemJournal.SETRANGE("Document No.","Document No.");
ItemJournal.SETRANGE("Posting Date","Posting Date");
ItemJournal.SETRANGE("Entry Type",4);
Prodordercomponent.SETRANGE("Prod. Order No.","Prod. Order No.");
IF Prodordercomponent.FINDFIRST THEN BEGIN
REPEAT
ItemJournal."Journal Template Name" := 'Transfer';
ItemJournal."Journal Batch Name" := 'ISSUE';
ItemJournal."Line No." := line;
ItemJournal."Document No." := "Document No.";
ItemJournal."Document Date" := "Document Date";
ItemJournal."Posting Date" := "Posting Date";
ItemJournal."External Document No." := "External Document No.";
ItemJournal."Entry Type" := "Entry Type";
ItemJournal."Location Code" := "Location Code";
ItemJournal.VALIDATE("Item No.",POC."Item No.");
ItemJournal.VALIDATE("Unit of Measure Code",POC."Unit of Measure Code");
ItemJournal.VALIDATE(Quantity,POC."Remaining Quantity");
ItemJournal.Description := POC.Description;
ItemJournal.MODIFY;
ItemJournal.INSERT;
line := line+10000;
UNTIL Prodordercomponent.NEXT = 0;
END;
And the error is
"The Item Journal Line already exists.
Identification fields and values:
Journal Template Name='TRANSFER',Journal Batch Name='ISSUE',Line No.='10000'"
0
Answers
-
lavanyaballurgi wrote:And the error is
"The Item Journal Line already exists.
Identification fields and values:
Journal Template Name='TRANSFER',Journal Batch Name='ISSUE',Line No.='10000'"
The error message is very clear that you already have lines in table..0 -
You shold write a code that find out last line no. in the Item Journal Line with the batch name & Template name.
then increment it by 10000 for every entry you are inserting.Uday Mer | MS Dynamics NAV Techno-Functional Consultant0 -
so only i am incrementing it by 10000...0
-
@Udayrmer - I thought of begining it with line no. 10000 only so didnt added that. By the way if the ITEM RECLASS is empty then my code should work right?0
-
Yes but best practice is to get last line no.
as well as why you are using both modify & Insert, please use only Insert.
ItemJournal.MODIFY;//remove it
ItemJournal.INSERT;Uday Mer | MS Dynamics NAV Techno-Functional Consultant0 -
Oh sorry I forgot to remove "Modify". I was actually trying to see if using MODIFY would overright the lines
And how to find out the last line no. used?0 -
ItemJournal.RESET;
ItemJournal.SETRANGE("Journal Template Name",'Transfer');
ItemJournal.SETRANGE("Journal Batch Name",'ISSUE');
IF ItemJournal.FINDLAST THEN
Line := ItemJournal."Line No."
ELSE
Line := 0;Uday Mer | MS Dynamics NAV Techno-Functional Consultant0 -
Still same error ... :-k0
-
Please give me your whole code.Uday Mer | MS Dynamics NAV Techno-Functional Consultant0
-
Here is it.
<Control1000000005> - OnPush()
ToIJ.RESET;
ToIJ.SETRANGE("Journal Template Name",'Transfer');
ToIJ.SETRANGE("Journal Batch Name",'ISSUE');
ToIJ.SETRANGE("Document No.","Document No.");
ToIJ.SETRANGE("Posting Date","Posting Date");
ToIJ.SETRANGE("Entry Type",4);
IF ToIJ.FINDLAST THEN
line := ToIJ."Line No."
ELSE
line := 0;
POC.SETRANGE("Prod. Order No.","Prod. Order No.");
IF POC.FINDFIRST THEN BEGIN
REPEAT
ToIJ."Journal Template Name" := 'Transfer';
ToIJ."Journal Batch Name" := 'ISSUE';
ToIJ."Line No." := line;
ToIJ."Document No." := "Document No.";
ToIJ."Document Date" := "Document Date";
ToIJ."Posting Date" := "Posting Date";
ToIJ."External Document No." := "External Document No.";
ToIJ."Entry Type" := "Entry Type";
ToIJ."Location Code" := "Location Code";
ToIJ.VALIDATE("Item No.",POC."Item No.");
ToIJ.VALIDATE("Unit of Measure Code",POC."Unit of Measure Code");
ToIJ.VALIDATE(Quantity,POC."Remaining Quantity");
ToIJ.Description := POC.Description;
ToIJ.MODIFY;
ToIJ.INSERT;
line := line+10000;
UNTIL POC.NEXT = 0;
END;0 -
Use
ItemJournal.RESET; ItemJournal.SETRANGE("Journal Template Name",'Transfer'); ItemJournal.SETRANGE("Journal Batch Name",'ISSUE'); IF ItemJournal.FINDLAST THEN Line := ItemJournal."Line No." + 10000 ELSE Line := 10000;
Remove Line := 10000; from your code..0 -
Use the suggested code before your code...0
-
Modify in below way,
ToIJ.RESET;
ToIJ.SETRANGE("Journal Template Name",'Transfer');
ToIJ.SETRANGE("Journal Batch Name",'ISSUE');
IF ToIJ.FINDLAST THEN
line := ToIJ."Line No."+10000
ELSE
line := 10000;
POC.SETRANGE("Prod. Order No.","Prod. Order No.");
IF POC.FINDFIRST THEN BEGIN
REPEAT
ToIJ.INIT;
ToIJ."Journal Template Name" := 'Transfer';
ToIJ."Journal Batch Name" := 'ISSUE';
ToIJ."Line No." := line;
ToIJ."Document No." := "Document No.";
ToIJ."Document Date" := "Document Date";
ToIJ."Posting Date" := "Posting Date";
ToIJ."External Document No." := "External Document No.";
ToIJ."Entry Type" := ToIJ."Entry Type"::Transfer;
ToIJ."Location Code" := "Location Code";
ToIJ.VALIDATE("Item No.",POC."Item No.");
ToIJ.VALIDATE("Unit of Measure Code",POC."Unit of Measure Code");
ToIJ.VALIDATE(Quantity,POC."Remaining Quantity");
ToIJ.Description := POC.Description;
ToIJ.INSERT;
line := line+10000;
UNTIL POC.NEXT = 0;
END;Uday Mer | MS Dynamics NAV Techno-Functional Consultant0 -
you can use Report 5405 Calc. Consumption..0
-
This one worked... Thank Mohana & Udayrmer... combining your expert opinion i could get this ...
IF ItemJournal.FINDLAST THEN
line := ItemJournal."Line No."+ 10000
ELSE
line := 10000;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