ganesh_kapase
21st March 2006, 11:10
In the existing custz print session we have defined the path to generate ASCII/ TXT file. Instead of pre-defined path in script I wish to generate txt file as per user's choice means user will give path for file in the session input.
existing code
path.id = sprintf$("\\prodn_pc\C\Reco download\bomprod.txt")
seq.id = seq.open(path.id,"w")
if seq.id < 1 then
message("Error in creating file")
exit()
else
create.header()
ret1 = seq.puts(hold.header,seq.id)
read.main.table.D()
seq.close(seq.id)
endif
message("BOM v/s Production Order Report is Generated. File is located at \\prodn_pc\C\Reco download\bomprod.txt")
Please tell me how I should write the script.
Thanks
en@frrom
21st March 2006, 11:20
If I understood you correctly, then this is extremely simple. Just declare you variable path.id as an external string-variable, let's say
extern domain tcmcs.str215 path.id
On the screen you place path.id . You may choose to assign a default path (for instance \\prodn_pc\C\Reco download\bomprod.txt) to it, which the user can choose to overwrite to a different path...
For the rest nothing changes...
Let me know if this helps you..
Pieter van de L
21st March 2006, 11:21
Hi Ganesh,
Here is an example on how we do that
declaration:
table ttisfc001 | sfc order header
table ttisfc010 | sfc order steps
domain tcmcs.st50 e.file.name
extern domain tcmcs.st50 e.file.name1
extern domain tcmcs.st50 e.file.name2
extern domain tcyesno e.local.file
long file | filepointer file
#pragma used dll ottdllbw
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
field.e.file.name1:
when.field.changes:
e.file.name2 = e.file.name1 & "2"
|****************************** choice section ********************************
choice.cont.process:
on.choice:
read.main.table()
|****************************** function section ******************************
functions:
function read.main.table()
{
e.file.name = e.file.name1
open.file()
write.record(concat$(";","tisfc001"
,"Order"
,"end item"
,"status"
,"planning method"
,"rework order"
,"Requested delivery date"
,"Delivery Date"
,"Production start date"
,"completion date"
,"close date"
,"ref date"
,"calc date"
,"actual offline date"
,"offline date"
,"Last Material Allocation"))
select tisfc001.*
from tisfc001
selectdo
write.record(concat$(";","tisfc001"
,tisfc001.pdno
,tisfc001.mitm
,enum.descr$("tcosta",tisfc001.osta)
,enum.descr$("tcplcd",tisfc001.cpla)
,enum.descr$("tcyesno",tisfc001.rwko)
,dat_str(tisfc001.rdld)
,dat_str(tisfc001.dldt)
,dat_str(tisfc001.prdt)
,dat_str(tisfc001.apdt)
,dat_str(tisfc001.cmdt)
,dat_str(tisfc001.cldt)
,dat_str(tisfc001.efdt)
,dat_str(tisfc001.cada)
,dat_str(tisfc001.opdt)
,dat_str(tisfc001.oldt)
,dat_str(tisfc001.lmad)
))
endselect
close.file()
e.file.name = e.file.name2
open.file()
write.record(concat$(";","tisfc010"
,"Order"
,"operation"
,"next operation"
,"end item"
,"task"
,"status"
,"production start date"
,"start date reminder"
,"earliest finish date"
,"latest finish date"
,"actual start date"
,"completion date"
,"planned start date"
,"planned finish date"
,"production ready"))
select tisfc010.*
from tisfc010
selectdo
write.record(concat$(";","tisfc010"
,tisfc010.pdno
,tisfc010.opno
,tisfc010.nopr
,tisfc010.item
,tisfc010.tano
,enum.descr$("tisfc.opst",tisfc010.opst)
,dat_str(tisfc010.prdt)
,dat_str(tisfc010.rsdt)
,dat_str(tisfc010.fidt)
,dat_str(tisfc010.lfdt)
,dat_str(tisfc010.asdt)
,dat_str(tisfc010.cmdt)
,dat_str(tisfc010.psdt)
,dat_str(tisfc010.pfdt)
,dat_str(tisfc010.prrd)))
endselect
close.file()
}
function open.file()
{
if e.local.file = tcyesno.yes then
file = seq.open.local(e.file.name, "w")
else
file = seq.open(e.file.name, "w")
endif
if (file < 1) then
message("fout %d bij openen %s voor schrijven",
file,e.file.name)
stop()
endif
}
function write.record(string buffer(1024))
{
long t.error
if e.local.file = tcyesno.yes then
buffer = buffer & chr$(13) & chr$(10)
t.error = seq.write.local(buffer, len(buffer), file)
if (t.error < 0) then
message("fout %d bij schrijven in %s", t.error,
e.file.name)
stop()
endif
else
t.error = seq.puts(buffer, file)
if t.error then
message("fout %d bij schrijven in %s", t.error,
e.file.name)
stop()
endif
endif
}
function close.file()
{
long t.error
if e.local.file = tcyesno.yes then
seq.close.local(file)
else
t.error = seq.close(file)
if (t.error) then
message("fout %d bij sluiten %s", t.error, e.file.name)
stop()
endif
endif
}
function string dat_str(domain tcutcd i.date)
{
domain tcmcs.st20 datestr
datestr = sprintf$("%u(%02d-%02m-%04Y) %U(%02H:%02m:%02s)",
i.date, i.date)
return(datestr)
}
Regard,
Pieter
en@frrom
21st March 2006, 11:32
Pieter, I don't understand why the long detailed sample program. I understood from Ganesh that he has a well-functioning session, and that the only requirement is to have the user control the fileout path, instead of hard-coding it...?
P.s. Ganesh, of course in your message at the end, you will have to replace your hard-coded file path with the variable, like this:
message("BOM v/s Production Order Report is Generated. File is located at %s", file.id)
ganesh_kapase
21st March 2006, 11:33
Hi En
Your guess is correct. Before posting this thread I tried in the same fashion but many times users are choosing path as (C:\Reco download\bomprod.txt) instead of as I defined in the script. Let me know how to overcome this problem. Is there any way to select path and file name by simply click on Browse or Open button.
You may choose to assign a default path (for instance \\prodn_pc\C\Reco download\bomprod.txt) to it, which the user can choose to overwrite to a different path...
RaymondH
21st March 2006, 13:37
Hi Ganesh,
Maybe the following option wil help you.
Create the file on the Baanserver and then transfer it with server2client to the pc of the user. The user can now use C:\Reco download\bomprod.txt as path and file name.
At the following thread you will find the code for an open file dialog on the local machine.
http://www.baanboard.com/baanboard/showthread.php?t=1910
Maybe this code will help you to write a save file dialog.
mark_h
21st March 2006, 14:52
Hi En
Your guess is correct. Before posting this thread I tried in the same fashion but many times users are choosing path as (C:\Reco download\bomprod.txt) instead of as I defined in the script. Let me know how to overcome this problem. Is there any way to select path and file name by simply click on Browse or Open button.
The sample by Pieter should work for others looking to write locally on the client. My question in this is why does the user entering C:\Reco download\bomprod.txt cause a problem? Are you trying to force them to enter a server name? It seems to me there was a command to make sure that local directories existed before you used the server2client or seq.write.local commands. You might want to try a search on local directories. If I get a chance I will see if I can find that thread.
NPRao
21st March 2006, 21:47
It seems to me there was a command to make sure that local directories existed before you used the server2client or seq.write.local commands. You might want to try a search on local directories.
Refer to the thread - Check client directory (http://www.baanboard.com/baanboard/showthread.php?t=7127&highlight=183)
Is there any way to select path and file name by simply click on Browse or Open button.
This is possible in LN Tools -
SSA ERP LN 6.1 Programmers Guide
seq.open.dialog.local()
--------------------------------------------------------------------------------
Syntax
long seq.open.dialog.local( boolean mselect, string defaultname, string directory, string filter, ref string filename )
Description This shows the Windows file-open dialog, to allow the user to select one or more local files.
Arguments
mselect When true, multiple select is allowed by the user else only one file can be selected by the user.
defaultname The default filename shown in the file-open dialog.
directory The startup directory for this dialog. In case of an empty string the "My Documents" directory will be the default. This parameter may include the string ${BSE_TMP} which indicates the ${BSE}\tmp directory in case of Baan Windows or Windows temp directory in case of Webtop.
filter This argument specifies all possible file extensions for the file. The string must contain pairs of strings that are separated by a "|" character. The first string in each pair is a filter name (for example: "Text Files"). The second string must be a filter patern (for example: "*.txt"). Multiple filter patters can be specified by separating the filter patterns with a semicolon. Example: "All Files(*.*)|*.*|Text Files(*.txt) Word documents(*.doc)|*.txt;*.doc"
filename Output argument which will contain the full path of the file selected by the user. In case mselect is true possible other selected file names can be retrieved using function seq.open.dialog.next()
Return values
>0 Number of files selected by the user.
0 File open dialog canceled by the user.
-1 Error occurred
Context ttdllbw library function.
ganesh_kapase
22nd March 2006, 07:32
Hi Mark
I have given the path as an example. User can enter the path according to the availability of drive/folders on their local PC. There is no compulsion to enter server name. As mentioned by me file is creating as per the path defined in the script. What I reqd. user has to define the path in the inputs and file should get generated accordingly.
My question in this is why does the user entering C:\Reco download\bomprod.txt cause a problem? Are you trying to force them to enter a server name?
en@frrom
23rd March 2006, 11:34
Sorry for late response; had very little time for BaanBoard lately.. I never tried opening a file-browser dialog in Baan, as I see from NPRao, this is available as standard functionality in LN.. Has anyone got a stable flowless way to do it in Baan IV/V?
vahdani
23rd March 2006, 15:28
Hi all,
here is my solution for local file selection problem. I want to dedicate this to Baanboard and all its members.
en@frrom
23rd March 2006, 16:10
Hi Vahdani,
Thanks for posting your solution. Can you please explain to us what exactly your program is meant to do? I installed it, but received no result...?
bdittmar
23rd March 2006, 16:33
Hi all,
here is my solution for local file selection problem. I want to dedicate this to Baanboard and all its members.
Hello,
what's $BSE/bin/......exe on Unix systems ??
Think it only works on MS systems.
Regards
mark_h
23rd March 2006, 16:37
I think it can work for a UNIX system also. I think all you have to do is change the app_start location to something on the client. Haven't tried it yet, but I hope to have time next week.
vahdani
23rd March 2006, 16:59
Hi all,
the exe is of course run on client and not on the server! It will be copied first to the Windows Temp directory to find out where this is just type the following in your dos box:
cd %TEMP%
The program generates a text file in this directory which will then be copied back to the server for interrogation ;)
You can do a stand alone test of the exe by copying it to your PC and running it. The usual windows file selector dialog should come up. If you select a file and exit a file BaanFileSelector.txt should be generated in the same directory.
en@frrom: You have to use the Baan function I provided in your own program therfeore this will only be of interest to Baan programers.
en@frrom
23rd March 2006, 17:33
:D Thanks Vahdani for making me smile :D
It didn't work by me at first. After checking, I saw that the exe-file was copied from server to local temp, but the new (local) file was an empty file -> 0kb.. Therefor also of course the second and third attempt didn't work, because the exe-file wasn't re-created... Only after removing the exe-file and running it again, it worked... Strange..
One remark/request: the file-browser dialog header is now in German. Would maybe be nice if you could make it variable, i.e. system language...
Thanks and regards,
En
en@frrom
23rd March 2006, 17:51
Ok, it's sticking into a standard DLL ready for use; it's already applied to one session...
One more question: I am sure you had a reason for the suspend(1000) in the function...??
vahdani
24th March 2006, 12:46
Hi en@frrom!
that's not your real name; Is it?
I'm glad that you had this running and find it usefull.
As for the Title: I've updated the zip-File with a new version of the exe in which the standard windows title in system language should be shown.
The 1 Sec delay is to allow the windows application (here BaanFileSelector) to launch. MS Word may take longer to launch BaanFileSelector on the other hand definitely takes less.
en@frrom
24th March 2006, 12:56
I just looked in my passport, and indeed my names is not mentioned "en@frrom". After wondering why, I remembered that the @ symbol didn't really exist back in those days.... So no, my "real" name is not en@frrom...
Thanks Vahdani for the updated version, this looks better...