marwest98
16th July 2008, 18:14
We have a session that requires the users to input a filename. Since we are in the process of converting from Unix to SQLServer 2005, I am testing scripts. Normally in this session the user types in a Direction File of /usr/bsp/myreport/rpdistnew.csv and an error file of /usr/bsp/myreport/rpdist.err. To convert to windows, I have modified the script to use \ instead of /. I have tried various ways to put the file name in, but the script builds the file path with \\ - \\usr\\bsp\\myreport\\rpdistnew.csv for example. It does not matter how I put the file name in - I've tried using the server name \\fwbaan\baan5c\usr etc, and then it does \\\\fwbaan\baan5c\usr..... If I try fwbaan\baan5c\usr... I get fwbann\\baan5c\\usr. How can I stop this from happening? Here is a copy the script.

|******************************************************************************
|* timjrc425 0 VRC B50C c prod
|* Print Period Profit Report for Branch Managers
|* General_User_UNIX
|* 2003-07-30
|******************************************************************************
|* Main table tfgld005 Periods, Form Type 4
|* Amit Biswas
|******************************************************************************
| This session is created to print reports for all Branch Managers/Gen. Managers.
| There should be a direction file. Currently it is maintained as
| /usr/bsp/mjreport/rpdistnew.csv .It may be modified according to needs.
| It is a CSV file containing the fields as following:-
| Name of the Manager, path string on I directory ( by concatenating another string with
| it respective file names are generated for the concerned Managers) and branch numbers.
| There are provisions for 16 branch numbers, each branch is designated with two-digit code
| and should be present on the branch table.
| The program reads this file , for each record it will generate three separate reports
| covering designated branches and push the files finally to different folders on I drive | meant for the concerned Manager .
| The type of file created is postscript( with .ps extension) to be opened with ghostview
| software.
| Error file will contain error message if any.
| Before writing any file on Client ( C: or I:) first it writes a temporary file on the
| Unix directory "/usr/bsp/mjreport" (to be removed after it is copied to client).
|****************************** declaration section ***************************
declaration:

table ttfgld005 | Periods
table ttfgld006 | End Dates by Year
table ttimjr907 | Sales Group with Sales category
table ttimjr906 | Sales Group
table ttimjr910 | Product
table ttimjr912 | Stores
table ttimjr913 | Retail Price
table ttimjr923 | Scanned Sales

extern string buff(2048)
extern string ebuf(2048)
extern domain tcmcs.str10 tbid.f
extern domain tcmcs.str10 tbid.t
extern domain tcmcs.str20 stor.f
extern domain tcmcs.str20 stor.t
extern domain tfgld.ptyp ptyp.t
extern domain tfgld.ptyp ptyp.f
extern domain tfgld.ptyp ptyp.t
extern domain tfgld.year year.f

extern domain tfgld.prod prno.f

extern domain tccitg scat.f,scat.t
extern domain tccitg sgrp.f,sgrp.t
extern domain tfgld.date last.date ,wk.ldt
extern domain tcamnt samnt
extern domain tcqana sunit
extern domain tcpric rpric,n.price,opric,wpric
extern domain tcweek weekno
extern domain tcyesno second.header
extern domain tcmcs.str50 dirpath,r.path,e.file
extern domain tcmcs.str15 nam
extern domain tcmcs.long el,id1,id2,id3
extern domain tcmcs.str4 lv0,lv1,lv2

extern domain tccitg bran.f1,bran.f2,bran.f3,bran.f4,bran.f5,bran.f6,bran.f7,bran.f8,bran.f9,bran.f10,bran.f11,bran.f12,bran.f13,bran.f14
extern domain tccitg bran.t1,bran.t2,bran.t3,bran.t4,bran.t5,bran.t6,bran.t7,bran.t8,bran.t9,bran.t10,bran.t11,bran.t12,bran.t13,bran.t14

extern domain tcmcs.str40 ps2pdf
extern domain tcmcs.long flno
|****************************** form section **********************************

form.1:
init.form:
get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
flno=0
if isspace(dirpath) or isspace(e.file) then
message("Direction file or Error file must not be empty..")
choice.again()
endif
read.main()


