kiranu
5th August 2005, 11:08
Hi,

Firstly, i am new in AFS and i am trying to write a afs function for tipcs2280m000. But i am working in tdsls1441m000 (my session) and i am trying to run tipcs2280m000 session from tdsls1441m000.

In tipcs2280m000 session, form fields are defined as external var. For example:

cprj.f , cprj.t, new.status, only.error.

Now, the thing that i want to do is :

stpapi.put.field("tipcs2280m000","cprj.f",str$(tdsls041.orno))
stpapi.put.field("tipcs2280m000","cprj.t",str$(tdsls041.orno))
stpapi.put.field("tipcs2280m000","new.status",str$(tcpsts.active))
stpapi.put.field("tipcs2280m000","only.errors",str$(tcyesno.yes))
retvall3 = stpapi.update("tipcs2280m000",1,err1)
stpapi.end.session("tipcs2280m000")


But when i run tipcs2280m000, this code is not working. In debug mode, i tried to read the value of fields and i see it working but i can not see the values when i run it.

Can you help me , please?

Unsal

jordimur
5th August 2005, 13:10
A couple of remarks
1º instead of stpapi.update, you shoul use stapi.continue
2º if this session makes a report you should add code to choise report + choise device

Jordi

kiranu
5th August 2005, 14:02
Hi Jordi,

First of all thanks for your reply.

May be you can be rigth. Because i have tried also stpapi.continue.process and it returned "Report not found".

But tipcs2280m000 session has a report and the problem is i am writing afs function in the script of tdsls1441m000. I mean the code i sent before is from script of tdsls1441m000. How can i use choise report + choise device in tdsls1441m000 script or is it possible to use?

Unsal

mark_h
5th August 2005, 16:35
Yes - I think Jordi is correct. Make sure to add the stpapi.set.report before calling the stpapi.continue.process. To test it you can just hard code the device for the report to "D" or "D66".

kiranu
9th August 2005, 09:18
Thanks guys,

it is working now.

kiranu
9th August 2005, 10:34
Hi Guys,

I have another problem.

In session tipcs2101m000, there is a filed for delivery date. If the users dont enter the delivery date, the session warn the users and they have to enter a date to this field.

So, in my script, i do this :

