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

SAP Data in VB 6

Former Member
0 Likes
866

Dear Gurus

(I am new to BAPI)

I have one Z table ZZONE_SMS. I have created a BAPI which is having one import field ZZone, one export field RETURN (Sale_Qty) and one i table IZONETAB. When I test BAPI and give ZZone parameter the BAPI return me the sale_qty figure.

I want to access it in VB Code. I am connected to TRN server through RFC and connection successful. Kindly guide me how I can have the sale_qty value in my VB code.

1. Am I missing something in my BAPI. Please guide me.

2. How I can have sale_qty it in VB.

regards,

RSA

Dear Gurus

(I am new to BAPI)

I have one Z table ZZONE_SMS. I have created a BAPI which is having one import field ZZone, one export field RETURN (Sale_Qty) and one i table IZONETAB. When I test BAPI and give ZZone parameter the BAPI return me the sale_qty figure.

I want to access it in VB Code. I am connected to TRN server through RFC and connection successful. Kindly guide me how I can have the sale_qty value in my VB code.

1. Am I missing something in my BAPI. Please guide me.

2. How I can have sale_qty it in VB.

regards,

RSA

5 REPLIES 5
Read only

Former Member
0 Likes
808

Hi,

Can you place the VB code, so that i ca help you.

How you are calling bapi using Vb

Read only

0 Likes
808

Private Sub Command1_Click()

Dim oBapiCtrl As Object

Dim oBapiLogon As Object

Dim oData As Object

Dim oItem, oReturn As Object

Dim iIndex As Integer

Dim oTable As Object

Set oBapiCtrl = CreateObject("sap.bapi.1")

Set oBapiLogon = CreateObject("sap.logoncontrol.1")

oBapiCtrl.Connection = oBapiLogon.NewConnection

oBapiCtrl.Connection.ApplicationServer = "192.168.2.219"

oBapiCtrl.Connection.System = "TRN"

oBapiCtrl.Connection.Client = "600"

oBapiCtrl.Connection.User = "xcom"

oBapiCtrl.Connection.Password = "abcdef"

oBapiCtrl.Connection.Language = "EN"

oBapiCtrl.Connection.SystemNumber = "00"

If oBapiCtrl.Connection.Logon(0, True) <> True Then

MsgBox "not connected", vbInformation, "SAP Logon"

Exit Sub

End If

If oBapiCtrl.Connection.Logon(0, True) <> False Then

MsgBox "SAP " & oBapiCtrl.Connection.System & " Connected!!!!", vbInformation, "SAP Logon"

End If

If oBapiCtrl.Connection.IsConnected Then

Set oData = oBapiCtrl.GetSAPObject("ZBapisms", "LALAMUS")

Set oTable = oBapiCtrl.DimAs(oData, "BapismsFm", "IZONETAB") 'DimAs only initialize the table/structure

MsgBox (oTable.ColumnCount)

MsgBox (oTable.RowCount)

For i = 1 To oTable.ColumnCount 'I only can get the column names from said table IZONETAB

MsgBox (oTable.Columns(i).Name)

Next i

''' there is no value as table opened with DimAs (Initialized)

MsgBox (oTable.Columns("ZZONE").Value(1))

MsgBox (oTable.Columns("SALE_QTY").Value(1))

End If

End Sub

Read only

0 Likes
808

Hi,

You are extracting only table values. If you need export parameters values, use structure in vbcode

Read only

0 Likes
808

How I can call structure and how i can use it in my code, can u pls give some example (VB CODE).

Thanks

RSA

Read only

0 Likes
808

Hi,

RfcDestination prd = RfcDestinationManager.GetDestination("SE37");

RfcRepository repo = prd.Repository;

IRfcFunction getdaterfcfunction = repo.CreateFunction("BAPI_DATESPECS_GETDETAILEDLIST");

getdaterfcfunction.SetValue("EMPLOYEENUMBER",

Login1.UserName);

IRfcTable getdaterfctable=getdaterfcfunction["DATESPECIFICATIONSDATA"].GetTable();

// IRfcStructure getdaterfcstructre = getdaterfctable[0] as IRfcStructure;

getdaterfcfunction.Invoke(prd);

getdaterfctable[0]["VALIDBEGIN"].GetString();

//Session["PERNR"] = ir["PERNR"].GetString();

Session["BEGDA"] = getdaterfctable[0]["VALIDBEGIN"].GetString();

Session["ENDDA"] = getdaterfctable[0]["VALIDEND"].GetString();