Quantcast
Channel: SCN : Unanswered Discussions - Scripting Languages
Viewing all 376 articles
Browse latest View live

Extract data from a Shell container using VBS - S_ALR_87012168

$
0
0

Hello everyone,

 

I'm trying to automate the extraction of informations to excel in some transactions, i was able to do this but im still missing a very important part, in transaction "S_ALR_87012168", i need to find a way to get this information from column Due-Total OI, row (Doc. Type=DG), is there a way to do this??

 

Thanks in advance for your help!!


How to Logon with RFC

$
0
0

Good Day!

 

I want do do a login with RFC SAP.Logoncontrol.1. I dont want to use SSO instead of Username and password.

 

Has anybody expierience with this? i am not sure what to type in the values marked red

 

    Dim oConnection As Connection

    Set oConnection = oLogonControl.NewConnection

   

    With oConnection

        .ApplicationServer = "pkgps50d.os.fth.sbs.de"

        .Client = 470

        .SystemNumber = 46

        .System = "PS5"

        .SystemID = "PS5"

        .Language = "DE"

        .SNC = True

        .SNCQuality = 9

        .SNCName = ""

        .UseSAPLogonIni = True

        .Logon 0, False

    End With

 

 

Would be appreciated if someone can help me.

 

Max

SAP GUI Script Development tool on Windows 7 and SAP GUI 7.30

$
0
0

Hi members,

 

I have the following question pertaining to the standard SAP GUI Script development tool. I hope someone has hit this already and can provide an answer.

 

Is there a way to enable the SAP Script Development tool (the Merlin character which allows you to do click tests and examine GUI properties and SAP transaction) if you run SAP GUI for Windows 7.30 and Windows 7?

 

I did my homework and searched the SCN. I already know about:

  • Microsoft KB 969168 Microsoft Agent-enabled programs do not work in Windows 7; I installed the hotfix on my Win 7 computer, but it does not help
  • SAP Note 1633639 - Script Development Tool disabled from Windows 7; give you a background of the issue but refers to SAP GUI 7.20
  • I know about Scripting Tracker Lite and Bebo, both tools made and promoted by Stefan Schnell; I use them but switching back and forth between 2 apps is not optimal. Also you have to rescan all the active connections when you change the screen and this takes time if you run 6 connections/ Still good they exist.

 

I did not find any info for Windows 7 and SAP GUI 7.30

Thanks a bunch.

failed to connect to sap using php

$
0
0

In intranet it was connecting .. When I tried to connect to the client server the following error..

 

 

Failed to connect to the SAP serverRFC Error Info : Key : RFC_IO5 Status : RFC DRV=??? ??? Message : >>> RfcOpenEx ... Got following connect_param string: ASHOST=[ipaddress] SYSNR=01 CLIENT=100 USER=IMP_SLCM PASSWD=******* CODEPAGE=1100 <<< RfcOpenEx failed Internal: IO HANDLE=1 DRV=??? LINE=1068 CODE=5

 

 

Can any one help me on this .. thanks in advance..

Copy-Paste dates from Excel in SAP script

$
0
0

Hello,

 

I did a script in SAP. It goes in an Excel file to copy delivery dates and goes and paste them in a purchase order.

The date format in Excel is the same one as in SAP (YYYY/MM/DD), except that the script pastes the date format shown in the toolbar only (YYYY-MM-DD). Which is different and blocks the script.

date.gif

I know you can change the regional settings of the computer, but to get YYYY/MM/DD I need to put it to English South Africa which is not good because it changes other settings. I can also change the date format in SAP to make it match to my Excel file, but this is not good either because the people using this script will have a date format in SAP different then the other users and will cause confusion.

 

Is there a way for the SAP script to copy-paste the date format in the cell 2014/01/16 and not the 2014-01-16?

 

 

Patricia

How to grab the value of an RC return on stms table?

$
0
0

I have to do a massive amount of transports in order from sap gui becouse of the athorization level i got on my company.

i've been using sapgui script to do some simple tasks like adding roles or adding a massive amount of transport request to the stack.

 

Now i want to make a script that transports some orders one by one in order but only after the previus one is over and the RC=0.

 

for that I'm planing on readign the icon on the third column to know if its green to proceed.

i've tried to get the value as a text like this:

 

session.findById("wnd[0]/usr/lbl[24,6]").text

 

but it doenst return any text.

 

Do you know how can i get the icon or the tooltip value that apears when i drag the mouse over the icon as a text?

 

I would really apreciate your help.

Input from Excel to SAP - make cycle.

$
0
0

Hi masters.

Could someone help me with my different problem...again?

