Andy..
13th May 2008, 16:41
I found a few posts on this general topic, but nothing with a solution for my problem. I'm trying to issue specific lot material to a production order using 'direct process outbound' then press 'initial inventory' button but its not working. I noticed the report the std session (ticst0101s000) is calling is actually coming from tisfc0207m000 (yes, its m000, no s000). So I've made the following code to handle this - but it doesnt work!

Having filled the form correctly, the first part of code shows getting values back to check that session is trying to do the right thing...

stpapi.get.field( "ticst0101s000", "ticst001.lsel", value )
stpapi.get.field( "ticst0101s000", "ticst001.clot", value )
|get qty
stpapi.get.field( "ticst0101s000", "ticst001.issu", value )


that seems to check out fine - next, i'm trying to use this sfc0207 hidden session that would print shortages if there were any - but always asks for a device. I think the code is correct, but not sure as it doesnt work!

|sfc0207 print session
stpapi.handle.subproc("ticst0101s000", "tisfc0207m000", "add")


|set device, set report
spool.device = "ASCIT"
spool.fileout="tisfc0207tmp.txt"
stpapi.put.field("tisfc0207m000", "spool.fileout", "tisfc0207tmp.txt")
stpapi.set.report("tisfc0207m000", "rtisfc020701000", spool.device, error)


|handle yesno prompt ticst01011=yes
stpapi.enum.answer("ticst0101s000", "ticst01011", tcyesno.yes)

|init inv
stpapi.form.command( "ticst0101s000", 5, "exec.cont.process", error )

The result when you next go into the session is the entire form is filled correctly and if you hit 'initiate inventory' it works fine

Someone else must have done this - help!

mark_h
13th May 2008, 17:57
Since I am not a baan 5 expert I can only make guesses on how I would expect it to work - at least in baan 4. First you put fields on ticst0101s000, then you do something to activate tisfc0207m000 - the question is what? I do not see anything for that. Here is what I would expect to happen.

stpapi.handle.subproc("ticst0101s000", "tisfc0207m000", "add")

| something happens here on ticst0101s000 to activate tisfc0207m00

