Excel and VBA
Hi experts
Need ur help
Actually what am i trying to do is to call the BAPI and display the data on to the SAP tableview the SAP connection is fine and the input parameters are also working fine but i m badly stuck in displaying the data on to the SAP table view kidly help
Just posting the code that i m using or if any other way out to it kindly inform me
Public Sub callBAPI()
Dim oBAPIHelp As Object
Dim oIAstnr As Object, oIAstna As Object 'Input parameters
Dim oReturn As Object, oMessages As Object
If Not CheckSAPConnection Then
Exit Sub
End If
'Make an instance of SAP object
Set oBAPIHelp = objBAPIControl.GetSAPObject("BAPISHELP")
'Set input parameters of the BAPI
'Set oIAstnr.Value = "022"
'Set oIAstna.Value = "*Luis*"
'Get a reference to the output parameters so they can be consulted
'after calling the BAPI
Set oApplHelp = objBAPIControl.DimAs(oBAPIHelp, "ApplicantHelp", "APPLHELP")
'Set oMessages = objBAPIControl.DimAs(oBAPIHelp, "ApplicantHelp", "MESSAGES")
'Set oReturn = objBAPIControl.DimAs(oBAPIHelp, "ApplicantHelp", "RETURN")
'Call object's method with applicant name *Care*
oBAPIHelp.ApplicantHelp _
IAstnr:=frmApplicant.txtApplicantNo, _
IAstna:=frmApplicant.txtApplicantName, _
ApplHelp:=oApplHelp, _
MESSAGES:=oMessages, _
RETURN:=oReturn
If oApplHelp.RowCount > 0 Then
Call ShowData
'MsgBox "Data found"
Else
On Error Resume Next
MsgBox "Errors."
End If
End Sub
------------------Show Data Method----------------------
Private Sub ShowData()
Dim Col As Object
'Connect Table object with the Table View
oApplHelp.Views.Add UserForm1.SAPTableView1.Object
[GIVES AN ERROR SAYING THAT OBJECT DOESN'T SUPPORT THIS PROPERTY]
'Table Update
oApplHelp.Refresh
[GIVES AN ERROR SAYING THAT OBJECT DOESN'T SUPPORT THIS PROPERTY]
Set Col = UserForm1.SAPTableView1
'Loop at table columnsFor Each Col In oApplHelp.Columns
For Each Col In oApplHelp.Columns
UserForm1.SAPTableView1.Columns(Col.Index).Name = Col.Name
UserForm1.SAPTableView1.Columns(Col.Index).Protect ion = True
Next Col
'Column Headings
UserForm1.SAPTableView1.Columns("I_ASTNR").Header = "Applicant No"
UserForm1.SAPTableView1.Columns("I_ASTNA").Header = "Applicant Name"
'Automatically adopt column width to contents
UserForm1.SAPTableView1.ColumnAutoWidth 1, UserForm1.SAPTableView1.ColumnCount
End Sub
|