yogesh kapil
23rd May 2013, 08:09
HI All,

Can anyone please give me beginner level tips on how to use dlls with examples. Thanks.

Yogesh Kapil
9711204433

mark_h
23rd May 2013, 16:57
I am on 4c4 and here is how I think of DLL's. These are libraries that will hold common routines that can be called from multiple programs. I do this for most of my API code since we may have multiple uses for the code. So for example below is just part of one DLL for outbound. Now I can write multiple sessions which call insert inbound for different scenarios - one might be read in a file and insert inbound, another might be to just insert inbound for certain items. Not exactly how I use them, but they are only examples. Just they other day we were looking at my bin to bin library - there are about 6 different user sessions which uses the library - (1) one for file loads of bin to bins, (2) one for inventory to process individual bin to bins, (3) one for bin to bin floor stock items, (4) one to move automated storage management moves, etc. So that is how I think of libraries. I do not know about LN or 5 and what other options might be available.

Funny - after posting this you can see comments that shows how long we have been using these libraries - at least since 2004.

|******************************************************************************
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
extern domain tcbool api.mode
extern domain timps.devi real.tag.printer
extern domain tcmcs.long tag.run.mode
extern string tag.temp.file(1024)
|******************************************************************************
|* 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")
}

bdittmar
24th May 2013, 13:54
HI All,

Can anyone please give me beginner level tips on how to use dlls with examples. Thanks.

Yogesh Kapil
9711204433

Hello,
example of an own LN DLL


function extern dhhtm.dll0001.get.employee.data(domain tcemno i.emno,
ref domain tcnama o.nama,
ref domain tcmcs.str25 o.telw,
ref domain tcmcs.str25 o.tefw,
ref domain bpmdm.info o.mail)
{
dllusage
Read employee data for Formdesigner reports.

Input: i.emno = Employee number
Output: o.nama = Name
o.telw = Phome
o.tefw = Fax
o.mail = Email
enddllusage
o.nama = ""
o.telw = ""
o.tefw = ""
o.mail = ""

select tccom001.nama
from tccom001
where tccom001._index1 = {:i.emno}
selectdo
o.nama = strip$(tccom001.nama)

select bpmdm001.*,
tcmcs010.tfcd,
tcmcs010.fxcd
from bpmdm001, tccom130, tcmcs010
where bpmdm001._index1 = {:i.emno}
and bpmdm001.cadr refers to tccom130 unref clear
and tccom130.ccty refers to tcmcs010 unref clear
selectdo
o.telw = not isspace(bpmdm001.telw) ? trim$(tcmcs010.tfcd) & " " & strip$(bpmdm001.telw) : ""
o.tefw = not isspace(bpmdm001.tefw) ? trim$(tcmcs010.fxcd) & " " & strip$(bpmdm001.tefw) : ""
o.mail = strip$(bpmdm001.mail)
endselect
endselect
}


Regards

yogesh kapil
27th May 2013, 09:48
Hi ,

thanks you so much to give me information regarding dll.

Yogesh Kapil