Kingsto88
5th January 2005, 11:09
Hi experts,

I am on baan4c4 and the code is as below

stpapi.put.field("tdpur4120m000", "form.dino", "SUP345")
stpapi.handle.subproc("tdpur4120m000", "tdpur4224s000", "add")
stpapi.put.field("tdpur4224s000", "form.orno", "220033")
stpapi.continue.process("tdpur4224s000",error.msg)
message("child error = %s",error.msg)
stpapi.end.session("tdpur4224s000")

stpapi.change.view("tdpur4120m000")

stpapi.put.field("tdpur4120m000","tdpur045.orno","220033")
stpapi.put.field("tdpur4120m000","tdpur045.pono","10")
stpapi.put.field("tdpur4120m000","tdpur045.diqu","2")
stpapi.put.field("tdpur4120m000","tdpur045.date","20032004")
stpapi.put.field("tdpur4120m000","tdpur045.dqua","2")
stpapi.insert("tdpur4120m000",1,err)

But I am getting this errors.

1) session not available
2) maximum two digits allowed for series


Could anyone tell me what went wrong?


rgds

mark_h
5th January 2005, 16:05
Below is what works for me. I have two subroutines - 1 creates the receipt and 1 modifies the receipt. This way if I have a open receipt for a PO/LINE I can just go modify and receive the line. You can see the flow and modify it as you see fit - you may not have to do conversion quantities or lot controlled items. Just remember that what works on my system may not work on yours - patch levels, porting set, object versions, etc.

Good Luck!

Mark


|******************************************************************************
|* API Code for creating a new receipt
|******************************************************************************
function extern domain tcrcno create_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
string dummy(6)

| Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

| Always use tdpur4224s000 to create receipt for all lines.
stpapi.put.field("tdpur4224s000","form.orno",str$(purchase.order))
stpapi.continue.process("tdpur4224s000",msg)
stpapi.end.session("tdpur4224s000")
|Currently tdpur4224s000 continue returns Process is gone
if not isspace(msg) and strip$(msg)<> "Process is gone" then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif
msg = ""

| Try a pause to make sure receipt is completed.
suspend(3000)

| Get the receipt so you can use the modify receipt to update the fields.
stpapi.get.field("tdpur4120m000","tdpur045.reno",dummy)
receipt.number = val(dummy)
stpapi.end.session("tdpur4120m000")

| Verify this receipt number has this PO and line on it.
select tdpur045.reno
from tdpur045
where tdpur045._index6 = {:receipt.number,:purchase.order,:purchase.line}
as set with 1 rows
selectdo
selectempty
receipt.number = 0
endselect
if receipt.number = 0 then
msg = "Receipt failed."
return(0)
endif

| Now go modify the new receipt.
modify_receipt( receipt.number,
purchase.order,
purchase.line,
packingslip.qty,
received.qty,
received.date,
purchase.lot,
purchaselot.date,
conv.factor,
purchase.unit,
purchase.item,
msg)
return(receipt.number)
}
|******************************************************************************
|* API Code for modifying an existing receipt.
|******************************************************************************
function extern modify_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
long rc, cnt
string dummy(6), error_code(16)
domain tcorno get.orno
domain tcpono get.pono

select tiitm001.stgu, tiitm001.kitm
from tiitm001
where tiitm001._index1 = {:purchase.item}
as set with 1 rows
selectdo
endselect

msg = ""
boi.call = "tdboidll0011.Create"
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(purchase.order))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(purchase.line))
rc = stpapi.find("tdpur4120m000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdpur4120m000")
return
endif
stpapi.get.field("tdpur4120m000","tdpur045.orno",dummy)
| Prepare to handle lot controlled items.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
endif

stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
stpapi.update("tdpur4120m000",1,msg)
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
return
endif

| Need to handle the conversion factor.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.put.field("tdilc4113s000", "tdilc402.clot",purchase.lot)
stpapi.put.field("tdilc4113s000", "tdilc402.date",str$(purchaselot.date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(received.qty*conv.factor))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(received.qty*conv.factor))
stpapi.insert("tdilc4113s000",1,msg)
error_code = stpapi.get.mess.code("tdilc4113s000",msg)
if strip$(error_code) = "tdilc40062" then
msg = ""
endif
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
}

