rohan_rege
21st October 2002, 21:29
Following i have posted the code i am using to try to match the invoices in session tfacp1131s000 ...

but the problem is , apart from the first Receipt ....all other receipts dont get updated .

infact i checked the return value of the stpapi.update but it shows a sucessful update value of 1 .

i am using stpapi.browse.set to get to the PO# , Position No.# and Sequence # that i want to update ,then i mark it and then go ahead and put the fields for Qty , amount and type of Matching , but ...apart from the first Receipt , it doesnt at all match the remaining receipts.

i found that stpapi.browse.set gets me to the correct record...
also after i mark , it and put field value and update ..it does so sucessfully..

but after update and save , when i issue get.field stmts and use a message () statement it shows me the Match = NO ,QTY = 0 and Amount = the amount i put for the first record..
when it shud show Match = Competely ,...and so on.


I tried stpapi.find earlier , but since the find available in this session is only on tdpur045.orno , pono ...while the key field for any record is tdpur045.orno , pono , srnb...so it always find the wrong record...so i had to resort to stpapi.browse.set to get to the correct record.....

but though it seems to be getting the correct record...it just wudnt update the record correctly

any suggestions

string ornot(8)
string ponot(4)
string srnbt(2)
ornot=""
ponot=""
srnbt=""


while ret <> 1 and count.find < 11
ret = stpapi.browse.set("tfacp1131s000" , "first.set" , error.mess)
count.find = count.find + 1
endwhile

while not(found)
stpapi.get.field("tfacp1131s000","tdpur045.orno",ornot )
stpapi.get.field("tfacp1131s000","tdpur045.pono",ponot )
stpapi.get.field("tfacp1131s000","tdpur045.srnb",srnbt )
if (ornot = read.orno) and (ponot = read.pono) and (srnbt = read.srnb) then
found = 1
ret = stpapi.mark("tfacp1131s000" , error.mess)
else
ret = stpapi.browse.set("tfacp1131s000" , "next.set" , error.mess)

endif
endwhile



domain tdpur.matc matc_to_check_partial

matc_to_check_partial=f1131s000.get.Matched( )


|If the Partial matching has already been done and current then go for Multiple Invoices session processing

if (matc_to_check_partial=tdpur.matc.partial) then
ret = ap1_multiple_invoices(read.qty , read.inv.amt,msg)
ret = stpapi.save( "tfacp1131s000", error.mess )
return(ret)
else
if matc_to_check_partial=tdpur.matc.no then
|FOLLOWING is to put values into tfacp1131s000 for complete or partial match

| to find the PO line using PO# , PO line and PO Sequence No.

count.find = 1
ret = 0
found = 0

ornot=""
ponot=""
srnbt=""

while ret <> 1 and count.find < 11
ret = stpapi.browse.set("tfacp1131s000" , "first.set" , error.mess)
count.find = count.find + 1
endwhile

while not(found)
stpapi.get.field("tfacp1131s000","tdpur045.orno",ornot )
stpapi.get.field("tfacp1131s000","tdpur045.pono",ponot )
stpapi.get.field("tfacp1131s000","tdpur045.srnb",srnbt )
if (ornot = read.orno) and (ponot = read.pono) and (srnbt = read.srnb) then
found = 1
ret = stpapi.mark("tfacp1131s000" , error.mess)

else
ret = stpapi.browse.set("tfacp1131s000" , "next.set" , error.mess)
endif

endwhile



| if the record is found then mark it to update its Match field to either Partial or Complete
|also if its a partial field then Invoice QTy and Invoice amount for that particular line have to be entered

if found = 1 then
long match_code
read.match = shiftl$(shiftr$(read.match))
ON CASE read.match
CASE "no": match_code=1
BREAK
CASE "complete":match_code=2
BREAK
CASE "partial": match_code=3
BREAK
ENDCASE

domain tdpur.matc match
match = ltoe(match_code)

stpapi.put.field( "tfacp1131s000", "tdpur045.matc", str$(match))

stpapi.put.field( "tfacp1131s000", "tdpur045.iqan", read.qty )
stpapi.put.field( "tfacp1131s000", "inv.amt.inv.curr", read.inv.amt )

