Reading dynamic flat files

raiym

Active Member
List,
We have a requirement of processing details from a flat file. We know the location of the flat file but unfortunately, the name of the file is dynamic and keeps changing. Is there a way in JDe that we can read files from a directory or some other way to work around this issue, other than use the same name? Also, would someone possibly be able to tell me if we can do a table conversion or for that matter any processing on an XML file.

Thank you
Yathindra
XE Update 4 SP 16.1 AS/400 Win 2000
 
Is the flat file name predictable? I have been able to use a processing option template to enter the various parts of the flat file name, then concatenate the necessary parts to use the business function B4700230 to copy the file to a specific file name, which is then available for use with a table conversion UBE.
 
We are developing a event driven process to do the table conversion. So there would be no user intervention. The flat files get populated on the specified directory and then a subsytem or a sleeper job picks up the file and runs the conversion on it. So there is no way of specifying the file names on the processing option every time. If you are asking if we could maintain a standard to do it, I guess we could. We could keep the starting elements same and then have a counter at the end and use it and use a concatenation of the two as the file name. I was just trying to get a more generic approach, so that even if there is a mismatch on the next number, the process works.

Thank you for the reply
Yathindra
Xe Update 4 SP16.1 AS/400 Win 2000
 
Check out B9600471 - functions FindFirstFile and FindNextFile. However I believe these functions will only work on Windows platforms.

Regards,

Larry Jones
[email protected]
OneWorld XE, SP 15.1
HPUX 11, Oracle SE 8.1.6
Mfg, Distribution, Financials
 
the file is on the windows directory.

Yathindra
XE Update 4 AS/400 Win 2000
 
Thank you Larry, That was exactly what I was looking for. It took some time though to understand the parameters and get it running.

Yathindra
XE Update 4 AS/400 Win 2000
 
Hi Yathindra,

I developed our interfaces in the past using Table Conversion into a workfile and processing the workfile with a main UBE.

I created recently three new interfaces and I tried an other method.

First I copied B34A1010 Flat File Operation business function and their Data Structures.
I made all necessary changes making possible to work the copied version as well as the original do (most of these steps were REPLACE string in the source).
I extended a bit the error handling of the funcions but it is now irrelevant.
I extended B34A1010 source module with a "Read One Line From Flat File xxxyy" function.

I omitted to use TC, I handled everything in my main UBE. The PO template of this UBE containes two field (including more) like "Path Name" and "File Name".

Some advantages of this solution:
* you can handle the file name and location dinamically
* you can write much ore flexible ER logic
* you can produce a riport in the same time, e.g.:
** print out PO values at the beginning
** report all detected errors
** print statistics on the end and one or more final status messages

Choosing this way, of course, you have to convert all values from string to the appropriate data type e.g. numeric and date. This wasn't a problem for me because we have already developed our "flexible" type conversions long ago.

Regards,

Zoltán

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Zoltán,

thx for this post (actually a similiar one you recently made). I am just now facing a similiar issue where I need to import data from a text file containing parts and BOM information. My investigation of the TC and standard Import ('Z') programs had me feeling they left something to be desired. Thx to your post I also cloned B34A1010 and added a 'ReadLine' function. Now all I have left is the minor tasks of validating and generating new items ... :)

Thanks again,



Larry Jones
[email protected]
OneWorld XE, SP 15.1
HPUX 11, Oracle SE 8.1.6
Mfg, Distribution, Financials
 
Zoltan,
Thank you for the descriptive reply. The only problem I am having with using a processing option is that the program I am using needs to work without any manual intervention. So we will not have someone entering the processing option values every time.

Yathindra
XE Update 4 AS/400 Win 2000
 
Hi Yathindra,

Passing the file name trough Processing Options is only one way and there are several other to use dynamic filenames. Here are some other:

1.) Pass the name through Report Interconnect.
2.) Build the filename inside the UBE based on a filename creation logic.
3.) Like 2nd but can the logic into a BSFN.
4.) Pick up the filename from somewhere (e.g. from a table or from a fixed named file) inside the UBE.

Regards,

Zoltán

B7332 SP11, ESU 4116422, Intel NT4, SQL 7 SP1
(working with B7321, B7331, XE too)
 
Hi All,

A much more flexible way is to make a C-function which reads in all files in a directory. In the processing options enter the directory and in the C-function first make a list of files in the directory (I think the only way on a windows computer is to use a shell-escape and use something like dir FilePath /A:-D /b > FilePath/dir.txt, on a Unix-computer use ls etc.). Read the file dir.txt in a loop and read and import the data from every data-file in a OneWorld-table.

Call this function in the initialize-section of a UBE and in the do-section loop through all records in the OneWorld-table and insert records in e.g. F47-tables.

FWIW,
Walter.

B7332 / XE / NT4 / SQL 7 / VisualStudio 6 SP5
 
Yathindra,

I think this will be the way to do it.

Let's assume you have a directory called "F:\FileDump" where all your files
are dumped.
In OneWorld create a report, in the "Initialize section" of the main
section - create a 'C' business function which will
execute the following program code - system("dir /b F:\FileDump >
Files.txt").

Now your Files.txt will contain all the files in the directory
"F:\FileDump" -
(1) start parsing the text file (using a business function) to get the
file names 1 by 1.
(2) For every file name you parse, use the following program code to
copy it to a static file name.
system("copy F:\FileDump\a1.txt
F:\FileDump\jdeinput.txt")
(3) Now call a Table Conversion UBE to parse contents of "jdeinput.txt"
& load the appropriate files (tables).
(4) When you are done with the contents of file, a1.txt (jdeinput.txt) -
use 1 more system command to move it to a processed folder:
system("move F:\FileDump\a1.txt
F:\FileDump\Processed")
(5) Pick up the next file name & continue the process
(6) When there are no more file names, call the same report again ....

You can throw this report on the scheduler, run it once in every 15 mins or
1/2 hour or 60 mins, based on whatever your
requirements are. Hope this helps !!

Regards,
Arvind.
 
Back
Top