now Im working in trscn QM02. Excel create numbers of lines and add part number, then it fills long text of each part number... Script looks like this:

 

                                                                
                                                               
                                                               
                                       

Private Sub ITEMS_Click()

Dim App, Connection, session As Object

Set SapGuiAuto = GetObject("SAPGUI")

Set App = SapGuiAuto.GetScriptingEngine

Set Connection = App.Children(0)

Set session = Connection.Children(0)

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").Text = "qm02"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtRIWO00-QMNUM").Text = Range("L37").Value

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10").Select

 

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/ctxtVIQMFE-BAUTL[9,0]").SetFocus

Application.Wait DateAdd("s", 1, Now)

Range("C2:C25").Copy   '''''''''Add part numbers...thats ok

SendKeys "^v", True

Application.Wait DateAdd("s", 1, Now)

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/txtVIQMFE-POSNR[0,0]").SetFocus

Application.Wait DateAdd("s", 1, Now)

Range("Q2:Q25").Copy '''''''''Add numbers of lines...thats ok

SendKeys "^v", True

Application.Wait DateAdd("s", 1, Now)

SendKeys "{ENTER}", True

 

'' Now it opens first line long text and insert the value of copied cell.

 

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/btnQMICON-LTFEHLER[8,0]").SetFocus

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/btnQMICON-LTFEHLER[8,0]").press

Application.Wait DateAdd("s", 1 / 3, Now)

Range("G2").Copy

SendKeys "{PGDN}"

Application.Wait DateAdd("s", 1, Now)

SendKeys "^v", True

Application.Wait DateAdd("s", 1 / 3, Now)

session.findById("wnd[0]/tbar[0]/btn[3]").press   

 

''First Long text is filled. Now I have the same script but it focus on second row/line long text in sap and takes value from next cell in excel:

 

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/btnQMICON-LTFEHLER[8,1]").SetFocus

session.findById("wnd[0]/usr/tabsTAB_GROUP_10/tabp10\TAB10/ssubSUB_GROUP_10:SAPLIQS0:7210/tabsTAB_GROUP_20/tabp20\TAB01/ssubSUB_GROUP_20:SAPLIQS0:7110/tblSAPLIQS0POSITION_VIEWER/btnQMICON-LTFEHLER[8,1]").press

Application.Wait DateAdd("s", 1 / 3, Now)

Range("G3").Copy

SendKeys "{PGDN}"

Application.Wait DateAdd("s", 1, Now)

SendKeys "^v", True

Application.Wait DateAdd("s", 1 / 3, Now)

session.findById("wnd[0]/tbar[0]/btn[3]").press

.......

""And so on 24times...

 

End Sub

 

 

So is there a way how to make a loop in SAP, when I have for example 5 part numbers to have just one of this block - something like i, For and Loop function in excel? Its working now but there is error when it comes to row/line in SAP where it isnt long text (which is created by entering a number of line and adding PN, so 6th line in this case). Using error handler I jump to another command to save the inserted values in SAP and everything is OK, but I find it extremely unpractical, loooong and unsafe due other errors that may occur.

 

If there is a thread with this problem I will be pleased to just link me there or explain here.

And as usual thanks in advance for your effort and time.

How to connect Access VBA with a customer specific function module using RFC

$
0
0

Hello,

 

I try to fetch some data from our SAP ERP system by using a customer specific function module.

The connection via RFC is working. Unfortunately, after trying to add the SAP function module to the connection, the result is still nothing.

 

I have a VBA function for the connection. The return value of this function is the working connectin to SAP system.

 

Private Function sapConnect() As Object
'---------------------------------------------------------------------------------------
' Procedure : sapConnect
' Author    : Steffen Retz
' Date      : 22.11.2013
' Purpose   :
'---------------------------------------------------------------------------------------
'
Dim sapConnection   As Object
Dim sapFunction     As Object
Dim RetVal          As Variant
Dim ME5             As Variant
Dim strSAP_System   As String   On Error GoTo sapConnect_Error
'Set sapConnect = False
Set sapFunction = CreateObject("SAP.Functions")
Set sapConnection = sapFunction.Connection
With sapConnection    .ApplicationServer = "xx.xxx.xx.xx"    .SystemNumber = xxx    .System = "xxx"    .client = "xxx"    .Language = "EN"    .User = m_strcUserName 'InputBox("Please insert your SAP user name", "SAP Connection: User")    '.Password = InputBox("Please insert you SAP password", "SAP Connection: Password")    RetVal = SysCmd(acSysCmdSetStatus, "Connecting to " & strSAP_System & " . . . ")           If .logon(0, True) <> True Then        If .logon(0, False) <> True Then            'No connection -> Error            .LastError             Exit Function        End If               Set sapConnect = sapFunction    End If   
End With
sapConnect_Exit:    On Error Resume Next    Exit Function   
sapConnect_Error:    Err.Number = vbObjectError + 1    Err.Source = m_strcClassName    Err.Description = "Error" & " <<>> " & Err.Description    LogError Err, Critical, "sapConnect"    GoTo sapConnect_Exit      On Error GoTo 0
End Function

 

