wmickey
28th April 2008, 21:27
I am trying to automate the matching and approving of receipts using AFS. After printing the Purchase Invoice, I am using AFS to create the data in session tfacp1110s000, which works fine. Then I want to continue and match/approve the receipt lines. When I say Yes to Link Receipts in tfacp1230s000, and the amount to be matched = receipt amount all works fine. However, when I say No to Link and go to tfacp1131s000 to find specific lines and change status to completely, it can not fine my specific record. Then once I get the records matched, I need to approve them. Attached is my code. Has anyone done something similar and can help me with this?
if curr.company = 100 then
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(fiscal.yr))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(batch))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", trans.type)
retval1 = stpapi.find("tfgld1101m000", error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfgld1101m000", recover.msg)
else
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "add")
stpapi.zoom.option("tfgld1101m000", 1, "tfacp1110s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.put.field("tfacp1110s000", "tfacp200.ninv", "0")
stpapi.put.field("tfacp1110s000", "tfacp200.suno", supplr)
stpapi.put.field("tfacp1110s000", "screen.amnt", str$(amnt))
stpapi.put.field("tfacp1110s000", "tfacp200.isup", supinv)
stpapi.put.field("tfacp1110s000", "tfacp200.refr", poref)
stpapi.put.field("tfacp1110s000", "tfacp200.orno", str$(purchord))
stpapi.put.field("tfacp1110s000", "tfacp200.loco",str$(orig.company))
stpapi.put.field("tfacp1110s000", "tfacp200.paym", "D06")
stpapi.put.field("tfacp1110s000", "tfacp200.bank", "ACH")
stpapi.put.field("tfacp1110s000", "tfacp200.reas", "MIS")
retval1 = stpapi.insert("tfacp1110s000", true, error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfacp1110s000", recover.msg)
else
|* get.receipt.amount()
|* Open Receipts match the Purch Invoice amount - match all receipts
|* Processing both as Yes- works fine. matches and approves.
if open.amount = amnt then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.yes)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.yes)))
stpapi.continue.process("tfacp1230s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.end.session("tfacp1230s000")
endif
|* This is where everything falls apart - I can not select specific records
|* and change them to completed status, then continue to approve them.
|* Open Receipts are <> the Purch Invoice amount - match individual receipts
|* Then need to aprove the records after matching
if open.amount <> amnt then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.no)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.no)))
stpapi.handle.subproc("tfacp1230s000", "tfacp1131s000", "add")
stpapi.zoom.option("tfacp1230s000", 1, "tfacp1131s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
|* This is where everything falls apart - I can not select specific records
|* and change them to completed status, then continue to approve them.
|* Find the specific Line to mark and update to completed
stpapi.put.field("tfacp1131s000", "tdpur045.suno", str$(supplr))
stpapi.put.field("tfacp1131s000", "tdpur045.orno", str$(purchord))
stpapi.put.field("tfacp1131s000", "tdpur045.pono", str$(10))
stpapi.put.field("tfacp1131s000", "tdpur045.srnb", "1")
retval1 = stpapi.change.view("tfacp1131s000", error.msg)
if not retval1 then
message("Record not found")
retval2 = stpapi.recover("tfacp1131", recover.msg)
else
retval1 = stpapi.mark("tfacp1131s000",error.msg)
if not retval1 then
message("Record not found")
endif
endif
stpapi.put.field("tfacp1131s000", "tdpur045.matc", str$(2))
retval1 = stpapi.update("tfacp1131s000", true, error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfacp1131s000", recover.msg)
endif
stpapi.end.session("tfacp1131s000")
|* Now finished matching receipts
|* Match/Apprive Purchase Invoice with Orders (Approve Button)
if amnt = tfacp200.link then
stpapi.continue.process("tfacp1230s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
else
message("Net= %d", net.amount)
endif
stpapi.end.session("tfacp1230s000")
endif |* End individual match
endif |* Can't write transaction record
stpapi.end.session("tfacp1110s000")
endif |* Can't find batch
stpapi.end.session("tfgld1101m000")
endif |* Company = 100
}
function get.receipt.amount()
{
switch.to.company(orig.company)
open.amount = 0
select *
from tdpur045
where tdpur045._index8 = {:supplr}
and tdpur045.orno = :purchord
and tdpur045.srnb > 0
and tdpur045.matc <> 2 |*Completely
selectdo
open.amount = open.amount + (tdpur045.amnt - tdpur045.iamt)
endselect
switch.to.company(100)
}
if curr.company = 100 then
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(fiscal.yr))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(batch))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", trans.type)
retval1 = stpapi.find("tfgld1101m000", error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfgld1101m000", recover.msg)
else
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "add")
stpapi.zoom.option("tfgld1101m000", 1, "tfacp1110s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.put.field("tfacp1110s000", "tfacp200.ninv", "0")
stpapi.put.field("tfacp1110s000", "tfacp200.suno", supplr)
stpapi.put.field("tfacp1110s000", "screen.amnt", str$(amnt))
stpapi.put.field("tfacp1110s000", "tfacp200.isup", supinv)
stpapi.put.field("tfacp1110s000", "tfacp200.refr", poref)
stpapi.put.field("tfacp1110s000", "tfacp200.orno", str$(purchord))
stpapi.put.field("tfacp1110s000", "tfacp200.loco",str$(orig.company))
stpapi.put.field("tfacp1110s000", "tfacp200.paym", "D06")
stpapi.put.field("tfacp1110s000", "tfacp200.bank", "ACH")
stpapi.put.field("tfacp1110s000", "tfacp200.reas", "MIS")
retval1 = stpapi.insert("tfacp1110s000", true, error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfacp1110s000", recover.msg)
else
|* get.receipt.amount()
|* Open Receipts match the Purch Invoice amount - match all receipts
|* Processing both as Yes- works fine. matches and approves.
if open.amount = amnt then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.yes)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.yes)))
stpapi.continue.process("tfacp1230s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
stpapi.end.session("tfacp1230s000")
endif
|* This is where everything falls apart - I can not select specific records
|* and change them to completed status, then continue to approve them.
|* Open Receipts are <> the Purch Invoice amount - match individual receipts
|* Then need to aprove the records after matching
if open.amount <> amnt then
stpapi.put.field("tfacp1230s000", "link", str$(etol(tcyesno.no)))
stpapi.put.field("tfacp1230s000", "approve", str$(etol(tcyesno.no)))
stpapi.handle.subproc("tfacp1230s000", "tfacp1131s000", "add")
stpapi.zoom.option("tfacp1230s000", 1, "tfacp1131s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
|* This is where everything falls apart - I can not select specific records
|* and change them to completed status, then continue to approve them.
|* Find the specific Line to mark and update to completed
stpapi.put.field("tfacp1131s000", "tdpur045.suno", str$(supplr))
stpapi.put.field("tfacp1131s000", "tdpur045.orno", str$(purchord))
stpapi.put.field("tfacp1131s000", "tdpur045.pono", str$(10))
stpapi.put.field("tfacp1131s000", "tdpur045.srnb", "1")
retval1 = stpapi.change.view("tfacp1131s000", error.msg)
if not retval1 then
message("Record not found")
retval2 = stpapi.recover("tfacp1131", recover.msg)
else
retval1 = stpapi.mark("tfacp1131s000",error.msg)
if not retval1 then
message("Record not found")
endif
endif
stpapi.put.field("tfacp1131s000", "tdpur045.matc", str$(2))
retval1 = stpapi.update("tfacp1131s000", true, error.msg)
if not retval1 then
message("Error %s", error.msg)
retval2 = stpapi.recover("tfacp1131s000", recover.msg)
endif
stpapi.end.session("tfacp1131s000")
|* Now finished matching receipts
|* Match/Apprive Purchase Invoice with Orders (Approve Button)
if amnt = tfacp200.link then
stpapi.continue.process("tfacp1230s000", error.msg)
if error.msg > "" then
message("Error %s", error.msg)
endif
else
message("Net= %d", net.amount)
endif
stpapi.end.session("tfacp1230s000")
endif |* End individual match
endif |* Can't write transaction record
stpapi.end.session("tfacp1110s000")
endif |* Can't find batch
stpapi.end.session("tfgld1101m000")
endif |* Company = 100
}
function get.receipt.amount()
{
switch.to.company(orig.company)
open.amount = 0
select *
from tdpur045
where tdpur045._index8 = {:supplr}
and tdpur045.orno = :purchord
and tdpur045.srnb > 0
and tdpur045.matc <> 2 |*Completely
selectdo
open.amount = open.amount + (tdpur045.amnt - tdpur045.iamt)
endselect
switch.to.company(100)
}