Kingsto88
6th January 2005, 03:43
Hi Mark,

Thank you very much for your answer to my question.

I don't understand why we need to modify the receipt. Can't we just combine both the create and modify together? I mean during the create receipt, we can also pass in the other fields, right?

Do I do the same if I want to generate outbound advice, ie. do i create the outbound record first and then modify it. Do you have the sample for generating outbound and release outbound.

Thanks and regards,

mark_h
6th January 2005, 04:25
I do it this way because in my program I may get a PO that has 40 lines. When they receive line 1 I create a receipt for all lines. Then when line two comes in I just jump in and complete the line - no new receipt. So, yes you could combine my two sub-routines if you wanted - but I kept it separate because not all receipts go thru my interface. I never know what the user has done before so I need to create and I need to do a modify.

Yeah - I have a version and I will post it tomorrow. Yes I have different routines to do generate, maintain, release. I do this because I load the outbound into a temp table that allows the users to maintain it, my version is friendly than the Baan maintain outbound. I will post that code tomorrow.

Mark

mark_h
6th January 2005, 16:55
Below are my routines for outbound. Just keep in mind that these are written for our current system. Most are generic, but some outbound sessions have company developed modifications. Example is gendate field - we track when outbound was created. So again this is just an example that you can try on your system.

Something that may work for you is the stpapi.clear - I have started putting all fields so that way user defaults do not get in the way. Some of our outbound forms have been changed to be empty anyway - keep the user from generating, printing, or releasing everything.

Mark

|******************************************************************************
|* 20041119 Mark 11/19/2004
|* Add generate date to print_outbound routine. Was only printing current
|* days outbound. Also traced duplicate tdilc970 records to this subroutine
|* need to pass an apishort variable to tdilc4201 to skip updating the
|* tdilc970 table.
|******************************************************************************
|* 20041011 Mark 10/11/2004
|* Add routine for generating outbound data.
|******************************************************************************
|* 092404 Mark 09/24/04
|* Include lot date and lot to the insert outbound routine.
|******************************************************************************
|******************************************************************************
|* Script Type: Library
|******************************************************************************
table ttiitm001 | Items
table ttdpur045 | Receipts

