1. Murugeshan KN
  2. PowerBuilder
  3. Saturday, 25 August 2018 06:28 AM UTC

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

 

Giuseppe moglia Accepted Answer Pending Moderation
  1. Thursday, 6 September 2018 14:36 PM UTC
  2. PowerBuilder
  3. # 1

Hi Murugeshan

Could you please publish API reference?

 

Thanks

Comment
  1. Murugeshan KN
  2. Friday, 7 September 2018 02:18 AM UTC
This is user (myself) created BAPI in SAP for attempting the case where input is the material no and output is few fields of MARA table.

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.
  1. Helpful
  1. Giuseppe moglia
  2. Friday, 7 September 2018 07:56 AM UTC
You should have in SAP BAPI SDK some help files (*.chm)

Could you send me so I can take a look into?
  1. Helpful
There are no comments made yet.
Murugeshan KN Accepted Answer Pending Moderation
  1. Tuesday, 28 August 2018 03:41 AM UTC
  2. PowerBuilder
  3. # 2

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

 

Comment
  1. Giuseppe moglia
  2. Wednesday, 29 August 2018 09:26 AM UTC
Hi

Could you please provide me with BAPI API reference?
  1. Helpful
  1. Murugeshan KN
  2. Thursday, 30 August 2018 02:12 AM UTC
This is user (myself) created BAPI in SAP for attempting the case where input it material no and output is few fields of MARA table.

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.





  1. Helpful
There are no comments made yet.
Alfredo Aldama Accepted Answer Pending Moderation
  1. Tuesday, 28 August 2018 02:35 AM UTC
  2. PowerBuilder
  3. # 3

 

Hi,

Try with webservices, It's the new in PB and I believe it´s possible in SAP

Regards !

Comment
  1. Murugeshan KN
  2. Thursday, 30 August 2018 02:23 AM UTC
I am using Pb2017 Standard version with which I am not able to try the webservice part. Any further input please ?
  1. Helpful
There are no comments made yet.
Giuseppe moglia Accepted Answer Pending Moderation
  1. Monday, 27 August 2018 06:52 AM UTC
  2. PowerBuilder
  3. # 4

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?

Comment
  1. Murugeshan KN
  2. Monday, 27 August 2018 09:34 AM UTC
Hi Giuseppe moglia, Thanks for responding. Please refer my response to Chris and help me to go further.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 27 August 2018 05:01 AM UTC
  2. PowerBuilder
  3. # 5

Hi Murugeshan;

  FYI. ... SAP BAPI 

HTH

Regards ... Chris

Comment
  1. Giuseppe moglia
  2. Monday, 27 August 2018 09:48 AM UTC
Murugeshan, BAPI sdk are COM objects?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 27 August 2018 13:57 PM UTC
Please feel free to post your Script. I am not by any means a BAPI person, but many form readers could be & able to jump in to help you further! I'm glad that at least my post got you started in the right direction!

  1. Helpful
  1. Murugeshan KN
  2. Tuesday, 28 August 2018 03:47 AM UTC
Done. Thanks
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.