The other function is using the returning connection to retrieve the data from the SAP system.

After adding the function module to the connection, I recognized that the object MyFunc is still empty.

 

Set MyFunc = R3.Add("Z_ZZMHP_HR_SAP_NOTES_READ")

 

I also tried this with RFC_READ_TABLE and BAPI_USER_GETLIST. Both functions are working.

 

 

Private Function RFC_SAP_NOTES_READ(sapConnection As Object, arrSAPNotes As Variant) As Boolean
'---------------------------------------------------------------------------------------
' Procedure : RFC_SAP_NOTES_READ
' Author    : Steffen Retz
' Date      : 03.12.2013
' Purpose   : FM in SAP: Z_ZZMHP_HR_SAP_NOTES_READ
'---------------------------------------------------------------------------------------
'
Dim strTemp As String
Dim RetVal As Variant, nSecondsLeft As Long, nTotalSeconds As Long
Dim R3, MyFunc, App As Object
Dim j As Integer
' Define the objects to hold IMPORT parameters
Dim IT_SAP_NOTES_KEY As Object
' Define the objects to hold the EXPORT parameters
Dim ZZMHP_TT_HR_SAP_NOTES_ERRORMSG As Object
Dim ET_SAP_NOTES As Object
' Use to write out results
Dim ROW As Object
Dim Result As Boolean
Dim iRow, iColumn, iStart, iStartRow, iField, iLength As Integer   On Error GoTo RFC_SAP_NOTES_READ_Error
If sapConnection Is Nothing Then    Set R3 = sapConnect
Else    Set R3 = sapConnection
End If
'*****************************************************
'Call RFC function Z_ZZMHP_HR_SAP_NOTES_READ
'*****************************************************
Set MyFunc = R3.Add("Z_ZZMHP_HR_SAP_NOTES_READ")
'EXPORTS
Set IT_SAP_NOTES_KEY = MyFunc.exports("IT_SAP_NOTE_KEY")
IT_SAP_NOTES_KEY.Value = arrSAPNotes
'IMPORTS
Set ZZMHP_TT_HR_SAP_NOTES_ERRORMSG = MyFunc.imports("ZZMHP_TT_HR_SAP_NOTES_ERRORMSG")
Set ET_SAP_NOTES = MyFunc.imports("ET_SAP_NOTES")
RetVal = SysCmd(acSysCmdSetStatus, "Extracting " & j & " . . . ")
MyFunc.Call
' Result = MyFunc.Call
' If Result = True Then
'     Set DATA = MyFunc.Tables("DATA")
'     Set FIELDS = MyFunc.Tables("FIELDS")
'     Set OPTIONS = MyFunc.Tables("OPTIONS")
' Else
'     MsgBox MyFunc.EXCEPTION
'     R3.Connection.LOGOFF
'     Exit Function
' End If     
Close #2
RetVal = SysCmd(acSysCmdRemoveMeter)
RFC_SAP_NOTES_READ = True
RFC_SAP_NOTES_READ_Exit:    On Error Resume Next    Exit Function   
RFC_SAP_NOTES_READ_Error:    RFC_SAP_NOTES_READ = False    Err.Number = vbObjectError + 1    Err.Source = m_strcClassName    Err.Description = "Error" & " <<>> " & Err.Description    Debug.Print Err.Description    LogError Err, Critical, "RFC_READ_TABLE"    GoTo RFC_SAP_NOTES_READ_Exit      On Error GoTo 0
End Function

I can't find the error. Do I have to use a specific method for a customer specific fuction module?

Or is it not possible to use a customer specific function module?

 

Thanks for any help.

 

Best regards,

 

Steffen


VB Script: check for existing open session

$
0
0

I use the code below often.  It is part of many automated processes I call from some function modules in Access as a step in a macro.  As the code is written now, it kills any existing connection or session and logs me in and runs whatever procedures I have.  The problem with this is I also work in SAP throughout the day and my automated script kicks me out periodically.  I can have up to 5 sessions open at once.  I have no clue how to make the script below do the following:

1. First, check if an open session exists.

2. If a session exists, open a new one.

3. If 5 open sessions exist, pause and generate a message box alerting me that "5 sessions already exist"

 

 

Function GrabOrdersToday()

 

Dim Application As Variant

 