#pragma used dll ottstpapihand | Baan API Handler
extern domain tcmcs.str132 boi.call
extern long rc
extern string some.msg(180)
extern domain tcmcs.str15 apishort
|******************************************************************************
|* API Code for Maintaining Outbound.
|******************************************************************************
function extern insert_outbound( domain tcmcs.str12 runnumber,
domain tdilc.kooa order.type,
domain tcorno order.number,
domain tcpono order.position,
domain tdilc.loca order.location,
domain tccuni order.stun,
domain tcqiv1 order.qty,
domain tdltc.clot order.lot,
domain tcdate order.date,
ref string strsera(),
ref string strserb(),
ref string msg())
{
msg = ""
stpapi.handle.subproc("tdilc4101m000","tdilc4102s000","add")
stpapi.put.field("tdilc4101m000","runnumber",runnumber)
stpapi.put.field("tdilc4101m000","k.o.order",str$(order.type))
stpapi.put.field("tdilc4101m000","ordernr",str$(order.number))
stpapi.continue.process("tdilc4101m000",msg)
if not isspace(msg) then
stpapi.end.session("tdilc4101m000")
return
endif
stpapi.enum.answer("tdilc4102s000","tdilc4102.1",tcyesno.no)
stpapi.put.field("tdilc4102s000","tdilc401.pono",str$(order.position))
stpapi.put.field("tdilc4102s000","tdilc401.loca",order.location)
| 092404.st - Add lot and date to insert outbound.
stpapi.put.field("tdilc4102s000","tdilc401.clot",order.lot)
stpapi.put.field("tdilc4102s000","tdilc401.date",str$(order.date))
| 092404.end
stpapi.put.field("tdilc4102s000","tdilc401.stun",order.stun)
stpapi.put.field("tdilc4102s000","tdilc401.qstr",str$(order.qty))
rc = stpapi.insert("tdilc4102s000",1,msg)
if isspace(msg) then
stpapi.get.field( "tdilc4102s000", "tdilc401.sera", strsera )
stpapi.get.field( "tdilc4102s000", "tdilc401.serb", strserb )
endif
stpapi.end.session("tdilc4513s000")
stpapi.end.session("tdilc4102s000")
stpapi.end.session("tdilc4101m000")
}
|******************************************************************************
|* API Code for Printing outbound for a production order. spool.report must
|* be set in order to use this library routine.
|******************************************************************************
function extern print_outbound( domain tcmcs.str12 runnumber,
domain tcorno run.order.f,
domain tcorno run.order.t,
domain tcpono run.opno.f,
domain tcpono run.opno.t,
domain tcitem run.item.f,
domain tcitem run.item.t,
domain tccwar run.cwar.f,
domain tccwar run.cwar.t,
domain tcdate run.gendate.f,
domain tcdate run.gendate.t,
domain tcmcs.str15 run.report,
ref string msg())
{
msg = ""
stpapi.put.field("tdilc4401m000","runnumber.f",runnumber)
stpapi.put.field("tdilc4401m000","runnumber.t",runnumber)
stpapi.put.field("tdilc4401m000","koor.f",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4401m000","koor.t",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4401m000","orno.f",str$(run.order.f))
stpapi.put.field("tdilc4401m000","orno.t",str$(run.order.t))
stpapi.put.field("tdilc4401m000","opno.f",str$(run.opno.f))
stpapi.put.field("tdilc4401m000","opno.t",str$(run.opno.t))
stpapi.put.field("tdilc4401m000","prdt.t",str$(date.num()+1000))
stpapi.put.field("tdilc4401m000","ddta.f",str$(date.num()-1000))
stpapi.put.field("tdilc4401m000","ddta.t",str$(date.num()+1000))
stpapi.put.field("tdilc4401m000","item.f",run.item.f)
stpapi.put.field("tdilc4401m000","item.t",run.item.t)
stpapi.put.field("tdilc4401m000","cwar.f",run.cwar.f)
stpapi.put.field("tdilc4401m000","cwar.t",run.cwar.t)
| 20041119 - Start passing generate date
|stpapi.put.field("tdilc4401m000","gendate.f",str$(date.num()))
|stpapi.put.field("tdilc4401m000","gendate.t",str$(date.num()))
stpapi.put.field("tdilc4401m000","gendate.f",str$(run.gendate.f))
stpapi.put.field("tdilc4401m000","gendate.t",str$(run.gendate.t))
| 20041119
stpapi.put.field("tdilc4401m000","gcid.f","")
stpapi.put.field("tdilc4401m000","gcid.t","ZZZZZZZZZZZZZZZZZZZZZZ")
stpapi.put.field("tdilc4401m000","ship.f","")
stpapi.put.field("tdilc4401m000","ship.t","ZZZZZZZZ")
stpapi.put.field("tdilc4401m000","cuno.f","")
stpapi.put.field("tdilc4401m000","cuno.t","ZZZZZZ")
stpapi.put.field("tdilc4401m000","cprj.f","")
stpapi.put.field("tdilc4401m000","cprj.t","ZZZZZZ")
stpapi.put.field("tdilc4401m000","cntr.f","")
stpapi.put.field("tdilc4401m000","cntr.t","ZZZ")
stpapi.put.field("tdilc4401m000","crte.f","")
stpapi.put.field("tdilc4401m000","crte.t","ZZZZZ")
|stpapi.set.report("tdilc4401m000","rtdilc440109000",spool.device,msg)
stpapi.set.report("tdilc4401m000",run.report,spool.device,msg)

if isspace(msg) then
stpapi.continue.process("tdilc4401m000",msg)
some.msg = stpapi.get.mess.code("tdilc4401m000",msg)
endif
stpapi.end.session("tdilc4401m000")
}
|******************************************************************************
|* API Code for releasing outbound for a production order
|******************************************************************************
function extern release_outbound( domain tcmcs.str12 runnumber.f,
domain tcmcs.str12 runnumber.t,
domain tcorno run.order.f,
domain tcorno run.order.t,
domain tcpono run.oper.f,
domain tcpono run.oper.t,
domain tcitem run.item.f,
domain tcitem run.item.t,
domain tccwar run.cwar.f,
domain tccwar run.cwar.t,
domain tcmcs.str14 run.sess,
ref string msg())
{
msg = ""
stpapi.put.field("tdilc4202m000","runnumber.f",runnumber.f)
stpapi.put.field("tdilc4202m000","runnumber.t",runnumber.t)
stpapi.put.field("tdilc4202m000","koor.f",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4202m000","koor.t",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4202m000","orno.f",str$(run.order.f))
stpapi.put.field("tdilc4202m000","orno.t",str$(run.order.t))
stpapi.put.field("tdilc4202m000","opno.f",str$(run.oper.f))
stpapi.put.field("tdilc4202m000","opno.t",str$(run.oper.t))
stpapi.put.field("tdilc4202m000","prdt.t",str$(date.num()+1000))
stpapi.put.field("tdilc4202m000","ddta.f",str$(date.num()-1000))
stpapi.put.field("tdilc4202m000","ddta.t",str$(date.num()+1000))
stpapi.put.field("tdilc4202m000","item.f",run.item.f)
stpapi.put.field("tdilc4202m000","item.t",run.item.t)
stpapi.put.field("tdilc4202m000","cwar.f",run.cwar.f)
stpapi.put.field("tdilc4202m000","cwar.t",run.cwar.t)
stpapi.put.field("tdilc4202m000","gcid.f","")
stpapi.put.field("tdilc4202m000","gcid.t","ZZZZZZZZZZZZZZZZZZZZZZ")
stpapi.put.field("tdilc4202m000","pino.f","0")
stpapi.put.field("tdilc4202m000","pino.t","999999")
stpapi.put.field("tdilc4202m000","cuno.f","")
stpapi.put.field("tdilc4202m000","cuno.t","ZZZZZZ")
stpapi.put.field("tdilc4202m000","cprj.f","")
stpapi.put.field("tdilc4202m000","cprj.t","ZZZZZZ")
stpapi.put.field("tdilc4202m000","cntr.f","")
stpapi.put.field("tdilc4202m000","cntr.t","ZZZ")
stpapi.put.field("tdilc4202m000","crte.f","")
stpapi.put.field("tdilc4202m000","crte.t","ZZZZZ")
stpapi.put.field("tdilc4202m000","deliver.costitem",str$(etol(tcyesno.no)))
if strip$(run.sess) = "tdapi4201m000" then
spool.fileout = creat.tmp.file$(bse.tmp.dir$())
stpapi.set.report("tdilc4202m000","rtdilc440201000","ASCIF",msg)
else
stpapi.set.report("tdilc4202m000","rtdilc440201000",spool.device,msg)
endif
if isspace(msg) then
stpapi.continue.process("tdilc4202m000",msg)
some.msg = stpapi.get.mess.code("tdilc4202m000",msg)
endif
stpapi.end.session("tdilc4202m000")
}
|******************************************************************************
|* API Code for Deleting outbound for a production order.
|******************************************************************************
function extern delete_outbound( domain tcmcs.str12 runnumber,
domain tcorno run.order,
domain tcpono run.pono.f,
domain tcpono run.pono.t,
ref string msg())
{
msg = ""
stpapi.put.field("tdilc4211m000","runnumber.f",runnumber)
stpapi.put.field("tdilc4211m000","runnumber.t",runnumber)
stpapi.put.field("tdilc4211m000","koor.f",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4211m000","koor.t",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4211m000","gcid.f","")
stpapi.put.field("tdilc4211m000","gcid.t","ZZZZZZZZZZZZZZZZZZZZZZ")
stpapi.put.field("tdilc4211m000","ship.f","")
stpapi.put.field("tdilc4211m000","ship.t","ZZZZZZZZ")
stpapi.put.field("tdilc4211m000","orno.f",str$(run.order))
stpapi.put.field("tdilc4211m000","orno.t",str$(run.order))
stpapi.put.field("tdilc4211m000","pono.f",str$(run.pono.f))
stpapi.put.field("tdilc4211m000","pono.t",str$(run.pono.t))
stpapi.continue.process("tdilc4211m000",msg)
stpapi.end.session("tdilc4211m000")
}
|******************************************************************************
|* API Code for Generating outbound data for a production runnumber, order,
|* operation, item or warehouse.
|******************************************************************************
function extern generate_outbound( domain tcmcs.str12 runnumber,
domain tcorno run.order.f,
domain tcorno run.order.t,
domain tcpono run.opno.f,
domain tcpono run.opno.t,
domain tcitem run.item.f,
domain tcitem run.item.t,
domain tccwar run.cwar.f,
domain tccwar run.cwar.t,
domain tgyenox run.advice,
ref string msg())
{
apishort= ""
export("apishort",apishort)
msg = ""
stpapi.put.field("tdilc4201m000","runnumber",runnumber)
stpapi.put.field("tdilc4201m000","koor.f",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4201m000","koor.t",str$(tdilc.koob.act.sfc))
stpapi.put.field("tdilc4201m000","cuno.f","")
stpapi.put.field("tdilc4201m000","cuno.t","ZZZZZZ")
stpapi.put.field("tdilc4201m000","orno.f",str$(run.order.f))
stpapi.put.field("tdilc4201m000","orno.t",str$(run.order.t))
stpapi.put.field("tdilc4201m000","opno.f",str$(run.opno.f))
stpapi.put.field("tdilc4201m000","opno.t",str$(run.opno.t))
stpapi.put.field("tdilc4201m000","prdt.t",str$(date.num()+1000))
|stpapi.put.field("tdilc4201m000","ddat.f",str$(date.num()-1000))
stpapi.put.field("tdilc4201m000","ddat.t",str$(date.num()+1000))
stpapi.put.field("tdilc4201m000","cprj.f","")
stpapi.put.field("tdilc4201m000","cprj.t","ZZZZZZ")
stpapi.put.field("tdilc4201m000","item.f",run.item.f)
stpapi.put.field("tdilc4201m000","item.t",run.item.t)
stpapi.put.field("tdilc4201m000","cwar.f",run.cwar.f)
stpapi.put.field("tdilc4201m000","cwar.t",run.cwar.t)
stpapi.put.field("tdilc4201m000","cntr.f","")
stpapi.put.field("tdilc4201m000","cntr.t","ZZZ")
stpapi.put.field("tdilc4201m000","crte.f","")
stpapi.put.field("tdilc4201m000","crte.t","ZZZZZ")

| The next 4 lines generate both the advice and shortages, if you want
| just one report then set the flags correctly, but always point the report
| to the advice report - This is the only way to get it to work.
| Advice Report
if run.advice = tgyenox.yes then
stpapi.put.field( "tdilc4201m000", "print.recom", str$(tcyesno.yes) )
else
stpapi.put.field( "tdilc4201m000", "print.recom", str$(tcyesno.no) )
endif
stpapi.put.field( "tdilc4201m000", "prnt.shortage", str$(tcyesno.no) )
stpapi.put.field( "tdilc4201m000", "pr.peg.shortage", str$(tcyesno.no) )
stpapi.set.report( "tdilc4201m000","rtdilc420101000",spool.device, msg )

stpapi.continue.process("tdilc4201m000",msg)
stpapi.end.session("tdilc4201m000")
}

Kingsto88
10th January 2005, 05:53
Dear Mark,

Thank you for the sample. I will try it on my server and see.

Thanks and regards,

Kingsto88
11th January 2005, 06:21
Dear mark,

I have these errors when i compiled.

(196) error: 'boi.call' not declared
(197) error: dimension in array assignment differs 0:1

The script on these two lines are :
196 boi.call = "tdboidll0011.Create"
197 stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))

