Import data to Item Journal Line table

Hello,

I want to import data to Table 83 Item Journal Line. I made a page action to run my xmlport. I have some code in OnBeforeInsertRecord to filter items based on the data in imported text file. I start the process, add the parameters on request page, but I get the following error message:

Phys. Inventory must be equal to ‘Yes’ in Item Journal Line: Journal Template Name=, Journal Batch Name=, Line No.=0. Current value is ‘No’.

My parameters are Journal Template Name and Journal Batch Name, so they don’t have the added value. I tried to set initial value of Phys. Inventory to yes. But after doing this, I have the following error message:

Phys. Inventory must be equal to ‘No’ in Item Journal Line: Journal Template Name=LELTAR, Journal Batch Name=LT2011_02, Line No.=1. Current value is ‘Yes’.

So, in this way I have the right data in Journal Template Name and Journal Batch Name, but Phys. Inventory is not good. In addititon to, the bulit-in Calculate Inventory function doesn’t work, too. So, it not a solution, either.

Any advice what to do?

Thanks.

are you inserting date into Qty. (Phys. Inventory) field also?

Yes, in my import file there are two data: BarCode (it is an own field) and Qty. (Phys. Inventory).

when you try to import to Qty. (Phys. Inventory) it check for Phys. Inventory to TRUE…

When exactly you are getting below error?

Phys. Inventory must be equal to ‘No’ in Item Journal Line: Journal Template Name=LELTAR, Journal Batch Name=LT2011_02, Line No.=1. Current value is ‘Yes’.

while importing only or while posting the entries?

While importing.

Are you validating Entry Type - Quantity fields also?

Entry type of Purchase,Sale,Transfer,Consumption,Output ???

No, I do not.

I have this code in “ItemJournalLine - Import::OnBeforeInsertRecord()”. NaploSablonInput and NaploLapInput are the parameters from request page. LineNo is set to 0 in OnPreXMLport() trigger.

Item.SETFILTER(BarCode, ItemJournalLine.BarCode);
IF Item.FIND(’-’) THEN BEGIN
LineNo := LineNo + 1;
ItemJournalLine.“Item No.” := Item.“No.”;
ItemJournalLine.“Line No.” := LineNo;
ItemJournalLine.“Journal Template Name” := NaploSablonInput;
ItemJournalLine.“Journal Batch Name” := NaploLapInput;
ItemJournalLine.“Posting Date” := TODAY;
ItemJournalLine.VALIDATE(“Location Code”);
ItemJournalLine.VALIDATE(“Item No.”);
ItemJournalLine.VALIDATE(“Posting Date”);
ItemJournalLine.“Gen. Bus. Posting Group” := ‘’;
ItemJournalLine.“Phys. Inventory” := TRUE;
ItemJournalLine.VALIDATE(“Qty. (Phys. Inventory)”);
ItemJournalLine.VALIDATE(“Document No.”);
END
ELSE BEGIN
currXMLport.SKIP;
END;

If you are not inserting any value to Entry Type then it will take Purchase as there is not blank option for entry type…

i think that is only causing the problem…

You need to use either Positive Adjmt. or Negative Adjmt. for Phys inv journals…

I added the next 3 lines to my code:

ItemJournalLine.“Entry Type” := 2;
ItemJournalLine.VALIDATE(“Entry Type”);
ItemJournalLine.VALIDATE(“Quantity”);

But I still have this error message:

Phys. Inventory must be equal to ‘Yes’ in Item Journal Line: Journal Template Name=, Journal Batch Name=, Line No.=0. Current value is ‘No’.

Is seems to me, that OnBeforeInsertRecord() is not done at all.

Should I write this code anywhere else?

Dont need quantity field and dont validate that…

Ok, I deleted, but I have the same error message.

I put a MESSAGE in the first line of OnBeforeInsertRecord() trigger to check if this trigger is done. But it is not. :frowning:

There is no message window after starting the page action, and getting the error message.

Did you try to check this with Debugger?

I used Debugger only for forms in Classic Client.

How to do it for pages?

http://blogs.msdn.com/b/clausl/archive/2008/10/14/debugging-in-nav-2009.aspx

Thanks, I am doing…

I have the code where the error message occurs.

In Table 83 Item Journal Line, the first line of Qty. (Phys. Inventory) OnValidate() trigger is the next:

TESTFIELD(“Phys. Inventory”, TRUE);

This is the last line that is done, and after this I get the error message.

Is there any possibility to solve this? What do you think?

Try to insert the same record manually in the Item Journal form and check if there is any error.

i’ve used this - it’s a dataport not an xmlport. but I find the order in which you import & validate is key!

OnAfterImportRecord()
“Item Journal Line”.VALIDATE(“Journal Template Name”,‘PHYS. INVE’);
“Item Journal Line”.VALIDATE(“Journal Batch Name”,‘CYCLE’); //change cycle to your code
“Item Journal Line”.VALIDATE(“Posting No. Series”,‘IJ-CC’); //change IJ-CC to your code
INIT;
“Line No.” := “Line No.” + 10000;
VALIDATE(“Posting Date”,WORKDATE);
VALIDATE(“Entry Type”,“Entry Type”::“Positive Adjmt.”);
VALIDATE(“Document No.”,‘10212011’); //If you have a doc # you would like to use add it here
VALIDATE(“Item No.”,ItemNo);
VALIDATE(“Location Code”,‘NY’); //change NY to your location code if using location codes
VALIDATE(“Source Code”,‘PHYSINVJNL’);
“Qty. (Phys. Inventory)” := 0;
“Phys. Inventory” := TRUE;
VALIDATE(“Qty. (Calculated)”,0);
VALIDATE(“Unit Amount”,0);

I will make the asumption if you follow the chain of fields as above you could fix your port.
you need to rfigure out which fields do & do not require validation

I tried my own code, and the code suggested by Savatage as well. They work properly in dataport, but the same code in xmlport gives the usual error message:

Phys. Inventory must be equal to ‘Yes’ in Item Journal Line: Journal Template Name=, Journal Batch Name=, Line No.=0. Current value is ‘No’.

In dataport the code is in OnAfterImportRecord(), in xmlport I have the code in InBeforeInsertRecord(). Is it good?

I think there is something important difference in operations of dataport and xmlport in such cases, but I can not figure out what it can be…

Unfortunately, my client has NAV 2009, so I have to use an xmlport in any case.

I think you can run the same xmlport from classic also and debug easily…

As I told you already, it may be expecting while inserting “Qty. (Phys. Inventory)”.

You need to set “Phys. Inventory” to TRUE before inserting “Qty. (Phys. Inventory)”