|****************************** field section *********************************
field.sgrp.f:
when.field.changes:
sgrp.t = sgrp.f
field.scat.f:
when.field.changes:
scat.t = scat.f
field.ptyp.f:
when.field.changes:
ptyp.t = ptyp.f



field.stor.f:
when.field.changes:
stor.t = stor.f


|****************************** function section *****************************

functions:
function read.main()
{


long count
long fl, ret
el=0
fl = seq.open(dirpath,"r+")
if fl < 0 then
message("Cannot open Direction file")
exit()
endif


db.retry.point()
while not seq.eof(fl)
buff=""
ebuf=""


seq.gets(buff ,2048,fl)

buff=strip$(shiftl$(buff))
if not isspace(buff) then

init.values()
read.line()


endif

endwhile
seq.close(fl)
fl=0
if el <> 0 then
seq.close(el)
endif
el=0


}
function read.main.table2()
{ second.header=tcyesno.yes
open.reports()
select timjr912.stor,timjr912.tbid,timjr912.nama,timjr912.bran
from timjr912
where timjr912._index1 between {:tbid.f,:stor.f} and {:tbid.t,:stor.t}
and ( timjr912._index2={:bran.f1}
or timjr912._index2={:bran.t1}
or timjr912._index2={:bran.f2}
or timjr912._index2={:bran.t2}
or timjr912._index2={:bran.f3}
or timjr912._index2={:bran.t3}
or timjr912._index2={:bran.f4}
or timjr912._index2={:bran.t4}
or timjr912._index2={:bran.f5}
or timjr912._index2={:bran.t5}
or timjr912._index2={:bran.f6}
or timjr912._index2={:bran.t6}
or timjr912._index2={:bran.f7}
or timjr912._index2={:bran.t7}
or timjr912._index2={:bran.f8}
or timjr912._index2={:bran.t8}


or timjr912._index2={:bran.f9}
or timjr912._index2={:bran.t9}
or timjr912._index2={:bran.f10}
or timjr912._index2={:bran.t10}
or timjr912._index2={:bran.f11}
or timjr912._index2={:bran.t11}
or timjr912._index2={:bran.f12}
or timjr912._index2={:bran.t13}
or timjr912._index2={:bran.f14}
or timjr912._index2={:bran.t14}


)
order by timjr912._index1
selectdo
last.date =0
select tfgld005.*, tfgld006.*
from tfgld005, tfgld006
where tfgld005._index1={tfgld.ptyp.financial, :year.f, :prno.f}

and tfgld005.year refers to tfgld006
order by tfgld005._index1
selectdo

last.date = tfgld005.stdt +27
if tfgld005.prno > 12 then
get.last.date.last.period()
endif
select timjr907.*,timjr906.dsca
from timjr907,timjr906
where timjr907.sgrp =timjr906.sgrp
order by timjr907._index1
selectdo

select timjr910.prid ,timjr910.dsca,timjr910.scat
from timjr910
where timjr910.scat=:timjr907.scat
order by timjr910.prid
selectdo
sunit =0
samnt = 0
rpric = 0
opric = 0
wpric = 0
n.price =0
select timjr923.*
from timjr923
where timjr923._index1={:timjr912.tbid,:timjr912.stor,:timjr910.prid}
and timjr923.scdt between :tfgld005.stdt and :last.date
and timjr923.qana <> 0
order by timjr923.scdt
selectdo
get.retail.price( timjr923.scdt)
wpric = timjr923.amnt/timjr923.qana
get.week.no()


if ( rpric <> 0 and n.price <> rpric ) or
( opric <> 0 and wpric <> opric ) then
send.reports()
sunit =0
samnt = 0
endif
rpric= n.price
opric = wpric
sunit =sunit + timjr923.qana
samnt =samnt + timjr923.amnt



selecteos


send.reports()
endselect
endselect
endselect

endselect

endselect
close.reports()
move.reports()

}