Please tell me what is wrong.

Thanks and regards

Kingsto88
11th January 2005, 11:16
Hi Mark,

My intention is to use the barcode scanner in our warehouse.

To use it during the receipt and issuing of goods. My thots are :

1) Print barcode for any goods that is received eg. receive a box of 12 pcs
2) Paste the barcode on the goods ie. on the 12pcs box
3) During issue of stock, print another barcode
and then paste on the goods (different quantity - issue only 2 pcs)
One barcode to issue the 2 pcs
4) Scan this barcode to update Release outbound and maintain
delivery


To implement the barcode scanner, I need to
1) Buy the scanner - should i get the wireless one?
2) Read the scanned data to Baan. How do I do this?
3) Write a program using stpapi to run the maintain receipt session
and update the appropriate tables. The scanner must be able
to run this stpapi program after each scan. How do I do this?

Thanks and regards,

mark_h
11th January 2005, 15:42
I have boi.call declared like this:

extern domain tcmcs.str132 boi.call


We do it just like you mention - Print Receipt barcode tag at time of receipt, tag is scanned for storing the item. Then when outbound is generated we generate another tag(Pick Tag) and is used for the release.

As for implementing barcode:
(1) Depends on what you are doing. Our receiving department has a couple of desks with PC's so we used fixed scanners on them. Eventually we will get to wireless but not at this point. Our users just need to get the feel of doing it the new way.
(2) With our scanners they are just like using the keyboard - they connect in the same port. So normal Baan sessions work. The only problem I have not completely overcome yet is doing a barcode for the enter key. This way the user does not even need the keyboard.
(3) I use normal 4GL Baan programs to do what I am talking about. If you are talking about a programmable Barcode machine that is different. I have not done that - maybe in the future. On our system the user logs in using a PC/Laptop, runs a session, picks a option(like tdapi4120m000-receipt). Then they scan purchase order, purchase item, date received, qty received - then they hit the enter key. It processes the receipt and waits for them to scan next Purchase Order.

