We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-scripting-l] Not Able to Connect from EXCEL to SAP

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Posted by Rajarokia
on Dec 4 at 9:24 PM
Hey Guys ,Thanks for your quick response.
I tried different codings to connect to sap. I tried to check whether the issue is with sap authorization or settings,but the technical expertise were not able to help me. When I get the codings from google ,it is showing RFC program error. Kindly advice me.

---------------Original Message---------------
From: arokia raj
Sent: Thursday, December 01, 2011 9:23 PM
Subject: Not Able to Connect from EXCEL to SAP

I need to do order confirmation in sap Using the data from EXCEL..

But I am facing issues in Login , I dont know where is the problem.

The coding I use is this ..

Private Sub CommandButton1_Click()
Dim i, j, k, l As Integer
'If Sheets("Raj").Range("i5") <> "0" Then
'Dim a As String
If Not IsObject(SapApp) Then
Set sapguiauto = GetObject("SAPGUI")
Set SapApp = sapguiauto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SapApp.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject SapApp, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "500"
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = Sheets("Raj").Range("C9").Text
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = Sheets("Raj").Range("C10").Tex t
session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
session.findById("wnd[0]").sendVKey 0
If session.findById("wnd[0]/titl").Text = "SAP" Then
session.findById("wnd[1]/usr/radMULTI_LOGON_O PT2").Select
session.findById("wnd[1]/usr/radMULTI_LOGON_O PT2").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]" ).press
End If
session.findById("wnd[0]/tbar[0]/okcd"). Text = "me23n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 17
session.findById("wnd[1]/usr/subSUB0:SAPLMEGU I:0003/ctxtMEPO_SELECT-EBELN").Text = Sheets("Raj").Range("E" & l).Value
session.findById("wnd[1]/usr/subSUB0:SAPLMEGU I:0003/ctxtMEPO_SELECT-EBELN").caretPosition = Sheets("Raj").Range("F" & l).Value
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]").sendVKey 7
session.findById("wnd[0]/usr/subSUB0:SAPLMEGU I:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS :1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:130 3/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1 SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/cmbMEPO13 34-BSTAE").Key = "Z001"
session.findById("wnd[0]/usr/subSUB0:SAPLMEGU I:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS :1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:130 3/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1 SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/txtMEPO13 34-LABNR").Text = Sheets("Raj").Range("G" & l).Value
session.findById("wnd[0]/usr/subSUB0:SAPLMEGU I:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS :1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:130 3/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1 SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/txtMEPO13 34-LABNR").SetFocus
session.findById("wnd[0]/usr/subSUB0:SAPLMEGU I:0019/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS :1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:130 3/tabsITEM_DETAIL/tabpTABIDT16/ssubTABSTRIPCONTROL1 SUB:SAPLMEVIEWS:1101/subSUB1:SAPLMEGUI:1334/txtMEPO13 34-LABNR").caretPosition = 16
session.findById("wnd[0]").sendVKey 21
session.findById("wnd[0]").sendVKey 18
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]").sendVKey 11


session.findById("wnd[1]/tbar[0]/btn[0]" ).press
'End If
session.findById("wnd[0]/tbar[0]/okcd"). Text = "me23n"
session.findById("wnd[0]").sendVKey 0
k = Sheets("Raj").Range("I5").Valu e
j = k + 5
l = 6
For i = 1 To k

Sheets("Raj").Range("H" & l).Value = "Extracted"
j = j + 1
l = l + 1
Next i
session.findById("wnd[0]").Close
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
MsgBox "Extraction Completed..!!"
'Else
MsgBox "No data found to extraction..!!"
'End If
End Sub

Private Sub CommandButton2_Click()
Sheets("Raj").Range("H6:H500") .ClearContents
Sheets("Raj").Range("E6:F500") .ClearContents
End Sub

__.____._
Copyright © 2011 Toolbox.com and message author.

Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
Mark as helpful
View this online
  
Popular White Papers

In the Spotlight
SAP BusinessObjects: Dashboards and Analytics. Learn more about this Toobox.com Marketplace online course.

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language