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

Accessing BAPI structures in Excel

Former Member
0 Likes
683

I am currently developing an Excel tool that calls BAPI_USER_GET_DETAIL to determine the user's firstname and lastname from the Export structure ADDRESS (BAPIADDR3). I am having trouble in how I should declare a variable to contain the contents of this structure and how to access the FIRSTNAME and LASTNAME fields of the structure. It seems that when I try to access ADDRESS as a string it returns a value of "Error 0". Any help here would help.

Thanks,

John

1 ACCEPTED SOLUTION
Read only

krzysztof_konitz4
Contributor
0 Likes
550

Hi,

I assume tha you are using Visual Basic...

You can find small example below. Generally structures similar to tables are managed as objects so you should define it as Object... In example I used PartnerList variable to get fields values of returned table.

Dim MyFunc, PartnerList, Row As Object

Dim Result As Boolean

Set MyFunc = Funct.Add("BAPI_FUNCTION_NAME")

Set PartnerList = MyFunc.Tables("PARTNER_LIST")

Result = MyFunc.Call

If Result = True Then

Set PartnerList = MyFunc.Tables("PARTNER_LIST")

For Each Row In PartnerList.Rows

Text = Row("PARTNER_NO") + " " + Row("BPTYPE") + " " + Row("NAME1")

MsgBox Text

Next Row

Else

MsgBox MyFunc.Exception

Funct.Connection.Logoff

End If

regards

Krzys

3 REPLIES 3
Read only

krzysztof_konitz4
Contributor
0 Likes
551

Hi,

I assume tha you are using Visual Basic...

You can find small example below. Generally structures similar to tables are managed as objects so you should define it as Object... In example I used PartnerList variable to get fields values of returned table.

Dim MyFunc, PartnerList, Row As Object

Dim Result As Boolean

Set MyFunc = Funct.Add("BAPI_FUNCTION_NAME")

Set PartnerList = MyFunc.Tables("PARTNER_LIST")

Result = MyFunc.Call

If Result = True Then

Set PartnerList = MyFunc.Tables("PARTNER_LIST")

For Each Row In PartnerList.Rows

Text = Row("PARTNER_NO") + " " + Row("BPTYPE") + " " + Row("NAME1")

MsgBox Text

Next Row

Else

MsgBox MyFunc.Exception

Funct.Connection.Logoff

End If

regards

Krzys

Read only

Former Member
0 Likes
550

I figured it out....seems I was doing it right all along, just didn't have the right VB to print the fields that I wanted form ADDRESS.

Thanks for the reply, it helped me see my VB mistake.

Regards,

John

Read only

Former Member
0 Likes
550

Hello John,

I am currently developing a Leave Application in VB that calls BAPI_USER_GET_DETAIL. I am facing same problem as u faced it earlier, to determine the user's FullName from the Export structure ADDRESS (BAPIADDR3). I am having trouble in how I should declare a variable to contain the contents of this structure and how to access the FullName fields of the structure. I hope that u overcame this problem.if so please give some details code

Thanks in advance,

Minaxi Shah