automatically logging in to SAP as part of a VBscript

2.4k views Asked by At

I am working in SAP (PR2) and I have a large report that usually takes a long time (2 or more hours) to run. I have to take the output of this report and drop it into Excel to be manipulated and cleansed before bringing it into Access.

The ideal result would be a script that could launch automatically around 4am, login in to SAP, run the report, and have the results waiting for me when I come in. In short, I am missing parts 1 and 2, the automatic launch and automatic login to SAP.

I have pulled together a script that will start the report and then output the results as I want. The downside of this is that I don't get the results until about noon-ish each day, and that interrupts the workflow of those whom I support.

I have tried to run the necessary report in the background as suggested in other questions, but due to the size of the report and my limited access inside of SAP, it comes out in a way that is completely useless to me.

Thanks in advance for your help. Also, thanks for the help ya'll have given on prior questions :)

PS:As a bonus, if anyone knows how to encrypt a VBscript, that would be helpful as well.

1

There are 1 answers

2
BertB On BEST ANSWER

Use the windows task scheduler to set a run daily at time task.

VBS cannot be encrypted but can be encoded. This will only stop the casual person fiddling with the code, decoding scripts are available online for anyone who really wants to get your code.

    'ENCODE VBS TO VBE
    Set oFilesToEncode          = WScript.Arguments 
    Set oEncoder                = CreateObject("Scripting.Encoder") 
    For i                       = 0 To oFilesToEncode.Count - 1 
        file                    = oFilesToEncode(i) 
        Set oFile               = fso.GetFile(file) 
        Set oStream             = oFile.OpenAsTextStream(1) 
        sSourceFile             = oStream.ReadAll 
        oStream.Close 
        sDest                   = Encoder.EncodeScriptFile(".vbs",sSourceFile,0,"") 
        sFileOut                = Left(file, Len(file) - 3) & "vbe" 
        Set oEncFile            = fso.CreateTextFile(sFileOut) 
        oEncFile.Write sDest 
        oEncFile.Close 
    Next 
    WScript.quit

I use a software 'exescript' to convert to exe. Seems to work OK for me...