none
Automatização de tarefa SAP utilizando planilha excel RRS feed

  • Pergunta

  • Em pesquisa na internet achei uma automatização para utilizar a transação MB1B com planilha excel, mas está apresentando erro de caracter, poderiam me ajudar, pois não localizo o erro.

    Segue abaixo:

    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

    REM  B1 INICIO***********************************************

    Dim objExcel

    Dim objSheet, intRow, i

    Set objExcel = GetObject(, “Excel.Application”)       

    Set objSheet = objExcel.ActiveWorkbook.ActiveSheet  
     
    For i = 2 To objSheet.UsedRange.Rows.Count           

        CODSAP   = Trim(CStr(objSheet.Cells(i, 1).Value))

        PEPORIG  = Trim(CStr(objSheet.Cells(i, 2).Value))

        QTDE     = Trim(CStr(objSheet.Cells(i, 3).Value))

        CENTORIG = Trim(CStr(objSheet.Cells(i, 4).Value))

        DEPORIG  = Trim(CStr(objSheet.Cells(i, 5).Value))

        CENTDEST = Trim(CStr(objSheet.Cells(i, 6).Value))

        DEPDEST  = Trim(CStr(objSheet.Cells(i, 7).Value))

        PEPDEST  = Trim(CStr(objSheet.Cells(i, 8).Value))


        session.findById(“wnd[0]”).maximize

    REM B1 FIM *************************************************


    session.findById("wnd[0]/tbar[0]/okcd").text = "/nmb1b"
    session.findById("wnd[0]").sendVKey 0                                   
    session.findById("wnd[0]/usr/txtMKPF-BKTXT").text = "e-mail Kelly 04/08"
    session.findById("wnd[0]/usr/ctxtRM07M-BWARTWA").text = "301"
    session.findById("wnd[0]/usr/ctxtRM07M-SOBKZ").text = "q"
    session.findById("wnd[0]/usr/ctxtRM07M-WERKS").text = "rjrj"
    session.findById("wnd[0]/usr/ctxtRM07M-LGORT").text = "rjrj"
    session.findById("wnd[0]/usr/ctxtRM07M-LGORT").setFocus
    session.findById("wnd[0]/usr/ctxtRM07M-LGORT").caretPosition = 4
    session.findById("wnd[0]").sendVKey 8                                   
    session.findById("wnd[0]/usr/ctxtMSEG-MATNR").text = CODSAP
    session.findById("wnd[0]/usr/subBLOCK1:SAPMM07M:2404/ctxtMSEG-MAT_PSPNR").text = PEPORIG
    session.findById("wnd[0]/usr/txtMSEG-ERFMG").text = QTDE
    session.findById("wnd[0]/usr/ctxtMSEG-WERKS").text = CENTORIG
    session.findById("wnd[0]/usr/ctxtMSEG-LGORT").text = DEPORIG
    session.findById("wnd[0]/usr/ctxtMSEG-UMWRK").text = CENTDEST
    session.findById("wnd[0]/usr/ctxtMSEG-UMLGO").text = DEPDEST
    session.findById("wnd[0]/usr/subBLOCK2:SAPMM07M:2402/ctxtMSEG-PS_PSP_PNR").text = PEPDEST
    session.findById("wnd[0]/usr/txtMSEG-SGTXT").setFocus
    session.findById("wnd[0]/usr/txtMSEG-SGTXT").caretPosition = 0
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/tbar[1]/btn[8]").press

    REM B2 ************************************************

    Next

    REM ****************************************************

    terça-feira, 8 de agosto de 2017 18:54