Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling BAPI_COMPANYCODE_GETDETAIL from VBA (Excel)

Former Member
0 Likes
1,156

Hi,

I've successfully called a number of BAPIs in VBA, however am getting a problem with BAPI_COMPANYCODE_GETDETAIL

It doesn't seem to pick up the structure of the tables - the 'Tables' objects just get set to 'nothing' rather than pulling back the structure, like it should. The call itself doesn't fail but obviously no data is returned.

Much appreciate any ideas!

Set oSAPFunctions = CreateObject("SAP.Functions")

Set oSAPBapiFn = oSAPFunctions.Add("BAPI_COMPANYCODE_GETDETAIL")

Set oSAPECC = oSAPBapiFn.Exports("COMPANYCODEID")

Set oSAPICCD = oSAPBapiFn.Tables("COMPANYCODE_DETAIL")

'Set oSAPICCA = oSAPBapiFn.Tables("COMPANYCODE_ADDRESS")

Set oSAPTRet = oSAPBapiFn.Tables("RETURN")

oSAPECC.Value = "xxxx"

If oSAPBapiFn.Call = False Then

iRet = False

Else

'worked

EndIf

Hi,

I've successfully called a number of BAPIs in VBA, however am getting a problem with BAPI_COMPANYCODE_GETDETAIL

It doesn't seem to pick up the structure of the tables - the 'Tables' objects just get set to 'nothing' rather than pulling back the structure, like it should. The call itself doesn't fail but obviously no data is returned.

Much appreciate any ideas!

Set oSAPFunctions = CreateObject("SAP.Functions")

Set oSAPBapiFn = oSAPFunctions.Add("BAPI_COMPANYCODE_GETDETAIL")

Set oSAPECC = oSAPBapiFn.Exports("COMPANYCODEID")

Set oSAPICCD = oSAPBapiFn.Tables("COMPANYCODE_DETAIL")

'Set oSAPICCA = oSAPBapiFn.Tables("COMPANYCODE_ADDRESS")

Set oSAPTRet = oSAPBapiFn.Tables("RETURN")

oSAPECC.Value = "xxxx"

If oSAPBapiFn.Call = False Then

iRet = False

Else

'worked

EndIf

4 REPLIES 4
Read only

Former Member
0 Likes
992

Hi,

Could you in your call pass empty values for tables. IMHO such behaviour is mandatory.

/wg

Read only

0 Likes
992

Hi wg,

Thanks for your reply, however I'm not entirely sure what you mean: the TABLES parameters are returned FROM the function module?

However I attempted what I thought you meant and changed the code as below:

Set oSAPFunctions = CreateObject("SAP.Functions")

Set oSAPBapiFn = oSAPFunctions.Add("BAPI_COMPANYCODE_GETDETAIL")

Set oSAPECC = oSAPBapiFn.Exports("COMPANYCODEID")

Set oSAPICCD = oSAPBapiFn.Tables("COMPANYCODE_DETAIL")

'Set oSAPICCA = oSAPBapiFn.Tables("COMPANYCODE_ADDRESS")

Set oSAPTRet = oSAPBapiFn.Tables("RETURN")

oSAPICCD("COMP_CODE").Value = "" <---- new line

oSAPECC.Value = "xxxx"

If oSAPBapiFn.Call = False Then

iRet = False

Else

'worked

EndIf

However I got the error that oSAPICCD hadn't been set yet, probably because it doesn't seem to be pulling down the structure of COMPANYCODE_DETAIL from SAP (i.e. being set to 'Nothing').

Read only

0 Likes
992

There is such limitation in SAP adapter for BizTalk:

"By default, table parameters are not surfaced in the response message. If you require table parameters in response message, you must pass empty table parameters in the request message."

Do you receive anything in the return?

/wg

Read only

0 Likes
992

Hi wg,

No, nothing is filled into RETURN but this is because the RETURN structure is not copied down to the object variable either. So it is 'Nothing' like the others.