raikar_raviraj
10th July 2007, 12:30
Hi,

I need to generate PO through AFS. I am able to generate PO header and extension to PO header. But when im trying to create PO lines, the process hangs.

I am handling the extension to PO lines too.

Please go through the code and tell me what changes are required.

tdpur4101m000 - Maintain PO header
tdpur4102s000 - Maintain PO lines
tdind0271s000 - Maintain Extension to PO lines

Thanks

Regards

mark_h
10th July 2007, 14:41
In this piece of code:

stpapi.insert("tdind0271s000", 1, error)
if isspace(error) then
tdind0271s000f.save(error)
tdind0271s000f.end()
else
message("" &error)
stpapi.recover("tdind0271s000", ret.mesg )
endif
stpapi.insert("tdpur4102s000", 1, error )
if isspace(error) then

stpapi.save("tdpur4102s000",error)| HANGS HERE

You say it hangs. First do you need the save? Check to see if the insert takes care of adding the record. If not do, what happens with the save? Do anyother sessions open up in the background? You might want to watch what is happening in the background as the sessions open. Last, but not least - do you have source code? That will make it easier to debug what is happening. Also you can search on your sessions in this forum to see if there are other posts which might give you a clue as to how to solve your problem.

raikar_raviraj
11th July 2007, 05:36
Hi Mark,

If i remove the stpapi.save command... the AFS doesnt hang. But the problem is it doesnt add any record in the lines nor the extension.
If i manually insert it, with the same piece of data that is mandatory it works perfectly fine without any glitches. and during manual insertion save is neccessary..

Ive searched all the threads in the forum to no avail. Most of the AFS are related to sales order, The sales order lines logic doesnt work out here cause the localized extension of lines in sales order is not on the tab event of the field.

wanted to know how can i handle the tab event of field through AFS.. ive used stpapi.handle.proc... If i use stpapi.continue then also it hangs forever..

mark_h
11th July 2007, 17:25
Part of the problem might be that you can not simulate a tab event in AFS. I was looking at the code some more:

tdpur4102s000f.put.Dimension_2.tdpur041.dim2(dim2)

stpapi.get.mess.code(error)
if not isspace(error) then
message(""&error)
endif

stpapi.handle.subproc("tdpur4102s000", "tdind0271s000", "add")
basedate = date.num()
tdind0271s000f.put.Base_Date(basedate)

I take it when you manually put dim2 in the tdpur4102s000 session, hit tab - the tdind0271s000 session starts? When you watch the processes in the background what action starts tdind0271s000? I would expect to see this command stpapi.handle.subproc("tdpur4102s000", "tdind0271s000", "add") followed by an action command on tdpur4102s000 ( a save, insert, update, continue). Without that I do not see how you are controlling tdind0271s000 linked with tdpur4102s000. I think the first put command on tdind0271s000 is actually starting the session. Do not forget that there are two modes to update and insert - true(1) to execute the update.db event or false(0) to skip execution of update.db. You might have to play around with these to see if it helps.

So with the session in debug mode use the option dialog and ps to see what starts with what AFS command. I have a feeling that even though the sessions are started the control between sessions is not there(mainly between tdpur4102 and tdinv0271).

Another thing is to think of work arounds - for example can you save tdpur4102s000 records, come back into the session, maybe hit save or some action to restart tdind0271s000. Kind of how I do the pegging in our A&D system for purchase orders. I actually cancel the first time the subsession comes up, then relaunch the session where I can actually control it. Of course I would not worry about this until you have tried all you can think of above.

There is always the possibility that you may have to get the support center involved.

Another question you did not answer? Do you have source code that you can compile into debug mode?

raikar_raviraj
12th July 2007, 07:19
Hi Mark,

Problem in adding data to purchase order extension session (tdpurl102s002)
The program code is here