/****************
stpapi.put.field("tipcs2101m000","tipcs020.cprj",str$(tdsls041.orno))
retvall1 = stpapi.find("tipcs2101m000",err1)
retvall2 = stpapi.update("tipcs2101m000",true,err1)
if retvall1 <> 1 then
stpapi.put.field("tipcs2101m000","tipcs020.dsca",tccom010.nama(1;30))
stpapi.put.field("tipcs2101m000","tipcs020.dscb",tccom010.namb)
stpapi.put.field("tipcs2101m000","tipcs020.dscc",tccom010.namc)
stpapi.put.field("tipcs2101m000","tipcs020.dscd",tccom010.namd)
stpapi.put.field("tipcs2101m000","tipcs020.ncmp",str$(get.compnr()))
stpapi.put.field("tipcs2101m000","tipcs020.kopr",str$(tckopr.single.project))
stpapi.put.field("tipcs2101m000","tipcs020.refe",str$(tdsls041.orno))
stpapi.put.field("tipcs2101m000","tipcs020.seak",tccom010.nama)
stpapi.put.field("tipcs2101m000","tipcs020.ffci","1")
stpapi.put.field("tipcs2101m000","tipcs020.psts",str$(tcpsts.free))
stpapi.put.field("tipcs2101m000","tipcs020.dsca",str$(tcplcd.backward))
stpapi.put.field("tipcs2101m000","tipcs020.ddta",str$(date.num()))
stpapi.put.field("tipcs2101m000","tipcs020.intp",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bkcs",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bkdt",str$(tdsls041.ddta))
stpapi.put.field("tipcs2101m000","tipcs020.bcbi",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bcim",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.erev",str$(tcyesno.yes))

retvall1 = stpapi.update("tipcs2101m000",true,err1)
if retvall1 then
stpapi.insert("tipcs2101m000",false,err1)
stpapi.put.field("tipcs2101m000","tipcs020.cprj",str$(tdsls041.orno))
stpapi.update("tipcs2101m000",true,err1)
retvall2 = stpapi.save("tipcs2101m000",err1)
if retvall2 = 0 then
stpapi.recover("tipcs2101m000",err1)
endif
endif
endif

/********************

So when i debug, stpapi.insert() function returns an error like "Delivery date must be entered".

Thats why this code do nothing.

How should i solve this problem?

Thanks

mark_h
9th August 2005, 14:31
On my system this field tipcs020.ddta is tipcs020.ddat. Is this just a typo?

Mark

kiranu
9th August 2005, 14:42
Hi Mark,

Ok. I change it, but the problem is different.

when i debug, stpapi.insert still return "Delivery Input must be entered".

i could not solve the problem. i am going to be crazy.

jordimur
22nd August 2005, 17:08
Kiranu,
Maybe I miss something, but I don't understand why you make a stpapi.update after stpapi.find.
what I would do is :
If stpapi.find = 1 then modify the needed field and then stpapi.update
If stpapi.find <> 1 then fill fields and then stpapi.insert (without stpapi.update's in the middle

I hope this helps

mark_h
23rd August 2005, 23:52
Yes jordimur is correct. I would expect you script to look something like this.


stpapi.put.field("tipcs2101m000","tipcs020.cprj",str$(tdsls041.orno))
retvall1 = stpapi.find("tipcs2101m000",err1)
if retvall1 <> 1 then
stpapi.put.field("tipcs2101m000","tipcs020.cprj",str$(tdsls041.orno))
stpapi.put.field("tipcs2101m000","tipcs020.dsca",tccom010.nama(1;30))
stpapi.put.field("tipcs2101m000","tipcs020.dscb",tccom010.namb)
stpapi.put.field("tipcs2101m000","tipcs020.dscc",tccom010.namc)
stpapi.put.field("tipcs2101m000","tipcs020.dscd",tccom010.namd)
stpapi.put.field("tipcs2101m000","tipcs020.ncmp",str$(get.compnr()))
stpapi.put.field("tipcs2101m000","tipcs020.kopr",str$(tckopr.single.project))
stpapi.put.field("tipcs2101m000","tipcs020.refe",str$(tdsls041.orno))
stpapi.put.field("tipcs2101m000","tipcs020.seak",tccom010.nama)
stpapi.put.field("tipcs2101m000","tipcs020.ffci","1")
stpapi.put.field("tipcs2101m000","tipcs020.psts",str$(tcpsts.free))
stpapi.put.field("tipcs2101m000","tipcs020.dsca",str$(tcplcd.backward))
stpapi.put.field("tipcs2101m000","tipcs020.ddta",str$(date.num()))
stpapi.put.field("tipcs2101m000","tipcs020.intp",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bkcs",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bkdt",str$(tdsls041.ddta))
stpapi.put.field("tipcs2101m000","tipcs020.bcbi",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.bcim",str$(tcyesno.no))
stpapi.put.field("tipcs2101m000","tipcs020.erev",str$(tcyesno.yes))
retvall2 =stpapi.insert("tipcs2101m000",false,err1)
if retvall2 = 0 then
stpapi.recover("tipcs2101m000",err1)
endif
else
| Put some fields for updating
retvall1 = stpapi.update("tipcs2101m000",true,err1)
endif


Granted there are times that you have to play with update/save to get the correct combination.

kiranu
24th August 2005, 10:54
Thanks guys,

it is working now. But i have another problem with tdsls4102s000 session.

When i want to insert a sales order line, it gives an error like "Delivery date is before order date".
This is the code:

inpstring = date.to.inputstr$(tmpddta,"%D002,3",8)

stpapi.put.field("tdsls4102s000","tdsls041.orno",str$(tm****o))
stpapi.put.field("tdsls4102s000","tdsls041.pono",str$(tmppono))

retvall1 = stpapi.find("tdsls4102s000",err1)
if retvall1 <> 1 then

stpapi.put.field("tdsls4102s000","tdsls041.orno",str$(tm****o))
stpapi.put.field("tdsls4102s000","tdsls041.pono",str$(tmppono))
stpapi.put.field("tdsls4102s000","tdsls041.item",str$(tmpitem))
stpapi.put.field("tdsls4102s000","tdsls041.cpva",str$(tmpcpva))
stpapi.put.field("tdsls4102s000","tdsls041.cuno",str$(tmpcuno))
stpapi.put.field("tdsls4102s000","tdsls041.cpva",str$(tmpcpva))
stpapi.put.field("tdsls4102s000","tdsls041.cwar",str$(tmpcwar))
stpapi.put.field("tdsls4102s000","tdsls041.ddta",inpstring)
stpapi.put.field("tdsls4102s000","tdsls041.oqua",str$(tmpoqua))
stpapi.put.field("tdsls4102s000","tdsls041.pric",str$(tmppric))

stpapi.insert("tdsls4102s000",1,err1)
if err1 <> "" then
message(err1)
endif

stpapi.save("tdsls4102s000",err1)
if err1 <> "" then
message(err1)
endif
endif

stpapi.end.session("tdsls4102s000",err1)

Where is the problem?

Thanks for your help

kiranu
24th August 2005, 11:54
Hi again,

In the last post, i sent a program code and i realize that it is working.
But it insert to next record. I mean, my order no is 970001 and i want to insert here. But it insert to next record (970004).

Why?

thanks

Unsal

Juergen
24th August 2005, 13:02
Hi,

I think in this case you have to use the stpapi.change.view command instead of using stpapi.find.

retvall1 = stpapi.change.view("tdsls4102s000",err1)
if retvall1 then
... insert action ...
endif

Juergen

kiranu
24th August 2005, 15:27
Okey guys,

thanks Juergen. It is working.

Unsal