This video provides and example of running GUI scripts to export table contents via SE16, or queries via SE38. This data is exported to CSV and loaded to Excel to be manipulated there.
GUI scripting allows external applications like MS Excel to connect to an existing GUI session and execute operations within the GUI. Excel does not hold and authorization and access information as it relies on you logging into SAP first.
This example is in CRM but it can be used in any GUI based SAP system.
Download the Excel file in this example from here: https://drive.google.com/file/d/0Bw1XOPtMPlsNRi1SdDhHTUMwY3c/view?usp=sharing
Playlist of my SAP GUI scripting Youtube playlist: https://www.youtube.com/watch?v=oPPhA14Pm-8&list=PLk9erb9HGsPh28DftWcP8BIXmBtu2wnsL
Hi, I am new to SAP and scripting. I was a little confused of what happened in this video. I am attempting to write a script that takes thousands of product cost reports and store them into a folder, all every report is individually saved as an excel sheet. Would a program such as this help me with that?
That's brilliant. For some reason i am failing to have excel connected to SAP still. it gives an error on the line
If objGui Is Nothing Then
Set SapGuiAuto = GetObject("SAPGUI") ----------->Highlighted in Yellow
Do you think i am putting the system wrongly? At the bottom right it says PE3 (1) 400 and the client is 400. so I have put PE3400 but still giving me this error.
I have also checked and I have added the GUI Scripting in Excel as you instructed. And my SAP GUI Scripting is installed and enabled as well. I am struggling here to be honest and would love your help. thank you
I am confused. PE3400 is the correct setting. If you are getting an error in that line my first guess would have been that you did not add the GUI Scripting in the references, but you did. What does the error message says?
Thank you so much for the video. I am using Excel 2016 and I am unable to run the macro I have "Missing: SAP GUI Scripting API" in the excel References. is there any other way that we can exclude and run the code
Thank you again and again for this great video.. i come back to you sir to ask you if there is a possibility to start a script and continue the same script in another window. I mean, when i will start my script, i want to open a new window in sap and continue my transactions in this window ( and the script is always recording my steps..) Thank you so much sir.
Your videos are of a great help! I just couldn't find the answer on how to select the dates range of the SAP report from Excel's cell. They are firmed in the script, while I would like them to be different every day, without changing them in the code. Does one of your videos explain the solution to that?
In most of my other videos I show how you can pass data from Excel to SAP and even back. So you create a recording in which you run SE16, you specify the object IDs. Record the steps as you paste in the list of Object IDs from the clipboard. In Excel, you can use a VBA code like: Range("A1:A10").Select. This will put the entries between A1 and A10 into the clipboard that you can paste into Excel.
Hello Csongor, thanks for the video, I have one query, i'm trying to extract the data in MHT format but while recording the script this doesn't gets captured, could you help me on this??? this way I'm trying to download the extract (List>>Export>>Spreadsheet [Shift+F4]).
The reason I'm extracting in MHT format is the amount and data comes in proper format but in others its jumbled. please help!
Csongor, I somehow made it to work with a different format... Thank you so much for all your videos which helped me a lot... Please share me your personal mail ID so that if any helped required I can write you a mail...
Csongor, I'm using the tcode: S_ALR_87011964 to get the company codes details, instead of download the file through Local File method, I'm using Spreadsheet method, where i get the HTML format extract. When recording this only the downloading part is not getting captured in the script. Is there a way to solve this ? or I need to use only local file method for extracting the file.
Hi Csongor. Thank you for your well-explained video. I have a question. Why don't we extract the report to Excel directly using the spreadsheet instead of text? Is it easier that we do not have to convert from csv?
Thanks, I am glad you liked the video. Whenever I was using the spreadsheet output in the past I got it in a format that I could not directly load to Excel without doing some manual conversion. Maybe Excel or SAP GUI itself got better in time, but I am just sticking to old habits I guess.
Thanks for the videos again, I already use this for some transacions like ME5A and I use to save the export with spreadsheet, and to open the file I use this way - Workbooks.OpenText Filename:= "C:\temp\myfile.xls"
sorry by poor english
You can call a macro over and over, that is not a big issue. Switching tabs in Excel can also be done programatically. That is not an issue at all. Just need to write some code for it which is probably a bit more than what I can explain here.
I'm getting a compile error "user defined not defined". objGui As GuiApplication is highlighted in the script. I use SAP GUI "EGP 301" so not sure if that's what causing it? however, I did change name from DCG210 to EGP 301" but not change.
yes, I just checked the SAP GUI scripting options under tools/preferences but it still didn't fix it and I also already had "EGP301" without spaces. The error is happening in below line for some reason.
Public objGui As GuiApplication
Hello Csongor, when stepping into your code, should SAP graphic show as running when you W_Ret = Attach_Session under the RunGuiScript sub routine or at W_System = "SIDClient" in the StartExtract sub routine? My SAP GUI code works fine, but i don't believe my connection works as it should. It connects at Set W_Sess = W_conn.Children(it + 0) under Attach_Session sub routine and i error out after the 1st line .maximize on My recorded GUI code. GUI codes works independently, but I "myerr" in excel.
Thank you for the video! I have one quick doubt
1) while you exporting data from SAP, you are using "%PC" Tcode is this SAP standard Tcode ?. while I'm using in my system it's not working
2) How to record "SAP GUI Security popup" window "Allow" button while exporting VBAK table information it's asking.
Kindly do this needful support to better understand :)
%PC is a command which does the same as export to local file, which is usually available in the menu in an SE16 like transaction. So it is a standard GUI shortcut.
I don't have SAP Logon installed on my laptop right now, but you can do two things with the security popup:
1) Tick Remember my decision and it will not be asked again for the same folder.
2) You can go into the SAP Logon settings, and in the Security group you can set if certain folders should be allowed or denies for export.
Hi Csongor Varga, I am trying to record tcode zv401 however, the scripting is not recording the exporting the data. could you please help me with it? Also, all the message pop-up in recorded.
Thank you in advance.
Yes, all the message pop-ups will be recorded. You can't so nothing about that. What do you mean not recording the exporting of data? Is your transaction using a Save as dialog window? That will never be recorded.
Hello Varga,Great video. It would help a lot.I did try run your code using SAP code FB03 and appear the error message after run the "StartExtract()" - "No Active session to system DCG210, or scripting is not anable" How could I check if DCG210 is the correct one for my SAP?
You should know in which SAP system you want to run the script. When you log into SAP you select a system and a client. It you click on the status bar where you see the transaction code or user, you will see the SID and client as well.
I never used MS Access, but Visual Basic for Applications are available for all MS products. The same code should work in Access as well (without the Excel specific lines). I am not sure what the options are for creating data from VB, but with some google I am sure you find some examples.
I hope you can help me.
whe run the script and in the moment is assigned the "session" Excell shows a message "The enumerator of the collection cannot find en element with the specified index" and I review in the "watches" and the connection variable don't have sessions and I have open session un SAP.
do you have any idea todo fix it?
I am running your script and it shows "no active session to system" un this case for me is "ACD"
I activated the scripting in SAP Options on Customize Local Layout
And the next message "Not connected to Client"
But client is working.
very interesting video. I could successfully generate the code and run the script.
Im running it from an Access file. Unfortunately what I couldn't do is to replace the part of the code where the inputs for SAP transaction are (dates, for instance) with a Variable that can take info from a particular field from an access table. My idea is to put fields in a form where I can complete the dates and when I run the macro, it downloads de SAP information for that dates (what it actually should do is to paste that date in an table and the code should be able to take the information from there). Do you know how to do this?
I have done the same in almost all of my videos. Even in this one I have a global variable for the file name and I am adding it to the script. You can do the same, and use the Format function to make sure your date is formatted in a way SAP expects it.
What I mean is that I recorded a macro, suppose a very simple one --> logging into SAP, entering a transaction and putting a date, then exporting it to excel and I put that code in an access. I created a form where I put a button that run that macro. Everything fine. The problem is that the date is fixed in the code. I want to replace that date for a variable (suppose "Date1") and defining that variable to take the date stored in a field of a table from the access (So I Can complete it before running the macro)
Problems starts when you have different table layout (ie grid list instead of standard se16 list) , different set of fields selection criteria in sap, too low number max number of hits, etc. Two choices then: enforce user to have a specific setup or add respective code into macro (which for me is not appropriate, to change user settings) I heard about RFC method which can bypass these potential complications, but I haven't had yet 100 hours to explore it.
There are some more advanced tools you can pay for that can do some of the coding for you. I have stumbled upon a few myself as well. This on the other hand is free, but requires you to get your hands dirty in the process.
Thank you for the video! I am almost done with the code but I am getting error from the last rows:
' Set the sid and client to connect to
W_System = "DCG210" <----- Here it says that "there is no session at "DCG210", or scripting is disabled (works in sap)"
' Run the GUI script
' End the GUI session
objSess.EndTransaction <----- And because of that it draws this one to yellow
Any idea how to deal with this issue please?
You do not need to calculate payroll premium if your policy is on a stipulated billing cycle.
Sample Payroll Report.
However, if your policy is not yet on a stipulated billing cycle, this is typically what you will see when we send you a payroll report.
A split payroll report is sent when there is an Anniversary Rating Date on your policy, which is the month and day that rates, rating plans and rating systems are initially applied to a policy in force and each annual anniversary thereafter. Your payroll will need to be annotated for each period specified.
Sample Split Payroll Report.
We will need a complete employee job description before we add the classification to the policy. Please do not report payroll in the new classification until it has been reviewed and endorsed to your policy.
Job Duties Questionnaire.
We recommend you keep a copy of your previous payroll reports and payroll records for at least seven years, as you would your tax records.
Submitting Payroll Reports.
There are three different ways to submit your payroll reports.
State Compensation Insurance Fund P.O. Box 7441 San Francisco, CA 94120-7441.
Free payroll reports.