|Update and save the record in tfacp1131s000
ret = stpapi.update("tfacp1131s000",1 , error.mess)
ret = stpapi.save( "tfacp1131s000", error.mess )


|to check values of the fields tdpur045.iqan and inv.amt.inv.curr
domain tcqrd1 qty
qty=f1131s000.get.Invoiced_Quantity( )
message(str$(qty))

domain tfgld.amnt amt
amt= f1131s000.get.Invoiced_Amount( )
message(str$(amt))

domain tcorno orno
orno=f1131s000.get.Purchase_Order( )
message(str$(orno))

string match_str(8)
match=f1131s000.get.Matched( )
match_str=enum.descr$("tdpur.matc" , match)
message(match_str)

mark_h
21st October 2002, 22:32
I do not think in this case you need to use stpapi.mark. The reason is that with stpapi.browse it should move to the next record and make it current for updating. Maybe just marking the record causes a problem - I am just not sure.

The only other thing I can think of right now is to try this:

get fields and check them
do update
get fields and check them
do save
get fields and check them

This should isolate where exactly the fields are getting changed. You may also want to get the pono and srnb - just to confirm you really have the record you think you have.

Mark

rohan_rege
22nd October 2002, 01:46
actually i found that when i manually use the sessions....i dont have to save the session after update ...only exiting the session saves it automatically....

so i removed update and save commands and just put the fields and then exited the session like we can do manually...but its not working that way...

i tried all comb. of update and save commands

but either wudnt work...

looks like using update or save resets the fields i have put ...
using put.field

any suggestions how to get around the problem

i also saw that manually if i use EXIT w/o save , it asked me for whether i shud save or no...ttstpq0104...i tried using the
stpapi.enum.answer ..that too didnt work

rgds
Rohan

mark_h
22nd October 2002, 16:01
Have you tried update with mode 0, then followed with a save.

Mark

rohan_rege
22nd October 2002, 19:57
i tried using update with 0 followed by save...

but when i do this only the first record gets Update properly wrt the fields Match ="Completely", QTY=1 , Amount =273.78....

other records that follow it have the Match field still as "NO"
Qty = 0 instead of a non zero no. and amount same as 273.78 from the first record ,instead of the actual amount .

also i noticed that , when i manually do the same stuff using session directly , i dont have to press the save button ,,,,it just directly saves even if we exit directly..

so i tried doing that thru AFS w/o using update ,save ...but then even the first record doesnt get saved ...rest records is a far off thing. i just put the fields and used an end session expecting like the manual process it wud save it ....

but it doesnt ...

looks like only the first record gets update when i use the update.
it never goes to the next record for some reason

any other suggestions ?

rgds
Rohan

mark_h
22nd October 2002, 20:48
From just a quick glance at the source maybe one of the choice.user options would do what you need. I am just not sure since I have never used the session. I am also fresh out of ideas to try.


Mark

rohan_rege
22nd October 2002, 20:58
hi ,

there is no choice.user that exist for the thing i want to do...

there is a choice.user for completely matching all the records...but i want to match only some of the records not all

what i see is that the first record gets update properly ,,,,but the next records dont


rgds

mark_h
22nd October 2002, 21:38
Sorry, but I can not think of any other suggestions. Anybody else - Gordon, Lisa, anyone?

Maybe if you contact Baan and describe the situation they will have a solution. Is there any other way to get to the data to do the matching?

Mark

rohan_rege
23rd October 2002, 00:55
i found in the tfacp1131s000 session as compared to the session tdpur4533m000 ,though both are based on tdpur045 ....when we press the find button on tfacp1131s000 we can do a search only on tdpur045.orno , pono .

as against this in a find on tdpur045.orno , pono and srnb......
is invoked in tdpur4533m000 when the find button is pressed

is this problem why i a find on these three fields in tfacp1131s000 doesnt take me to the correct record.

i tried changing the find in tfacp1131s000 so that it allows me to find on tdpur045.srnb also in addition to tdpur045.orno and tdpur045.pono....but i wasnt successful...