|set device, set report
spool.device = "ASCIT"
spool.fileout="tisfc0207tmp.txt"
stpapi.put.field("tisfc0207m000", "spool.fileout", "tisfc0207tmp.txt")
stpapi.set.report("tisfc0207m000", "rtisfc020701000", spool.device, error
| Now I would expect something to happen here to generate the report -
| maybe a continue on tisfc0207m000 and then return to ticst0101s00
| for final processing.

I know baan 5 is not like 4, but this is my best guess.

Andy..
13th May 2008, 18:07
Hi Mark, thanks for swift response - if I look in the source for session ticst0101s000 that is called when I hit the 'Continue' button (labelled Init. Inv) i see it calls tisfc0207m000 in the background without a window:

function extern exec.cont.process()
{
if item.is.replaced(ticst001.sitm) then |#131495.n
if ask.issue.inventory.immediately() then
execute(find.data)
|* to display new values
endif
endif |#131495.n
}

function domain tcbool ask.issue.inventory.immediately()
{
domain tcmcs.st12 question |#118885.n

if ticst001.issu >= 0 then |#118885.sn
question = "ticst01011"
|* Issue inventory immediately?
else
question = "ticst010110"
|* Receive inventory immediately?
endif
if ask.enum(question, empty) = tcyesno.yes then |#118885.en
| if ask.enum("ticst01011", empty) = tcyesno.yes then |#118885.so
| |* Issue inventory immediately? |#118885.eo
check.all.input()
tisfc010.pdno = ticst001.pdno
tisfc010.opno = ticst001.opno
zoom.position = ticst001.pono
start.session(MODELESS, "tisfc0207m000", "ticst001.pdno","")
|* Initiate Inventory Issue
if api.mode then |#ADC.sn
if boi.call =
"tiboidll100003.initiateinventoryforitem" then
|* This applies to initiateinventoryforitem method
|* in tiboidll100003.
boi.structmatissuereport1 =
xmlDuplicateToProcess(
processno.boi, |#162780.n
| parent , |#162780.o
boi.structmatissuereport2,
0)
export("structmatissuereport2",
boi.structmatissuereport1)
|#162780.sn
put.var(processno.boi, "structmatissuereport2",
boi.structmatissuereport1)
|#162780.en
endif
endif |#ADC.en
return(true)
endif

return(false)
}

the only clue the session user gets is that it pops up the shortage report device selection with report tisfc020701000

mark_h
13th May 2008, 20:23
I notice it does some checking for api.mode - have you tried setting that boi.call variable(to tiboidll100003.initiateinventoryforitem)? Not sure if you need to export this from the AFS program or not.

Sorry, but since this baan 5 I am not sure what to expect or how to code things. The only other suggestion I have is to put tisfc0207m000 in debug mode and see what happens when you execute the continue process on ticst0101s000. If you do this you should be able to see what happens in the tisfc session - what is set, what is execute, etc. That might help you code it or figure a work around.

Andy..
14th May 2008, 11:08
Hi Mark, that's a good suggestion - I just ran it with sfc0207 in debug and notice the following...

1. the put.field for spool device starts 1 instance of sfc0207 with the variable 'background' set to 0
2. the cont.process of cst0101s000 calls a 2nd instance of sfc0207 (background=1), when you look in option dialog there are 2 copies running - so spool device setting method is not working in this case
3. the api.mode settings in sfc0207 deliberately stop you running this via api from cst0101s000 as can be seen here in the sfc0207 code:

function extern continue.process()
{
DllUsage
Expl: This function sets the output device and then the function
initiate.wh.orders is called to activate warehouse order lines.
Pre : -
Post : -
Input : -
EndDllUsage

long ret.val |* return value

domain tcmcs.s132m error.mess |* error message
domain tisfc.devi outp.devi |* output device

check.all.input() |* Necessary?

if api.mode then |#ADC1.0.sn
if boi.call = "tiboidll200001.initiateinventory" then
|* This applies to initiateinventory method in
|* tiboidll200001
import("boi.ctr1", boi.ctr)
import("boi.error.ctr1", boi.error.ctr)
import("structinventoryissuerpt1",
boi.fillstructinventoryissuerpt)
import("errorstruct1", boi.fillerrorstruct)
import("set.error", boi.set.error)
import("set.updatestatus", boi.set.updatestatus)
boi.node.ctr = 0
endif
endif |#ADC1.0.en
|#ADC.sn |#ADC1.0.so
| if boi.call <> "tiboidll100003.initiateinventoryforitem" then
| |* This applies to initiateinventoryforitem method in
| |* tiboidll100003 |#ADC.en |#ADC1.0.eo
|#ADC1.0.sn
if boi.call <> "tiboidll100003.initiateinventoryforitem" and
boi.call <> "tiboidll200001.initiateinventory" then
|* This applies to initiateinventoryforitem method in
|* tiboidll100003
|* and initiateinventory method in tiboidll200001 |#ADC1.0.en
if not job.process and
not tisfc.dll0225.get.interactive.device(outp.devi) then
return
endif

mark_h
14th May 2008, 13:52
I have literally had to code around some things. So in this case I do not think you need the put field for tisfc0207 since it starts an instance that is not controlled by the baan sessions or you code.

(1) You can try this to see what happens

spool.device = "ASCIT"
spool.fileout="tisfc0207tmp.txt"
boi.call = "tiboidll200001.initiateinventory"
stpapi.form.command( "ticst0101s000", 5, "exec.cont.process", error )

Just to see if the sub-session generates the report. I am not sure if boi.call has to be imported. Don't do any put fields on tisfc0207m000.

(2) The other method I have used is to import variables into the subsession and code around what baan does. We don't own source so I am limited at times, but in this case you could fix the tisfc0207 code to work.

lakoon
15th May 2008, 14:56
Hi,

This code is working fine...



#define P.MAIN "ticst1501m000"
#define P.SUB "ticst0101s000"
#define P.PRINT "tisfc0207m000"

function create.prodissue()
{
string get.pono(10)
string get.disp.offen(20)
domain tcitem get.item
stpapi.put.field(P.MAIN, "ticst001.pdno", str$(pdno))
stpapi.put.field(P.MAIN, "ticst001.pono", str$(pono))
ret.find = stpapi.find(P.MAIN, err.msg)
if ret.find = 1 then
stpapi.get.field(P.MAIN, "ticst001.pono", get.pono)
stpapi.get.field(P.MAIN, "disp.offen", get.disp.offen)
stpapi.get.field(P.MAIN, "ticst001.sitm", get.item)
ret.sync = stpapi.synchronize.dialog(P.MAIN, "modify", err.msg)
if ret.sync then
modify.lines.asf()
else
get.api.messages(P.MAIN, sprintf$(
"Auftragsposition '%d-%d' kann nicht verwaltet werden",
pdno, pono))
endif
else
get.api.messages(P.MAIN, "Auftrag nicht vorhanden")
ret.reco = stpapi.recover(P.MAIN, err.msg)
endif
stpapi.end.session(P.MAIN, err.msg)
}

function modify.lines.asf()
{
string get.subd(20)
string get.ques(20)
string get.issu(20)
domain tcqst1 ques
domain tcqst1 subd
domain tcitem get.item

stpapi.get.field(P.SUB, "ticst001.ques", get.ques)
ques = val(get.ques)
stpapi.get.field(P.SUB, "ticst001.issu", get.issu)
stpapi.get.field(P.SUB, "ticst001.subd", get.subd)
subd = val(get.subd)
stpapi.get.field(P.SUB, "ticst001.sitm", get.item)
if not issue.end then
| Lothandling
if item.lot.needed() then
stpapi.put.field(P.SUB, "ticst001.lsel", str$(etol(tclsel.specific)))
stpapi.put.field(P.SUB, "ticst001.clot", clot)
endif
| Issue
stpapi.put.field(P.SUB, "ticst001.issu", str$(quan))
else
|Letzte Buchung, Nachentnahmen löschen.
| Chargenhandling
if item.lot.needed() then
stpapi.put.field(P.SUB, "ticst001.lsel", str$(etol(tclsel.specific)))
stpapi.put.field(P.SUB, "ticst001.clot", clot)
endif
stpapi.put.field(P.SUB, "ticst001.issu", str$(quan))
stpapi.put.field(P.SUB, "ticst001.subd", "0.0")
endif

ret.updt = stpapi.update(P.MAIN, true, err.msg)
if not ret.updt then
get.api.messages(P.MAIN,
sprintf$("Auftragsposition '%d-%d' nicht gespeichert",
pdno, pono))
ret.reco = stpapi.recover(P.SUB, err.msg)
else
stpapi.get.field(P.SUB, "ticst001.ques", get.ques)
stpapi.get.field(P.SUB, "ticst001.issu", get.issu)
stpapi.get.field(P.SUB, "ticst001.subd", get.subd)
if quan >= 0 then
stpapi.enum.answer(P.SUB,"ticst01011", tcyesno.yes)
else
stpapi.enum.answer(P.SUB,"ticst010110", tcyesno.yes)
endif
stpapi.handle.subproc(P.SUB, P.PRINT, "add")
stpapi.set.report(P.PRINT, "tisfc020701000", printer, err.msg)
if not isspace(err.msg) then
get.api.messages(P.SUB, "Drucker konnten nicht gesetzt werden")
else
stpapi.form.command(P.SUB, 5, "exec.cont.process", err.msg)
if not isspace(err.msg) then
get.api.messages(P.SUB,
sprintf$("Bestand für Auftragsposition '%d-%d' nicht gespeichert",
pdno, pono))
ret.reco = stpapi.recover(P.MAIN, err.msg)
else
trans.result(1) = str$(pdno) & "|" & str$(pono)
send.data.to.client(0,1)
endif
endif
endif
stpapi.end.session(P.PRINT, err.msg)
stpapi.end.session(P.SUB, err.msg)
}


/lakoon

Andy..
20th May 2008, 18:47
Hi lakoon - unfortunately I didnt get the email telling me you had posted a response. I had to rewrite to run the two sessions seperately - not as elegant but at least its working! Thanks for posting your code, I'll take a look at it and see if I can spot the difference

lakoon
19th November 2008, 22:55
Hi Andy

I just had to solve the same problem as you did. I think the reason of our problem is sp23. Before sp23 my solution was working fine.

source:


function create.prodissue()
{
string get.pono(10)
string get.opno(10)
string get.disp.offen(20)
domain tcopno opno
domain tcitem get.item
stpapi.put.field(P.MAIN, "ticst001.pdno", str$(pdno))
stpapi.put.field(P.MAIN, "ticst001.pono", str$(pono))
ret.find = stpapi.find(P.MAIN, err.msg)
if ret.find = 1 then
stpapi.get.field(P.MAIN, "ticst001.pono", get.pono)
stpapi.get.field(P.MAIN, "disp.offen", get.disp.offen)
stpapi.get.field(P.MAIN, "ticst001.sitm", get.item)
stpapi.get.field(P.MAIN, "ticst001.opno", get.opno)
opno = lval(get.opno)
ret.sync = stpapi.synchronize.dialog(P.MAIN, "modify", err.msg)
if ret.sync then
modify.lines.asf()
else
get.api.messages(P.MAIN, sprintf$(
"Auftragsposition '%d-%d' kann nicht verwaltet werden",
pdno, pono))
endif
else
get.api.messages(P.MAIN, "Auftrag nicht vorhanden")
ret.reco = stpapi.recover(P.MAIN, err.msg)
endif
stpapi.end.session(P.MAIN, err.msg)
book.material.definitive(opno)
}


function modify.lines.asf()
{
if not issue.end then
| Chargenhandling
if item.lot.needed() then
stpapi.put.field(P.SUB, "ticst001.lsel", str$(etol(tclsel.specific)))
stpapi.put.field(P.SUB, "ticst001.clot", clot)
endif
| Entnahme
stpapi.put.field(P.SUB, "ticst001.issu", str$(quan))
else
|Letzte Buchung, Nachentnahmen löschen.
| Chargenhandling
if item.lot.needed() then
stpapi.put.field(P.SUB, "ticst001.lsel", str$(etol(tclsel.specific)))
stpapi.put.field(P.SUB, "ticst001.clot", clot)
endif
stpapi.put.field(P.SUB, "ticst001.issu", str$(quan))
stpapi.put.field(P.SUB, "ticst001.subd", "0.0")
endif
ret.updt = stpapi.update(P.MAIN, true, err.msg)
if not ret.updt then
get.api.messages(P.MAIN,
sprintf$("Auftragsposition '%d-%d' nicht gespeichert",
pdno, pono))
ret.reco = stpapi.recover(P.SUB, err.msg)
else
endif
stpapi.end.session(P.SUB, err.msg)
}


function book.material.definitive(
domain tcopno i.opno)
{
long ret
stpapi.put.field(P.PRINT, "pdno.f", str$(pdno))
stpapi.put.field(P.PRINT, "pdno.t", str$(pdno))
stpapi.put.field(P.PRINT, "way.of.selection", str$(etol(tisfc.wybf.one)))
stpapi.put.field(P.PRINT, "operation", str$(i.opno))
stpapi.set.report(P.PRINT, "tisfc020701000", printer, err.msg)
stpapi.form.command(P.PRINT, 5, "continue.process", err.msg)
if not isspace(err.msg) then
get.api.messages(P.SUB,
sprintf$("Bestand für Auftrag und AG '%d-%d' nicht verbucht",
pdno, i.opno))
ret.reco = stpapi.recover(P.MAIN, err.msg)
else
trans.result(1) = str$(pdno) & "|" & str$(i.opno)
send.data.to.client(0,1)
endif
stpapi.end.session(P.PRINT)
}


/lakoon

lakoon
23rd November 2008, 20:06
Hello

I solved also the "old" way. (Running tisfc0207m000 from the Button in Session ticst0101s000").
I had to customize the script of Session tisfc1501m000 to pass the variable boi.call. I you do so, the session tisfc0207m000 behaves as expected.

/Lakoon