jeffersyuan
27th May 2014, 09:28
Hi, All,

I am not sure about I am using the right way to do the AFS function.
Try to add routing via AFS, however, the result is very strange, for example, I have three lines to be added for one finish goods item. However, the strange result as:
For this finish goods item, only 1 tasks had been added, the other two lines had been added to other finish goods item, to me, it seems, the find function or synchronize.dialog cannot seek the right record. Any ideas on it?
Thanks.

Jeffers

The code as following:

stpapi.clear(sess)
stpapi.put.field(sess, "tirou102.mitm", " " & pmitm)
stpapi.put.field(sess, "tirou102.opro", popro)
stpapi.put.field(sess, "tirou102.opno", popno)
stpapi.put.field(sess, "tirou102.seqn", pseqn)
ret = stpapi.find(sess,error.msg)
|ret =0 table empty
|ret =1 Found
|ret =2 Not Found
if ret <> 1 then
add = stpapi.synchronize.dialog(sess, "add", error.msg)
|0 cannot synchronized
|1 synchronized
if add = 1 then

bhushanchanda
27th May 2014, 10:55
Hi,

I guess the item field is segmented. Try using -

stpapi.put.field(sess, "tirou102.mitm.segment.2",pmitm)

jeffersyuan
27th May 2014, 11:12
bhushanchanda,

Tried, same as before.


Jeffers
Hi,

I guess the item field is segmented. Try using -

stpapi.put.field(sess, "tirou102.mitm.segment.2",pmitm)

bhushanchanda
27th May 2014, 11:29
Hi,

Can you name the session on which you are doing the AFS? Would like to give it a try.

jeffersyuan
27th May 2014, 11:45
bhushanchanda,

session as tirou1102m000
Thanks.
Jeffers
Hi,

Can you name the session on which you are doing the AFS? Would like to give it a try.

bhushanchanda
27th May 2014, 11:52
Oh,

So I can see there are view fields in the session, so try using stpapi.change.view() instead of find.

I guess it will solve your problem.

jeffersyuan
27th May 2014, 12:01
bhushanchanda,

I have no idea about view fields or stpapi.change.view() function, any example about it?
Thanks.
Jeffers
Oh,

So I can see there are view fields in the session, so try using stpapi.change.view() instead of find.

I guess it will solve your problem.

bhushanchanda
27th May 2014, 12:10
Hi,

There's a similar session tirou1101m000 with just one view field. You can refer below code:-

select tcibd001.*
from tcibd001
where tcibd001.item(10;4) = "TEST" | I am trying to insert Routing Data for "TEST" item.
selectdo

stpapi.put.field("tirou1101m000", "tirou101.mitm.segment.1", tcibd001.item(1;9))
stpapi.put.field("tirou1101m000", "tirou101.mitm.segment.2", tcibd001.item(10;38))
ret = stpapi.change.view( "tirou1101m000", error )
if ret = 0 then
ret = stpapi.synchronize.dialog("tirou1101m000", "add", error)
if ret then
stpapi.put.field("tirou1101m000", "tirou101.opro", "100")
stpapi.put.field("tirou1101m000", "tirou101.dsca", "TESTING ROUTING")
stpapi.put.field("tirou1101m000", "tirou101.stor", str$(etol(tcyesno.no)))
stpapi.put.field("tirou1101m000", "tirou101.maru", str$(etol(tcyesno.no)))
ret = stpapi.insert("tirou1101m000", true, error)
if ret then
ret = stpapi.save("tirou1101m000", error)
endif
endif
endif
stpapi.end.session("tirou1101m000", error)

endselect

Similarly, you can try for your session.

jeffersyuan
27th May 2014, 16:02
bhushanchanda,
Thanks a lot for your kindly answer on it.
Jeffers


Hi,

There's a similar session tirou1101m000 with just one view field. You can refer below code:-

select tcibd001.*
from tcibd001
where tcibd001.item(10;4) = "TEST" | I am trying to insert Routing Data for "TEST" item.
selectdo

stpapi.put.field("tirou1101m000", "tirou101.mitm.segment.1", tcibd001.item(1;9))
stpapi.put.field("tirou1101m000", "tirou101.mitm.segment.2", tcibd001.item(10;38))
ret = stpapi.change.view( "tirou1101m000", error )
if ret = 0 then
ret = stpapi.synchronize.dialog("tirou1101m000", "add", error)
if ret then
stpapi.put.field("tirou1101m000", "tirou101.opro", "100")
stpapi.put.field("tirou1101m000", "tirou101.dsca", "TESTING ROUTING")
stpapi.put.field("tirou1101m000", "tirou101.stor", str$(etol(tcyesno.no)))
stpapi.put.field("tirou1101m000", "tirou101.maru", str$(etol(tcyesno.no)))
ret = stpapi.insert("tirou1101m000", true, error)
if ret then
ret = stpapi.save("tirou1101m000", error)
endif
endif
endif
stpapi.end.session("tirou1101m000", error)

endselect

Similarly, you can try for your session.

bhushanchanda
27th May 2014, 16:05
Glad that you figured out the issue.

If possible please post your solution and the problem which caused the issue. It will help others facing similar problem.