Hi,
I'm trying to create a way to :
1. Automatically Import Item Journal from a txt file.
2. Automatically post the imported item journal.
Can you help me on this :
I have a 3rd party application supplying the txt file daily to the folder "C:\ITEJOURNAL" and it's format is IteJourn_<date>.txt
I'm thinking of creating a recurring job entries which run a codeunit that will check whether there is a new file, and if it has new txt with new date then it will import them and directly update the item journal line and post it afterward.
Is there even a way to import the file directly using c/al function ?
Can you kindly suggest on how to code the codeunit or at least point out an example ?
0
Answers
As suggest by @KTA8, you'll need to create a loop throught the folder in which the txt files will be placed and read them, one by one, to an instream variable.
Check this: https://docs.microsoft.com/en-us/dynamics-nav/how-to--use-streams-to-read-from-text-files
After you read a file, you'll then call a XMLPort and import that txt file (instream variable).
Check this: https://docs.microsoft.com/en-us/dynamics-nav/import-function--xmlport-