Running App Server without Batch file

MohammedMohammed Member Posts: 42
Hi All,
I'm using App server to do automatic Sales shipment posting. The input is an xml file. Whenever an xml file is copied in to the folder, the system should import and post the data. I'm using App server and created a single instance codeunit with Timer. The process works fine when I'm using a batch file for running the app server. But its not working without the batch file, when the application server is running as a service. Is it possible to do the process without using the batch file? The process will be going on in the server, always looking for a new xml file at regular interval of time and then doing the posting. I'm using Nav 5.0 SP1.

Please advice.

Answers

  • garakgarak Member Posts: 3,263
    edited 2009-02-10
    Search also the forum for this ant take a look behind the selected account of your service (must be a windows user that has access to connect to the database).

    I would do it so (to see why the invoice can't post):

    Import the XML file into a "working table". If all validatins are fine (like exist the vendor, exist the item, and so on) create the invoice. If nothing is fine, fill the ErrorCommentField in this table to see why the XMLData can't process.
    If all is fine create the Header and the lines. Then try to post the invoice (don't forgett the GUIALLOWED in the posting codeunits). If the invoice can't post (for example the GEneral Posting Setup isn't correct filled) get the LASTERROR and write this into the ErrorCommentField in your "working Table". So you can see, why the invoice can not be posted (store there also the invoice no). If all is fine and the invoice is posted, delete the rec in the working table (or if you need to know if it is ok, store also the posted no here).

    Regards
    Do you make it right, it works too!
  • tragtrag Member Posts: 23
    please note, that the sales posting codeunit 80 is using a window, which is not allowed in an application server. you have to modify the code with "IF GUIALLOWED THEN" to support the application server. but furthermore, there are other codeunits also involved, where a window might appear, i remember one, if automatic inventory costing is used, that there might popup another window. you should get an error message in the event viewer from the application server, if there is a window used.
  • MohammedMohammed Member Posts: 42
    Yes, I'm using GUIALLOWED and eror Logging using GETLASTERRORTEXT. Actually my problem is not with posting, but to use the app server without the batch file. Sorry, I've mentioned in the subject as automatic posting. Now I've changed the subject.
  • kinekine Member Posts: 12,562
    1) If it is not working, there will be some error in Event Log...
    2) Running ithrough batch he NAS is running under your account. Running as service will run under selected account (Localsystem by default). Check that the account have enough permission to connect to the NAV DB and to read the files.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bhalpinbhalpin Member Posts: 309
    Some points worth mentioning (from someone with some ugly scars from importing XML files under NAS)

    - If the XMLPort encounters any elements that are unexpected, you are dead before you hit the floor. If I had it to do over again, I would invest the time to use Automation objects to read/dissect the XML file.

    - GETLASTERRORTEXT is of limited use - I have found that if you have a codeunit calling the XMLPort, the only way to live through an error is to create an intermediary codeunit that's only job is to execute the XMLPort. Then, in your main codeunit you call the intermediate one in an IF statement. (YMMV)

    - Log everything - and that's not easy. I may be nuts here but when I added log-creating/writing code to my project I found that when disaster struck NAV would roll back the database AND THE LOG FILE - so I had nothing to go on. In my current code each write is a file open, a seek to the end, the write, then I close the file.

    - Write the logging code first. You can go blind (and/or insane) in the debugger.

    - Use the Event Viewer as well. Sprinkle lot of code like this in:

    IF NOT GUIALLOWED THEN
    MESSAGE('Whatever ...');

    Under NAS (no gui) MESSAGE output goes to the event log and you can use the Event Viewer to see what happened.

    - Finally, the order of execution in an XMLPort can be somewhat arcane. To get a proper picture of what was happening and when, I ended up putting in a log-line in every trigger and then studying the order of the output.

    Have 'fun'!

    Bob
  • MohammedMohammed Member Posts: 42
    Thank you kine.. it is working now.. the startup parameter for the service was also wrong.. I've corrected that.. Thank you All for all your valuable comments :D

    Cheers,

    Mohammed
  • kinekine Member Posts: 12,562
    You are welcome... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.