baancust2
4th December 2007, 11:53
Hi,

We are trying to generate sales Order header and lines using the code given below, Header gets created successfully but the lines creation gives problem. It gives an error Cannot read the session or object tdsls00009058 continously in a loop .
Can someone please help?


function read.main.table()
{
domain tccom.cadr ofad1
String add1(20),add2(20),add3(20),result(30)

ret = stpapi.synchronize.dialog("tdsls4100mkro", "add", error7)
stpapi.put.field("tdsls4100mkro", "tdsls400.ofbp", cuno.f)
stpapi.put.field("tdsls4100mkro", "tdsls400.ofad", cadr.f)
stpapi.put.field("tdsls4100mkro", "tdsls400.cofc", cofc.f)
stpapi.put.field("tdsls4100mkro", "tdsls400.sotp", cotp.f)
stpapi.put.field("tdsls4100mkro", "tdsls400.orno", ord.seri)
stpapi.put.field("tdsls4100mkro", "tdsls400.oadt", str$(date.f))
stpapi.put.field("tdsls4100mkro", "tdsls400.ddat", str$(date.f))
stpapi.put.field("tdsls4100mkro", "tdsls400.ccur", "INR")
ret = stpapi.insert("tdsls4100mkro", true, error1)
stpapi.get.field("tdsls4100mkro", "tdsls400.orno", m.orno)
message("Sales Order %s",m.orno)

message("%s",error1)
fill.SO.lines()
stpapi.end.session("tdsls4100mkro", error2)
}

function fill.SO.lines()
{
string pono1(5)
stpapi.put.field("tdsls4101m000", "tdsls401.orno",m.orno)
ret = stpapi.change.view("tdsls4101m000", error3)
ret = stpapi.synchronize.dialog("tdsls4101m000", "modify", error7)
if ret then
stpapi.put.field("tdsls4101m000", "tdsls401.orno", m.orno)
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.1"," " )
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.2", item.f)
stpapi.put.field("tdsls4101m000", "tdsls401.qoor", "1")
stpapi.put.field("tdsls4101m000", "tdsls401.pric", str$(pric.f))
stpapi.put.field("tdsls4101m000", "tdsls401.ddta", str$(date.f))
stpapi.put.field("tdsls4101m000", "tdsls401.ccty", "IND")
stpapi.put.field("tdsls4101m000", "tdsls401.cvat", cvat.f)
stpapi.put.field("tdsls4101m000", "tdsls401.bptc", "IND")
stpapi.put.field("tdsls4101m000", "tdsls401.rnso", str$(seqn.2))
stpapi.put.field("tdsls4101m000", "tdsls401.rnsb", str$(seqn.1))
ret = stpapi.insert("tdsls4101m000", true, error4)
stpapi.get.field("tdsls4101m000","tdsls401.pono",pono1)
pono = lval(pono1)
message("Position no %s",pono1)
message("%s",error4)
stpapi.end.session("tdsls4101m000", error5)
stpapi.end.session("tdsls4101m000", error5)
endif
}


Regards,
Baancust2

mark_h
4th December 2007, 14:20
First - shouldn't this ret = stpapi.synchronize.dialog("tdsls4101m000", "modify", error7) have "add" instead of modify. According to the help document you use add when you want to insert. Not sure if that will solve your problem.

baancust2
5th December 2007, 06:17
hi,

Thank you for the suggestion.We tried doing as suggested by you but still it is not working. We are getting the error "Command Disabled".
To add to your information, we have copied the session tdsls4100m000 to tdsls4100mkro with session type as "Maintain" and synchronised to itself. We have not done any changes in the session tdsls4101m000. What else can be done?

Regards,
baancust2

