Quantcast
Channel: SCN: Message List - Scripting Languages
Viewing all 1708 articles
Browse latest View live

Re: SAPRFC works on XP not on 2003


Copy from Excel, Paste in SAP, how to retain the same order of values?

$
0
0

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.

Re: Save SAP report in Excel format into specified drive

$
0
0

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

Method 'Text' of object 'ISapTextFieldTarget' failed

$
0
0

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:

 

2015-02-24_073717.png

 

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?

Re: Copy from Excel, Paste in SAP, how to retain the same order of values?

$
0
0

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.

Re: Method 'Text' of object 'ISapTextFieldTarget' failed

$
0
0

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.

Re: Method 'Text' of object 'ISapTextFieldTarget' failed

$
0
0

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

Re: Save report to MHTML format using Gui script

$
0
0

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


Re: Method 'Text' of object 'ISapTextFieldTarget' failed

$
0
0

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.

Re: Could not install SAPRFC with PHP 5.4.4 in XAMPP 1.8.0 Win7

$
0
0

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,

Re: Could not install SAPRFC with PHP 5.4.4 in XAMPP 1.8.0 Win7

SAP GUI Scripting and VBA - Export and save as MHTML file

$
0
0

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

Menu "Script Recording and Playback..." randomly greyed out

$
0
0

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.  

Please suggest better usuage of onScreen & GoTo??

$
0
0

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;

Re: Could not install SAPRFC with PHP 5.4.4 in XAMPP 1.8.0 Win7

$
0
0

Hello,

 

Thank you, it work with my php 5.6.5 x64 with windows 2012.

 

Best regards,

 

Rodolphe Nesti


SAP GUI Scripting does not

$
0
0
Hello everybody.
I want to use the SAP GUI Scripting (Recording and Playback) to optimize many activities here in my company (I work as an intern - Project Planning).

The option "Recording and Playback" isn't grey. I can click on it and it show to me the buttons. When I click "Record", it appears an progress bar on the lower left of SAP Gui (it looks like a candlestick, white and red). It says (when I pass the mouse near it) "SAP GUI Scripting: Script is Running".

But when I save the file (by clicking stop in the Recording and Playback scripting window), no file is saved. And I can't playback because no file was generated. What can be happening? The I.T. service here takes too long to help with this issues and it seems that they are not aware of this great tool.
I have SAP Gui 7.3 and SAP Netweaver Bussined Client 4.0.

Re: SAP GUI Scripting does not

$
0
0

Hello.

 

Have you checked in path:

 

%appdata%\sap\sap gui\scripts

 

SAP_Scripting.png

Re: SAP GUI Scripting does not

$
0
0

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.

Re: SAP GUI Scripting does not

$
0
0

Hello. This can have a few root causes:

 

  1. You have not enough local Access to write in a specific Folder structure. If this is the case try to select an existing Folder in your private document Folder.
  2. Some restrictions exist on sap Scripting Parameter in Transaction RZ11. Probably you have not enough authorization to Access this area in SAP. This Need to check by your local SAP Basis adminstrator.
  3. Check SAP Gui Option for Scripting. See screenshot below.

 

SAPGUI_Options.png

Re: SAP GUI Scripting does not

$
0
0


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!

Viewing all 1708 articles
Browse latest View live


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