Mark

Kingsto88
14th January 2005, 03:27
Dear Mark,

Thanks, I got it compiled already.

But sorry for my ignorance. Need to ask another question.

In your explanation, you say we scan in the PO information and quantity to be received.

Before that we must print a receipt Tag with all these information to be scanned in.

So what I don't understand is what is the purpose of the barcode if we still have to enter these information in another screen, print the receipt tag then scan in the information again. It will be the same if we just enter the information in the normal maintain receipt session.

Thanks and regards,

Kingsto88
14th January 2005, 03:51
Hi Mark,

I tried your functions but nothing happens. Maintain receipt is not done.

Could you troubleshoot my code and see what i have done wrong.

thanks and regards

|******************************************************************************
|* tdpur9449mctm 0 VRC B40C c4 PRD
|* Update Receipts
|* System - Admin User
|* 2005-01-10
|******************************************************************************
|* Main table tdpur045 Receipts, Form Type 4
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttdpur045 | Receipts
table ttcmcs003 | Warehouses
table tticpr010 | Cost Price Components
table ttisfc001 | Production Orders
table tticst002 | Estimated and Actual Hours
table ttrtoc120 | Logistic Bill of Material
table ttcmcs005 | Reasons for Rejection
table ttiitm001

extern domain ttyeno txta.txt

