ltannous
3rd July 2003, 00:36
I have a session in baan that has a list of files that exist on our server. I want to be able to select one file in my baan session and when I select continue or run I need to find the file on the server and move it to a certain directory on the server.
Any ideas?
lbencic
3rd July 2003, 00:49
You can review this very active thread on how to create a file browser and get a result based on user selection.
http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1844&highlight=browser
You can then use OS commands - also listed in this thread - to move or copy the file as needed.
NPRao
3rd July 2003, 01:23
I would suggest to use BaaN functions instead of direct OS commands to make it platform independent -
Directory and file operations synopsis (http://www.baanboard.com/programmers_manual_baanerp_help_functions_dynamic_sql_queries_synopsis)
ltannous
3rd July 2003, 06:53
This is my session script. Basically, I want to select a file from my baan table, press a button to copy the file I selected from a specified directory in UNIX to another directory in UNIX.
When I press the button option, the file is created called recued in the proper directory, but it is not the file I have selected. I looks like it is copying everything in my home directory to this file.
Any ideas
declaration:
table twtedi011 | TLe Recue Releases
string path, apath
extern long fp
form.1:
init.form:
get.screen.defaults()
choice.cont.process:
on.choice:
|before.program:
|path = "/apps/tlink/baan/customer_files/history/"
|apath = concat$("/",path,wtedi011.reln)
form.all:
choice.user.0:
on.choice:
select wtedi011.reln
from wtedi011
where wtedi011.reln = :wtedi011.reln
selectdo
path = "/apps/tlink/baan/customer_files/history/"
apath = concat$("/",path,wtedi011.reln)
file.cp(apath,"/apps/baan/bse/tmp/recued")
endselect
NPRao
3rd July 2003, 07:52
Here is a sample code -
table twtedi011 |* TLe Recue Releases
string fpath(80) |* file path variable
long fp |* file pointer
|******************************************************************************
form.all:
init.form:
if not (api.mode or job.process or background) then
get.screen.defaults()
endif
|******************************************************************************
choice.cont.process:
on.choice:
select wtedi011.reln
from wtedi011
where wtedi011.reln = :wtedi011.reln
|* you can use as set with 1 rows in case of only one file
selectdo
fpath = "/apps/tlink/baan/customer_files/history/" & wtedi011.reln
e = file.cp(apath,"/apps/baan/bse/tmp/recued")
if e < 0 then
message("File Handling Problems")
|* Action - continue/break
endif
selectempty
message("No files found")
endselect
|******************************************************************************
I am not sure how are you getting the value of the variable - :wtedi011.reln in
the select statement.
dorleta
3rd July 2003, 10:26
To select a file baan have an file explorer you first select and after copy. Here you have an example. This dll lets you to select more than one file. Watch the explanation of the parameter in the script source.
declaration:
#pragma used dll "otgbrg0019"
string source(80)
string target(80)
field.desc:
before.zoom:
dummy = select.file("/baan4c4/bse/tmp", 1, desc2, desc = desc2(1,1)
display("desc")
choice.again()
after.input:
dummy = file.cp( source, target )
ltannous
3rd July 2003, 23:38
It does not seem to be finding my file on the server, it does create a recued file with junk in it
What I have done is created a print session and modified it.
The options on the form is to select the file name.
The user can zoom to a baan table and select the file name.
This file name needs to be noticed in the script in the file directory path.
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ***
choice.cont.process:
on.choice:
execute(print.data)
choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif
|****************************** function section *
functions:
function read.main.table()
{
select wtedi011.reln
from wtedi011
where wtedi011._index1 = {:reln.f}
selectdo
apath = "/apps/baan/bse/tmp"
fpath = concat$("/",apath, reln.f)
fp = seq.open(fpath,"r")
if fp < 1 then message("Cant get into directory")
endif
if fp >=1 then
e = file.cp(fpath,"/apps/baan/bse/tmp/recued")
if e < 0 then
message("File Handling Problems")
endif
endif
selectempty
message("No files found")
endselect
}
NvanBeest
4th July 2003, 10:55
Have you tried compiling it into debug mode, and trace it? There must be something small that is causing the problem. Especially trace the variables fpath and apath. The reason for stating this is that I see in your first source post, you declared this as string apath, fpath which will create two strings of 1 character long, meaning that the contents you think goes in them is totally incorrect!