das_k_tushar
11th August 2004, 14:34
Hi,
we are trying to call a session (Customized) from a standard session, we have BaaNIV
My requirement is like this.
After executing the session tipcs5210m000 (Confirm Planned PRP production Order), it update the Order Status based on Project & production order on table tipcs510. when we again execute session tipcs5250m00 (Transfer Planned PRP production order) and after transfer it update the table tipcs510 (previous record) with new status. Therefore in table tipcs510, there is no history, when the PRP production order confirmed and transferred. We want keep track of the confirmation and transfer. To do so, we have created a customized table as replica of tipcs510 with a key of project, production order & order status and we have developed a session for updating based on project & production order. We want to run the this customized session, when ever user run this two session (tipcs5210m000 & tipcs5250m000), after press continue button the system will activate the customized session and update the customized table with respect to project no and production order.
Looking for help.
Regards,
mark_h
11th August 2004, 15:28
Do you have source code for the sessions? If so just use that to update any tables you want or to zoom.to or activate other sub-sessions.
If you do not have source then you could use one of the wrapper programs - RMCgen, qkey, extend source code(in code and utilities forum). Then you can activate or update your other table as needed. It is a little more difficult with this method but it is doable.
Mark
das_k_tushar
12th August 2004, 05:55
Thanks Mark, We donot have source Code, we want to do the other work around. could you please provide me some light in that area, how to write or send me some sample, so that we can try to solve our problem.
Best Regards,
SriksAdi
12th August 2004, 07:18
Hi Tushar,
You mentioned "We want to run the this customized session, when ever user run this two session (tipcs5210m000 & tipcs5250m000)". Instead of running the customized session from the standard session, why not run the standard session from customized session? Call standard session to update the replica table and then call tipcs5210m000 or tipcs5250m000 to perform the standard process.
I understand that the there would be pretty less control on the updations on the replica table. In this case the users has to maintain the discipline of updating the session thoughtfully.
regards
Sriks
das_k_tushar
12th August 2004, 07:28
Hi Sriks,
I was thinking the same way, but how we will pass the production order no and project no and other parameter to the standard session from customised session and also if the user cancel the the standard session instead of continue, how we can get the return value, so that we can roll back our customised table. any light? I will be greatful.
Regards,
Tushar
SriksAdi
12th August 2004, 07:43
Hi,
As I said earlier it's the users decipline to continue and not cancel.
Other option available is AFS, where in the user access the standard session from your customised session. And you are very much sure, that the continue button is pressed, rather you are pressing continue only.
regards
Sriks
Hitesh Shah
13th August 2004, 07:21
As others pointed out AFS is an obvious solution . tipcs5250m000 also has subsession tipcs5250s000 which uses the same script . So u can declare all form fields of tipcs5250s000 as extern and set values for those variables in ur customer script and call the session tipcs5250s000 with zoom.to$ function . This way u would be able to run tipcs5250s000 automatically without user having to key in the values again in tipcs5250m000 .
das_k_tushar
14th August 2004, 06:32
Thanks Hitesh,
the suggestion u provide is logical and we want to do that, can you provide me a sample program scripts using zoom.to$, I will change according to our requirments.
Best regards,
Hitesh Shah
14th August 2004, 09:47
We already have an AFS code working for tipcs5250m000. Maybe u find it useful.
|Here AFS is used to Transfer only confirmed PRP orders only.Series for studded is hardcoded
|to >10 (if free nos available) and unstudded items are to series >41.
|This will release sfc orders too.
function domain tcbool afs.transfer()
{
domain tcbool afs.done,stud.found
domain tcorno stud.orno
domain tcgrno ord.series
error.msg = ""
afs.done = true
stud.found = false
stud.orno = 1000000
select tipcs510.orno:stud.orno
from tipcs510
where tipcs510._index1 = {:tipcs901.cprj}
and tipcs510.osta = tcorsa.release
and tipcs510.item refers to tijwx984
and tijwx984.stun = tcyesno.yes
as set with 1 rows
selectdo
stud.found = true
endselect
mess("tijwx0199m001",0)
ord.series = get.ord.series(10) |Hardcoded
stpapi.put.field("tipcs5250m000","cprj.f",tipcs901.cprj)
stpapi.put.field("tipcs5250m000","cprj.t",tipcs901.cprj)
stpapi.put.field("tipcs5250m000","orno.f",str$(0))
stpapi.put.field("tipcs5250m000","orno.t",str$(stud.orno - 1))
stpapi.put.field("tipcs5250m000","item.f"," ")
stpapi.put.field("tipcs5250m000","item.t","ZZZZZZZZZZZZZZZZ")
stpapi.put.field("tipcs5250m000","citg.f"," ")
stpapi.put.field("tipcs5250m000","citg.t","ZZZZZZ")
stpapi.put.field("tipcs5250m000","planner.f",str$(0))
stpapi.put.field("tipcs5250m000","planner.t",str$(999999))
stpapi.put.field("tipcs5250m000","order.series",str$(ord.series))
stpapi.set.report("tipcs5250m000","rtipcs525001000","D",error.msg)
if isspace(error.msg) then
stpapi.continue.process("tipcs5250m000",error.msg)
endif
if not isspace(error.msg) then
message(error.msg)
afs.done = false
endif
if afs.done and stud.found then
mess("tijwx0199m002",0)
ord.series = get.ord.series(41) |Hardcoded
stpapi.put.field("tipcs5250m000","cprj.f",tipcs901.cprj)
stpapi.put.field("tipcs5250m000","cprj.t",tipcs901.cprj)
stpapi.put.field("tipcs5250m000","orno.f",str$(stud.orno))
stpapi.put.field("tipcs5250m000","orno.t",str$(999999))
stpapi.put.field("tipcs5250m000","item.f"," ")
stpapi.put.field("tipcs5250m000","item.t","ZZZZZZZZZZZZZZZZ")
stpapi.put.field("tipcs5250m000","citg.f"," ")
stpapi.put.field("tipcs5250m000","citg.t","ZZZZZZ")
stpapi.put.field("tipcs5250m000","planner.f",str$(0))
stpapi.put.field("tipcs5250m000","planner.t",str$(999999))
stpapi.put.field("tipcs5250m000","order.series",str$(ord.series))
stpapi.set.report("tipcs5250m000","rtipcs525001000","D",error.msg)
if isspace(error.msg) then
stpapi.continue.process("tipcs5250m000",error.msg)
endif
if not isspace(error.msg) then
message(error.msg)
afs.done = false
endif
endif
stpapi.end.session("tipcs5250m000",error.msg)
return (afs.done)
}
|Here AFS is used to release production orders with planned status.
|Full range for that project.
function domain tcbool afs.release()
{
domain tcbool afs.done
mess("tijwx0199m003",0)
error.msg = ""
afs.done = true
stpapi.put.field("tisfc0204m000","cprj.f",tipcs901.cprj)
stpapi.put.field("tisfc0204m000","cprj.t",tipcs901.cprj)
stpapi.put.field("tisfc0204m000","pdno.f",str$(0))
stpapi.put.field("tisfc0204m000","pdno.t",str$(999999))
stpapi.put.field("tisfc0204m000","item.f"," ")
stpapi.put.field("tisfc0204m000","item.t","ZZZZZZZZZZZZZZZZ")
stpapi.put.field("tisfc0204m000","prdt.f",str$(date.num() - 500 ))
stpapi.put.field("tisfc0204m000","prdt.t",str$(date.num() + 500 ))
stpapi.set.report("tisfc0204m000","rtisfc020401000","D",error.msg)
if isspace(error.msg) then
stpapi.continue.process("tisfc0204m000",error.msg)
endif
if not isspace(error.msg) then
message(error.msg)
afs.done = false
endif
stpapi.end.session("tisfc0204m000",error.msg)
return (afs.done)
}
function domain tcgrno get.ord.series(domain tcgrno ser.type)
{
domain tcgrno tmp.ser
tmp.ser = 0
select tcmcs047.grno:tmp.ser
from tcmcs047
where tcmcs047._index1 = {tcckon.act.sfc}
and tcmcs047.grno >= :ser.type
and tcmcs047.ffno < 9999
and tcmcs047.blck = tcyesno.no
as set with 1 rows
selectdo
endselect
return (tmp.ser)
}
The technique suggested by my is working for generating
purchase orders for direct deliveries . AFS on on tdinv3260m000
is not supported. Hence this workaround . U may try this
workaround if u do not wish to use AFS on tipcs5250m000 for any reason.
order.series = 0
srvo.f = 0 srvo.t = 999999
orno.f = sorn.f orno.t = sorn.t
comp.f = 0 comp.t = 999
pono.f = 0 pono.t = 9999
buyr.f = 0 buyr.t = 999999
cplb.f = 0 cplb.t = 999999
cuno.f = "" cuno.t = "ZZZZZZ"
cwar.f = "" cwar.t = "ZZZ"
item.f = "" item.t = "ZZZZZZZZZZZZZZZZ"
cntr.f = "" cntr.t = "ZZZ"
ddta.f = 0 ddta.t = 999999
prin.r = tcyesno.yes
zoom.to$("tdinv3260s000",z.session,"sls4240","",0)
|This generates purchase order for direct deliveried.
|3rd arg may be blank for tipcs5250s000.
das_k_tushar
14th August 2004, 09:50
Dear Hitesh,
Thank you very much for the help
regards
das_k_tushar
16th August 2004, 11:56
Dear Hitesh,
I have created one customised session, but when compiling the session I am getting compilation errors
Unresolve reference to function 'stpapi.put.field'
Unresolve reference to function 'stpapi.set.report'
Unresolve reference to function 'stpapi.continue.process'
I am attaching the script of the session, Please help me how to clear this error.
Regards
Hitesh Shah
16th August 2004, 12:03
U need to use the dll ttstpapihand like
#pragma used dll ottstpapihand
avpatil
17th August 2004, 04:31
Tushar,
If the sessions you are trying to run are type 4 sessions then you can call the standard session logic without a source code or wrapper program. I have done many sessions like- Print Picking List, Generate O/B, Release O/B without using wrapper program. And the best part will be that it will take into account any customization you would have done to the program. For this you will need to use to w standard Baan functions- load_dll and exec_func. Let me know if you need an example.
Arvind
SriksAdi
17th August 2004, 14:07
Hi Arvind
An example is definitely appriciated.
regards
Sriks
das_k_tushar
18th August 2004, 06:13
Dear Arvind,
Thanks for the reply, Please send me an example so that I can use it in future.
Regards,
das_k_tushar
18th August 2004, 12:45
Dear Friends,
As per our requirements, we have created one session (with BaaNBoard help), there are no such compilation error, while executing the session, it is not executing session tipcs5210m000 and not able to update table tipcs510 and the session hangs without any message.
I am attaching the script, Please help me to find out the error, why it is not executing the session.
|******************************************************************************
|* tipcs9994m200 0 VRC B40U c4 deve
|* Confirmed Planned PRP Production Orders (Status)
|* General_User_NT
|* 2004-08-16
|******************************************************************************
|* Main table tipcs990 Planned PRP Production Orders (Status), Form Type 4
|******************************************************************************
|****************************** declaration section ***************************
declaration:
table ttipcs990 | Planned PRP Production Orders (Status)
table ttipcs510 | Planned PRP Production Orders
extern domain tccprj cprj.f fixed
extern domain tccprj cprj.t fixed
extern domain tcorno orno.f
extern domain tcorno orno.t
extern domain tcorsa osta.f
extern domain tcorsa osta.t
domain tcdate cur.date
domain tcbool afs.done,stud.found
extern domain tcdsca error.msg
#pragma used dll ottstpapihand
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ********************************
choice.cont.process:
on.choice:
read.main.table()
|****************************** field section *********************************
field.cprj.f:
when.field.changes:
cprj.t = cprj.f
field.orno.f:
when.field.changes:
orno.t = orno.f
select tipcs990.*
from tipcs990
where tipcs990._index1 = {:cprj.f, :orno.f}
order by tipcs990._index1
selectdo
if tipcs510.osta = tcorsa.release then
message(" This Project and Order No has been Confirmed")
input.again()
endif
if tipcs510.osta = tcorsa.actualized then
message(" This Project and Order No has been Transfered")
input.again()
endif
if tipcs510.osta = tcorsa.cancelled then
message(" This Project and Order No has been Cancelled")
input.again()
endif
endselect
|****************************** function section ******************************
functions:
function read.main.table()
{
cur.date = date.num()
db.retry.point()
select tipcs990.*
from tipcs990 for update
where tipcs990._index1 = {:cprj.f, :orno.f}
and tipcs990.osta = tcorsa.release
order by tipcs990._index1
selectdo
selectempty
afs.confirm()
if afs.done = true then
tipcs990.cprj = cprj.f
tipcs990.orno = orno.f
tipcs990.trdt = cur.date
tipcs990.osta = tcorsa.release
db.insert(ttipcs990, db.retry)
commit.transaction()
endif
endselect
commit.transaction()
}
|Here AFS is used to confirm PRP orders only
function afs.confirm()
{
error.msg = ""
afs.done = true
stud.found = false
select tipcs510.*
from tipcs510
where tipcs510._index1 = {:cprj.f,:orno.t}
selectdo
if tipcs510.osta <> tcorsa.planned then
|and tipcs510.osta <> tcorsa.firm.planned then
stud.found = false
else
stud.found = true
endif
endselect
if stud.found = false then
message(" This Production Order cannot be Confirmed ! Contact Manufacturing Consultant")
afs.done= false
return
endif
|passing parameters to tipcs5210m000
stpapi.put.field("tipcs5210m000","cprj.f",cprj.f)
stpapi.put.field("tipcs5210m000","cprj.t",cprj.t)
stpapi.put.field("tipcs5210m000","orno.f",str$(orno.f))
stpapi.put.field("tipcs5210m000","orno.t",str$(orno.t))
stpapi.put.field("tipcs5210m000","item.f"," ")
stpapi.put.field("tipcs5210m000","item.t","ZZZZZZZZZZZZZZZZ")
stpapi.put.field("tipcs5210m000","citg.f"," ")
stpapi.put.field("tipcs5210m000","citg.t","ZZZZZZ")
stpapi.put.field("tipcs5210m000","psdt.f",str$(date.num() - 500))
stpapi.put.field("tipcs5210m000","psdt.f",str$(date.num() + 500))
stpapi.put.field("tipcs5210m000","planner.f",str$(0))
stpapi.put.field("tipcs5210m000","planner.t",str$(999999))
stpapi.set.report("tipcs5210m000","rtipcs521001000","D",error.msg)
if isspace(error.msg) then
stpapi.continue.process("tipcs5210m000",error.msg)
endif
if not isspace(error.msg) then
message(error.msg)
afs.done = false
endif
if afs.done and stud.found then
afs.done = true
stpapi.end.session("tipcs5210m000")
endif
}
Hitesh Shah
18th August 2004, 17:27
Please tell us at which line it hangs . What is the service pack u r working on. Have u checked the afs.log.
mark_h
18th August 2004, 18:52
Confused by the script - are you actually looking for one project and order number? This code:
select tipcs990.*
from tipcs990 for update
where tipcs990._index1 = {:cprj.f, :orno.f}
and tipcs990.osta = tcorsa.release
order by tipcs990._index1
makes me think you are only asking for one order and one project. Is cprj.t actually on the form? Because then from this one order you try to release a range with this code:
stpapi.put.field("tipcs5210m000","cprj.f",cprj.f)
stpapi.put.field("tipcs5210m000","cprj.t",cprj.t)
stpapi.put.field("tipcs5210m000","orno.f",str$(orno.f))
stpapi.put.field("tipcs5210m000","orno.t",str$(orno.t))
If you are only doing one project and order number then I would expect this to be:
stpapi.put.field("tipcs5210m000","cprj.f",cprj.f)
stpapi.put.field("tipcs5210m000","cprj.t",cprj.f)
stpapi.put.field("tipcs5210m000","orno.f",str$(orno.f))
stpapi.put.field("tipcs5210m000","orno.t",str$(orno.f))
Notice I changed the ".t" variables. I recommend running the code in debug mode and making sure the order and project ranges are populated correctly.
Mark
das_k_tushar
19th August 2004, 05:57
Dear Friends,
Yes we will run for one project and one order no. regarding program hand, when I run the script in debugger mode, and checked step by step, it continue without any problem, even it return afs.done = true and insert record in our customise table, at the end of the program, we find the session is hanged and hourglass is running,
we are not getting any result from the session tipcs5210m000 means, it is not updating the the record and no output is coming, if I run the session in normal way with same input then the result is coming perfectly.
I have not found any AFS.log in my system.
we have installed upto service pack 13 for BaaNIV.
Best Regards,
mark_h
19th August 2004, 14:51
Use -- -set AFSLOG=1 in your logon script to create the AFS log file. In this case afs.done means only that the code ran. When you run a report it will not return an error if no report or action takes place. In this case to me it looks like you ranges are incomplete - project and orno. Use the set command and create an afs logfile and this will help someone to see what is happening. Also after the continue I think you can use stpapi.get.mess.code to see if it is returning "No data found" or something like that.
Mark
avpatil
2nd September 2004, 16:11
Tushar,
Below is the example of "Print Sales Invoice session". This program will call standard Sales Invoice program.
long dll_id, sp.id1
long func_id
spool.fileout = "\\baanapp\f-baan\rob.txt"
spool.id = spool.open( "rtdsls440401000","ASCIF ",0)
sp.id1 = spool.id
if sp.id1 > 0 then
prog.name$= "tdsls4404m000"
dll_id = load_dll("otdsls4404")
func_id = get_function(dll_id,"before.program")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"init.form.1")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"before.choice.modify.set")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"before.input.all")
Exec_function(dll_id,func_id)
printed = tcyesno.no
inv.date = date.num()
text = ""
selection = tcyesno.no
comp.f = 0
comp.t = 999
cuno.f = ""
cuno.t = "ZZZZZZ"
orno.f = f.orno
orno.t = f.orno
cotp.f = ""
cotp.t = "ZZZ"
amount.f = -999999999
amount.t = 999999999
definite = tcyesno.yes
func_id = get_function(dll_id,"before.input.all")
Exec_function(dll_id,func_id)
direct.process = tcyesno.no
totals = tcyesno.no
prnt.options = tcyesno.yes
prnt.sellpr = tcyesno.yes
ttyp.f = ""
ttyp.t = "ZZZ"
invn.f = 0
invn.t = 99999999
prog.name$= "tdsls4404m000"
func_id = get_function(dll_id,"before.choice.cont.process")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"check.input.inv.date")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"on.choice.cont.process")
Exec_function(dll_id,func_id)
func_id = get_function(dll_id,"after.choice.cont.process")
Exec_function(dll_id,func_id)
}
func_id = get_function(dll_id,"after.program")
Exec_function(dll_id,func_id)
spool.close()
end()
|spool.id = sp.id2
endif
Basically call each program section and use Exec_fucntuion and get_function calls.
Arvind