pedromrs
5th December 2002, 21:23
Hi all,

Is there any change to call a subsession that is listed in the zoom menu for the session?
I have a session (still tdpur4120m000) that has only one zoom option for it.
That zoom option in turn calls a menu that has 5 subsessions available.
I need to call the 3rd session.

Reading the afs doc it seems I should use:


stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
stpapi.handle.subproc("tdpur4120m000","menu_name","3")
stapi.zoom.option("tdpur4120m000",1,"tdpur4131s000")


It always hangs during the zoom.option() call. Doing a ps in the shell I can see it opens the first subsession listed in the menu and not the one I requested for.
Did anyone work with this type of menu yet?
I found out the menu name in the "maintain menus" session under the name of tdpur00009030.
I tried using that name, also I tried the Baan codification "mtdpur000090301" to no sucess.
The document I use for AFS reference also has Baan V functions listed so maybe I can't do this in Baan IVc4.

Thanks in advance,

mark_h
5th December 2002, 21:36
Both times I have used the zoom option I do not declare the process and a sub-process controlled by the main session. I just do a stpapi.zoom to the other session. I have never zoomed to a menu and am not sure how that works. Do you have to zoom to the menu to see the session? You may want to search this forum - I think Lisa posted something about zooming to menus not too long ago.


Mark

pedromrs
5th December 2002, 21:51
Hi Mark,

I have to open the subsession through the menu.
The session dropdown just displays "zoom CTRL+B". It then displays the menu where I have to select the subsession.
I think that option is controlled via code since it displays that menu or zooms directly to a subsession depending in the phase of data entry.
I tried not to call the zoom session but it seems the only way to add more lines to the receipt. I just need to be able to add more lines to finish it since I can already do a complete reception (including lots) for one order line. :cool:

Thanks,

mark_h
5th December 2002, 22:02
I was wondering if you could get the data from the tables rather than the subsession. I just went and did a test - on our system when I zoomed to the sub-session it looks like it just returned data to the main session. So is it possible for you to lookup the data in the tables and just do put fields on the Maintain Receipt Session? I am not an expert, but it looks to me like you could just add the records to the receipt.

Also in both cases when I zoomed the session was right under the application button. I was wondering if you could just add this session so that you see it under the drop down on application. Just something to try. On our system you see 4 sessions, then zoom. You select zoom to get the menu which has select receipts.


Mark

pedromrs
5th December 2002, 22:20
Hi Mark,

Thanks for the help.
I tought of adding the subsession to the application dropdown before but I was afraid it didn't return the correct values.
I have this bad habit of trying everything first using code and then touching the sessions ;) (except in reports).
I just had a closer look to the subsession and you're right. It just returns values to the session. I wanted to use that subsession because it lists depending on a status field and I'm not really sure about that criteria yet.
So I will try to add it to the application dropdown to see if it works.
This one is really tough (my second AFS, the first was employees)but I'm learning a lot of new things because of it.

Thanks once more,

pedromrs
6th December 2002, 16:31
Mark,

Can you check in your screen for the session tdpur4120m000 what is the code of the user option user.* used to call the select receipt subsession? The ones I tried didn't work.

I also tried to change the menu order so as to make select receipts the first in the list. It worked but zoom.option still calls the old first session in the list. I also followed your suggestion of inputing the fields directly into the main session but I'm missing something. When I call insert, it creates a new receipt instead of adding a new line to the one selected. In our system the insert line button is greyed out in the toolbar. When I try update it updates the first line inserted. Do you have any idea on how to insert new lines in a session like this?

Thanks

mark_h
6th December 2002, 19:36
I only glanced but it looks like the tdpur4131s000 session is started in the choice.add.set. So I am not sure I understand the question.

Could you post your code - it might help me find a solution.

Mark

pedromrs
6th December 2002, 20:12
Hi Mark,

I don't have source code for tdpur4120m000 or tdpur4131s000.
Maybe I understood you wrong but didn't you say you have tdpur4131s000 available in the application options? (I mean that can be called by stpapi.application.option())
Maybe the only option is to insert directly into the main session but I can't do it.

Here is my code:



|******************************************************************************
|* 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,i,lines
long my.orno,my.pono,iteracoes
extern table ttdpur041
extern table ttdpur045

my.orno=220003
my.pono=10
iteracoes=4

