jojovalenton
22nd October 2014, 15:48
hello,

i just want to ask if it is possible for an afs application (LN fp7) to run at a certain time/date automatically? i am planning to make an afs for a standard print session that will run automatically.

thanks,

jojo

mark_h
22nd October 2014, 15:56
I can't say for sure for LN, but for 4c4 we have some that are scheduled to run on a nightly basis.

jojovalenton
22nd October 2014, 16:30
Is it ok to ask for your afs scripts used and where it is placed in the system to run automatically?

thanks,

jojo

benito
22nd October 2014, 17:53
is there any reason why you can't use the windows task scheduler?

jojovalenton
23rd October 2014, 08:11
if it is possible to run LN sessions through windows task scheduler maybe i can consider using it or if you can suggest how to use it in LN. thanks.

mark_h
23rd October 2014, 15:53
Our 4c4 system we use cron to schedule them. The jobs are setup through the normal baan sessions - Maintain Jobs. The scripts that run are the same scripts the users use. What we do in the session is something to initial items the users might select. Here is an example:


If job.process then
tag.report = "rtdilc940116000"
outbound.report = "rtdilc440110000"
process.operation.table()
endif


The API code is really all in the libraries not in the session itself. But basically the above will call a routine to generate outbound based some tables. Then it will print the pick tags we use and the outbound for the user. I am not sure this example is in production. We have another pick program that runs nightly where the user tells us what warehouse, what reports and what printer to send them do. Basically the same stuff they could do in the session itself - we just read the setup parameters from another table before running any AFS code.

jojovalenton
23rd October 2014, 17:16
can i ask what API code you used in the declaration? thanks.

mark_h
23rd October 2014, 20:25
Not sure what you mean. Below is basically the code - the actuall api calls are in libraries.


declaration:
table ttdilc410 | Run Numbers
table tttaad300 | Devices
table ttdapi402 | Warehouse groups
table ttdinv990 | Floor Stock Warehouses
table ttcmcs003 | Warehouses
table ttdudi071 | Pick by Operation Table
table tticst001 | Estimated and actual materials

| Form fields
extern domain tcmcs.str12 runn
extern domain tcitem item.f, item.t
extern domain tcorno orno.f, orno.t
extern domain tcopno opno.f, opno.t
extern domain tccwar cwar.f, cwar.t
extern domain tgyenox prnt.advice, prnt.shortage, prnt.tag, prnt.outbound
extern domain timps.devi advice.printer, shortage.printer, tag.printer, outbound.printer
extern domain tcdsca advice.dsca, shortage.dsca, tag.dsca, outbound.dsca

| script fields
string errmsg(120)
extern domain tcbool group.warehouse
long retcode
extern domain tcmcs.str15 tag.report, outbound.report
extern domain tcmcs.str8 zoom.prog

string hlddatetime(12)
extern string temp.file(1024)

long event_3(EVTMAXSIZE)
|****************************** PROGRAM SECTION ***************************
before.program:
|Clear pending events
while pending.events()>0
next.event(event_3)
endwhile

|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
form.1:
init.form:
get.screen.defaults()

|****************************** CHOICE SECTION ***************************
choice.cont.process:
on.choice:
check.all.input()
if job.process or getenv$("LOGNAME")="hollanma" or getenv$("LOGNAME")<>"henkencd" or getenv$("LOGNAME")<>"maloneab" then
tag.report = "rtdilc940116000" |20090407
outbound.report = "rtdilc440110000" |20090407
process.operation.table()
endif
|****************************** FIELD SECTION ***************************
field.runn:
before.zoom:
zoom.prog = "outbound"
check.input:
select tdilc410.runn
from tdilc410
where tdilc410._index1 = {tdilc.kofr.outbound, :runn}
as set with 1 rows
selectdo
selectempty
message("Run number not setup for outbound.")
set.input.error("")
endselect

field.orno.f:
after.input:
orno.t = orno.f

field.opno.f:
after.input:
opno.t = opno.f

field.item.f:
after.input:
item.t = item.f

field.cwar.f:
after.input:
cwar.t = cwar.f

check.input:
group.warehouse = false
select tdapi402.cwar
from tdapi402
where tdapi402._index2 = {:cwar.f}
as set with 1 rows
selectdo
group.warehouse = true
endselect

before.zoom:
cwar.f = ""
after.zoom:
if isspace(cwar.f) then
cwar.f = tcmcs003.cwar
endif

field.cwar.t:
before.input:
if group.warehouse then
attr.input = false
endif

field.advice.printer:
before.input:
if prnt.advice <> tgyenox.yes then
advice.printer = ""
attr.input = false
endif

after.input:
|* 20041222.st - Printer defaults as requested
advice.printer = toupper$(advice.printer)
shortage.printer = advice.printer
outbound.printer = advice.printer
display("shortage.printer")
display("outbound.printer")
|* 20041222.end - Printer defaults as requested


check.input:
if prnt.advice = tgyenox.yes then
select ttaad300.devc, ttaad300.desc:advice.dsca
from ttaad300
where ttaad300._index1 = {:advice.printer}
and ttaad300._compnr = 0
as set with 1 rows
selectdo
selectempty
message("Not a valid output device.")
set.input.error("")
endselect
display("advice.dsca")
endif

field.shortage.printer:
before.input:
if prnt.shortage <> tgyenox.yes then
shortage.printer = ""
attr.input = false
endif

after.input:
shortage.printer = toupper$(shortage.printer)