mark_h
5th December 2007, 14:17
See this thread (http://www.baanboard.com/baanboard/showthread.php?t=28812&highlight=tdsls4100m000) for one solution by Kathuria.

baancust2
6th December 2007, 04:45
hi,

Our AFS is already created using the same thread as suggested by you. Still we are facing the error. Can there be an error due to some setup problem?

Regards,
Baancust2

mark_h
6th December 2007, 14:41
The question I have (and I do not know anything about ln) is did you copy tdsls4101m000 to something like tdsls4101mpol? I know in the post by Kathuria it mentions copying both sessions and breaking the synchronization. Then in the code is does use tdsls4101m000, but I think it should be tdsls4101mpol in the put fields. In your code I still see tdsls4101m000 and I do not know if that makes a difference.

And there are several things that could cause it to not work - tools libraries, patch release and even session objects. One of things I usually say is "just because in works for someone else does not mean it will work for you". Sometimes posted code in just a starting point.

som.papai
7th December 2007, 07:08
Hi All,
I am able to generate Sales Order Header Through DAL2, But when I going to generate Sales Order Lines at in this way, getting error ret.val=12.


dal.new.object("tdsls401")
dal.set.field("tdsls401.orno", tdsls400.orno)
dal.set.field("tdsls401.item", v.item)
dal.set.field("tdsls401.qoor", o.qoor)
ret.val = dal.save.object("tdsls401")


we already maintain this item standard price,warehouse .

Suggestion needed

Thankx & Regards
Sudipta Som

som.papai
7th December 2007, 07:55
Hi All,

I am able to generate Sales Order Lines Through AFS, But When i am going to
end session "stpapi.end.session("tdsls4100m900", error)" this give a Fatal error "Object 0 in process 283 not found". Here 283 is pid of tdsls4100m900 session.

Here is the code

stpapi.put.field("tdsls4100m000", "tdsls400.orno", vt.orno)
ret_val=stpapi.find("tdsls4100m000",error)
ret_val=stpapi.mark("tdsls4100m000", error)
ret_val=stpapi.synchronize.dialog("tdsls4100m000", "add", error)
ret_val=stpapi.synchronize.dialog("tdsls4101m000", "add", error) |(*1)
stpapi.put.field("tdsls4101m000", "tdsls401.orno", vt.orno)
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.1"," " )
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.2", shiftl$(strip$(timsl305.mitm)))

stpapi.put.field("tdsls4101m000", "tdsls401.qoor", str$(timsl305.qnty))
ret_val = stpapi.insert("tdsls4101m000", true, error)
tpapi.end.session("tdsls4101m000", error)
stpapi.end.session("tdsls4100m900", error) |(*2)
stpapi.end.session("tdsls4100m000", error)

(*1)-> here i am getting error Command is Disable.
(*2)-> here i am getting error "Object 0 in process 283 not found".


Suggestion needed

Thankx & Regards
Sudipta Som.

baancust2
7th December 2007, 13:02
Hi,

It's working now..

mark_h
7th December 2007, 13:11
Hi All,

I am able to generate Sales Order Lines Through AFS, But When i am going to
end session "stpapi.end.session("tdsls4100m900", error)" this give a Fatal error "Object 0 in process 283 not found". Here 283 is pid of tdsls4100m900 session.

Here is the code

stpapi.put.field("tdsls4100m000", "tdsls400.orno", vt.orno)
ret_val=stpapi.find("tdsls4100m000",error)
ret_val=stpapi.mark("tdsls4100m000", error)
ret_val=stpapi.synchronize.dialog("tdsls4100m000", "add", error)
ret_val=stpapi.synchronize.dialog("tdsls4101m000", "add", error) |(*1)
stpapi.put.field("tdsls4101m000", "tdsls401.orno", vt.orno)
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.1"," " )
stpapi.put.field("tdsls4101m000", "tdsls401.item.segment.2", shiftl$(strip$(timsl305.mitm)))

stpapi.put.field("tdsls4101m000", "tdsls401.qoor", str$(timsl305.qnty))
ret_val = stpapi.insert("tdsls4101m000", true, error)
tpapi.end.session("tdsls4101m000", error)
stpapi.end.session("tdsls4100m900", error) |(*2)
stpapi.end.session("tdsls4100m000", error)

(*1)-> here i am getting error Command is Disable.
(*2)-> here i am getting error "Object 0 in process 283 not found".


Suggestion needed

Thankx & Regards
Sudipta Som.

See the thread I linked to above by Kathuria.

Thomasm
9th December 2007, 21:51
I am successfully using the main session tdsls4102m000 to work the sales order lines. I did experience different kinds of problems when using the sub-session but have found no problems using this main session.

Good luck,
/Thomas

baanspider
3rd January 2009, 11:52
Hi baancust2

Could you share how you got the program to work.
Were you able to successfully insert a new line.

thanks n regards