pedromrs
8th November 2002, 14:47
Hi all
I had to rewrite the subsession code for tdpur4131s000 because the find function wasn't reliable.
Now I have another problem. stpapi.mark doesn't seem to work:
#pragma used dll ottstpapihand
function extern void manterrecep( )
{
DLLUSAGE
Teste
ENDDLLUSAGE
string err(50),reno(20)
string orno(50),pono(50)
long ret
long fl
stpapi.put.field("tdpur4120m000", "form.dino", "xxx")
stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
| Preparar para a subsessao
stpapi.handle.subproc( "tdpur4120m000", "tdpur4131s000", "add")
| Activa a subsessao de escolha por fornecedor
ret = stpapi.change.view("tdpur4120m000")
|Lista todos as ordens deste fornecedor
stpapi.put.field("tdpur4131s000","tdpur045.suno","281")
ret = stpapi.change.view("tdpur4131s000")
|Procurar o nosso
fl=0
ret=stpapi.browse.set("tdpur4131s000","first.set")
stpapi.get.field("tdpur4131s000", "tdpur045.orno", orno)
stpapi.get.field("tdpur4131s000", "tdpur045.pono", pono)
while ret<>0
if (orno="100030" and pono="10") then
fl=1
ret=stpapi.mark("tdpur4131s000")
break
endif
ret=stpapi.browse.set("tdpur4131s000","next.set")
stpapi.get.field("tdpur4131s000", "tdpur045.orno", orno)
stpapi.get.field("tdpur4131s000", "tdpur045.pono", pono)
endwhile
if (fl=1) then
stpapi.get.field("tdpur4131s000", "tdpur045.orno", orno)
stpapi.get.field("tdpur4131s000", "tdpur045.pono", pono)
Message(" Order = %s",orno)
Message(" Linha = %s",pono)
stpapi.continue.process("tdpur4131s000", err)
if (strip$(err) <> "" and strip$(err)<> "Process is gone") then
Message(" Erro na subs. tdpur4131s000 = %s",err)
endif
| Desligar a subsessao
stpapi.end.session("tdpur4131s000")
| Receber o numero da recepcao criada
stpapi.get.field("tdpur4120m000","tdpur045.reno",reno)
| Fechar a sessao principal
stpapi.end.session("tdpur4120m000")
else
message(" Nao encontrou a ordem!")
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
endif
}
The record I'm trying to find is the 4th in the multi-oco list. I have verified it finds the correct record this way.
The problem is I always get the first line marked (I mean I always get the first record returned to the main session). The mark function returns one.
This subsession allows for multiple selection. Maybe that is the problem?
Any ideas? Thanks in advance.
mark_h
8th November 2002, 16:02
I have never thought to try this - I guess I just assumed that I needed to mark and process each record individually. Since this worked, I never even thought about trying to mark more than one record, but I suspect(as you said) that is the problem. From reading on stpapi.mark it looks like it only works on one record.
Mark
pedromrs
8th November 2002, 16:37
Mark,
I'm not trying to mark several records. I'm just trying to mark one. The problem is I always get the first one marked inspite having the 4th one correctly selected with browse.set.
Thanks,
mark_h
8th November 2002, 17:29
My appologies I did not read it close enough. Anyway I have not always used stpapi.mark. Stpapi.browse.set also marks the record as current, so you could just try removing the stpapi.mark command. I think I have only used it in 1 or 2 function servers, in most cases I found that just using stpapi.browse.set was good enough. In your case the continue should work off the current record that was set with the stpapi.browse.set. Notice that I said should, because I can not guarantee it.
Mark
pedromrs
11th November 2002, 10:11
Mark,
Sorry for the late reply.
I tried your suggestion today and it doesn't work. If I don't use mark it returns to the main session without any record.
Have you seen this before? I wonder if there is some trick on stpapi.mark?
Thanks,
pedromrs
11th November 2002, 15:27
Hi all,
I have found another strange thing. The code below works after it finds an order in the subsession (if it worked correctly). The strange thing is when running it in debug mode I can get the new receipt number and order number (message box) but when I just compile it I get blank fields but, and this is the strange part, the receipt is getting generated as well.
if (fl=1) then
stpapi.continue.process("tdpur4131s000", err)
if (strip$(err) <> "" and strip$(err)<> "Process is gone") then
Message(" Erro na subs. tdpur4131s000 = %s",err)
endif
| Desligar a subsessao
stpapi.end.session("tdpur4131s000")
| Receber o numero da recepcao criada - so funciona em debug
| va-se la saber porque
stpapi.get.field("tdpur4120m000","tdpur045.reno",reno)
stpapi.get.field("tdpur4120m000", "tdpur045.orno", orno)
stpapi.get.field("tdpur4120m000", "tdpur045.pono", pono)
Message(" Order = %s, Linha = %s Order N = %s",orno,pono,reno)
| Fechar a sessao principal
stpapi.end.session("tdpur4120m000")
else
message(" Nao encontrou a ordem!")
stpapi.end.session("tdpur4131s000")
stpapi.end.session("tdpur4120m000")
endif
mark_h
11th November 2002, 15:31
Sorry to say - I have not had that problem. But I have seen things that work in debug mode and not when compiled. In those cases I have used the sleep command. You can look at some of my replies to Rohan about this.
I have seen sub-sessions not pull up a correct record, but not a main session. When returning to the main session could you just do another find to get back to where you need to be?
Mark
pedromrs
11th November 2002, 19:53
Mark,
Can you think of a way to put the order I want in the top of the list so the stpapi.mark() function can work?
Find doesn't work for this purpose because it just scrolls to the record I want.
Meanwhile I tried to insert the record directly in the main session but it's giving me a "Cost price structure not present for this date". I have verified I have the price structure so it may be a problem in Baan. I just checked Baan Support and solution 158082 seems to address this. I will try it tomorrow.
Nevertheless I wonder if I should open a new case because of this stpapi.mark problem.
Thanks,
mark_h
11th November 2002, 22:24
I am offsite right now, but are there any index options on the sessions that you could change to get the stpapi.mark command to work? I was just thinking that if you change the default index that may work and may get the find to work like you want it.
Mark
pedromrs
11th November 2002, 22:32
Mark,
I tried to change the index.
The problem is always the same. The find function works correctly but I think it just scrolls to the correct record. It isn't the first in the list. If I touch the scroll bar I get all the other records for that supplier. What I was trying to do is getting the order I want to be first in the list.
I found another strange thing. There is an user option in this session to mark all the records. If I call it from code using stpapi code it marks all the records except 1 (in my example the second on the list). Isn't this weird?
I will try again tomorrow.
Thanks for being so patient,
mark_h
11th November 2002, 23:17
Yes I do find that weird. Maybe there is a patch for that. I am not sure what else to try. Wish I was more help. I am hoping to gather requirements for doing a receipt FS next week, but am not sure I am going to have time with the Baan Finance conversion we have going on.
Mark
Paul P
29th November 2002, 08:02
Dear Pedro,
The culprit of your code in your first post of this thread is the "while ret<>0" part. The thing is, the program is probably unable to find your record, hit the last record, can't perform next.set, and returns 0. What's silly about next.set is that if it's performed at the last record, it will return 0 declaring that it failed and reset the current record to the first one. This is why it always marks your first record. I found out about it when I was constructing my API session for receipt (whinh3520m000).
This is what I had to do to make sure the correct record is marked:
stpapi.browse.set("whinh3520m000","first.set")
record.oorg=whinh.oorg.purchase
record.orno=""
record.pono=0
record.seqn=0
while not (record.oorg=whinh910.oorg and record.orno=whinh910.orno and record.pono=whinh910.pono and record.seqn=target.seq)
stpapi.get.field("whinh3520m000","whinh210.oorg",dummy.str)
record.oorg=ltoe(lval(dummy.str))
stpapi.get.field("whinh3520m000","whinh210.orno",dummy.str)
record.orno=dummy.str
stpapi.get.field("whinh3520m000","whinh210.pono",dummy.str)
record.pono=lval(dummy.str)
stpapi.get.field("whinh3520m000","whinh210.seqn",dummy.str)
record.seqn=lval(dummy.str)
dummy.long=stpapi.browse.set("whinh3520m000","next.set")
endwhile
if dummy.long=0 then
stpapi.browse.set("whinh3520m000","last.set")
else
stpapi.browse.set("whinh3520m000","prev.set")
endif
stpapi.mark("whinh3520m000")
Rgds,
Paul
pedromrs
30th November 2002, 02:13
Hi Paul,
Thanks a lot for remembering this thread :)
I will try those modifications first thing on Monday at the Office.
Best Regards,
Ilansu
1st December 2002, 11:08
Pedro Hi
(I can't see your code I dont knew if it's my browser or something else so I hope it's not like your code)
Im using this code and it works fine:
select tdpur041.pono,tdpur041.suno,tdpur041.ddtb
from tdpur041
where tdpur041._index1={:my.orno}
and tdpur041.item=:my.item
selectdo
stpapi.put.field("tdpur4120m000","form.dino",str$(my.dino))
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
stpapi.change.view( "tdpur4120m000" )
stpapi.put.field("tdpur4131s000","tdpur045.suno",tdpur041.suno)
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(tdpur041.ddtb))
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(my.orno))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(tdpur041.pono))
stpapi.find("tdpur4131s000")
stpapi.get.field("tdpur4131s000","tdpur045.suno",str.suno)
stpapi.get.field("tdpur4131s000","tdpur045.ddtb",str.ddtb)
stpapi.get.field("tdpur4131s000","tdpur045.orno",str.orno)
stpapi.get.field("tdpur4131s000","tdpur045.pono",str.pono)
if str.suno=tdpur041.suno and str$(tdpur041.ddtb)=str.ddtb and
val(str.orno)=my.orno and val(str.pono)=tdpur041.pono then
stpapi.mark("tdpur4131s000")
stpapi.continue.process("tdpur4131s000", error.mess)
Hope that helps
Ilan S
pedromrs
4th December 2002, 14:24
Hi all,
Thanks for all the help (Mark, Paul, Ilan), you were all very helpfull:
The following code allows me to create a full receipt with one line and one lot in my system (info hardcoded for testing).
Now I will improve the code to enable multiple lots and lines.
|******************************************************************************
|* tdpurmcgteste 0 VRC B40C c4 dese
|* Teste ao manter recepcoes - MCG - Nosso
|* psousa - Pedro Sousa
|* 06/11/02 [16:26]
|******************************************************************************
|* Script Type: Library
|******************************************************************************
#pragma used dll ottstpapihand
function extern void manterrecep( )
{
DLLUSAGE
Automatização do manter recepções
ENDDLLUSAGE
string err(150),reno(20)
string orno(50),pono(50),data(20),item(30),msg(50)
long ret
long my.orno,my.pono
extern table ttdpur041
extern table ttdpur045
|Uma guia qualquer
stpapi.put.field("tdpur4120m000", "form.dino", "xxx")
|Não à cadeia de suprimentos
stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)
| Preparar para a subsessao
stpapi.handle.subproc( "tdpur4120m000", "tdpur4131s000", "add")
| Activa a subsessao de escolha por fornecedor
ret = stpapi.change.view("tdpur4120m000")
| Para dada ordem e numero de linha (tabela de ordens de compra)
my.orno=320004
my.pono=10
select tdpur041.pono,tdpur041.suno,tdpur041.ddtb |Seleccionar os 4 campos de find
from tdpur041
where tdpur041._index1={:my.orno,:my.pono}
selectdo
stpapi.put.field("tdpur4131s000","tdpur045.suno",str$(tdpur041.suno))
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(tdpur041.ddtb))
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(my.orno))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(tdpur041.pono))
ret=stpapi.find("tdpur4131s000")
stpapi.get.field("tdpur4131s000","tdpur045.suno",item)
stpapi.get.field("tdpur4131s000","tdpur045.ddtb",data)
stpapi.get.field("tdpur4131s000","tdpur045.orno",orno)
stpapi.get.field("tdpur4131s000","tdpur045.pono",pono)
if item=tdpur041.suno and str$(tdpur041.ddtb)=data and
orno=str$(my.orno) and pono=str$(my.pono) then
ret=stpapi.mark("tdpur4131s000")
endif
endselect
stpapi.continue.process("tdpur4131s000", err)
if (strip$(err) <> "" and strip$(err)<> "Process is gone") then
Message(" Erro na subs. tdpur4131s000 = %s",err)
endif
| Desligar a subsessao
stpapi.end.session("tdpur4131s000")
| Receber o numero da recepcao criada - so funciona em debug
| va-se la perceber porque
stpapi.get.field("tdpur4120m000", "tdpur045.reno", reno)
| Assumindo que tudo correu como deve ser vamos preencher os lotes
|Comecamos com uma quantidade de guia de remessa = 0
|A sessao de lotes vai-se encarregar de preencher este campo
|correctamente
stpapi.put.field("tdpur4120m000", "tdpur045.diqu", "2000")
| Data da recepção
stpapi.put.field("tdpur4120m000", "tdpur045.date", str$(date.num()))
stpapi.put.field("tdpur4120m000", "tdpur045.dqua", "2000")
stpapi.handle.subproc( "tdpur4120m000", "tdilc4113s000", "add")
stpapi.update("tdpur4120m000",1,err)
stpapi.handle.subproc("tdilc4113s000", "tdltc0101s000", "add")
stpapi.zoom.option("tdilc4113s000", 1, "tdltc0101s000", err)
stpapi.end.session("tdltc0101s000")
stpapi.put.field("tdilc4113s000","tdilc402.clot","02/001/01/001")
stpapi.put.field("tdilc4113s000","tdilc402.date",str$(date.num()))
stpapi.put.field("tdilc4113s000","tdilc402.qstr","2000")
stpapi.insert("tdilc4113s000",1,err)
stpapi.continue.process("tdilc4113s000", err)
stpapi.end.session("tdilc4113s000")
| Fechar a sessao principal
stpapi.end.session("tdpur4120m000")
}
(Sorry for the comments in portuguese)
When I have more code I'll post it here.
Thanks,
minizao
20th June 2005, 13:14
Hi there,
I'm trying to do this, but new receipt wasn't created...
I did this :
---------------------------------------------
stpapi.put.field("tdpur4120m000", "form.dino", "Nuno1")
stpapi.handle.subproc( "tdpur4120m000", "tdpur4131s000", "add")
ret = stpapi.change.view("tdpur4120m000")
stpapi.put.field("tdpur4131s000","tdpur045.suno",str$(tdpur041.suno))
stpapi.put.field("tdpur4131s000","tdpur045.ddtb",str$(tdpur041.ddtb))
stpapi.put.field("tdpur4131s000","tdpur045.orno",str$(my.orno))
stpapi.put.field("tdpur4131s000","tdpur045.pono",str$(tdpur041.pono))
ret=stpapi.find("tdpur4131s000")
stpapi.get.field("tdpur4131s000","tdpur045.suno",item)
stpapi.get.field("tdpur4131s000","tdpur045.ddtb",data)
stpapi.get.field("tdpur4131s000","tdpur045.orno",orno)
stpapi.get.field("tdpur4131s000","tdpur045.pono",pono)
ret=stpapi.mark("tdpur4131s000")
When i create a dll to session tdpur4131s000, this function doesn't exists...
stpapi.continue.process("tdpur4131s000", err)
stpapi.end.session("tdpur4131s000")
---------------------------------------------
When i create a dll to session tdpur4131s000 with session ttstpcreatdll, function "stpapi.continue.process("tdpur4131s000", err)" doesn't exists...
This function is necessary to create the receipt... isn't it?
I have tryed with update + save... and still didn't created the new receipt for that order.
Does anyone know what i should do to solve my problem?
regards,
Nuno Mota
mark_h
20th June 2005, 15:30
I have never really looked at why ttstpcreatdll does not always create all of the functions, but just because the function is not created does not mean it does not work. What exactly happens when you run the code? Does the find work? More info may help others make suggestions.
minizao
20th June 2005, 16:09
Hi Mark,
sorry for my last poor info... :-P
When i try to call function :
"stpapi.continue.process("tdpur4131s000",Err)"
I get this error code : -1, that is "Function Unknown!"
----------
The find works and i can get some values of order.
----------
Thanks
Nuno
mark_h
20th June 2005, 17:12
I would recommend getting the latest version of the session. In the mean time do you have source for the session? If no source do you have one of the wrapper products like qkey or RMCgen? Also check the form and make sure that it does have the continue option turned on.
minizao
20th June 2005, 17:47
Ok...
I don't know my version of session...
I don't have the source.
My client doesn't have those wrappers, or anyone else.
The continue button wasn't activated. So we active this button, but function continue is not available :-(
We already have the patch 165041 to update ttstpcreatdll, but it still not creating the function for "continue".
It maybe of version of the session?
Nuno
mark_h
20th June 2005, 18:32
It could be several things - my first guess would be the session. I just checked our system and then is no continue option on it also. Since we do not use this session I am not familiar with how it works. It could even be one of the stpapi.application.option commands that you need to use.