ue_api_sbo

With this object you've access to the SAP Business one Datainterface (DI-API)

 

Note: If it possible: User Beas Service Layer. This is the new interface for creating documents and support all Beas Rules.

 

How to use ue_api_sbo:

 

You can declare it with

declare=[objektname]=ue_api_sbo

 

Now you can access the DI-API directly via Object Names.

 

Example: change item-entry

declare=myitem=ue_api_sbo

myitem=getbusinessobject=oitem

myitem=getbykey=A001

myitem=itemname=new itemname

myitem=update

destroy=myitem

 

You can access almost any Property with api_sbo. api_sbo will not perform any checks.

More information can be found within the SAP SDK Documentation.

 

hmtoggle_plus1Important: Only one DI-API Object  a time is allowed.

don't work with

declare=b1=ue_api_sbo

declare=b2=ue_api_sbo

 

because you can have problems with special variables as example "<getlasterror>"

After using the DI-API object: Destroy it! Otherwise you can produce bad mirror effects.

 

 

Error handling

The Object return values in the return object

Return code: <objectname.ret_code>   -1 = error, 1 = ok

Return Text: <objectname.ret_text>     Return last error

Additional information about error you can read with <objectname.getlasterror>.

vdoc.add

if <vdoc.ret_code> = -1 then

 message=fehler$error create Order: <vdoc.getlasterror>

end if

 

Functions like add, getbusinessobject, update, getbykey and so on will return "value"

vdoc.ret_code = 1  = ok

vdoc.ret_code = -1 = error

 

Additional examples

hmtoggle_plus1Create goods receipt

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=59

di_doc=lines=itemcode=Jesús

di_doc=lines=quantity=1

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

destroy=di_doc

hmtoggle_plus1Goods Receipt with UDF

//Create goods receipt with UserFields

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=59

di_doc=lines=itemcode=RM

di_doc=lines=quantity=1

di_doc=lines=userfield=U_test2=N

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

destroy=di_doc

hmtoggle_plus1Goods Receipt with Batches and Serials

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=59

di_doc=lines=itemcode=RAWMAT_NORMAL

di_doc=lines=quantity=100

di_doc=lines=add

di_doc=lines=itemcode=RAWMAT_BATCH

di_doc=lines=quantity=100

di_doc=lines=batchnumber=batchnumber=<today,yyyymmdd>

di_doc=lines=batchnumber=quantity=100        

di_doc=lines=add

di_doc=lines=itemcode=RAWMAT_SERIAL

di_doc=lines=quantity=5

di_doc=lines=serialnumbers=internalserialnumber=<today,yyyymmdd><now,hhmmss>_1

di_doc=lines=serialnumbers=quantity=1

di_doc=lines=serialnumbers=add

di_doc=lines=serialnumbers=internalserialnumber=<today,yyyymmdd><now,hhmmss>_2

di_doc=lines=serialnumbers=quantity=1

di_doc=lines=serialnumbers=add

di_doc=lines=serialnumbers=internalserialnumber=<today,yyyymmdd><now,hhmmss>_3

di_doc=lines=serialnumbers=quantity=1

di_doc=lines=serialnumbers=add

di_doc=lines=serialnumbers=internalserialnumber=<today,yyyymmdd><now,hhmmss>_4

di_doc=lines=serialnumbers=quantity=1

di_doc=lines=serialnumbers=add

di_doc=lines=serialnumbers=internalserialnumber=<today,yyyymmdd><now,hhmmss>_5

di_doc=lines=serialnumbers=quantity=1

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

destroy=di_doc

hmtoggle_plus1Create Purchase order

//Work with Purchase order

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=22

di_doc=cardcode=P001

di_doc=lines=itemcode=Jesús

di_doc=lines=quantity=1

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

 

destroy di_doc

hmtoggle_plus1Create Goods Receipt PO based on a purchase order

//Create Goods receipt PO based on a purchase order

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=20

di_doc=lines=itemcode=Jesús

di_doc=lines=quantity=2

di_doc=lines=basetype=22

di_doc=lines=baseentry=1371

di_doc=lines=baseline=0

di_doc=add

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

 

destroy di_doc

hmtoggle_plus1Create SAP Receipt from production

//Create SAP receipt from production

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=59

//di_doc=lines=itemcode=SAP_BOM

di_doc=lines=quantity=1

di_doc=lines=basetype=202

di_doc=lines=baseentry=34

di_doc=lines=baseline=0

di_doc=add

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

 

destroy di_doc

hmtoggle_plus1Sales return with Batchnumbers

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=16

di_doc=cardcode=C001

di_doc=lines=itemcode=batchitem

di_doc=lines=quantity=2

di_doc=lines=whscode=02

di_doc=lines=batchnumber=batchnum=test

di_doc=lines=batchnumber=quantity=1

di_doc=lines=batchnumber=add

di_doc=lines=batchnumber=batchnum=test2

di_doc=lines=batchnumber=quantity=1

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

 

setvar=newkey=<di_doc.getnewobjectkey>

 

destroy di_doc

hmtoggle_plus1Create Inventory transfer based on a transfer request

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=16

di_doc=lines=itemcode=Jesús

di_doc=lines=quantity=1

di_doc=lines=batchnumber=batchnum=111

di_doc=lines=batchnumber=quantity=1

di_doc=lines=basetype=5

di_doc=lines=baseentry=<ls_docentry>

di_doc=lines=baseline=<ls_linenum>

di_doc=add

 

//Create Inventory transfer

declare=di_doc=ue_api_sbo

di_doc=getbusinessobject=67

di_doc=lines=itemcode=RM_B

di_doc=lines=quantity=1

di_doc=lines=batchnumber=batchnum=20190209

di_doc=lines=batchnumber=quantity=1

di_doc=lines=fromwhscode=01

di_doc=lines=whscode=02

di_doc=add

 

if <di_doc.ret_code> = -1 then

 message=error$item not found <di_doc.getlasterror>

 return failure

end if

 

setvar=newkey=<di_doc.getnewobjectkey>

 

destroy di_doc

 

 

Functions

debug=y

extended Debugging

connect_extern

connect to external database. see connect_extern

 

Methoden (generell)

add

add a document

return variable "value" 0=failure, 1=ok

 

...

// create manual goods receipt

// table oign/ign1

declare=mrcp=ue_api_sbo

mrcp=getbusinessobject=59

// set current stationname

mrcp=U_beas_station=<stationname>

mrcp=line.itemcode=9008100021

mrcp=line.price=3.44

mrcp=line.quantity=5

mrcp=add

// error?

if <value> = 0 then

 messagebox=error$$document not created: <mrcp.getlasterror>

 destroy=mrcp

 return failure

end if

// get last docentry - from this station

select max("DocEntry") into ll_docentry from "OIGE" &

   where "U_beas_station"=<stationname,dbstring>

messagebox=ok$$Document <ll_docentry> created

 

cancel

cancel

close

close the document

savetofile=<file>

save document to file

savexml=<file>

save document to xmlfile

getasxml=<file>

get document from xml-file

getbusinessobject=<documenttype>

create business object (see examples).
see documenttyp

getbusinessobjectfromxml=<path>

Load object from definition saved in "path" file

update

save
return variable "value" 0 = failure, 1 = ok

In Silent-Mode

return variable "errortext" with the current Error, only if value=0

getbykey

get entry (only char. if numeric: getbykeynum)

after loading you can get all information from the current object. Attention: only with correct lower / uppercase

getbykey

get entry (typ numeric)

silent=true/false

set silent-Mode

in silent-mode beas set only variables and send no error-Meesage