tdpur4101m000f.put.Purchase_Order(order.series)
tdpur4101m000f.put.Supplier(tdind041.suno)
tdpur4101m000f.put.Order_Type(ordr.type)
tdpur4101m000f.put.Company(comp)
tdpur4101m000f.put.Order_Date(basedate)
tdpur4101m000f.put.Delivery_Date.tdpur040.ddat(basedate)
stpapi.insert("tdpur4101m000", 1, error )
orno = tdpur4101m000f.get.Purchase_Order()
tdpur4101m000f.handle.sub.process("tdpur4101m000", "add")
stpapi.zoom.option("tdsls4101m000",14,"tdpurl102s002", error)
stpapi.continue.process( "tdpurl102s002", error )
stpapi.put.field("tdpurl102s002","tdind014.orno",str$(orno))
stpapi.put.field("tdpurl102s002","tdind014.exci",str$(value))
stpapi.put.field("tdpurl102s002","tdind014.odis",str$(buf))
stpapi.put.field("tdpurl102s002","tdind014.svyn",str$(value))
stpapi.put.field("tdpurl102s002","tdind014.octr",str$(var))
stpapi.put.field("tdpurl102s002","tdind014.srtx",str$(value))
stpapi.insert("tdpurl102s002", 1, error )
extorno = tdpurl102s002f.get.Order_No( )
stpapi.end.session("tdpurl102s002", error)

here the session tdpurl102s002 opens on the tab event of tdpur040.ddat, so i am not able to understand how do i control this. i tried everything i cud do.
stpapi.insert returns 1(true) still data doesnt get inserted. Ive put all the mandatory fields required. also when i try to get the orderno from extension i.e field extorno it returns 0. Ive checked in the ps the sessions starts and ends properly based on the event.

I dont have the source code of this standard session. I really cant figure out where i am going wrong.

mark_h
12th July 2007, 13:54
Hi Mark,
I dont have the source code of this standard session. I really cant figure out where i am going wrong.
You might not be doing anything wrong - some sessions do not support AFS code. You might contact the support center to see what they say - it could be that you need new session objects. I have had the support center tell me that a session was not supported for use with API commands. I did eventually figure a work around - I have used Qkey(source extension) to solve some problems.

raikar_raviraj
16th July 2007, 14:12
hi Mark,

After playing with the AFS for nearly a week now, i was able to generate the PO through AFS.
But the management has new requirement now, they want the position no to start with 10 and not 1, i tried putting it in the AFS, i.e
stpapi.put.field("tdpur4102s000","tdpur041.pono",str$(10))

but the AFS creates a po starting with 1 only.

is it possible to do so, because when we manually creat a PO lines, it gives us the option to change the PO No..

Thanks..

mark_h
16th July 2007, 15:23
I am not positive that it will let you change the position number - I have never tried it. I just let the position number default.

dear00
23rd May 2008, 10:52
Hi!
I have the same problem.
when I tried to insert the line order, the program seems to work write, but doesn't insert the line.
Colud you send me your code that work right?
I working in this more a week and I don't now whata to do to solve this.
Thank yo in advanced.
Desiree (Desiree.Argento@grupoaciturri.com)

hi Mark,

After playing with the AFS for nearly a week now, i was able to generate the PO through AFS.
But the management has new requirement now, they want the position no to start with 10 and not 1, i tried putting it in the AFS, i.e
stpapi.put.field("tdpur4102s000","tdpur041.pono",str$(10))

but the AFS creates a po starting with 1 only.

is it possible to do so, because when we manually creat a PO lines, it gives us the option to change the PO No..

Thanks..

mark_h
23rd May 2008, 13:51
Desiree - what exactly is your problem? Is it inserting a line or is it inserting a line and changing the line number? If you post your code for inserting a line we can take a look at it and maybe make some suggestions.

dear00
23rd May 2008, 17:56
Hi!
The problem is that api doesn't insert the lines.
I don't now how to do , I have prove a lot of things and nothing.
I added the code ina file.
Thank you very much.

mark_h
26th May 2008, 01:10
Sorry - I thought this was purchase orders. For sales orders just search for the sales order sessions. There are a lot of threads around on those sessions. Sorry to say we do not use them, so I have nothing that will help.

baanguy2
19th June 2008, 16:08
Hi Raikar,

Did you get your purchase order position issue fixed?
if you have not had it fixed, it has nothing to do with the AFS, there is a purchase order parameter session and you need to change the interval of the pistion number as you want it.

Regards,