IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

IHM Discussion :

Ouvrir SAP et lancer un script


Sujet :

IHM

  1. #1
    Membre régulier Avatar de totor92290
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    418
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 418
    Points : 102
    Points
    102
    Par défaut Ouvrir SAP et lancer un script
    Bonjour à tous,
    Avant tout je ne sais pas si mon post est au bon endroit !!
    Je souhaite derrière un évennement "AfterUpdate" ouvrir une session SAP et recupérer (copier) une info d'un champ SAP et le coller dans un champ access.

    j'ai ce code mais j'ai un pop up sur la ligne 2 Set Proc
    message: "Compile error: Assignment to constant not permitted"

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Private Sub OTBareCodeSelection_AfterUpdate()
     
     
    'The below section will create an SAP session.
    Set WshShell = CreateObject("WScript.Shell")
    Set Proc = WshShell.Exec("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe")
          Do While Proc.Status = 0
                WScript.Sleep 100
          Loop
     
    Set SapGuiAuto = GetObject("SAPGUI")
    Set SapGuiApp = SapGuiAuto.GetScriptingEngine
     
    Set oConnection = SapGuiApp.OpenConnection("..SAP2000 Production             PGI", True)
    Set session = oConnection.Children(0)
     
    session.findById("wnd[0]").resizeWorkingPane 107, 26, False
    session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USERXXXXX"
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "MDPXXXXXXX"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "fr"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
    session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nlt21"
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/txtLTAK-TANUM").Text = "OT_NUMBER_XXXXX"
    session.findById("wnd[0]/usr/txtRL03T-TAPOS").Text = "POSTE_OT_NUMBER_XXXXX"
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").Text = "MAGASIN_XXXXX"
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").caretPosition = 3
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").caretPosition = 0
     
    End Sub
    Je ne suis pas DU TOUT de connaissance !!

    Merci
    Totor

  2. #2
    Membre régulier Avatar de totor92290
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    418
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 418
    Points : 102
    Points
    102
    Par défaut
    Alors j'ai modifié le code.
    Il semble fonctionner, mais,
    Je voudrais:
    1- ajouter une ligne qui vérifie, si SAP est ouvert, alors on continue sinon on ouvre SAP
    2- la derniere ligne ne fonctionne pas j'ai trouvé pour copier

    mais cel ne fonctionne pas, message d'erreur:Run time error 13: type mismatch

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Private Sub OTBareCodeSelection_AfterUpdate()
     
     
    'The below section will create an SAP session.
    Set WshShell = CreateObject("WScript.Shell")
    '
    If Not IsObject(SAPGuiApp) Then
     
        Set SapGuiAuto = GetObject("SAPGUI")
        Set SAPGuiApp = SapGuiAuto.GetScriptingEngine
    End If
     
     
    Set oConnection = SAPGuiApp.OpenConnection("..SAP2000 Production             PGI", True)
    Set session = oConnection.Children(0)
     
    session.findById("wnd[0]").resizeWorkingPane 107, 26, False
    session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USERxxxx"
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "MDPxxxx"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "fr"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
    session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nlt21"
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/txtLTAK-TANUM").Text = Me.OTSelection
    session.findById("wnd[0]/usr/txtRL03T-TAPOS").Text = Me.OTPoste_Selection
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").Text = Me.OTMAG_Selection
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").caretPosition = 3
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").caretPosition = 0
    'A partir de là je voudrais copier le contenu du champ et ensuite le coller dans le champ access
    session.findById("wnd[0]").sendVKey "^{a}" 'message d'erreur! Run time error 13: type mismatch
     
    End Sub
    quelqu'un a une idée?

    Merci

  3. #3
    Membre régulier Avatar de totor92290
    Homme Profil pro
    Inscrit en
    Janvier 2010
    Messages
    418
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France

    Informations forums :
    Inscription : Janvier 2010
    Messages : 418
    Points : 102
    Points
    102
    Par défaut
    C'est bon ça marche !


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Private Sub OTBareCodeSelection_AfterUpdate()
     
                                        Dim W_Ret As Boolean
     
                                        W_Ret = Attach_Session
                                        If Not W_Ret Then
                                        'Exit Sub
                                        End If
     
     
    'The below section will create an SAP session.
    Set WshShell = CreateObject("WScript.Shell")
    '
    If Not IsObject(SAPGuiApp) Then
     
        Set SapGuiAuto = GetObject("SAPGUI")
        Set SAPGuiApp = SapGuiAuto.GetScriptingEngine
    End If
     
    'ouverture de SAP
    Set oConnection = SAPGuiApp.OpenConnection("..SAP2000 Production             PGI", True)
    Set session = oConnection.Children(0)
     
    session.findById("wnd[0]").resizeWorkingPane 107, 26, False
    session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USER" ' user
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "MDP" 'MDP
    session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "fr"
    session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
    session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
    session.findById("wnd[0]").sendVKey 0
     
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nlt21" 'appel de la transaction SAP
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/txtLTAK-TANUM").Text = Me.OTSelection ' remplissage de SAP à l'aide des champs se trouvant dans access
    session.findById("wnd[0]/usr/txtRL03T-TAPOS").Text = Me.OTPoste_Selection ' remplissage de SAP à l'aide des champs se trouvant dans access
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").Text = Me.OTMAG_Selection ' remplissage de SAP à l'aide des champs se trouvant dans access
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAK-LGNUM").caretPosition = 3
    session.findById("wnd[0]").sendVKey 0
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").SetFocus
    session.findById("wnd[0]/usr/ctxtLTAP-MATNR").caretPosition = 0
     
    Me.CMSNumber_Selection.Value = session.findById("wnd[0]/usr/ctxtLTAP-MATNR").Text 'selection du champ CMS et copie dans le champ du formulaire access
     
    session.findById("wnd[0]/tbar[0]/okcd").Text = "/nex" 'fermeture de la session SAP
    session.findById("wnd[0]").sendVKey 0
     
    End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 19/02/2016, 14h32
  2. Ouvrir un fichier Excel / Lancer un script JS
    Par ch7787 dans le forum Documents
    Réponses: 3
    Dernier message: 19/07/2010, 15h03
  3. Réponses: 4
    Dernier message: 28/02/2007, 15h24
  4. [web] Lancer un script en arrière plan
    Par gracouille dans le forum Web
    Réponses: 4
    Dernier message: 27/05/2004, 16h37
  5. [web] Lancer un script CGI
    Par Calou20 dans le forum Web
    Réponses: 10
    Dernier message: 01/03/2004, 16h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo