2010-12-02 44 views
0

SAPのデータの大量アップロードを行いたいと思います.100 POの価格を更新します。 VBスクリプトを使用してマクロを作成し、SAPスクリプトの記録および再生オプションを使用してマクロを実行できますが、その間にSAP GUI IDが変更されるとマクロが停止することがあります。これのための修正はありますか?VBスクリプトを使用したSAPマクロ

例コード:

If Not IsObject(application) Then 
    Set SapGuiAuto = GetObject("SAPGUI") 
    Set application = SapGuiAuto.GetScriptingEngine 
End If 
If Not IsObject(connection) Then 
    Set connection = application.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 application, "on" 
End If 
session.findById("wnd[0]").maximize 
session.findById("wnd[0]/tbar[0]/okcd").text = "me22n" 
session.findById("wnd[0]").sendVKey 0 
session.findById("wnd[0]/tbar[1]/btn[17]").press 
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").text = "44101194" 
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").caretPosition = 8 
session.findById("wnd[1]").sendVKey 0 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-KONNR[17,0]").text = "46062154" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").text = "10" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").setFocus 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").caretPosition = 3 
For i = 0 To 3 
    session.findById("wnd[0]").sendVKey 0 
Next 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").text = "29.4" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").setFocus 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").caretPosition = 14 
session.findById("wnd[0]").sendVKey 0 
On Error Resume Next 
session.findById("wnd[0]/tbar[1]/btn[21]").press 
For i = 0 To 3 
    session.findById("wnd[0]/tbar[1]/btn[18]").press 
    session.findById("wnd[1]/tbar[0]/btn[0]").press 
Next 
session.findById("wnd[0]/tbar[0]/btn[11]").press 
session.findById("wnd[0]/tbar[1]/btn[17]").press 
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").text = "44101195" 
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-EBELN").caretPosition = 8 
session.findById("wnd[1]").sendVKey 0 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-KONNR[17,0]").text = "46062154" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").text = "10" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").setFocus 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-KTPNR[18,0]").caretPosition = 3 
For i = 0 To 3 
    session.findById("wnd[0]").sendVKey 0 
Next 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").text = "29.4" 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").setFocus 
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/txtMEPO1211-NETPR[9,0]").caretPosition = 14 
session.findById("wnd[0]").sendVKey 0 

答えて

0

ごspesificトランザクションを使用していますか?ところで、最初に最大化するまで部品を削除してください。これを入れて

Set SapGuiAuto = GetObject("SAPGUI") 
Set SAPApp = SapGuiAuto.GetScriptingEngine 
    Set SAPCon = SAPApp.Children(0) 
    Set session = SAPCon.Children(0) 
関連する問題