extern domain tcorno orno.f
extern domain tcorno orno.t
extern domain tcpono pono.f
extern domain tcpono pono.t
extern domain tcsrnb srnb.f
extern domain tcsrnb srnb.t
extern domain ttyeno txta.txt
extern domain tcrcno pass.recno
extern string pass.mess(30)

extern domain tcmcs.str132 boi.call

#pragma used dll ottstpapihand

|****************************** form section **********************************

form.1:
init.form:
get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
|read.main.table()
pass.recno = create_receipt(0,220033,10,2.0,2.0,date.num(),"",0,0.0,"PCS","",pass.mess)


|****************************** field section *********************************


|****************************** function section ******************************

functions:

function read.main.table()
{
long count

db.retry.point()

select tdpur045.*
from tdpur045
where tdpur045._index1 inrange {:orno.f, :pono.f, :srnb.f}
and {:orno.t, :pono.t, :srnb.t}
order by tdpur045._index1
selectdo
| update set
count = count + 1
if count > 50 then
count = 0
commit.transaction()
endif
endselect

commit.transaction()
}

|******************************************************************************
|* API Code for creating a new receipt
|******************************************************************************
function extern domain tcrcno create_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
string dummy(6)

| Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

| Always use tdpur4224s000 to create receipt for all lines.
stpapi.put.field("tdpur4224s000","form.orno",str$(purchase.order))
stpapi.continue.process("tdpur4224s000",msg)
stpapi.end.session("tdpur4224s000")
if not isspace(msg) and strip$(msg)<> "Process is gone" then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif
msg = ""

