iiparrag
19th May 2010, 12:47
Hello.

I'd like to know whether there is a specific way to simulate a zoom from a fomr field to a session using ASF.

I've already read in other (closed) thread that is imposible doing this in the case we want to activate product configurator (tipcf5120s000) from mantaining sales order lines. In this case, we can't use stpapi.zoom.option because tipcf5120s000 doens't appear neither the Special menu nor any choice. It is activated zooming to it once you have entered a generic item code.

I've also read we can create a product variant in other way, but although I haven't tried it yet, how can we do it with any field that has a zoom to a session (or subsession)?

Thanks a lot.

Ione

mark_h
19th May 2010, 15:33
Not being familiar with the sessions it is hard to say. The first thing I would try is putting the generic item using AFS - then followed by a save, an update(with and without do.update set to true) or maybe even continue. I would see if I could get the session to activate. If that failed then I would probably try to add the session to the special menu or on the choice command.

Do you own source code? With that you can debug what happens with each command and try various different things.

iiparrag
19th May 2010, 16:30
Hi mark_h.
Thanks for your quick reply.
I was talking about tdsls4102s000 (Maintain sales order lines).
In section "when.field.changes" for field tdsls041.item there is a zoom (in standard code)to Product configurator (tipcf5120s000) but not for api.mode.
Anyway, I'll try what you say with debugger to see what happens and will tell you something.

Thanks a lot.

Ione

iiparrag
20th May 2010, 13:41
Hi again.

I couldn't exec any SO line saving nor updating since it's mandatory to specify variant (cpva) field that is what I want to get with this process. Not only getting a variant number but also defining it.

I tried doing this in my code to automatically generate a SO line with a generic item, but first of all, I try to generate a variant and defining it:

select tccom010.nama, tccom010.ccur
from tccom010
where tccom010._index1={:cuno}
selectdo
endselect

stpapi.put.field("tipcf5101m000","tipcf500.dsca",tccom010.nama)
stpapi.put.field("tipcf5101m000","tipcf500.item", "PRODOGEN")
stpapi.put.field("tipcf5101m000","tipcf500.reft", str$(tcreft.sls.order))
stpapi.put.field("tipcf5101m000","tipcf500.refo", str$(orden))
| stpapi.putfield("tipcf5101m000","tipcf500.refp", str$(pono)) |Después de generar la línea
stpapi.put.field("tipcf5101m000","tipcf500.cuno", cuno)
stpapi.put.field("tipcf5101m000","tipcf500.ccur",str$(tccom010.ccur))
stpapi.put.field("tipcf5101m000","tipcf500.vali", str$(tcyesno.no))

ret = stpapi.insert("tipcf5101m000",true,error)
if not ret then
stpapi.recover("tipcf5101m000", error)
endif
if isspace(error) then
stpapi.get.field("tipcf5101m000","tipcf500.cpva",variante)
endif

stpapi.continue.process("tipcf5101m000", error)

