psuryava
7th December 2013, 08:38
Hi
I need to automate Maintain Costs session tpppc2811m000.
Has anybody done it?
I call session tpppc2811m000 which activates tpppc2131m000, after this api call, the process hangs and does not proceed to tpppc2111m000.
please help.
thanks !
mark_h
9th December 2013, 16:00
Well I did not do one for that session, but I did do one for another situation just like that. No promises something like it will work for you.
When I run tpptc9820m00c it automatically launches tpptc9110m00c. like tpppd2811m000 auto launches tpppc2131m000. When I tried writing AFS code against tpptc9820m00c I could never get it to work. I was not able to control them. So what I did was I wrote a new session call tpptc9831m00c and all it does is launch tpptc9110m00c. This allowed me to control tpptc9110m00c. The same type technique might work for you. See below for the simple code for both the new session and the AFS code to call it.
This is all the code for the session:
|******************************************************************************
|* tpptc9831 0 VRC B40C c3 dev
|* Maintain Element Demand
|* 701holla
|* 08-30-01 [13:28]
|******************************************************************************
|* Script Type: 4
|******************************************************************************
|****************************** DECLARATION SECTION ***************************
declaration:
long child.id
extern domain tcmcs.str1 x
|****************************** PROGRAM SECTION ***************************
before.program:
child.id = 0
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
choice.cont.process:
on.choice:
if(child.id<>0) then
kill(child.id)
endif
child.id=activate("tpptc9110m00c")
switch.to.process(child.id)
| Cannot use zoom because tpptc9110m00c is waiting for a
| switch.to.process
execute(end.program)
choice.interrupt:
before.choice:
execute(end.program)
choice.abort.program:
before.choice:
execute(end.program)
choice.end.program:
before.choice:
kill(child.id)
And here is the AFS code that works with it:
function add.contract.requirement()
{
if(first) then
stpapi.put.field("tpptc9831m00c","x","A")
stpapi.handle.subproc("tpptc9831m00c","tpptc9110m00c","add")
stpapi.handle.subproc("tpptc9831m00c","tipgc8120m00b","add")
stpapi.continue.process( "tpptc9831m00c", errmsg)
first = false
endif
| Set the first view.
stpapi.put.field( "tpptc9110m00c", "tpptc120.cprj", project )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cspa", "1000" )
e = stpapi.change.view( "tpptc9110m00c" )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cprj", project )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cspa", "1000" )
stpapi.put.field( "tpptc9110m00c", "tpptc120.sern", str$(msnumber*10) )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cpla", "001" )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cact", milestone )
stpapi.put.field( "tpptc9110m00c", "tpptc120.item", item )
stpapi.put.field( "tpptc9110m00c", "tpptc120.prog.a", program )
stpapi.put.field( "tpptc9110m00c", "tpptc120.eser.a", unit )
stpapi.put.field( "tpptc9110m00c", "tpptc120.ese1.a", str$(series) )
stpapi.put.field( "tpptc9110m00c", "tpptc120.ese2.a", str$(series) )
stpapi.put.field( "tpptc9110m00c", "tpptc120.quan", str$(msqty) )
stpapi.put.field( "tpptc9110m00c", "tpptc120.cuni", "EA" )
if current.compnr <> 101 and current.compnr<> 555 then
stpapi.put.field( "tpptc9110m00c", "tpptc120.clin.c", "" )
stpapi.put.field( "tpptc9110m00c", "tpptc120.stat", str$(tpptc.stat.free) )
else
stpapi.put.field( "tpptc9110m00c", "tpptc120.clin.c", clin )
stpapi.put.field( "tpptc9110m00c", "tpptc120.stat", str$(tpptc.stat.actual) )
endif
if current.compnr <> 101 and current.compnr<> 555 then
stpapi.put.field( "tpptc9110m00c", "tpptc120.simu.a", str$(tcyesno.yes))
else
stpapi.put.field( "tpptc9110m00c", "tpptc120.simu.a", str$(tcyesno.no))
endif
stpapi.put.field( "tpptc9110m00c", "tpptc120.ccco", "200" )
stpapi.put.field( "tpptc9110m00c", "tpptc120.dfpc", str$(tppdm.yeno.no) )
stpapi.put.field( "tpptc9110m00c", "tpptc120.butm.a", builditem )
stpapi.put.field( "tpptc9110m00c", "tpptc120.sbtm.a", subitem )
stpapi.put.field( "tpptc9110m00c", "tpptc120.dtyp.a", str$(tppss.dtyp.a.customer) )
stpapi.insert( "tpptc9110m00c", 1, errmsg )
if(strip$(errmsg)<>"") then
mess.5= "5. "&errmsg
write.error(mess.5)
stpapi.recover("tpptc9110m00c",errmsg)
if(strip$(errmsg)<>"") then
message(errmsg)
endif
else
mess.5="5. MDO Added."
endif
display("mess.5")
}
psuryava
13th December 2013, 07:47
Hi Mark,
Thankyou for your reply.
I could not use your solution but I did manage to resolve theissue with the of another solution that you had posted. :)
My basic requirement was to enter data in table tpppc211.
So What I did was,
in session tpppc2111m000 - in section before.program there is call to wait.to.switch()
I by-passed this call, if session is invoked using afs by checking variable free$
Then in my afs,
I invoked tpppc2811m000 with command ignore.
I then exported values all the variables that are received by tpppc2111m000 from tpppc2811m000. Only I exported them through my afs session.
I set variable free$.
I then invoked tpppc2111m000 with command add.
As variable free$ is set , wait.for.swtich() is by passed in session tpppc2111m000.
Tpppc2111m000 reads all the variables that I exported from afs session and executes as expected.
Not sure if this is a correct solution, but it is working for me.
mark_h
13th December 2013, 15:14
Yes - I have had to do some stuff different things like that to get some of the sessions to work. Glad you found a solution.