I was assigned a new task. I have to write a processing-only report. From what I could tell, a processing report is like a batch file, which runs a few tasks on the background.
It shouldn’t be too hard. Basically, I have to check values from a field of a table, and if the content of that field is 0, it should copy values from a field from another table, obviously bearing in mind that the selected item of those two tables must be the same one.
Ok, so, if you could give me some pointers about where should I start, it would be great. I wish there was a beginner’s forum for these rookie questions, but I guess this is the place where the experts are…
What does the company you were hired by do? Do they sell NAV or sell a product related to NAV? Then they are a partner. Do they use NAV to run their business? Then they are a customer.
If they are paying their enhancement fee (customer) or partner fees then they will have access to the documentation. You can also search the C/SIDE Help menu within the client and / or MSDN. Here is a file with a lot of training: http://dynamicsuser.net/media/p/188498.aspx
Ok, so this is what I have until now (obviously it doesn’t work…yet):
RecItem.RESET;
RecRoutingLine.RESET;
RecItem.SETRANGE(“No.”, ‘M000000’, ‘M999999’);
IF RecItem.FINDFIRST() THEN BEGIN
REPEAT
IF RecItem.“Tempo Fabrico Machos” > 0 THEN BEGIN
RecRoutingLine.“Run Time” := RecItem.“Tempo Fabrico Machos”;
RecRoutingLine.MODIFY;
MESSAGE(’%1’, RecRoutingLine.“Run Time”);
RecItem.NEXT;
END
UNTIL RecItem.“No.” = ‘M999999’;
END
What I want is to filter only the items that begin with the letter ‘M’, then if those items have a certain field > 0, I want that value to be copied to another table, but on the same item…
I tried doing it alone, with what I know until now, but I was hoping you could point me in the right direction…
I’ll point out some of the obvious ones. Firstly, have you abandoned the processing only report idea? This looks like code from a Codeunit or something based on the REPEAT…UNTIL loop. That type of loop would be automatically handled in a processing only report.
In the C/SIDE Help from the NAV Client Help Menu, search for SETFILTER. It’s like SETRANGE, but gives you more control.
Not a big deal, but when you will be looping through multiple records, do a FINDSET instead of FINDFIRST. It’s better for execution time. You can also search for the optional parameters in the same place as above.
When you are setting the value for the RecRoutingLine variable you have not retrieved a record from the database. You’ll need to do filters / ranges along with a FIND, or look into the GET function.
REPEAT…UNTIL loops are usually done as REPEAT…UNTIL myRecordVar.NEXT = 0. The NEXT will move to the next record in the filtered set.
Lookup all of these keywords in the NAV help and on the forums to find examples.
Its showing an error that says something like this (I’m translating from the portuguese, so it might not say the same in English): “It’s not possible to make any changes in the database until a transaction is initiated”…
I’m not a programmer…yet, so I don’t really know what I’m doing of if what I’m doing is a Processing Report or a Codeunit. I was given a task, and that task was to create a processing report. And that’s what I’m trying to do. I appreciate you pointing me all the mistakes I make, I hope it will make me a better programmer…
I was pointed to the right direction: they told me to eliminate the repeat…until and to write the code in the OnAfterGetRecord trigger(I’m using the Item Data Item, but I’m not sure if I should be using the Routing Line Data Item).
IF RecItem.FIND AND RecRoutingLine.FIND THEN
IF RecItem.“Tempo Fabrico Machos” > 0 THEN BEGIN
RecRoutingLine.“Run Time” := RecItem.“Tempo Fabrico Machos”;
RecRoutingLine.MODIFY;
END
Did you search for “Processing Only” in the NAV Client C/SIDE Help Menu? The same place I mentioned you could find information about SETFILTER and other development topics? There is a step by step guide for how to create a processing only report here.
You can also search for “Classic Report Walkthroughs”. It’ll be in the middle of the results, but have that exact name (in the US version anyway).
To me it seems like you need more understanding of the basic concepts. Go through the Help Menu. There are literally hundreds of pages of documentation there. It’s what used to be known as the Application Developer’s Guide, but not it is located there instead of a monster PDF on the product CD.