Set SapGuiAuto = GetObject("SAPGUI")

     Set Application = SapGuiAuto.GetScriptingEngine

     Set Connection = Application.OpenConnection("PRD")

     Set SapSession = Connection.Children(0)

 

If IsObject(WScript) Then

     WScript.ConnectObject SapSession, "on"

     WScript.ConnectObject Application, "on"

End If

 

SapSession.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "myuserid"

SapSession.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "mypassword"

SapSession.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus

SapSession.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8

SapSession.findById("wnd[0]").sendVKey 0

 

'In case you are already logged in...

If SapSession.Children.Count > 1 Then

     SapSession.findById("wnd[1]/usr/radMULTI_LOGON_OPT1").Select

     SapSession.findById("wnd[1]/usr/radMULTI_LOGON_OPT1").SetFocus

     SapSession.findById("wnd[1]/tbar[0]/btn[0]").press

End If

 

...and then my actual script starts here where I run transactions or whatever I need.  I picked up this code a long time ago and it looks like it has some sort of If statement that is supposed to check for a login, but it doesn't.  Every time this code runs, it kills the existing session and logs me into SAP all over again.  I only want it to log me into SAP if no current session exists.  Thanks in advance for any help!

Gathering MHTML reports

$
0
0

Dear All,

 

At the moment I am using SAP P12.

From T-code IW33 I am trying to gather data from MHTML.

I have tried to follow some scripts which looked fantastic, but just weren't able to apply to what I use.

The below is as far as I got.

 

 

 

Sub GetPlanCostData()
'---------------------------------
  '---------------------------------
' Parameters


'---------------------------------
   '-------- SAP LOGIN --------------
   '---------------------------------


    'If Right(CLPdirName, 1) <> "\" Then CLPdirName = CLPdirName & "\"

    On Error Resume Next

    If SAPApp Is Nothing Then
        Set SapGuiApp = GetObject("SAPGUI")
        Set SAPApp = SapGuiApp.GetScriptingEngine
       ' If SAPApp Is Nothing Then GoTo Exit_AllReport
    End If
    If Connection Is Nothing Then
        Set Connection = SAPApp.Children(0)
    End If
    If session Is Nothing Then
        Set session = Connection.Children(0)
    End If


    If Err = 0 Then flgSapIsOpen = True
    Err.Clear
   
    On Error GoTo 0

    If flgSapIsOpen = False Then
        Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
        Set Connection = SapGuiApp.OpenConnection(CLPsapName, True, False)
      '  If Connection Is Nothing Then GoTo Exit_AllReport
   '?     Set session = Connection.Children(0)

        If Not IsObject(Connection) Then
            Set Connection = SAPApp.Children(0)
        End If
        If Not IsObject(session) Then
            Set session = Connection.Children(0)
        End If

    End If

'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

'Start Processing in SAP
i = 2

Do While Cells(i, 1) <> ""


SO = Cells(i, 1)


session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/niw33"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").Text = SO
session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").caretPosition = 7
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/tabsTS_1100/tabpKOAU").Select
session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1107/tabsTS_1100/tabpKOAU/ssubSUB_AUFTRAG:SAPLICO1:1100/btnPUSH1").press
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press

 

i = i + 1
Loop

End Sub

 

 

 

I am very new to this, and I wanted to make something similar to what I was given some time ago.

Different t-code but gathers information I need.

 

Sub GetPlanCostData()
'---------------------------------
  '---------------------------------
' Parameters
FilePath = "C:\cemacro\"
'Sheets.Add.Name = "RESULTS"


' Clearthe folder
On Error Resume Next
    Kill "C:\cemacro\*.xls"
   On Error GoTo 0
On Error Resume Next
Kill "C:\cemacro\*.dat"
On Error GoTo 0

'---------------------------------
   '-------- SAP LOGIN --------------
   '---------------------------------
               
     Para_check = True
 
    CLPsapName = ActiveSheet.Range("F29").Value
    CLPuserid = ActiveSheet.Range("F30").Value
    CLPpasswd = ActiveSheet.Range("F31").Value
    'CLPdirName = ActiveSheet.Range("C5").Value
    CLPrptName = "Worksheet in Basis (1)"

    'If Right(CLPdirName, 1) <> "\" Then CLPdirName = CLPdirName & "\"

    On Error Resume Next

    If SAPApp Is Nothing Then
        Set SapGuiApp = GetObject("SAPGUI")
        Set SAPApp = SapGuiApp.GetScriptingEngine
       ' If SAPApp Is Nothing Then GoTo Exit_AllReport
    End If
    If Connection Is Nothing Then
        Set Connection = SAPApp.Children(0)
    End If
    If session Is Nothing Then
        Set session = Connection.Children(0)
    End If


    If Err = 0 Then flgSapIsOpen = True
    Err.Clear
   
    On Error GoTo 0

    If flgSapIsOpen = False Then
        Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
        Set Connection = SapGuiApp.OpenConnection(CLPsapName, True, False)
      '  If Connection Is Nothing Then GoTo Exit_AllReport
   '?     Set session = Connection.Children(0)

        If Not IsObject(Connection) Then
            Set Connection = SAPApp.Children(0)
        End If
        If Not IsObject(session) Then
            Set session = Connection.Children(0)
        End If

     

    End If