function get.retail.price( domain tfgld.date scdt)
{
domain tcbool got
got = false
n.price = 0
select timjr913.pric,timjr913.efdt
from timjr913
where timjr913._index1={:timjr912.tbid,:timjr910.prid,:timjr912.stor}
and timjr913.efdt <= :scdt
and timjr913.exdat >=:scdt
and timjr913.exdat > 0
order by timjr913.efdt
selectdo
selecteos
got=true
n.price = timjr913.pric
selectempty
got= false
endselect
if not got then
get.default.retail.price( scdt)
endif
timjr913.pric =0
}

function get.default.retail.price( domain tfgld.date scdt0)
{
n.price = 0
select timjr913.pric,timjr913.efdt
from timjr913
where timjr913._index1={:timjr912.tbid,:timjr910.prid,:timjr912.stor}
and timjr913.efdt <= :scdt0
and timjr913.exdat = 0

order by timjr913.efdt
selectdo
selecteos
n.price = timjr913.pric

endselect


}


function get.last.date.last.period()
{ domain tfgld.year yr
yr = tfgld005.year
select tfgld006.fpdt:last.date
from tfgld006
where tfgld006._index1={:yr}
selectdo
endselect

}

function get.week.no()
{


if timjr923.scdt >= (tfgld005.stdt+21) and
timjr923.scdt <= (tfgld005.stdt +27) then
weekno = (tfgld005.prno -1)*4 +4
wk.ldt = tfgld005.stdt +27
endif
if timjr923.scdt >= (tfgld005.stdt+14) and
timjr923.scdt <= (tfgld005.stdt +20) then
weekno = (tfgld005.prno -1)*4 +3
wk.ldt = tfgld005.stdt +20
endif
if timjr923.scdt >= (tfgld005.stdt+7) and
timjr923.scdt <= (tfgld005.stdt +13) then
weekno = (tfgld005.prno - 1)*4 +2
wk.ldt = tfgld005.stdt +13
endif
if timjr923.scdt >= (tfgld005.stdt) and
timjr923.scdt <= (tfgld005.stdt +6) then
weekno = (tfgld005.prno -1)*4 +1
wk.ldt = tfgld005.stdt +6
endif

}

function init.values()
{
nam=""
r.path=""
bran.f1=""
bran.f2=""
bran.f3=""
bran.f4=""
bran.f5=""
bran.f6=""
bran.f7=""
bran.f8=""
bran.t1=""
bran.t2=""
bran.t3=""
bran.t4=""
bran.t5=""
bran.t6=""
bran.t7=""
bran.t8=""


bran.f9=""
bran.f10=""
bran.f11=""
bran.f12=""
bran.f13=""
bran.f14=""
bran.t9=""
bran.t10=""
bran.t11=""
bran.t12=""
bran.t13=""
bran.t14=""

id1=0
id2=0
id3=0
lv0=""
lv1=""
lv2=""
}

function read.line()

{
if string.scan(buff,"%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
nam,r.path,bran.f1,bran.f2,bran.f3,bran.f4,bran.f5,bran.f6,bran.f7,bran.f8,bran.f9,bran.f10,bran.f11,bran.f12,bran.f13,bran.f14,
bran.t1,bran.t2,bran.t3,bran.t4,bran.t5,bran.t6,bran.t7,bran.t8,bran.t9,bran.t10,bran.t11,bran.t12,bran.t13,bran.t14) < 18 then
ebuf="strip$(buff)&"|Err:Incorrect format "
write.error()

else
r.path=shiftl$(r.path)


read.main.table2()

endif


}

function write.error()
{
if el = 0 then
el = seq.open( e.file,"w+")
endif
seq.puts(ebuf,el)
ebuf=""

}

function open.reports()
{
spool.fileout="\usr\bsp\mjreport\rep1.ps"
id1=brp.open("rtimjrc42311000","POSTSCRIPT",0)

spool.fileout="\usr\bsp\mjreport\rep2.ps"
id2=brp.open("rtimjrc42312000","POSTSCRIPT",0)

spool.fileout="\usr\bsp\mjreport\rep3.ps"
id3=brp.open("rtimjrc42313000","POSTSCRIPT",0)
}

