smusba
12th January 2016, 14:15
I have written a program for monthly sales report for a year 2015.
When this program is defined as report layout it is fine. But, the same script if I want the output to excel there are some modifications which I have perfromed in the script. But the output is not as desired. I have attached my script as well as my Excel file for your reference.
Check the Excel Sheet1 and Excel Sheet 2 . I want Excel Sheet1 layout to be same as Excel Sheet 2 layout.
Excel file attached
In the first sheet I have written a script as follows.
#pragma used dll ottdllbw
#pragma used dll ottstpapihand
#include <bic_tt>
|****************************** program section ********************************
before.program:
determine.number.of.periods.by.year()
determine.current.year.and.period()
|****************************** group section **********************************
group.1:
init.group:
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
|****************************** field section *********************************
field.ctyp.f:
when.field.changes:
ctyp.t = ctyp.f
|****************************** function section ******************************
functions:
function read.main.table()
{
error.log = bse.tmp.dir$()
error.log = strip$(shiftl$(error.log)) &"\Error_Log_"&dte$()&".txt"
error.log.ptr = seq.open(error.log, "w+")
save.ctyp = ""
save.item = ""
qty(12) = 0.0
|save.item = ""
whse.count = 0
first.pass = tcyesno.yes
temp.line = concat$("|" ,"Employee"
,"Employee Description"
,"January"
,"February"
,"March"
,"April"
,"May"
,"June"
,"July"
,"August"
,"September"
,"October"
,"November"
,"December")
seq.puts(temp.line,error.log.ptr)
seq.puts("",error.log.ptr)
read.qty()
}
function read.qty()
{
cisli240.crep = ""
save.dsca = ""
qty(12) = 0.0
whse.count = 0
| month.in.year = 0
curr.comp = get.compnr()
select cisli240.*,cisli245.*
from cisli240,cisli245
where cisli240.crep <> ""
and cisli240._index1 = {:curr.comp,1,3,cisli245.slso,cisli245.oset}
and cisli240.crep inrange (:crep.f) and (:crep.t)
order by cisli240.crep,cisli245.apdt
selectdo
reset.vars()
ret = utc.to.date(cisli245.apdt,period.year,month.in.year,day.in.month,hrs2,mins2,sec2)
if cur.year = period.year then
qty(month.in.year) = qty(month.in.year) + (cisli245.amth(1)-cisli245.ldai)
tot.qty = tot.qty + (cisli245.amth(1)-cisli245.ldai)
read.tccom001()
rprt_send()
write.line()
else
endif
selectempty
endselect
close.and.transfer.file()
}
function reset.vars()
{
tot.qty = 0
qty(12) = 0.0
for i = 1 to 12
qty(i)=0.0
endfor
}
function determine.number.of.periods.by.year()
{
year.peri = 12
}
function determine.current.year.and.period()
{
long year.no,mnth.no,mnth.day
utc.to.date(utc.num(),year.no,mnth.no,mnth.day,hrs3,mins3,sec3)
cur.year = year.no
cur.peri = mnth.no
cur.day = mnth.day
|message ("year.no % d,mnth.no %d,mnth.day %d",year.no,mnth.no,mnth.day)
}
function read.tccom001()
{
select tccom001.nama:save.dsca
from tccom001
where tccom001._index1 = {:cisli240.crep}
selectdo
selectempty
cisli240.crep= "XXXXX"
save.dsca= "Other Sales"
endselect
}
function close.and.transfer.file()
{
seq.close(error.log.ptr)
create.local.directory ("C:\tmp")
|
client.file = "C:\tmp\Error_Log_"&dte$()&".xls"
|
|
server2client( error.log,client.file ,false)
app_start ( client.file, "C:\tmp","","","")
| message("File is created at "&client.file)
}
function write.line()
{
item.no = item.no + 1
if item.no >0 then
temp.line = concat$("|" ,cisli240.crep
,save.dsca
,qty(1)
,qty(2)
,qty(3)
,qty(4)
,qty(5)
,qty(6)
,qty(7)
,qty(8)
,qty(9)
,qty(10)
,qty(11)
,qty(12))
seq.puts(temp.line,error.log.ptr)
endif
|seq.puts("",error.log.ptr)
}
When this program is defined as report layout it is fine. But, the same script if I want the output to excel there are some modifications which I have perfromed in the script. But the output is not as desired. I have attached my script as well as my Excel file for your reference.
Check the Excel Sheet1 and Excel Sheet 2 . I want Excel Sheet1 layout to be same as Excel Sheet 2 layout.
Excel file attached
In the first sheet I have written a script as follows.
#pragma used dll ottdllbw
#pragma used dll ottstpapihand
#include <bic_tt>
|****************************** program section ********************************
before.program:
determine.number.of.periods.by.year()
determine.current.year.and.period()
|****************************** group section **********************************
group.1:
init.group:
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
|****************************** field section *********************************
field.ctyp.f:
when.field.changes:
ctyp.t = ctyp.f
|****************************** function section ******************************
functions:
function read.main.table()
{
error.log = bse.tmp.dir$()
error.log = strip$(shiftl$(error.log)) &"\Error_Log_"&dte$()&".txt"
error.log.ptr = seq.open(error.log, "w+")
save.ctyp = ""
save.item = ""
qty(12) = 0.0
|save.item = ""
whse.count = 0
first.pass = tcyesno.yes
temp.line = concat$("|" ,"Employee"
,"Employee Description"
,"January"
,"February"
,"March"
,"April"
,"May"
,"June"
,"July"
,"August"
,"September"
,"October"
,"November"
,"December")
seq.puts(temp.line,error.log.ptr)
seq.puts("",error.log.ptr)
read.qty()
}
function read.qty()
{
cisli240.crep = ""
save.dsca = ""
qty(12) = 0.0
whse.count = 0
| month.in.year = 0
curr.comp = get.compnr()
select cisli240.*,cisli245.*
from cisli240,cisli245
where cisli240.crep <> ""
and cisli240._index1 = {:curr.comp,1,3,cisli245.slso,cisli245.oset}
and cisli240.crep inrange (:crep.f) and (:crep.t)
order by cisli240.crep,cisli245.apdt
selectdo
reset.vars()
ret = utc.to.date(cisli245.apdt,period.year,month.in.year,day.in.month,hrs2,mins2,sec2)
if cur.year = period.year then
qty(month.in.year) = qty(month.in.year) + (cisli245.amth(1)-cisli245.ldai)
tot.qty = tot.qty + (cisli245.amth(1)-cisli245.ldai)
read.tccom001()
rprt_send()
write.line()
else
endif
selectempty
endselect
close.and.transfer.file()
}
function reset.vars()
{
tot.qty = 0
qty(12) = 0.0
for i = 1 to 12
qty(i)=0.0
endfor
}
function determine.number.of.periods.by.year()
{
year.peri = 12
}
function determine.current.year.and.period()
{
long year.no,mnth.no,mnth.day
utc.to.date(utc.num(),year.no,mnth.no,mnth.day,hrs3,mins3,sec3)
cur.year = year.no
cur.peri = mnth.no
cur.day = mnth.day
|message ("year.no % d,mnth.no %d,mnth.day %d",year.no,mnth.no,mnth.day)
}
function read.tccom001()
{
select tccom001.nama:save.dsca
from tccom001
where tccom001._index1 = {:cisli240.crep}
selectdo
selectempty
cisli240.crep= "XXXXX"
save.dsca= "Other Sales"
endselect
}
function close.and.transfer.file()
{
seq.close(error.log.ptr)
create.local.directory ("C:\tmp")
|
client.file = "C:\tmp\Error_Log_"&dte$()&".xls"
|
|
server2client( error.log,client.file ,false)
app_start ( client.file, "C:\tmp","","","")
| message("File is created at "&client.file)
}
function write.line()
{
item.no = item.no + 1
if item.no >0 then
temp.line = concat$("|" ,cisli240.crep
,save.dsca
,qty(1)
,qty(2)
,qty(3)
,qty(4)
,qty(5)
,qty(6)
,qty(7)
,qty(8)
,qty(9)
,qty(10)
,qty(11)
,qty(12))
seq.puts(temp.line,error.log.ptr)
endif
|seq.puts("",error.log.ptr)
}