'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
'==============================================
'Clear out the status field in B-column
i = 2
Do While Cells(i, 1) <> ""
i = i + 1
Cells(i, 2) = ""
Loop

'==============================================

'Start Processing in SAP
i = 2

Do While Cells(i, 1) <> ""


WBS = Cells(i, 1)

session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/ns_alr_87013542"
session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]").maximize

' Blank fields in screen
session.findById("wnd[0]/usr/ctxtCN_PROJN-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtCN_PROJN-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxtCN_VBELN-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtCN_VBELN-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxtCN_PSPNR-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxtCN_NETNR-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtCN_NETNR-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxtCN_ACTVT-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtCN_ACTVT-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxtCN_MATNR-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtCN_MATNR-HIGH").Text = ""
session.findById("wnd[0]/usr/ctxt$6-KOKRS").Text = "1000"
session.findById("wnd[0]/usr/ctxt$6-VERP").Text = "0"
session.findById("wnd[0]/usr/txt$6-GJAHV").Text = "2000"
session.findById("wnd[0]/usr/txt$6-GJAHB").Text = "2100"
session.findById("wnd[0]/usr/ctxt$6-PERBV").Text = "1"
session.findById("wnd[0]/usr/ctxt$6-PERBB").Text = "12"
session.findById("wnd[0]/usr/ctxt$6-KSTAR").Text = ""


session.findById("wnd[0]/usr/ctxtCN_PSPNR-LOW").Text = WBS
session.findById("wnd[0]/usr/ctxt_6-KSTAR-LOW").Text = "400000"
session.findById("wnd[0]/usr/ctxt_6-KSTAR-HIGH").Text = "920000"

session.findById("wnd[0]/tbar[1]/btn[8]").press

 

If session.findById("wnd[0]/sbar").Text = "Report 6PP1-001 does not contain any data pages." Then
' This means no Actual Cost, no Commitment and no Plan Cost exist.
Cells(i, 2) = "No Actual Cost, no Commitment and no Plan Cost exist"
session.findById("wnd[0]/tbar[0]/btn[3]").press


Else 'If data exist for the WBS in S_ALR, then save it into a file

'session.findById("wnd[0]/shellcont/shell/shellcont[2]/shell").hierarchyHeaderWidth = 232 ' Clear?
session.findById("wnd[0]/mbar/menu[0]/menu[3]").Select
session.findById("wnd[1]/usr/radLGRWO-X_EXPONLY1").Select
session.findById("wnd[1]/usr/ctxtLGRWO-OUT_FILE").Text = FilePath & WBS & ".dat"
session.findById("wnd[1]/usr/radLGRWO-X_EXPONLY1").SetFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[2]/usr/btnSPOP-VAROPTION2").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[1]/usr/btnBUTTON_YES").press



End If  'End If for checking if data exist for the WBS in S_ALR

i = i + 1
Loop



' Parameters
'FilePath = Cells(2, 3)
'Sheets.Add.Name = "RESULTS"

'------------------  Read the files
AddTime = Format(Now(), "yyyymmddhhmmss")
SheetName = "RESULTS" & AddTime

Sheets.Add.Name = SheetName
Sheets("Macro2").Activate
i = 2


k = 2
'================Start reading data files
'For each WBS in column A in Macro2 sheet
Do While ThisWorkbook.Sheets("Macro2").Cells(i, 1) <> ""
' Check if any datafile exist, by checking status column B in Macro 2 sheet
If ThisWorkbook.Sheets("Macro2").Cells(i, 2) <> "No Actual Cost, no Commitment and no Plan Cost exist" Then

WBS = ThisWorkbook.Sheets("Macro2").Cells(i, 1)

Fil = FilePath & WBS & ".xls"

Name FilePath & WBS & ".dat" As Fil


