Hi
The best way to check is follow the procedure
Open RZ11 -> sapgui/user_scripting = TRUE ( Current value )
sapgui/user_scripting_disable_recording = FALSE.
logoff and logon again
The problem will be solved.
Regards
Piroz
Hi
The best way to check is follow the procedure
Open RZ11 -> sapgui/user_scripting = TRUE ( Current value )
sapgui/user_scripting_disable_recording = FALSE.
logoff and logon again
The problem will be solved.
Regards
Piroz
Hi,
Thanks for the Suggestions.
By the way is it possible to use the same function for multiple files.
Because for me the task is, each Numbers needs to be attached with the unique appropriate Attachment.
Am placing the Numbers in A column and File path in B column in excel and am trying to execute the program with similar modifications.
Can you please provide some suggestion?
Have a Nice Day!
Thanks in Advance,
Krishna E S
Hi guys!
I am currently developing a macro tool wherein I can export the attachment of a document using FB03 and saving it in a specific folder.
I was able to create one but I have the following problem:
> I don't know why there is an error with the path of the file whenever I try to link specific paths to a cell from my excel. But when I input the path directly to the VBA, it works. (hope this question was clear. )
> I am a VBA beginner so I would like to loop this macro and I want it to perform the export for a list of documents and not just one.
> Is it possible for me to insert the exported file into the excel sheet next to the document number?
Hope I was clear with what intend to do...Please help.
THANK YOU SO MUCH!!
Below are the details that I have in my Excel sheet
A | B | C | ||
1 | Destination File | C:\Users\LIX2628\Desktop\PUll outs export\ | ||
2 | Document Number | Co. Code | Year | |
1200072996 | u001 | 2014 |
And below is the script that I used.
Sub FB03export()
Dim application
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
session.findById("wnd[0]").resizeWorkingPane 196, 15, False
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Cells(3, 2).Value
session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Cells(3, 3).Value
session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Cells(3, 4).Value
session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus
session.findById("wnd[0]/usr/txtRF05L-GJAHR").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").currentCellColumn = "BITM_DESCR"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%BDS_START_BDN"
session.findById("wnd[0]/shellcont[1]/shell").selectedNode = "Doc-00000001"
session.findById("wnd[0]/mbar/menu[0]/menu[6]").Select
session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").Text = "C:\Users\LIX2628\Desktop\PUll outs export\"
session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").caretPosition = 42
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[1]/tbar[0]/btn[12]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
End Sub
Dear Script Man and Ullah
I'm with this problem too. We're running some reports every hour and sometimes the SAP Gui crashes without connection issues or something like that. Do you know how to solve this problem?
SAP GUI 730 Final Release with patch 7 - Windows 7 SP 1.
Hi Guys,
I'm having troubles when I try to execute the script below. The first input works fine, but the loop does not.
Somebody has a clue what is wrong on the code listed below?
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
Dim ApplicationPath, CredentialsPath, ServerPath, FilePath
Dim ExcelApp, ExcelWorkbook, ExcelSheet, Row
Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWorkbook = ExcelApp.Workbooks.Open("C:\temp\Excel_File.xls")
Set ExcelSheet = ExcelWorkbook.Worksheets(1)
Row = 1
Do Until ExcelSheet.Cells(Row,1).Value = ""
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "mysaplogin"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "*******"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "fd32"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkRF02L-D0210").selected = true
session.findById("wnd[0]/usr/ctxtRF02L-KUNNR").text = ExcelSheet.Cells(Row,1).Value
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").text = ExcelSheet.Cells(Row,2).Value
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").setFocus
session.findById("wnd[0]/usr/ctxtRF02L-KKBER").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/mbar/menu[0]/menu[5]/menu[1]").select
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
Row=Row+1
Loop
ExcelApp.Quit
Set ExcelApp = Nothing
Set ExcelWorkbook = Nothing
Set ExcelSheet = Nothing
Hi Douglas,
you could try the following:
. . .
Row = 1
'Do Until ExcelSheet.Cells(Row,1).Value = ""
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "mysaplogin"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "*******"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").setFocus
session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
Do Until ExcelSheet.Cells(Row,1).Value = ""
session.findById("wnd[0]/tbar[0]/okcd").text = "fd32"
session.findById("wnd[0]").sendVKey 0
. . .
Regards,
ScriptMan
Could anyone reply to this post if you have any answer or please confirm that it is not possible to get the script for above query?
Dear Script Man,
Thank you so much for sharing your knowledge about SAP GUI script. I wonder if we can connect to develop some business applications that has some commercial values. There is currently a need in our company to do something like this - needs some more refinement. It can save a lot of time for a lot of SAP users.
If you are interested, please drop me an email note, Kevinwu64@yahoo.com
Look forward to work with you,
Kevin
I HAVE AN QUESTION HOW WE CAN AUTOMATE TO RUN ONE T-CODE WITH MULTIPLE VARIANTS ONE EACH AND EXPORT IT INTO SEPARATE EXCEL FILE.(ALL VARIANT SHOULD BE RUN PARALLELY, MAX:6)
Good day!
I need a help please .
How do i get the current year, keep in a variable and then write in a text field ?
Thanks!
Sorry, missed some information.
It is the Screen Personas using javascript.
Thanks.
Hi,
Please check in C:\Program Files (x86)\SAP\FrontEnd\SAPgui
if the file Guixt.exe dose not exists there this is the reason for this error
in this case you need to reinstall SAP GUI and include in the installation the guixt.dll and guixt.exe fies
Regards,
M
Hi Sayuti,
I'm very interested in knowing if you did accomplish the upload through the services for object Dialog box.
I would also want to know if you could share some of the code to guide myself. Cause i dont yet know how to do several of the steps on the comment above.
Please let me know!
Thanks!
Rodolfo
Dear Krishna,
Yes, it is possible using a loop procedure. However, depending on the size of your file and the speed of the connection to the SAP server, the script will be very prone to error.
I've not done any stress test on my codes since the project was halted a year ago due to a major re-org in my organization.
Sorry cant be of much help.
Regards,
Sayuti
Dear Rodolfo,
My organization had a major re-org in the end of 2013 and I was unable to really complete my project. The file upload procedure work, but I never properly integrate it to the rest of my project as it was shelved.
For Step 1:
I put the following codes in a range in Excel sheet named 'myCache' and named the range 'myVBS'.
Set Wshell = CreateObject("WScript.Shell") |
fileAdd = WScript.Arguments(0) |
Do |
bWindowFound = Wshell.AppActivate("Import file") |
WScript.Sleep 1000 |
Loop Until bWindowFound |
bWindowFound = Wshell.AppActivate("Import file") |
If (bWindowFound) Then |
Wshell.appActivate "Import file" |
Wshell.Sendkeys "{tab}{tab}{tab}{tab}{tab}" |
Wshell.Sendkeys fileAdd |
Wshell.Sendkeys "{ENTER}" |
End If |
I used the following subroutine to generate the the VBS file 'attach.vbs' whenever an upload is required.
Sub createVBS()
Dim rng As Range
Dim myVBS As String
myVBS = ThisWorkbook.Path & "\attach.vbs"
Open myVBS For Output As #1
For Each rng In myCache.Range("myVBS")
Print #1, rng
Next rng
Close #1
End Sub
For Step 2 & 3:
I created two subroutines, one to shell the VBS and another to open the import file dialog box. These two subroutines will be called by another subroutine.
Do note that sap_IW22 is subroutine that check connection and open sessions for a specific IW22 (Change PM Notification) transaction in SAP. If the session does not exist, it will execute the transaction. I also used custom class module mySAP for connection and session handling.
Sub runVBS(fileFullPath As String)
Dim scr As String
Dim myFile As String
myFile = Chr(34) & fileFullPath & Chr(34)
scr = Chr(34) & ThisWorkbook.Path & "\attach.vbs" & Chr(34) & " " & myFile
Shell "wscript " & scr
End Sub
Sub sap_IW22_Upload(myNotification As String)
sap_IW22 (myNotification)
mySAP.SAPSession.FindById("wnd[0]/titl/shellcont/shell").PressContextButton "%GOS_TOOLBOX"
mySAP.SAPSession.FindById("wnd[0]/titl/shellcont/shell").SelectContextMenuItem "%GOS_PCATTA_CREA"
End Sub
'The following is the subroutine to call both the above subroutines.
Sub uploadFile(ByVal filetoupload As String, ByVal myNotification As String)
runVBS (filetoupload)
sap_IW22_Upload (myNotification)
End Sub
'To upload, you can call the uploadFile subroutine as per following example:
Sub testUpload()
Call uploadFile("c:\test.txt", "23011119")
End Sub
For multiple files, try looping this subroutines.
For Step 4:
Sub deleteVBS()
Dim myVBS As String
myVBS = ThisWorkbook.Path & "\attach.vbs"
If Dir(myVBS) = "attach.vbs" Then
Kill myVBS
Else
MsgBox myVBS & " not found", vbExclamation, "File Don't Exist"
End If
End Sub
Regards,
Sayuti
Hi guys,
Writing a simple vbs from Excel to perform SAP tasks but having a problem when I want to use the loop variable.
If I'm not in a loop then this works perfectly. Data is stored in variable Enumber and I can work with it.
Enumber = session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK[2,1]").Text
The problem I'm having is when I want to use a loop to check all the rows in the square brackets. For example, when I want to check 10 rows I'd do this ....
For r = 1 to 10
But what format do I need to use to be able to use the r variable for the row number in the square bracket?
I've tried ..
....[2,) & r & (]") but that doesn't work and tried a few other variants too.
Thanks,
Mark
It's ok, I found the answer myself through looking on this forum.
Syntax should be ....
[2," & r & "]").Text
:-)
I Have completed steps 1 & 2 but im having an issue with the "Sub sap_IW22_Upload(myNotification As String)" I tried to conect to my box and run the code untill it just stops and pulls the dialog box. Not sure where the "attach" vbs file comes in. Any help? Now, i im not familiarized with the "mynotification" part, what should i change that for?
*****************Code below*******
Dim SapGuiApp As Object
Dim oConnection As Object
Dim session As Object
Dim SAPCon As Object, SAPSesi As Object
Dim SAPGUIAuto As Object, SAPApp As Object
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If oConnection Is Nothing Then
Set oConnection = SapGuiApp.OpenConnection(" SSO", True)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
End If
With SAPSesi
.FindById("wnd[0]").maximize
.FindById("wnd[0]/tbar[0]/okcd").Text = "/nudm_dispute"
.FindById("wnd[0]").sendVKey 0
.FindById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").selectedNode = " 1"
.FindById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").expandNode " 2"
.FindById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 1"
.FindById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").selectedNode = " 5"
.FindById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell/shellcont[1]/shell").doubleClickNode " 5"
.FindById("wnd[0]/usr/cntlCLFRM_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell/shellcont[0]/shell/shellcont/shell").currentCellColumn = "SEL_ICON2"
.FindById("wnd[0]/usr/cntlCLFRM_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell/shellcont[0]/shell/shellcont/shell").pressButtonCurrentCell
.FindById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,0]").Text = "500001024788"
.FindById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,0]").caretPosition = 12
.FindById("wnd[1]/tbar[0]/btn[8]").press
.FindById("wnd[0]/usr/cntlCLFRM_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell").pressButton "DO_QUERY"
.FindById("wnd[0]/usr/cntlCLFRM_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").doubleClickCurrentCell
.FindById("wnd[0]/titl/shellcont/shell").PressContextButton "%GOS_TOOLBOX"
.FindById("wnd[0]/titl/shellcont/shell").selectContextMenuItemByText "Create...|Store business document"
.FindById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").hierarchyHeaderWidth = 269
.FindById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").selectedNode = "0000000005"
.FindById("wnd[1]/usr/ssubSUB110:SAPLALINK_DRAG_AND_DROP:0110/cntlSPLITTER/shellcont/shellcont/shell/shellcont[0]/shell").doubleClickNode "0000000005"
End With
End Sub
Hi everyone.
I need help .
I'm trying to run a complet list from SAP automatically.
But I'm stuck in the option
List/Export/Spreadsheet.
I need the code for write in the windows popup Save As (from VBS script)
I'm trying save like .MHTML because my other file was created with this type of file.
I'm running the Script Recording option, but is not recording the name placed .
The IW22 is the transaction in which I need the file to be uploaded. The variable mynotification is to take the IW22 Notification number as argument.
You can disregard this variable.and replace the subroutine SAP_IW22_Upload with your codes above.