en@frrom
2nd August 2005, 18:20
I'm still very new to AFS. I am trying to fetch the correct price by activating the price simulator in AFS mode. The stpapi.get.field gives me an empty string in return.

function get.price()
{
domain tcmcs.str100 err

stpapi.put.field("tdpcg0200m300", "typ.of.ord", "9") | algemeen (verkoop)
stpapi.put.field("tdpcg0200m300", "bus.prt", bpid)
stpapi.put.field("tdpcg0200m300", "item", tcibd300.lcom)
stpapi.put.field("tdpcg0200m300", "trn.cur", "EUR")
stpapi.put.field("tdpcg0200m300", "qty", str$(tcibd300.quan))
stpapi.put.field("tdpcg0200m300", "qty.unt", tcibd001.cuni)
stpapi.put.field("tdpcg0200m300", "prc.dte", str$(sys.date))

stpapi.handle.subproc("tdpcg0200m300", "tdpcg0200m100", "add")
stpapi.form.command("tdpcg0200m300", 5, "exec.user.0", err)

stpapi.get.field("tdpcg0200m100", "unt.prc", unt.prc.str)

stpapi.end.session("tdpcg0200m100")
stpapi.end.session("tdpcg0200m300")


}

mark_h
2nd August 2005, 19:15
Since this is Baan 5 I thought I would ask if it was a segmented field?

Paul P
3rd August 2005, 05:23
Sharp observation, Mark! As per API manual, any segmented field must be filled segment by segment in API. So en@frrom, what you could try to do first is to replace the line
stpapi.put.field("tdpcg0200m300", "item", tcibd300.lcom)
with these 2 lines
stpapi.put.field("tdpcg0200m300", "item.segment.1", tcibd300.lcom(1;9))
stpapi.put.field("tdpcg0200m300", "item.segment.2", tcibd300.lcom(10;38))
Please come back and tell us how it goes. I don't have BaanERP system right in front of me right now so I'm not even sure how tdpcg0200m300 supposed to work normally as well as under API

Rgds,
Paul

en@frrom
3rd August 2005, 10:50
Mark, Paul,

Thanks for your responses. I didn't mention on my first post that I had already debugged tdpcg0200.1 to see what's happening there, and found the following:
1) item is filled correctly, even when not splitted out per segment.. Indeed susprisingly, maybe someone can shed me some more light onto that?
2) when I trace the variable unt.price in tdpcg0200.1, I see it IS getting filled correctly, and from what I see does not get blanced out afterwards or so.

Thus, it seems like all variables are passed on correctly to tdpcg, and the price is indeed fetched in tdpcg, just the stpapi.get.field doesn't seem to send on the variable. I guess there is something I am doing wrong...?

mark_h
3rd August 2005, 15:30
Okay - is one a typo. I see unt.prc in the script and unt.price in the last message. Can you confirm which is correct.

en@frrom
3rd August 2005, 15:32
Sorry, a typing mistake, it is unt.prc

Paul P
4th August 2005, 07:35
My question is still:
Have you tried to split the item segment in API? Does it help?

Rgds,
Paul

en@frrom
4th August 2005, 09:34
Paul, sorry if I wasn't clear in my previous post, but yes, I HAVE splitted the item segments, and the result is the same.

mark_h
4th August 2005, 16:02
Just curious - but while debugging tdpcg0200.1 was there any display that was done for the unt.prc field? Are there other fields on this session you can test? I am just wondering if the field buffer is not being set. According to the documentation you usually have to execute something to get this loaded. I did a quick test and found that no matter how I started one session I could not get the get.field to work as the first command issued against the session(even tried mutliple gets in a row). I had to do a find or other type command first. I am just wondering if this maybe the case here - you zoom to the session, it runs, but nothing takes place from the stpapi end to load this field buffer. Just speculating and I could be way off base.

pconde
4th August 2005, 16:14
Hello,

I have do this on baan 5.0c SP15: here is my code and it work for me
#define SES300 "tdpcg0200m300"
#define SUB100 "tdpcg0200m100"
#define SUB200 "tdpcg0200m200"

mycomp = get.compnr()
itccom0000.get.multi.currency.data(mycomp)

tcibd.dll0010.determine.segment(i.item,tcibd.apco.project,tprj)
tcibd.dll0010.determine.segment(i.item,tcibd.apco.none,titem)

stpapi.put.field(SES300, "typ.of.ord", str$(etol(tdpcg.tyor.gp)))
stpapi.put.field(SES300, "bus.prt", i.bus)
stpapi.put.field(SES300, "item.segment.1", tprj)
stpapi.put.field(SES300, "item.segment.2", titem)
stpapi.put.field(SES300, "trn.cur", itccom0000.hcur(1,1))
stpapi.put.field(SES300, "qty", edit$(i.qty, "999"))
stpapi.put.field(SES300, "qty.unit", "pcs")
stpapi.put.field(SES300, "prc.dte", str$(utc.num()))
stpapi.handle.subproc(SES300, SUB100, "add")
stpapi.form.command(SES300, 5, "exec.user.0", error.msg)
stpapi.find(SUB100, str.get)
|PCE : 21/6/2005 Without the find the get return an empty value
stpapi.get.field(SUB100, "iunt.prc", str.get) | prix unitaire
val.pric = val(str.get)
stpapi.get.field(SUB100, "tot.dsc.amt", str.get)
tot.dsc.amt = val(str.get)
stpapi.end.session(SUB100)
stpapi.end.session(SES300)
return(val.pric)
Regards
Philippe

en@frrom
4th August 2005, 17:18
Mark & Philippe, thanks for your suggestion. I added the stpapi.find("tdpcg0200m100", err) before the get.field, but now I get a "NULL POINTER on tdpcg0200m100 in DLL: ottstpstandard (retry.point)" every time it hits the stpapi.find command. From a search on the board on NULL POINTERS, it seems like a lot of people have/had problems, but I see more problems of reports or/and old versions. Our software is SP16, yet on Baan 5.0B... would it maybe have to do with that? That certain patches for Baan 5 have only been applied for Corelli and Rieger and nog for Grieg...?

pconde
4th August 2005, 17:38
Hello,

I think that the most important is the portingset. The related dll ottstpstandard, ottstpapihand and ottstpapiserv must belong to the same solution. I had problems with the API when these 3 DLL are not coming for the same solution

My porting set is 7.1d.01. Some of the API programs that worked on this porting set don't work on 7.1d.04. :-(

So control via PMC the last solution for these 3 DLL

Regards
Philippe

en@frrom
5th August 2005, 11:58
Hi Philippe, I want to refrain from changing my standard dll's, for sure from backporting to an older version!! Is there no other way??

pconde
5th August 2005, 15:02
Hi,

The only thing that I can suggest it that you test different options. May be try to set the key fields via stpapi.put.field before the find?. If you have the sources try to set all in debug and see what happens?

Good luck
Philippe

en@frrom
10th August 2005, 17:25
Just FYI, I have logged a case at Baan Support regarding this issue. Will post any news...

mark_h
12th August 2005, 15:20
Not sure if you got this message yesterday since posts were lost.

Do you have source code or one of the source extension programs? With one of these you could probably come up with a temporary solution until baan solves your problem.