|Uma guia qualquer
stpapi.put.field("tdpur4120m000", "form.dino", "xxx")

|Não à cadeia de suprimentos
stpapi.enum.answer("tdpur4120m000","tdpur41206",tcyesno.no)

for lines=1 to 2 step 1

if (lines <> 1) then |> 1ª linha
stpapi.put.field("tdpur4120m000", "tdpur045.reno", reno)
ret=stpapi.find("tdpur4120m000")
endif

| Para dada ordem e numero de linha (tabela de ordens de compra)
|Vamos começar por criar os novos lotes - sessao principal de criacao de lotes
select tdpur041.pono,tdpur041.suno,tdpur041.ddtb,tdpur041.item
from tdpur041
where tdpur041._index1={:my.orno,:my.pono}
selectdo
|Criar novo lote
for i=1 to iteracoes step 1
|Artigo
stpapi.put.field("tdltc0101m000", "tdltc001.item",str$(tdpur041.item))
|Lote
stpapi.put.field("tdltc0101m000", "tdltc001.clot","02/002/01/00"&str$(i))
|Fornecedor
stpapi.put.field("tdltc0101m000", "tdltc001.suno",str$(tdpur041.suno))
|Data
stpapi.put.field("tdltc0101m000", "tdltc001.oudt",str$(date.num()))
stpapi.insert("tdltc0101m000",1,err)
if (strip$(err) <> "") then
stpapi.recover("tdltc0101m000",err)
endif
stpapi.end.session("tdltc0101m000")
endfor



if (lines <> 1) then |> 1ª linha
|Start the subsession - hangs, calls other session
stpapi.zoom.option("tdpur4120m000", 1, "tdpur4131s000", err)
| I also tried to insert fields directly into main table with no success
else
| Activa a subsessao de escolha por fornecedor
| Preparar para a subsessao
stpapi.handle.subproc( "tdpur4120m000", "tdpur4131s000", "add")
ret = stpapi.change.view("tdpur4120m000")
endif

|Preencher os campos de find
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")
if (ret=1) then |Encontrado
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
else
msg="Ordem,Linha não encontrada!"
endif

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")

if (ret=1) then |Se correu bem a subsessao
| 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 recebida = 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")

|O update tem função dupla, além de actualizar os dados dispara a
|subsessão de lotes
stpapi.handle.subproc( "tdpur4120m000", "tdilc4113s000", "add")
stpapi.update("tdpur4120m000",1,err)
for i=1 to iteracoes step 1
stpapi.put.field("tdilc4113s000","tdilc402.clot","02/002/01/00"&str$(i))
stpapi.put.field("tdilc4113s000","tdilc402.date",str$(date.num()))
stpapi.put.field("tdilc4113s000","tdilc402.qstr","2000")
stpapi.insert("tdilc4113s000",1,err)
endfor
|stpapi.continue.process("tdilc4113s000", err)
ret = stpapi.change.view("tdilc4113s000")
stpapi.end.session("tdilc4113s000")
endif

endselect
my.orno=my.orno+1
stpapi.end.session("tdpur4120m000")
endfor
| Fechar a sessao principal

}



Thanks :)

mark_h
7th December 2002, 00:41
Sorry if I mis-led you, to get to the session I have to do application/zoom/select receipts. So it is not directly under applications. I thought you might be able to add it there, but it looks like the way they have it setup you need the source code in order to add this as a user option. I have the source for tdpur4120m000, but not tdpur4131s000.

I though since I was going to have to develop one in a month or so I would start on it. So I did this just to see if I could do a receipt.


stpapi.put.field( "tdpur4120m000", "tdpur045.reno", "0" )
stpapi.put.field("tdpur4120m000","form.dino","1")
stpapi.handle.subproc("tdpur4120m000","tdpur4131s000","add")
stpapi.get.field( "tdpur4120m000", "tdpur045.reno", msg )
|

| Zoom and Go get last Suppliers' first record
stpapi.zoom.option("tdpur4120m000",1,"tdpur4131s000",msg)
stpapi.browse.view( "tdpur4131s000", "last.view")
stpapi.browse.set( "tdpur4131s000", "first.set")
rc = stpapi.mark("tdpur4131s000", msg)
stpapi.continue.process("tdpur4131s000",msg)
stpapi.end.session("tdpur4131s000")
stpapi.browse.set("tdpur4120m000","first.set")
stpapi.get.field( "tdpur4120m000", "tdpur045.reno", reno )
stpapi.get.field( "tdpur4120m000", "tdpur045.orno", orno )
stpapi.get.field( "tdpur4120m000", "form.dino", dino )
stpapi.end.session("tdpur4120m000")