check.input:
if prnt.shortage = tgyenox.yes then
select ttaad300.devc, ttaad300.desc:shortage.dsca
from ttaad300
where ttaad300._index1 = {:shortage.printer}
and ttaad300._compnr = 0
as set with 1 rows
selectdo
selectempty
message("Not a valid output device.")
set.input.error("")
endselect
display("shortage.dsca")
endif

field.tag.printer:
before.input:
if prnt.tag <> tgyenox.yes then
tag.printer = ""
attr.input = false
endif

after.input:
tag.printer = toupper$(tag.printer)

check.input:
if prnt.tag = tgyenox.yes then
select ttaad300.devc, ttaad300.desc:tag.dsca
from ttaad300
where ttaad300._index1 = {:tag.printer}
and ttaad300._compnr = 0
as set with 1 rows
selectdo
selectempty
message("Not a valid output device.")
set.input.error("")
endselect
display("tag.dsca")
endif

field.outbound.printer:
before.input:
if prnt.outbound <> tgyenox.yes then
outbound.printer = ""
attr.input = false
endif

after.input:
outbound.printer = toupper$(outbound.printer)

check.input:
if prnt.outbound = tgyenox.yes then
select ttaad300.devc, ttaad300.desc:outbound.dsca
from ttaad300
where ttaad300._index1 = {:outbound.printer}
and ttaad300._compnr = 0
as set with 1 rows
selectdo
selectempty
message("Not a valid output device.")
set.input.error("")
endselect
display("outbound.dsca")

endif

|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
functions:
function process.operation.table()
{
domain tccwar hold.cwar
hold.cwar = cwar.f
select tdapi402.*
from tdapi402
where tdapi402._index2 = {:cwar.f}
selectdo
cwar.f = tdapi402.cwar
cwar.t = tdapi402.cwar
if job.process then |20060206
hlddatetime = dte$() |20060206
message("Generate: " & cwar.f & " " & hlddatetime(7;2) & ":" & hlddatetime(9;2)) |20060206
endif |20060206
select tdudi071.pdno, tdudi071.opno
from tdudi071, ticst001
where tdudi071.pdno > 0 and
tdudi071.gendte <= date.num()
and ticst001._index1 = {tdudi071.pdno}
and ticst001.opno = tdudi071.opno
and ticst001.cwar = :cwar.f
and ticst001.issu > 0
group by tdudi071.pdno, tdudi071.opno
selectdo
orno.f = tdudi071.pdno
orno.t = orno.f
opno.f = tdudi071.opno
opno.t = opno.f
generate.the.outbound()
print.outbound.stuff()
endselect
selectempty
if job.process then |20060206
hlddatetime = dte$() |20060206
message("Generate: " & cwar.f & " " & hlddatetime(7;2) & ":" & hlddatetime(9;2)) |20060206
endif |20060206
select tdudi071.pdno, tdudi071.opno
from tdudi071, ticst001
where tdudi071.pdno > 0 and
tdudi071.gendte <= date.num()
and ticst001._index1 = {tdudi071.pdno}
and ticst001.opno = tdudi071.opno
and ticst001.cwar = :cwar.f
and ticst001.issu > 0
group by tdudi071.pdno, tdudi071.opno
selectdo
orno.f = tdudi071.pdno
orno.t = orno.f
opno.f = tdudi071.opno
opno.t = opno.f
generate.the.outbound()
print.outbound.stuff()
endselect

endselect
}
| 20121116.end
function generate.the.outbound()
{

spool.device = advice.printer
errmsg=" "
generate_outbound(runn,
orno.f,
orno.t,
opno.f,
opno.t,
item.f,
item.t,
cwar.f,
cwar.t,
prnt.advice,
errmsg)
if errmsg(1;17) = "Printing canceled" then |20060206
errmsg = "" |20060206
endif |20060206
if not isspace(errmsg) then
message("Generate:" & errmsg)
endif
spool.device = shortage.printer
errmsg=" "
if prnt.shortage = tgyenox.yes then
print_shortages(runn,
orno.f,
orno.t,
opno.f,
opno.t,
item.f,
item.t,
cwar.f,
cwar.t,
errmsg)
if not isspace(errmsg) then
message("Shortage:" & errmsg)
endif
endif
}
function print.outbound.stuff()
{
spool.device = tag.printer
errmsg=" "
if prnt.tag = tgyenox.yes then

print_pick_tags(runn,
orno.f,
orno.t,
opno.f,
opno.t,
item.f,
item.t,
cwar.f,
cwar.t,
tag.report,
errmsg)
if errmsg(1;13) = "No data found" then
errmsg = ""
endif
if not isspace(errmsg) then
message("Pick Tag:" & errmsg)
endif
endif
spool.device = outbound.printer
errmsg=" "
if prnt.outbound = tgyenox.yes then
print_outbound(runn,
orno.f,
orno.t,
opno.f,
opno.t,
item.f,
item.t,
cwar.f,
cwar.t,
date.num(),
date.num(),
outbound.report,
errmsg)
if not isspace(errmsg) then
message("Outbound:" & errmsg)
endif
endif
}

jojovalenton
24th October 2014, 06:15
hi mark,

thanks a lot for this help, i will try this out in my case.

jojo

bhushanchanda
29th October 2014, 10:03
Hi,

To know how to use Windows Task Scheduler to automate the sessions follow this Thread (http://www.baanboard.com/baanboard/showthread.php?p=192438#post192438)

jojovalenton
30th October 2014, 17:12
Thanks a lot for this link.

regards,

jojo