Hello,
i compiled saprfc php extension for php version 5.6.5 x64. You can download from: https://sourceforge.net/projects/saprfc2/files/
Hello,
i compiled saprfc php extension for php version 5.6.5 x64. You can download from: https://sourceforge.net/projects/saprfc2/files/
I am aware of the clipboard function to copy from excel, but when I paste in SAP in a certain format, the output screen has the values in ascending order, how do I ensure that the output screen retains the way I copied from excel? Any help is greatly appreciated.
Hello Script Man,
I wanted to add your code to enable the auto save but I'm not able to make it work.
Here is my script. There are four "moments" where I'd like to enable the auto save.
Could you please check it and advice where and what exactly to add to make it work?
Thank you in advance!
Petr
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]").maximize
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsq01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[19]").press
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").currentCellRow = 6
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").selectedRows = "6"
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").currentCellRow = 28
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").selectedRows = "28"
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").select
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsq01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[19]").press
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").currentCellRow = 6
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").selectedRows = "6"
session.findById("wnd[1]/usr/cntlGRID1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").currentCellRow = 27
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").firstVisibleRow = 26
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").selectedRows = "27"
session.findById("wnd[0]/usr/cntlGRID_CONT0050/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").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").setCurrentCell 1,"TEXT"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "1"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[4]/menu[0]/menu[1]").select
session.findById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell").setCurrentCell 1,"TEXT"
session.findById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell").selectedRows = "1"
session.findById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell").clickCurrentCell
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").select
session.findById("wnd[0]/tbar[0]/okcd").text = "/nmb5t"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[2]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]").sendVKey 0
session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/okcd").text = "/nmb52"
session.findById("wnd[0]").sendVKey 0
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").setCurrentCell 1,"TEXT"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "1"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").select
Hi,
I am trying to run a a script via Excel that will log on to SAP and run a report for me. However on occasion I will get the following error:
My code is as follows:
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
Dim sMsg As String
Dim result As String
Set SAPSesi = Nothing
Set SapGuiApp = Nothing
Set oConnection = Nothing
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
SendKeys "{ENTER}"
If oConnection Is Nothing Then
Set oConnection = SapGuiApp.OpenConnection(SAPSystemBox.Value, True)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = oConnection.Children(0)
End If
Application.DisplayAlerts = False
With SAPSesi
.findbyid("wnd[0]/usr/txtRSYST-MANDT").Text = CStr(ClientBox.Value)
The error occurs on the last line that I quoted (.findbyid("wnd[0]/usr/txtRSYST-MANDT").Text = CStr(ClientBox.Value))
Any ideas on how to get past this?
Hello.
I would suggest to copy Excel cell value into SAP destionation cell by target each cel one by one.
When you have any detailed Information about your requirement (may some code snippets to see Destination structure, or screenshot of SAP destionation object) we may can give more suggestions to achieve your requirements.
Hello. It could be that this field you refer to is not usable in same way as it is in SAPGUI application.
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
SAP GUI modal called by this Scripting object is bit different to SAP GUI Dialog.
what else can I use instead of
Holger Kohn wrote:
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
, I am opening the SAP session via scripting, based on code I read in this forum
Hi Script Man,
I am having a similar issue to export to MHTML using SAP Scripting. I created a macro that open SAP GUI and do the required transaction. However, I got stuck exporting to MHTML. The code must save as MHTML in the path described below and then open the "export.MHTLM" file.
This is the code I have until now:
Sub SAPScripting_exportMHTML()
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("# E05 - R/3 - Produção", True)
Set Session = Connection.Children(0)
'Code to login on SAP GUI and do desired transaction:
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "C2MARCOSEC"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "*******"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selecedNode = "F00003"
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
Session.findById("wnd[0]/tbar[1]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[17]").press
Session.findById("wnd[1]/tbar[0]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[8]").press
'This is where I try to export to MHTML:
Path = "D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\export.MHTML" 'The "export.MHTML" file already exists
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\save_as.vbs """ & Path
Session.findById("wnd[0]/tbar[1]/btn[16]").press
End Sub
It would be great to get this code done. I send several reports everyday. This will save a lot of time.
Best Regards,
Marcos Eickhoff Cortopassi
Use one of the open sessions called from SAP GUI. You can check it in document area of this Forum. I have publish a guidance how to Setup an interactive EXCEL MACRO-ENABLED WORKBOOK. This Loop over all existing sessions. In a customized userform you can select one this this list for execution of script.
Hello,
I am looking for sap module for php 5.6.5 x64. Your link seems broken, may you update it?
Is it the saprfc 1.4.1?
Thank you really much,
Hello,
right link is:
saprfc/sapnwrfc - Browse Files at SourceForge.net
you can download compiled php extension for saprfc and sapnwrfc projects. Let me know if that works.
Hi All,
I am running some macros at Excel that open SAP GUI and do the required transaction. However, I got stuck exporting to MHTML. The code must save the data (MHTML format) in the path described below and then open the "export.MHTLM" file.
This is the code I have until now:
Sub SAPScripting_exportMHTML()
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("# E05 - R/3 - Produção", True)
Set Session = Connection.Children(0)
'Code to login on SAP GUI and do desired transaction:
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "USERNAME"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "*******"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selecedNode = "F00003"
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
Session.findById("wnd[0]/tbar[1]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[17]").press
Session.findById("wnd[1]/tbar[0]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[8]").press
'This is where I try to export to MHTML:
Path = "D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\export.MHTML" '''''''' The "export.MHTML" file already exists '''''''''
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\save_as.vbs """ & Path
Session.findById("wnd[0]/tbar[1]/btn[16]").press
End Sub
It would be great to get this code done. I send several reports everyday. This will save a lot of time.
Best Regards,
Marcos Eickhoff Cortopassi
The menu "Script Recording and Playback..." randomly grey out and we could not find the reason for a long time.
Usually when it happened, we entered into menu "SAP GUI Options - CDE" and check (or uncheck) the boxes of "Interaction Design" and "Accessibility & Scripting" (see attached screenshots). If lucky enough, the menu "Script Recording and Playback..." will turn black.
If it still does not turn black, we usually have to reboot the computer several times and if lucky, it will turn black.
Has anyone come across this similar issue and could you share your solutions please? Thank you in advance.
Hi Guys!
I am new to GuixT and would appreciate your valuable inputs.
I have listed few basics questions below.
Q1)Is it good practise to club all the screen related instructions in one block?
eg. in below snippet SCREEN A has two different blocks.
onscreen 'SCREEN A'
if(id == 'id'){
enter('=code');
}
onmessage
if(isErrMsg(_message)){
enter('?');
leave();
}
else {
enter();
}
onscreen 'SCREEN B'
set('F[var2]','&V[z_phone]');
enter('=code');
onscreen 'SCREEN A'
if(param.chk == 'my_check'){
enter('/3');
}
OR is it different from below code where I have clubbed all code for SCREEN A ?
Any impact on performance.
onscreen 'SCREEN A'
if(id == 'id'){
enter('=PZKU');
}
onmessage
if(isErrMsg(_message)){
enter('?');
leave();
}
else {
enter();
}
if(param.chk == 'my_check'){
enter('/3');
}
onscreen SCREEN B'
set('F[var2]','&V[z_phone]');
enter('=code');
2) Should be avoid emplty label usuage for better performance?
Eg.
if(tt == '')
goto label1;
i++;
goto label2;
label1:;
if(code == 'AP' ){
enter('?');
}
else
enter('/3');
Can it be re-written as below for better performance?
if(tt == '')
{
if(code == 'AP' ){
enter('?');
}
else
enter('/3');
}
i++;
goto label2;
Hello,
Thank you, it work with my php 5.6.5 x64 with windows 2012.
Best regards,
Rodolphe Nesti
Hello! Thanks for your answer!
In fact this folder is not created when I record and stop the script. And, of course, no script is created. When I click at the "..." to go to folder, it appears my desktop. I tried to create this folder "Scripts" inside my "...SAP Gui" folder, but no file is generated.
Do you know what can be happening?
Thanks for your help. This tool would help me in unimaginable ways.
Hello. This can have a few root causes:
Thanks for your fast answer.
I tried to save in many folders that I have acess, including usb cards. My SAP Gui option for scripting is marked (as the other 2, about notifyings). So the problem seem to be Scripting Parameter in Transaction RZ11. I'm not authorized to acess this transaction, perhaps only SAP Admin as you pointed.
To change the permission level of my user profile I must contact them. But isn't it strange that I can open the window "Record and Playback"?
I will contact them. But unfortunately it will take at least 1 month to resolve this, and as an intern I won't have priority.
Thanks Kohn!