outra9e
11th March 2003, 18:48
Im full of them today!!
I want to create a Baan session that will enable a user to upload a csv file from their local machine to the Unix server.
Is this possible?
Cheers
evesely
11th March 2003, 19:50
Take a peek at the client2server() function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_client_file_access_client2server) .
outra9e
12th March 2003, 10:43
Ed
I have had a look and it seems to be what I need.
How do I go about creating this session?
Obviously I cannot use the "Generate Sessions" because the session will not be based on any tables.
Is there a specific type of session that I need to create?
Or is there a certain type of form field that I need to put on the form?
Im guessing that I write a on.choice command on the button and then in there, I out the client2server command.
Is that correct?
Cheers
outra9e
12th March 2003, 12:20
Ed
I have created a blank session with a button.
On the choice section I have put this....
choice.user.0:
on.choice:
client2server("C:Andy.txt", bse.tmp.dir$() & "/Andy.txt", false, false)
However when I compile, it says that "there is an unresolved reference to client2server function".
Any ideas?
There is nothing else in the script.
Cheers
evesely
12th March 2003, 16:04
You need to tell it where to find that library function. You can add this to the beginning of your program script (where you would put all of your includes, defines, global variables, etc.):
#pragma used dll "ottdllbw"
This library contains the BW client functions.
outra9e
12th March 2003, 16:08
Ed
I have tried this in a number of places on the script and it keeps telling me that only statements can be placed in sections.
Is there a line I need to add before this?
Cheers
outra9e
12th March 2003, 16:12
Ed
please ignore the last post, I had put the line into the declaration section without putting in "Declaration:"!!
However I am now being told that ....
"3 arguments epected for function 'client2server'"
and
"Illegal argument 4 for function 'client2server'"
here is the code. whats is the fourth argument here?
*************************************************
choice.user.0:
on.choice:
client2server("C:Andy.txt", bse.tmp.dir$() & "/Andy.txt", false, false)
*************************************************
Cheers
lbencic
12th March 2003, 17:25
The guide on this forum is for ERP, and sometimes the syntax is different even on the shared commands. Even sometimes depending on porting sets for the bw libraries.
The Baan 4c version we have on our system has the following call, expecting 3 arguments.
function extern long client2server(
const string source(),
const string dest(),
long text.mode )
This is probably common for updated c4 systems. You can check your version for sure by doing a bic_info on the ottdllbw object:
In Unix, from the $BSE\baan\bin directory, run:
$ bic_info6.1 ottdllbw
NPRao
12th March 2003, 20:39
Andy,
choice.user.0:
on.choice:
client2server("C:Andy.txt", bse.tmp.dir$() & "/Andy.txt", false, false)
Change the 1st parameter from "C:Andy.txt" to "C:\\Andy.txt"
outra9e
13th March 2003, 11:15
I have managed to get the script to compile using this code, however it does not appear to have put the file onto the Baan server.
Here is the code...
|**************** DECLARATION SECTION *************
Declaration:
#pragma used dll "ottdllbw"
|************ FORM SECTION **************
|************* CHOICE SECTION ****************
choice.user.0:
on.choice:
client2server("C:\\Andy.txt", bse.tmp.dir$() & "/Andy.txt", false)
************************************************
The "bse.tmp.dir$()" part, what does this do? Does it put it into a static dir? or does it do something else?
Also, is it possible to adapt this session so that the user can browse for the file to upload themselves?
Cheers
evesely
13th March 2003, 15:53
The bse.tmp.dir$() function returns the value of the Baan temp directory (see library entry (http://www.baanboard.com/programmers_manual_baanerp_help_functions_system_and_user_information_bse_tmp_dir) ). As far as browsing, you may want to check out this thread (http://www.baanboard.com/baanboard/showthread.php?threadid=1910).
outra9e
13th March 2003, 16:48
Ed
That thread talks about a server browser, I want to create a session that will browse the local machine allowing the user to put a local file onto the server in a specified directory, bit like a file upload web page...
Cheers
outra9e
13th March 2003, 17:09
Ed
Following on, I am going to speak to our UNIX admin about working on this session...
Aside from that, the session is now compiling successfully...
|**************** DECLARATION SECTION *************
Declaration:
#pragma used dll "ottdllbw"
|************ FORM SECTION **************
|************* CHOICE SECTION ****************
choice.user.0:
on.choice:
client2server("C:\\Andy.txt", bse.tmp.dir$() & "/Andy.txt", false)
************************************************
However when I click the button it is not actually uploading the file...
ANy ideas?
Cheers
lbencic
13th March 2003, 18:02
I think you want just C:\Andy.txt.
Also, we're sure that file exists in the Baan tmp directory, correct?
outra9e
13th March 2003, 18:15
The file does not yet exist on the Baan server.
The file is on the local client and I want it to go to the Baan server.
The file is definitely on the local machine in C:
Cheers
lbencic
13th March 2003, 18:19
O I see. I should have said, we're sure this exists in the c:\ directory, right?
Still, I think you want to say 'c:\Andy.txt', not 'c:\\Andy.txt'. I know that slash sometimes gets stripped, but I have a working example of server2client that just uses 'c:\tmp' for the path.
outra9e
13th March 2003, 18:25
Ok
I have removed the extra \, but it does not seems to have made any difference, the Baan account that I am currently logged in as and I am running the session under is bsp so it has permissions...
Any ideas?
Cheers
lbencic
13th March 2003, 18:39
Well, the darn thing works, I have done it.
In my example, I use a true for text mode. Try that...
Also, try typing out the full paths, although the bse.tmp part should work, at least we are eliminating one less problem.
In my example, I also have notes that the capitalization is very important.
This performs an FTP - I am assuming if you try to FTP this file, there is no permission or firewall issues, correct?
About all I can say - here's the simple example I have of server2client that works for us:
server2client("\\Kerma\Baan\TMP\HazMat1.txt", "C:\TEMP\HazMat1.txt", 1)
where Kerma is our server name - this is an NT example.
outra9e
13th March 2003, 18:42
Ahhhh
this is interesting, in your example, the UNIX path is the first path with the path on the client to the file being second....
would this make a difference? Mine is the other way around...
I will give your example a try....
Cheers
lbencic
13th March 2003, 18:44
Mine is for server to client, but they use the same concept. And this example is NT ... I don't think so, but maybe an OS issue.
Try the server to client and see I guess, since this example does work. Put the file in the tmp directory in Baan and see if you can get it to transfer to your PC
outra9e
13th March 2003, 18:54
I have given the server2client a try as you suggested...
server2client "/baan/bse/home/bsp/rop2.txt", "C:\rop2.txt", 1)
This did not work either?
Is there something missing?
Cheers
lbencic
13th March 2003, 19:05
A starting parenthesis?? :)
Assuming you have that in the code -
If you try to FTP to this server using an FTP tool from your PC - are there any issues there?
Also.../baan/bse/home/bsp ... that's the actual name of the path? Our home directories are not part of the BSE path...everyone is set up different, though.
When you go to the file on the os, and do 'pwd', the path it gives should be the exact path you use, including capitals.
If still problems, you could include screen shots of the paths so there is a little better visual on our part.
First make sure FTP is not an issue in general.
outra9e
14th March 2003, 11:09
FTP is definitely not an issue, I use FTP on a daily basis, although I generally use the cmd prompt to ftp to the server as opposed to an ftp client.
I have attached screens of the relevant paths in terms of the client2server funtion...
Many thanks
outra9e
14th March 2003, 18:50
Many apologies
Here are the attachments...
Cheers
NPRao
14th March 2003, 19:46
Andy,
Here is an example to make it simple for you.
string source(80), target(80), fname(20)
fname = "np.txt"
source = "C:\" & fname
target = "/app/common/home/nprao/" & fname
e = client2server(source, target, false)
fname = "ipad"
source = "/app/common/home/nprao/" & fname
target = "C:\" & fname
e = server2client(source, target, false)
It works fine for me so maybe you need to change your code use some variables and test it out.
tools123
15th March 2003, 19:21
If your problem is still unresolved, you may want to make sure a
couple of things are going right:
1.The Path on the server exists and you are able to write a new file onto that path.
example: try creating a new file on the server in the following path:/home/yourbaanlogin
you may use seq.puts or through any other approach.
try to open and look at the file on the server.
2.The path syntax for file on the client side is correct
example:
here is one I use for server2client
f2 = "C:\\Test\\" & "File_"
e=server2client("/home/" & logname$ & "/shortsreport", f2, false, false)
if the file does get created on the client side, you may try the
similar approach for client to server.
Try to use a normal user login to run the session(instead of bsp)
as in the end I am assuming the session could be used by any user.
In the debug, you may want to look at the return values for
server2client or client 2server if they are infact successful.
Good luck
outra9e
18th March 2003, 11:33
NPRao
I have followed your example....
|****************** CHOICE SECTION *************
choice.user.0:
on.choice:
string source(80), target(80), fname(20)
fname = "Andy.txt"
source = "C:\" & fname
target = "/baan/bse/home/bsp/" & fname
e = client2server(source, target, false)
*************************************************
This compiles with no problems, however it is not putting the file on the server.
I know that there are no issues Unix server side. It should put the file into bsp's home dir in which bsp can create files.
Any ideas, or is there anything Im missing?
Cheers
outra9e
18th March 2003, 11:40
Guys
Many many apologies, the session is now working.
I am the biggest idiot...
I had not assigned the program script to the session!
Thanks for all your help...
Cheers