| Try a pause to make sure receipt is completed.
suspend(3000)

| Get the receipt so you can use the modify receipt to update. the field.
stpapi.get.field("tdpur4120m000","tdpur045.reno",dummy)
receipt.number = val(dummy)
stpapi.end.session("tdpur4120m000")

| Verify this receipt number has this PO and line on it.
select tdpur045.reno
from tdpur045
where tdpur045._index6 = {:receipt.number,:purchase.order,:purchase.line}
as set with 1 rows
selectdo
selectempty
receipt.number = 0
endselect
if receipt.number = 0 then
msg = "Receipt failed."
return(0)
endif

| Now go modify the new receipt.
modify_receipt( receipt.number,
purchase.order,
purchase.line,
packingslip.qty,
received.qty,
received.date,
purchase.lot,
purchaselot.date,
conv.factor,
purchase.unit,
purchase.item,
msg)
return(receipt.number)
}
|******************************************************************************
|* API Code for modifying an existing receipt.
|******************************************************************************
function extern modify_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
long rc, cnt
string dummy(6), error_code(16)
domain tcorno get.orno
domain tcpono get.pono

select tiitm001.stgu, tiitm001.kitm
from tiitm001
where tiitm001._index1 = {:purchase.item}
as set with 1 rows
selectdo
endselect

msg = ""
boi.call = "tdboidll0011.Create"
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(purchase.order))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(purchase.line))
rc = stpapi.find("tdpur4120m000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdpur4120m000")
return
endif
stpapi.get.field("tdpur4120m000","tdpur045.orno",dummy)
get.orno = val(dummy)
stpapi.get.field("tdpur4120m000","tdpur045.pono",dummy)
get.pono = val(dummy)

| Prepare to handle lot controlled items.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
endif

stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
stpapi.update("tdpur4120m000",1,msg)
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
return
endif

| Need to handle the conversion factor.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.put.field("tdilc4113s000", "tdilc402.clot",purchase.lot)
stpapi.put.field("tdilc4113s000", "tdilc402.date",str$(purchaselot.date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(received.qty*conv.factor))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(received.qty*conv.factor))
stpapi.insert("tdilc4113s000",1,msg)
error_code = stpapi.get.mess.code("tdilc4113s000",msg)
if strip$(error_code) = "tdilc40062" then
msg = ""
endif
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
}

mark_h
14th January 2005, 15:38
In your explanation, you say we scan in the PO information and quantity to be received.

Before that we must print a receipt Tag with all these information to be scanned in.


When we receive a purchase order from a supplier the barcodes are already on the paper work. That is what we scan for the receipt. Then we print a tag that is used for the inbound piece - this is what we call a receipt tag. Our purchasing department worked with our suppliers on getting them to send in barcoded information - most already did, but some needed some help.

I will look at the code and see if I see anything glaring.

Mark

mark_h
14th January 2005, 15:52
In this section what happens?


| Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

| Always use tdpur4224s000 to create receipt for all lines.
stpapi.put.field("tdpur4224s000","form.orno",str$(purchase.order))
stpapi.continue.process("tdpur4224s000",msg)
stpapi.end.session("tdpur4224s000")
if not isspace(msg) and strip$(msg)<> "Process is gone" then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif
| Get the receipt so you can use the modify receipt to update. the field.
stpapi.get.field("tdpur4120m000","tdpur045.reno",dummy)
receipt.number = val(dummy)
stpapi.end.session("tdpur4120m000")


Run in debug mode and see if stpapi.change.view("tdpur4120m000",msg) actually starts tdpur4224s000. Use option dialog and start a shell. Do a ps and make sure that you see tdpur4120m000 and tdpur4224s000 as subprocesses for this program. If that works then step through tdpur4224s000. The key is to first make sure that you get a receipt.

