rohan_rege
29th October 2002, 21:39
hi ,
curr my code is opening and reading a file from a directory on the server.
i.e : i am hardcoding the file location as follows :
input.file = "/work/rrege/acs.inbound"
but the files are going to be stored in the respective directories as acs.inbound.10282002 , i.e its going to be appended with a date stamp at its end.
how do i go about ...to open the file when i have already hardcoded it as above.
i mean , everyday the file will have a different date appended to it at the end.
rgds
Rohan
benito
29th October 2002, 23:59
Please take a look at the sample below:
choice.print.data:
on.choice:
d = "*" |*File delimiter
dat = dte$()
disk = "\\hagar\edi\prod\"
function open.files()
{
mode = "ab"
fln4 = strip$(disk) & "dat"
fp4 = seq.open(fln4, mode)
if fp4 < 1 then
open.error(fp4, fln4)
endif
}
rohan_rege
30th October 2002, 00:21
thanks for the reply,
actually it might be possible that i will be receiving the file with filename as
for eg : <filename>.datetimestamp , where the date time stamp is not current date and time but yesterdays ,bcoz it has to be processed again bcoz yesterday the processing was unsucessfull
datetimestamp will be in YYMMDDHHM ,format
also i was thinking whether there is some way of coding where we can say that seq.open <filename>.*
and since there is always going to be only one file in the directory irrespective of the datetimestamp it will always open the file due to the wildcard.
rgds
Rohan
NPRao
30th October 2002, 01:05
Rohan,
You can use the BaaN Tools function - dir.entry() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_directory_file_operations_dir_entry)
So you can open the files in that directory and do the processing.
Paul P
30th October 2002, 03:13
Dear Rohan,
Last time we did barcode implementation using flat files (with date stamp), we place the flat file for different type of transaction in the different directory. For example, inbound files in inbound directory, outbound files in outbound directory, and so on. This way we can just point the program to look for every file in that directory and process the valid records
Rgds,
Paul
deepaksachdeva
2nd November 2006, 19:14
Dear Rohan,
Last time we did barcode implementation using flat files (with date stamp), we place the flat file for different type of transaction in the different directory. For example, inbound files in inbound directory, outbound files in outbound directory, and so on. This way we can just point the program to look for every file in that directory and process the valid records
Rgds,
Paul
Dear Paul;
could u please share the code of the dir.open() as at my end i have same requirement, the sample code pasted by you could be really helpful to me.
With regards
Deepak
NPRao
2nd November 2006, 21:49
Deepak,
Here is sample code-
function main()
{
long fd, counter, rt, size, mode, fp
string fname(80), fpath(256)
counter = 0
fpath = "/app/common/home/bsp"
fd = dir.open(fpath)
if fd < 0 then
mess("zmadms0046", 1, fpath)
|* Directory Handling Errors: %1$s
exit(1)
endif
fname = dir.entry(fd, TFILE, rt, size, mode)
while (not isspace(fname))
counter = counter + 1
fp = seq.open(fname, "r")
if fp < 0 then
mess("zmadms0036", 1, fname)
|* File Opening Error: %1$s
e = seq.close(fp)
continue
else
|* file found - do.something......
e = seq.close(fp)
endif
fname = dir.entry(fd, TFILE, rt, size, mode)
endwhile
e = dir.close(fd)
if counter <= 0 then
mess("zmadms0045", 1, fpath)
|* No files in directory: %1$s
exit(1)
else
message("%d files in directory %s", counter, fpath)
endif
}
NPRao
3rd November 2006, 00:00
Refer to the release notes of the latest Porting Set - 8.3a
DevCage: # 31304 (BDNT23402): Fixed dir.open resultcode on windows
Date: Wed, 28 Jun 2006 17:22:07 +0200 (CEST)
Created on: MaintSchoenberg
Type: bugfix
Problem Description (Customer terms)
On MS-Windows the function dir.open(""), so on an empty directory, returns a "1". This is wrong because a return value greater than zero means that the function succeed. The return value should be "-2" because the directory could not be opened.
The function dir.open.tree("") has the same problem.
This problem occurs on MS-Windows with BaanIVc and Corelli. This problem doesn't occur on Unix.
Test Procedure
Run script below on a Windows system, result should be -2
function main()
{
long result
string file(255)
long return_type
long filesize
long mode
result = dir.open("")
IF result >= 0 THEN
REPEAT
file = dir.entry(result, TFILE, return_type, filesize, mode)
UNTIL len(file) = 0
result = dir.close(result)
ENDIF
}
Affected Executables
ntbshell.exe
dirtest.exe
sidtest.exe
timetest.exe
Motive source
TCS:800-141911
Paul P
3rd November 2006, 04:02
Sorry, Deepak, I don't have the code with me since the code belongs to my customer. Anyhow, we only did this back in 2001 (5 years ago!) simply because by then the AFS (http://www.baanboard.com/baanboard/forumdisplay.php?f=59) technology was not well known yet. Right now, I use AFS for most of my external integration to BaanERP
Rgds,
Paul