In the last line, when choice.cont.process.is executes in tipci5101m000 it zooms to "Product configurator". That's ok 'till now. It generates a product variant, but it tipcf5120s000 (Product configurator) hangs because it enters in a loop waiting to a boolean to be set to true, and for this is NECESSARY graphical.mode predefined variable to have TRUE value (but working in api.mode it will be always FALSE.

Would the only way to solve this problem changing tipcf5120s000 session's code to not to check graphical.mode variable?

Thank you so much and sorry because of my english...:(

Ione

mark_h
20th May 2010, 19:39
Yes - you would need to change the code. Maybe you could add not api.mode in some fashion to either get the variable to true or skip the check.

iiparrag
21st May 2010, 08:34
Ok. I'll try it.

But I still have the same doubt that I had a t the begining. If I'm designing a session A who calls trhough AFS to session B, an this has a form field defined with a zoom to C session. How can I repeat the action of zooming from field of B session from A? I mean:
Probably there is a before.zoom and/or an after.zoom in session B's source. So understand that I would have two ways:
1.- Repeating the code of before.zoom in A; zooming directly to C from A; an d finally repeting the code of after.zoom.
2.- Using some other AFS function (that I don't know wether it exists or not)

I have this doubt because I know there is a way to simulate choices (you can see it in my code piece) or Especial menu entries. And this case I'm asking about doesn't work with one nor the other.

Thank you.

mark_h
21st May 2010, 16:36
Maybe I do not understand the question. But below I wrote session tfoca9120m000 which calls tfoca0120m000 and then I zoom to tfoca0122s000. What I am doing is ready a table which has my calculated head count. I then call this subroutine for each record in the table. In my case this is not an automatic zoom - tfoca0122s000 is on the special menu. This works and is repeatable - I do not have to worry about any baan code.


function update.headcnt()
{
stpapi.put.field("tfoca0120m000","tfoca020.base",str$(basegrp))
rc = stpapi.find("tfoca0120m000",errmsg)
if not isspace(errmsg) or rc<>1 then
write.error("Base Code(" & str$(basegrp) & ") not found.")
stpapi.end.session("tfoca0120m000")
return
endif
stpapi.handle.subproc("tfoca0120m000", "tfoca0122s000","add")
stpapi.zoom.option("tfoca0120m000",1,"tfoca0122s000",errmsg)
stpapi.put.field("tfoca0122s000","tfoca022.bdcf",dims)
rc = stpapi.change.view("tfoca0122s000",errmsg)
if not isspace(errmsg) or rc<>1 then
write.error("Base dimension code(" & str$(basegrp) & " " & dims & ") not found.")
else
stpapi.put.field("tfoca0122s000", "tfoca022.quan", str$(headcnt))
stpapi.update("tfoca0122s000", 1, errmsg)
if not isspace(errmsg) then
write.error("Unable to update record.")
endif
endif
stpapi.end.session("tfoca0122s000")
stpapi.end.session("tfoca0120m000")
}


Now if I understood your case you have a session where if you put an item into the field it would automatically zoom to another session. Now if I understood correctly when tipcf5120s000 gets executed it never ends. All you have to do is change the code so it gets out of that loop. Close tipcf5120s000 and close tipcf5101m000. Your are done. Then your AFS code in session A can start it all over again with a new record.

The only thing I see missing in your code is the stpapi.handle.subproc:

stpapi.put.field("tipcf5101m000","tipcf500.dsca",tccom010.nama)
stpapi.put.field("tipcf5101m000","tipcf500.item", "PRODOGEN")
stpapi.put.field("tipcf5101m000","tipcf500.reft", str$(tcreft.sls.order))
stpapi.put.field("tipcf5101m000","tipcf500.refo", str$(orden))
| stpapi.putfield("tipcf5101m000","tipcf500.refp", str$(pono)) |Después de generar la línea
stpapi.put.field("tipcf5101m000","tipcf500.cuno", cuno)
stpapi.put.field("tipcf5101m000","tipcf500.ccur",str$(tccom010.ccur))
stpapi.put.field("tipcf5101m000","tipcf500.vali", str$(tcyesno.no))

ret = stpapi.insert("tipcf5101m000",true,error)
if not ret then
stpapi.recover("tipcf5101m000", error)
endif
if isspace(error) then
stpapi.get.field("tipcf5101m000","tipcf500.cpva",variante)
endif
stpapi.handle.subproc("tipcf5101m000", "tipcf5120s000","add")
stpapi.continue.process("tipcf5101m000", error)
stpapi.end.session("tipcf5120s000")
stpapi.end.session("tipcf5101m000")

Now if tipcf5120s000 hangs in that loop then you just need to break it. Then the above code should work.

iiparrag
25th May 2010, 11:41
Hi Mark

Thank you. As you said in your example, you call to a session in the Special menu. And I know that to do this I must use stpapi.handle.subproc. And maybe you can also use this in a zoom that appears in the Special menu. But when the zoom is programmed after changing the value of an input field, I supose it should be executed automatically as soon as you put a value through AFS in that field using stpapi.put.field. That was my doubt. The example it didn't work was:
When I put a value in the item field into the tdsls4102s000 I couldn't start tipcf5120s000 (it's zoomed to in when.field.changes section in tdsls4102s000).

About the product configurator (tipcf5120s000), I decided not to touch its code because it's functionality stands on that loop I wans't able to come out from, so I created tipcf500 register through tipcf5101m000 (using AFS calls), and manually the registers in tipcf510 and tipcf520.

Thanks a lot.