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'"
0
Answers
The error message is very clear that you already have lines in table..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
then increment it by 10000 for every entry you are inserting.
as well as why you are using both modify & Insert, please use only Insert.
ItemJournal.MODIFY;//remove it
ItemJournal.INSERT;
And how to find out the last line no. used?
ItemJournal.SETRANGE("Journal Template Name",'Transfer');
ItemJournal.SETRANGE("Journal Batch Name",'ISSUE');
IF ItemJournal.FINDLAST THEN
Line := ItemJournal."Line No."
ELSE
Line := 0;
<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;
Remove Line := 10000; from your code..
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
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;
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
IF ItemJournal.FINDLAST THEN
line := ItemJournal."Line No."+ 10000
ELSE
line := 10000;