function send.reports()
{
spool.fileout="\usr\bsp\mjreport\rep1.ps"
brp.ready(id1)

spool.fileout="\usr\bsp\mjreport\rep2.ps"
brp.ready(id2)
spool.fileout="\usr\bsp\mjreport\rep3.ps"
brp.ready(id3)
}


function close.reports()
{
brp.close(id1)
brp.close(id2)
brp.close(id3)
}

function move.reports()
{
flno=flno +1
|server2client("\usr\bsp\mjreport\rep1.ps","I:\PRISMREPORTNEW\TEMP_DIR\"&"rp1"&str$(flno)&".ps",0,0)

server2client("\usr\bsp\mjreport\rep1.ps","I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"1"&str$(year.f)&str$(prno.f)&".ps",0,0)
|convert.files(ps2pdf,"I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"1" ,flno,"1")

flno=flno +1
|server2client("\usr\bsp\mjreport\rep2.ps","I:\PRISMREPORTNEW\TEMP_DIR\"&"rp2"&str$(flno)&".ps",0,0)

server2client("\usr\bsp\mjreport\rep2.ps","I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"2"&str$(year.f)&str$(prno.f)&".ps",0,0)
|convert.files(ps2pdf,"I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"2" ,flno,"2")

flno=flno +1
|server2client("\usr\bsp\mjreport\rep3.ps","I:\PRISMREPORTNEW\TEMP_DIR\"&"rp3"&str$(flno)&".ps",0,0)

server2client("\usr\bsp\mjreport\rep3.ps","I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"3"&str$(year.f)&str$(prno.f)&".ps",0,0)
|convert.files(ps2pdf,"I:\PRISMREPORTNEW\"&strip$(shiftl$(r.path))&"3" ,flno,"3")

file.rm("\usr\bsp\mjreport\rep1.ps")
file.rm("\usr\bsp\mjreport\rep2.ps")
file.rm("\usr\bsp\mjreport\rep3.ps")

}


function convert.files( domain tcmcs.str40 pspd ,domain tcmcs.str40 rpth , domain tcmcs.long fl0,domain tcmcs.str1 fl)
{
long aid

if not isspace(pspd) then
aid = app_start( strip$(shiftl$(pspd))&" I:\PRISMREPORTNEW\TEMP_DIR\"&"rp"&fl&str$(fl0)&".ps "&rpth&str$(year.f)&str$(prno.f)&".pdf","","","","")
endif
}

It won't let me copy the form.

Hitesh Shah
16th July 2008, 18:41
Extra \ appear only as an escape character while debugging . Actually it works only without an extra \ . We have never encountered problem like this in our windows installation.

marwest98
16th July 2008, 20:02
It doesn't make any difference whether I am in debug mode or not. I still cannot get the file.

dkulikow
16th July 2008, 20:42
Hello,

We went from Unix to Windows w/SQL database a couple of years ago and I'm not sure if this will help you out or not, but we had similar issues.

This is a path we used to have in Unix with our program: seq.path = "/usr/local/flexfab/data/Juarez/packlist/current/". Now it looks like this: seq.path = "e:\Baan\flexfab\data\Juarez\packlist\current\".

The "e:" drive is our Baan Application server drive.

Like I said, it may or may not be helpful. I hope it is and good luck to you.

Best regards...

marwest98
16th July 2008, 20:52
Does not seem to make any difference. Our Baan application server drive happens to be c:, I've tried the c: \\fwbaan - (server name) baan5c - server drive name and also using ${BSE}. It doesn't seem to make any difference.

I'm really not impressed with Baan. I've worked on a lot of different packages, and this one is a pain.

marwest98
16th July 2008, 20:59
Got It!!!!!!!!

wiggum
17th July 2008, 12:09
You can always use slashes. It is not necessary to change backslash to slash as baan converts the path by itself for windows.

marwest98
22nd July 2008, 19:45
done with this closing

mark_h
22nd July 2008, 22:27
Glad you solved your problem, but we typically leave threads open so that in the future someone else with the same problem can ask additional questions.

Thanks