'Workbooks.Open Filename:=Fil
    Set wbkA = Workbooks.Open(Filename:=Fil)
   
   
    ' Count Rows in WBS file
    j = 2
    Do While Sheets(WBS).Cells(j, 1) <> ""
      j = j + 1
     
    Loop
   
   
    Range_String = "A" & 2 & ":Q" & j
    Range(Range_String).Copy
    ThisWorkbook.Activate
    Sheets(SheetName).Activate
   
    '*** Select the destination cell and copy
    Range_Target = "B" & k
    Range(Range_Target).Select
    ActiveSheet.Paste
    ActiveSheet.Cells(k, 1) = WBS
    
     ' ----- Close WBS file
    Application.DisplayAlerts = False
    wbkA.Activate
    wbkA.Close
    Application.DisplayAlerts = True

k = k + j - 3 ' This variable keep track of printing position
End If ' End if checking the B-column in Macro2 sheet
i = i + 1
Loop

 

RESULT_sheet = SheetName

i = 2

WBS = ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1)

Do While ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 2) <> ""

' Calculate diff between Plan Cost and Assigned cost, if Plan cost is to low, print  mount
If CDec(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 6)) < CDec(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 5)) Then
ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 19) = CDec(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 5)) - CDec(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 6))
End If

 

If Left(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 2), 3) <> "All" Then

If ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1) <> "" Then
WBS = ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1)
End If

If ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1) = "" Then
ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1) = WBS
End If

End If

 

 

 

i = i + 1
Loop
i = i - 1
'Range_String = "A" & i & ":R" & i
'ThisWorkbook.Sheets(RESULT_sheet).Range(Range_String) = ""
'ThisWorkbook.Sheets(RESULT_sheet).Range(Range_String).Delete

'Cells(Range_String) = ""
Range_String = i & ":" & i

Rows(Range_String).Select
Selection.Delete Shift:=xlUp


Columns("G:R").Select
Selection.Delete Shift:=xlToLeft

ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 1) = "WBS"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 2) = "Cost Element"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 3) = "Actual Cost"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 4) = "Commitments"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 5) = "Assigned Cost"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 6) = "Plan Cost"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 7) = "Adjustment needed"

ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 8) = "Description"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 9) = "Amount"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 10) = "Curr"
ThisWorkbook.Sheets(RESULT_sheet).Cells(1, 11) = "CE"

 


'==== Create PRIM

i = 2
WBSold = ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1)


Do While ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1) <> ""

WBS = ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 1)

'Mark cells for each new WBS to make more easy to read
If WBS <> WBSold Then
RangeBoarder = "A" & i & ":K" & i
Range(RangeBoarder).Borders(xlEdgeTop).LineStyle = xlDash
End If

 

CE = Left(ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 2), 6)

' If external cost adjustment needed, then pepare PRIM
If Left(CE, 1) = "4" And ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 7) <> "" Then

TodayDate = Format(Now(), "yyyymmdd")

ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 8) = "PRIM " & CE & " Plan Cost Adjustment"
ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 9) = ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 7)
ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 10) = "KRW"
ThisWorkbook.Sheets(RESULT_sheet).Cells(i, 11) = CE

End If

WBSold = WBS
i = i + 1
Loop

      
' Resizing columne
Columns("A").ColumnWidth = 18.15
Columns("B").ColumnWidth = 38
Columns("C").ColumnWidth = 10
Columns("D").ColumnWidth = 11.9
Columns("E").ColumnWidth = 12.6
Columns("F").ColumnWidth = 12.6
Columns("G").ColumnWidth = 16.6
Columns("H").ColumnWidth = 29.5
Columns("I").ColumnWidth = 8
Columns("J").ColumnWidth = 3.71
Columns("K").ColumnWidth = 6
               


End Sub

 

 

 

However, I am nowhere near gathering all that excel data.

Your help will be very very much appreciated!!

 

BR,

Cathy

Excel VB Code for getting the warning Icon text / Colour

$
0
0

Hi,

 

Could anyone please help me to get the the warning / error icon color or text ?

 

Capture.PNG

 

I'm using the following code to assign the text or color to a variable which is not working.

 

WarningMessageText = session.findById("wnd[0]/usr/ssubSUBSCR_1200:SAPLCMFV:1200/tblSAPLCMFVT_MKAL/lblMKAL_AMPEL_X[8,0]").text

 

 

Thanks,

Ram

How to Create Script Mass User Login & Doing Transaction

$
0
0

Hi SAP Experts,

 

I have a activity to do performance test with 100 concurrent users.

But unfortunately i have no supplement PT software for this activity (Like Rational PT or Loadrunner).

So i think i will do it with sapgui script.

Is it possible to create vb script (SAP GUI Scripting) to fulfill my requirement to do this activity. If yes how to create this script.

 

Thanks & Best Regards,

Husin

SAP GUI Appearance Changes After VBScript Manipulation

$
0
0


I can't seem to find any posts on this issue in the forum; perhaps someone out there knows how to fix this via VBScript.

 

