Hi,
I am interested in interfacing a Powerbuilder 2017 application with SAP BAPI.
Some example code that will help me to connect to and interface with an SAP BAPI will be of great help.
Thanks in advance.
Regards
Murugeshan KN
Hi,
I am interested in interfacing a Powerbuilder 2017 application with SAP BAPI.
Some example code that will help me to connect to and interface with an SAP BAPI will be of great help.
Thanks in advance.
Regards
Murugeshan KN
Hi Murugeshan
Could you please publish API reference?
Thanks
Giuseppe moglia, Its a BAPI.
Here is my script.
--------------------------------------------------------------
oleobject iole_bapi, iole_connection
boolean lb_success = false
integer li_rc
// create the bapi
if not isvalid(iole_bapi) then
iole_bapi = CREATE OLEObject
li_rc = iole_bapi.ConnectToNewObject("sap.bapi.1")
end if
// check return code
// -2 Class name not found
// -3 Object could not be created
// -4 Could not connect to object
// -9 Other error
// -15 MTS is not loaded on this computer
// -16 Invalid Call: this function not applicable
if li_rc < 0 then
MessageBox("SAP Connect Failure","Unable to connect to SAP. " + &
"Please verify that SAP is installed on this machine.~r~n" + &
"The return code is: " + string(li_rc))
return false
end if
// create the connection object
if not isvalid(iole_connection) then
iole_connection = CREATE OLEObject
iole_connection = iole_bapi.Connection()
end if
long ll_row
ll_row = dw_1.Getrow()
iole_connection.client = trim(dw_1.Object.client_id[ll_row])
iole_connection.user = trim(dw_1.Object.user_name[ll_row])
iole_connection.language = trim(dw_1.Object.appl_lang[ll_row])
iole_connection.password =trim(dw_1.Object.user_pass[ll_row])
iole_connection.applicationserver = trim(dw_1.Object.app_server[ll_row])
iole_connection.systemnumber = trim(dw_1.Object.sys_num[ll_row])
// logon now (silently)
lb_success = iole_connection.logon(0, FALSE)
// set instance
if lb_success then
ib_connected = true
else
ib_connected = false
end if
if ib_connected = true then
OLEObject pbobject, bo_sap
// set o_sap oleobject
bo_sap = iole_bapi.GetSAPObject("ZBUSMAT01")
oleobject omaterials, omat_list, sapreturn
// These look good too! I don't know Sales Order much but you got the right idea.
omaterials = iole_bapi.DimAs(bo_sap,"ZbapiMaterials","Material")
omat_list = iole_bapi.DimAs(bo_sap,"ZbapiMaterials","MaterialDetails")
sapreturn = iole_bapi.DimAs(bo_sap,"ZbapiMaterials","Return")
omaterials.Value[1] = "373.172"
// Script is successfully executing till this line and PB comes out in next line
bo_sap.ZbapiMaterials(omaterials, omat_list, sapreturn )
if sapreturn.TYPE = "E" then
Messagebox("Error","Message - Error",STOPSIGN!)
else
Messagebox("Information","Material List Executed")
end if
end if
Hi,
Try with webservices, It's the new in PB and I believe it´s possible in SAP
Regards !
Hi Murugeshan
We develop every day with SAP Business One (never worked on SAP Business Object) but the connection method is very similar to the submitted by Chris
Have you already tried?
Shall I put the screen shot of all the BAPI components involved. If I am wrong, let me know What is BAPI API reference to provide the same.
Could you send me so I can take a look into?