can somebody help me out as to how do i customise thesession tfacp1131s000 so that the find also includes tdpur045.srnb inaddition to orno and pono

i think if the find is fixed in the session ...i can continue wiith the AFS ...since then stpapi.find will get me the correct record


rgds
Rohan

gfasbender
23rd October 2002, 02:41
I don't even know what Rohan's problem is anymore from reading this thread.

Sounds like he is having a problem using stpapi.browse.set(), with the first.set and next.set options. I have no idea what his current code is either.

Here's an example of some code that successfully uses stpapi.browse.set() with first.set and next.set and does an stpapi.update() and stpapi.save():


| put all main table browse header keys (fld1 & fld2 in this case)
stpapi.put.field(session, "table001.fld1", fld1)
stpapi.put.field(session, "table001.fld2", fld2)
| loop through records and set enum field
| det.fld() array and det.cnt relate to the additional key fields not in the header,
| but in the current browse.set
for i = 1 to det.cnt
update.flag = false
rc = stpapi.browse.set(session, "first.set", e.msg)
if not isspace(e.msg) then
e.msg = session & ":browse.set(first.set):" & strip$(e.msg)
stpapi.end.session(session)
return(true)
endif
while update.flag = false
stpapi.get.field(session, "table001.fld1", t.fld1)
stpapi.get.field(session, "table001.fld2", t.fld2)
stpapi.get.field(session, "table001.fld3", t.fld3)
| Make sure you're on the correct record (fld3 in this case)
if strip$(det.fld3(1, det.cnt)) = strip$(t.fld3) then
rc = stpapi.find(session)
stpapi.put.field(session, "table001.mark", "1") | Yes
rc = stpapi.update(session, 1, e.msg)
if not isspace(e.msg) then
e.msg = session & ":update:" & strip$(e.msg)
stpapi.end.session(session)
return(true)
endif
update.flag = true
else
rc = stpapi.browse.set(session, "next.set", e.msg)
if not isspace(e.msg) then
e.msg = session & ":browse.set(next.set):" & strip$(e.msg)
stpapi.end.session(session)
return(true)
endif
endif
endwhile
endfor
rc = stpapi.save(session, e.msg)


Maybe Rohan can review this code, associate it with his process, and figure out the problem.

If not, he should let us know exactly what the problem is and post his current code set.

rohan_rege
23rd October 2002, 17:57
hi gordon ,

on the very first post , on this thread , i have posted the code i have been using.

now i will explain what i am trying to do.

there is this session tfacp1131s000 , Match Receipts that is part of the process for Matching Invoices.

When i get to this session in my AFS program...

I am trying to find the Receipt against which i have to match a Invoice.

If u have a look at the Match receipts session tfacp1131s000
Now the tfacp1131s000 is based on tdpur045 table.
which has 3 fields as part of its key :
tdpur045.orno , tdpu045.pono and tdpur045.srnb.

Accordingly to do a Matching i have to find the correct Receipt in tfacp1131s000 and then update the tdpur045.matc Match field on it to either Complete or Partial .
also when Match field = partial , i have to update the invoice qty and amount fields on the session.

Note : only the above 3 feilds are input fields on this session


Now to find a Receipt , i tried using a stpapi.find() after putting the fields for tdpur045.orno , tdpur045.pono and tdpur045.srnb .

but the problem is that it is never able to find the correct record...
since it looks like even when u manually try to do a find in the tfacp1131s000 session the only find options u have , r on Purchase Order no. tdpur045.orno and Position no. tdpur045.pono

So the last key field of tdpur045 , i.e tdpur045.srnb is never considered for the stpapi.find()

for eg , if there are two receipts
the first haveing foll key
tdpur045.orno = 1
tdpur045.pono = 1 tdpur045.srnb = 1

and the second havng
tdpur045.orno = 1
tdpur045.pono = 1 tdpur045.srnb = 2

then the stpapi.find takes me always to the first receipt , even when i have mentioned all 3 fields in the stpapi.put. before issuing the stpapi.find command


