1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Sub MD_04()
Dim SapGuiAuto As Object
Dim AppliSAP As Object 'SAPFEWSELib.GuiApplication
Dim Connection As Object ' SAPFEWSELib.GuiConnection
Dim Session As Object ' SAPFEWSELib.GuiSession
Dim Grille As Object ' SAPFEWSELib.GuiTableControl
Dim I As Long
Dim TotalRow As Long, VisibleRow As Long
On Error GoTo Erreur
'Partie connexion
'################################################
Set SapGuiAuto = GetObject("SAPGUI")
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set AppliSAP = SapGuiAuto.GetScriptingEngine()
If Not IsObject(AppliSAP) Then
Exit Sub
End If
Set Connection = AppliSAP.Connections(0)
If Not IsObject(Connection) Then
Exit Sub
End If
Set Session = Connection.Sessions(0)
If Not IsObject(Session) Then
Exit Sub
End If
'################################################
Session.FindById("wnd[0]").Maximize
Session.FindById("wnd[0]/tbar[0]/okcd").Text = "/nMD04" 'Démarre la requête
Session.FindById("wnd[0]/tbar[0]/btn[0]").Press
'Entrer le code et l'entrepôt
Session.FindById("wnd[0]/usr/tabsTAB300/tabpF01/ssubINCLUDE300:SAPMM61R:0301/ctxtRM61R-MATNR").Text = "10043282"
Session.FindById("wnd[0]/usr/tabsTAB300/tabpF01/ssubINCLUDE300:SAPMM61R:0301/ctxtRM61R-WERKS").Text = "ZV01"
Session.FindById("wnd[0]/tbar[0]/btn[0]").Press
'Affiche Détails entêtes et sélectionne l'onglet Stocks/Couverture
Session.FindById("wnd[0]/usr/btnBUTTON_GROKO").Press
Session.FindById("wnd[0]/usr/tabsTABTC/tabpTB03").Select
Session.FindById("wnd[0]/usr/btnBUTTON_EZ_PS").Press
'Recherche dans la table
Set Grille = Session.FindById("wnd[0]/usr/subINCLUDE1XX:SAPMM61R:0770/tabsPS_TAB/tabpPS_D/ssubPS_SUBSCR:SAPMM61R:0760/tblSAPMM61RTC_PS")
TotalRow = Grille.VisibleRowCount
For I = 0 To TotalRow - 1
If Grille.GetCell(I, 1).Text = "12.02.16" Then
MsgBox Grille.GetCell(I, 4).Text
Exit For
End If
Next
Set Session = Nothing
Set Connection = Nothing
Set AppliSAP = Nothing
Set SapGuiAuto = Nothing
Exit Sub
Erreur:
MsgBox Err.Number & vbCrLf & Err.Description
Stop 'pour débogage
Resume 'pour débogage
End Sub |
Partager