I did this a test function server - it works the first time through. If I run it twice it locks up on the stpapi.browse.view( "tdpur4131s000", "last.view"). In effect I can not even create two receipts for the same PO. The last view gets a supplier that has three records. Not sure what to do at this point. I will look at it some more next week.

You did mention that you could do mutliple receipts, but it appears that does not work for me. Is there a reason you have to do one receipt? In my last inventory meeting I talked with our users about this and what they do is everything gets a new receipt. So I will be lucky in that respect - of course I have to get it working first.

Mark

pedromrs
7th December 2002, 13:37
Hi Mark,

They want orders with different numbers to be on different receipts but orders with the same number and different line numbers should all be in the same.
Maybe I have to convice them to change that. I tought of another thing. If it was possible to mark several records it should them be easy to add multiple lines.

The only reason I might see for it to lock up the second time out is that maybe the zoom.option() is not opening the subsession and so the next command on tdpur4131s000 just freezes.
You might want to check if the second iteration is really generating a new receipt number because if it isn't the main session might behave in a different way if it works like mine (new receipt - change.view() opens tdpur4131s000, old receipt select - change view opens lot control).
Also if you use a PO line in a receipt it might not be available the next time out because the status field for that order changes. That status field depends on the slip quantity and received quantity in some way I didn't quite understand yet because I don't have the source.

This one is a pain :rolleyes:

mark_h
9th December 2002, 14:51
Yes it is a tough one. I can now do individual receipts using tdpur4131s000 and I can do one receipt for all lines using tdpur4224s000. I want to look at trying to use tdpur4131s000 to add additional lines. I will post something later today before I leave today.


Mark

mark_h
9th December 2002, 17:22
Well nothing seems to work with the tdpur4131s000 session. The change view always wants to start a new receipt. I even tried using the stpapi.application.option for "select all receipts" in tdpur4131s000, but it does not work. The best I could do was mark one receipt and return it from tdpur4131s000.

I never did see you mention tdpur4224s000 - does your system bring up that session? All it asks for is the order number. When I enter that, do a continue, and return to the tdpur4120m000 session all of the order and lines are in the receipt.

Sorry I am not much help, but I think I have enough to do what I need. I can not think of any other options to try.

Mark

pedromrs
9th December 2002, 19:50
Hi Mark,

Well I made it work :)
When you call tdpur4131s000 for the first time try several finds and mark all the lines you want. To my surprise it marks all the records in the for loop.
Here an example for 3 lines (I have made tests for less and more):


for ilines=1 to 3
select tdpur041.pono,tdpur041.suno,tdpur041.ddtb,tdpur041.item
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")
if (ret=1) then |Encontrado
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
else
msg="Ordem,Linha não encontrada!"
endif
my.pono=my.pono+10
endselect
endfor


First line has lots filled already.

Thanks for the help.

mark_h
9th December 2002, 20:07
Hmmm - I did not try it with find, but with stpapi.browse using next.set, mark and repeat. It would only find the first record. You might want to try stpapi.application.option("tdpur4131s000",1,1,err) with tdpur4131s000 - it says it would mark all records. It did not work for me also, but who knows you may have a more current object.

Glad to see you have it working. :)

Mark

pedromrs
9th December 2002, 21:19
Hi Mark,

I had a bad experience with browse and this session. It would only mark my first record in the list. (I guess it just works ok with find).
The application option works for me but it doesn't really help me because I can't filter i.e. display just the lines I want with find (for every situation). Example: orno: 120001 and lines 10 & 30.

About the tdpur4224s000 session. Our consultant told us that this session can't be used with SP and c4?

Maybe you could try it with find?

mark_h
10th December 2002, 15:01
Yes the find did work. It still locks up when I try to modify a receipt and add a line - but I will not have to worry about that. So it looks like you actually solved your own problem and save d me some time - so thanks. :)

We are getting ready to upgrade to C4 and A&D 1(they changed this and I am not sure the actual number now). At the same time we are doing a Baan finance conversion and some Inventory Automation. The next year should be interesting.

Mark