this i am just guessing might be the problem , bcoz even when we manually try to find in the session ,it allows us to find on only
PO # and Postion No. and not on Sequence no.


NOW , bcoz the stpapi.find was not working...

I tried using the stpapi.browse ...the code for which i posted in the very same thread right at the start.

the problem with this alternative to server my purpose is the foll:

here i get to the correct record...but when i update the fields and then save the record....it just doesnt upadte it correctly

to verify i used get fields ......but then if found it updates only the first receipt correctly....the others receipts are updated as follows :


The Match field = No when it shud be "Complete" as set by my program
Invoice qty = 0
Invoice amount = 273 which is set wrongly to the same value as for the first Receipt.......while it shud contain a new value

I hope things r a more clearer.....if u need any more clarifications pls reply back.


whatever code i had written has been already posted on posting 1 on this thread .

rgds
Rohan

rohan_rege
23rd October 2002, 18:20
I was going thru the code u posted to see if it is what i need !

i needed some help from u in understanding the following statemnet in the code u posted

if strip$(det.fld3(1, det.cnt)) = strip$(t.fld3) then

i didnt understand what is this det.fld3() array and det.cnt used for .

pls elaborate on it .......

rgds
Rohan

mark_h
23rd October 2002, 18:32
Rohan,

Sorry but I just caught these posts. If you can compile the session then that opens up a whole new arena. Here is how I tricked one function server. The Baan session had a when.field.changes section that set a table field. I think tiitm001.cuni. Anyway when I put the form field this section did not get executed and when I did the update the unit of measure was incorrect. So what I did was include table tiitm001, set the tiitm001.cuni variable, and then do the update on the session. Now the update ran correctly.

What you can do is put the session in debug mode. Run through it manually, keeping track of what routines it runs, and what things are set to. Then run through the function server, again keep track of what things are set to. You may be able to compare the output from the runs and find a table field that you need to set to get the update to work correctly. It may also show you were you need to fix the session code if you go that route.

Mark

gfasbender
23rd October 2002, 19:20
Rohan,

I don't have access to tfacp1131s000 right now. I have a good idea of what it looks like, so I'll continue. Maybe you can provide a screen print of it.

tfacp1131s000 is probably has a type-3 form, with header key fields tdpur045.orno and pono. These relate to my example fields table001.fld1 and fld2.

Each detail line in the session, probably contains your tdpur045.srnb field or is related to it. This relates to my table001.fld3 example field.

What you are trying to do is step through the multiple detail records, (sub-indexed) by the srnb field within the orno and pono header browse-set, and selectively updating the detail records. Once you have selectively updated all the records, you want to run a process on all of them.

The det.fld3() array holds the key to the records in the browse-set, that you want to modify, and det.cnt just lets you know how many of them there are. In my case, det.fld3 is an array of strings, yours would be an array of whatever the domain is for srnb.

So, in my routine, you want to start the session, then loop through the detail records, det.cnt times. In each pass, start at the first record in the browse-set by putting orno and pono then calling browse.set with first.set option. Then get the key fields, orno, pono, and srnb and check to see if it's (srnb) is the one you have in your array for that pass. If so, update the field on the record. If not, move to the next record in the set using browse.set with the next.set option and test again.

After your det.cnt loop, do a stpapi.save or stpapi.continue to process all the records of the session.

rohan_rege
28th October 2002, 23:32
hi

i am facing a very peculiar problem in session tfacp1131s000

suppose there are two receipts in the session that are available to match.

and suppose thru my afs i match only the first receipt...

then i run the prog again and this time try to match the second receipt , but the stpapi.browse.set("tfacp1131s000" , first.set ,error.mess) returns a 0 with a error.mess = Update Cancelled.

This doesnot happen if i do it manually thru sessions...
i.e when i try the same thing manually i can first match one of the two receipts ..then close the sessions ...and then go back again to match the second receipt....

but thru afs , i see that ,if there are n receipts to be matched and i match even 1 of them in my first run .


then when i run my prog again to match the remaining receipts , the first stpapi.browse.set returns a error "Update Cancelled"


pls give me some suggestion if u have encountered such a prob

rgds
Rohan