Typically for something like this I build it one step at a time, making sure each piece works through debug mode. And keep in mind that what happens on my system may not happen on your system - just because the code I posted works at my site does not mean it will work at your site. Our site is on the A&D extension. One of the first things I almost always recommend is getting the latest stpapi patch from Baan.

Mark

Kingsto88
17th January 2005, 06:54
Hi Mark,

I debug and add in messge to see the error.

No it does not open tdpur4224s000.

Creating a receipt always use 0 for the tdpur045.reno field.
msg = ""
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(0))
stpapi.change.view("tdpur4120m000",msg)
if not isspace(msg) then
stpapi.end.session("tdpur4120m000")
return(receipt.number)
endif

msg variable is not space, so it ends session tdpur4120m00 and return.

the msg variable contains "Series must be filled"
What does it mean? What must I do now? I dont see any series to be filled.

Thanks and regards,

mark_h
18th January 2005, 17:32
When doing a receipt manually do you all enter something in receipt number or packing slip number? I am not sure if you can force that with parameter settings or not. Do you have source code for tdpur4120 where you can debug it?

Mark

Kingsto88
19th January 2005, 05:21
Hi Mark,

I changed the receipt number to "10" instead of just "0".
This is because we set 2 digits series for our receipt number.

Now the receipt is working. I need to try the outbound now.

thanks and rgds

Kingsto88
24th January 2005, 03:24
Hi Mark,

Need your help again.

I managed to get it to create a new receipt if I put in the series 10 as in the example below and not 0.
Is this correct?


function create_receipt()
...
stpapi.handle.subproc("tdpur4120m000","tdpur4224s000","add")
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(10))
...


Also I call the create_receipt with
pass.recno = create_receipt(0,orno.t,pono.t,2.0,2.0,date.num(),"",0,0.0,"PCS","",pass.mess)
Is this correct?

Problem now I have is it hangs at this point in the modify_receipt:

function modify_receipt()
...
stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
stpapi.update("tdpur4120m000",1,msg)
----- "hang here"
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
return
endif
...

The process seems to hang at stpapi.update("tdpur4120m000",1,msg)
If I use option dialog and kill tdilc4113s000 and tdpur4120m000, then only the process continues from there.
What must I do now?

Thanks and regards,

mark_h
24th January 2005, 15:38
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
endif

stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
stpapi.update("tdpur4120m000",1,msg)
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif


In the above is the "if ((not isspace(purchase.lot)...." being executed? It sounds like my if statement does not work for you. The stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add") needs to be executed in order to control the tdilc4113s000 sub-session. I know I have found a couple of cases where our items are set-up incorrectly and the if statement does not work. The update launches tdilc4113 and my program locks.

Mark

Kingsto88
2nd February 2005, 11:42
Dear Mark,

Thanks again for you help with the receipt. It is working now and am still testing on it.
Anyway, i am required to write another program where the session is a print session. At the end of this session, we need to run another print session automatically.
In the second print session, I need to pass in the fields from the first session then activate the continue process.
My sample is below but it does not work.

if rprt_open() then
read.main.table()
rprt_close()

msg = ""
stpapi.handle.subproc("tfacr2411m000","","add")
stpapi.put.field("tfacr2411m000","cuno.f","A00980")
stpapi.put.field("tfacr2411m000","cuno.t","A00980")

stpapi.continue.process("tfacr2411m000",msg)
stpapi.end.session("tfacr2411m000")

else
choice.again()
endif

Thanks and regards

kbartelds
2nd February 2005, 12:10
skip the handle.subproc, set the report (and device) and it will work.

Regards,
Klaas

mark_h
2nd February 2005, 14:45
You also need to set which report and device to use. So as Klaas said skip the handle.subproc and add a stpapi.set.report command like below.

stpapi.set.report("tdilc4202m000","rtdilc440201000","ASCIF",msg)

In my case I am sending it to a temp file. You can use something like this to send it to the same printer as the first report.

stpapi.set.report("tdilc4202m000","rtdilc440201000",spool.device,msg)

Of course fill in the your session and report number in these commands.

Mark