I have an Excel macro that manipulates SAP via embedded VBScript. The script was recorded using the SAP Script recorder.  After the code has run, the GUI appearance for popups (session.findById("wnd[1]) forms and subsequent forms look different and less user-friendly. The original session.findById("wnd[0] appearance seems unaffected and looks fine.  Is there a way to ensure that the original, default appearance for session.findById("wnd[1] is maintained after manipulating SAP via VBScript?  The only way I found so far is to log out of the SAP GUI

 

Example:

 

After drilling down to find a WBS code by clicking the drop down icon indicated below:

 

PopUpVBS.png

 

The subforms (popups - session.findById("wnd[1]) look like the screenshots below (before and after):

 

Before Running Script (every day user look and feel):

 

BeforeVBS.png

 

After running script:

 

AfterVBS.png

Connect excel 2010 64 bits with SAP

$
0
0

Hi!

 

I have a macro in Excel that connects to SAP.

With Office 32 bits and Windows 7 64bits works perfectly.

With Office 2010 64bits it returns the error '429' An ActiveX component cannot create the object.

 

 

I've tried to register libsvr32.dll and copy it to system32 directory but nothing works.

 

The error appears at line

 

  Set R3 = CreateObject("SAP.Functions")

 

I think there's some incompatibility between office 64 bits and SAP but I'm no really sure.

 

Could I use another method to connect SAP instead of libsvrc32.dll?

 

Help will be appreciated!

 

Thanks!

GuiXT Copytext or VBScript - not allowing to paste values to multiple selection

$
0
0

Hello Guru's of Scripting.

We have a requirement to download inspection lot information for 4500+ plants using transaction QA33. We cannot use all plants at a time to get result output. I would like to run this report in parts. example: 20 plants at a time.

QA33 screen with plant selection:

2-19-2014 9-17-06 AM.jpg

Multiple selection for plant:

2-19-2014 9-18-01 AM.jpg

 

Here is my code so far:

_______________________________________________________________________________________________________________________________**********************************************************************************************************************************************************************************

//Counter

Set V[i] 1

//Input file that contains more than 4500 plants

Parameter mat_file1 "C:\Documents and Settings\Desktop\ip2.txt"

//Intermediate file to copy 20 plants at a time

Parameter mat_file3 "C:\Users\Desktop\myfile.txt"

 

 

//create myfile.txt text file on C:\Users\Desktop\ location before running program

  OpenFile "&U[mat_file3]" -Output

  OpenFile "&U[mat_file1]"

 

 

 

 

 

 

 

label Read_File

  ReadFile "&U[mat_file1]" C

 

 

if not Q[ok]

    CloseFile "&U[mat_file1]"

    CloseFile "&U[mat_file2]"

    CloseFile "&U[mat_file3]"

    Return "Job done!" "&U[mat_file1]"

  endif

 

 

// loops

//1st loop to make sure the total no of records do not exceed 4500

If V[i<4500]

AppendFile "&U[mat_file3]" C

Set V[i] "&V[i]" + 1

//Checking to make sure we append only 20 plants at a time.

//These 20 plants are added to myfile.txt

if V[i=21]

//myfile has 20 file it goes to transaction qa33 screen

Goto next_step

endif

goto Read_File

endif

 

 

 

 

 

 

label next_step

 

 

//Deletes default values from selection fields

Set F[%_QL_ENSTD_%_APP_%-TEXT] ""

Set F[%_QL_ENSTD_%_APP_%-TO_TEXT] ""

Set F[Plant] ""

Set F[Maximum No. of Hits] ""

 

 

 

 

// Inspection Lot Selection

Screen RQEEAL10.1000

//Clicked on multiple selection button

  Enter "=%043"       // Multiple selection.6

 

 

 

// Multiple Selection for Order

 

 

Screen SAPLALDB.3000

//This is equivalent to clicking on delete button from multiple selection

Enter "/16" //delete contents

 

 

// Multiple Selection for Plant

 

 

Screen SAPLALDB.3000

 

//Copy 20 plants from myfile to text t1

Copytext fromFile="&U[mat_file3]" toText="t1"

//Copy those 20 plants from t1 to clipboard

Copytext fromText="t1" -toclipboard

//Next step is to click on paste icon on dynamic selection

Enter "/24" //copy from clipboard

 

 

// Multiple Selection for Material

Screen SAPLALDB.3000

  Enter "/8"

 

 

// Inspection Lot Selection

Screen RQEEAL10.1000

  Enter "/8"       // Execute

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSLVC_FULLSCREEN.0500

  Enter "/Menu=1,4,3"       // Local file...

 

// Save list in file...

Screen SAPLSPO5.0110

  Set R[Spreadsheet] "X"

  Enter

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSFES.0200

  Set F[DY_PATH] "C:\Users\Desktop"

  Set F[DY_FILENAME] "temp.txt"

  Enter "/7"       // Extend

 

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSLVC_FULLSCREEN.0500

  Enter "/3"

 

 

Set V[i] 1

//OpenFile "&U[mat_file3]" -Output

Set V[t2] ""

Copytext fromText="t2" toFile="C:\Users\Desktop\myfile.txt"

// Display data for inspection lot: Worklist for Inspection Lots

 

 

CloseFile "&U[mat_file3]" -Output

 

 

 

 

 

 

//Screen SAPLSLVC_FULLSCREEN.0500

//  Enter "/nqa33"

goto Read_File

 

******************************************************************************************************************************************************************************____________________________________________________________________________________________________________________________

 

 

 

 

Problem part of the code:

 

Copytext fromFile="&U[mat_file3]" toText="t1"

 

Copytext fromText="t1" -toclipboard

 

Enter "/24" //copy from clipboard


When I debug this code ..I see empty value for t1 or clipboard.

I have tried several Copytext options but no solution so far.

Please help me with this issue.

GuiXT solution OR VBScript but I want it to be able to paste 20 values.

I really appreciate you'r time and effort in this regard.


SAP Krazy




Add informations from Excel to SAP

$
0
0

Hello guys!

 

I'm totaly new in this area, but I'm really excited about it!!

 

I need to export data from Excel to SAP (in a determinated function).

 

As example the sheet:

imagem.JPG

 

I need to fill the Sheet and use the macro that will use the informations that the sheet have in each row and create (for each row) a SAP Number (after this function, if I press enter it will generate a "Request ID") and put it automatically in the SAP ID Colum.

 

Is that even possible?

 

It will help me alot!!

 

I use SAP GUI.

 

Thx!!!!

how to get data from SAP into the excel

$
0
0

Hi all,

 


I need data from SAP to excel using VBA. till now I was able to log into SAP and run the desired transaction I need using excel and VBA now my second biggest Challenge is to export the data I see in SAP into the excel sheet. there are options in SAP to export the data but I need to do it using the VBA. Kindly help me


Please see below the VB code I have written so far, but its just takes me to the data I need but now as I said my second biggest chalange is to get that data from SAP back to Excel.



 

Sub TEST()

'setting the connection with sap:

Dim App, Connection, session As Object

Set SapGuiAuto = GetObject("SAPGUI")

Set App = SapGuiAuto.GetScriptingEngine

Set Connection = App.Children(0)

Set session = Connection.Children(0)

 

 

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").Text = "iw29"

session.findById("wnd[0]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[1]/btn[17]").press

session.findById("wnd[1]/tbar[0]/btn[8]").press

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellColumn = "TEXT"

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "0"

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell

session.findById("wnd[0]/tbar[1]/btn[8]").press

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell -1, ""

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectAll

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").contextMenu

session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItem "&XXL"

session.findById("wnd[1]/tbar[0]/btn[0]").press

 

End Sub




Regards,

Imran

SAPUI5 in NWDI

$
0
0

What sort of SCA dependencies do I need to do UI5 development through NWDI Track.

 

I need to create a track and define dependencies. I know I need the UI5 component. What else do i need?

 

Thank You!
Nitin    

SAP VBScript and the Easy Access Screen

$
0
0

Hello All. I am recording SAP vbScripts and have found that I can't use them unless I am at the Easy Access Screen (the screen you get when you first login to SAP). However, I am not always at the Easy Access Screen when I need to run the script.

 

I've tried creating adding several "Back" (or F3) entries in the script to get to the E.A.S., but sometimes there is a message box which that triggers after pressing the back button and the script errors out. Does anybody know if there is a solution to this?

 

Also, I don't want to record a script going back to the E.A.S. because I could be at any transaction at the time of running the script.

 

Thanks in advance.

SAP GUI Scripting uses wrong Theme

$
0
0

Hi

I'm using SAP GUI Scripting for automating SAP GUI 720 from another application. It's a c# application that uses Interop.SAPFEWSELib. A user marks one or many documents ids in one system, clicks a button and the SAP GUI is opened showing a list of documents in SAP DMS.

This is all working fine but the SAP GUI does not look the same when using the GUI Scripting as when opened the normal way. It does not have the correct theme, SAP Signature Theme. It looks like it is using the Classic Theme. When running under Windows 7 the SAP GUI is even worse. Buttons and tabs are invisible.

Is there some way to change so it uses the SAP Signature Theme or another theme when SAP GUI Scripting is used?

Gunnar

Viewing all 376 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>