Quantcast
Channel: SCN : All Content - Scripting Languages
Viewing all 522 articles
Browse latest View live

Problem with Clipboard while transfering Data from SAP to Excel

$
0
0

I use the clipboard for a import of ordernumbers to excel. i use this code to copy all the numbers (the whole column):

 

 

.findById("wnd[0]/usr/cntlALV_CONTAINER/shellcont/shell").selectColumn "AUFNR"
.findById("wnd[0]/usr/cntlALV_CONTAINER/shellcont/shell").contextMenu
.findById("wnd[0]/usr/cntlALV_CONTAINER/shellcont/shell").selectContextMenuItemByPosition "0"

 

 

Usually it works, but: Only the first 98 Numbers are transfered. Overall about 300 Numbers should be transfered, but they arent.

 

When i do this step by hand, it works sometimes, sometimes not. i have no idea why. the numbers are only 7 digit, so i dont think my memory is too small

 

 

i paste the numbers with this code:

 

Range("A3").PasteSpecial skipblanks:=True

 

 

someone got a solution?


CCo (COM Connector) for SAP NetWeaver RFC Library for Scripting Languages

$
0
0

Hello community,

 

SAP offers different connectors to develop ABAP compatible components and applications. JCo for Java environments, NCo for dotNET languages and the NetWeaver RFC SDK for C++. But what's up if you work neither with Java or dotNET environments nor with C++?

 

Here is another alternative, CCo - the COM Connector for SAP. CCo is a COM library and offers wrappers around all functions of the SAP NetWeaver RFC library. So it is possible to use all functionalities of the SAP NetWeaver RFC library inside any language which support COM technic.

 

With CCo it is easily possible to use the SAP NetWeaver RFC functions inside VBScript, Visual Basic for Applications (VBA) or AutoIt script.

 

Here a VBScript example to connect an SAP system:

 

'-Begin-----------------------------------------------------------------

  '-Directives----------------------------------------------------------
    Option Explicit


  '-Variables-----------------------------------------------------------
    Dim SAP, hRFC, rc


  '-Main----------------------------------------------------------------

    Set SAP = CreateObject("COMNWRFC")
    If IsObject(SAP) Then

      SAP.About

      hRFC = SAP.RfcOpenConnection("ABAP", "00", "001", "BCUSER", "", _

        "EN", "0", "0")


      If hRFC Then
        MsgBox "Check connection with TAC SMGW in the SAP system"
        rc = SAP.RfcCloseConnection(hRFC)
      End If
      Set SAP = Nothing
    End If

'-End-------------------------------------------------------------------

 

Here a VBA example to ping an SAP system:

 

'-Begin-----------------------------------------------------------------


  Option Explicit


  '-Constants-----------------------------------------------------------

    Const RFC_OK = 0


  '-Sub Ping------------------------------------------------------------

    Sub Ping()
 
      '-Variables-------------------------------------------------------
        Dim SAP As CCo.COMNWRFC
        Dim hRFC As Long
        Dim rc As Integer
        Dim hFunc, hFuncDesc As Long


      Set SAP = CreateObject("COMNWRFC")

      If IsObject(SAP) Then
 
        hRFC = SAP.RFCOPENCONNECTION("ABAP", "00", "001", "BCUSER", _
          "", "EN", "0", "0")
        If hRFC Then
       
          '-Variant1----------------------------------------------------
            hFuncDesc = SAP.RFCGETFUNCTIONDESC(hRFC, "RFC_PING")
            If hFuncDesc Then
              hFunc = SAP.RFCCREATEFUNCTION(hFuncDesc)
              If hFunc Then
                If SAP.RFCINVOKE(hRFC, hFunc) = RFC_OK Then
                  Debug.Print "Ping successful"
                Else
                  Debug.Print "Ping not successful"
                End If
                SAP.RFCDESTROYFUNCTION hFunc
              End If
            End If
         
          '-Variant2----------------------------------------------------
            If SAP.RFCPING(hRFC) = RFC_OK Then
              Debug.Print "Ping successful"
            Else
              Debug.Print "Ping not successful"
            End If
       
          rc = SAP.RFCCLOSECONNECTION(hRFC)
        End If
        Set SAP = Nothing
   
      End If
     
    End Sub

'-End-------------------------------------------------------------------

 

To the duality of accesses via SAP GUI Scripting and RFC with scripting languages

ScriptStructure.jpg

CCo opens a powerful second channel to communicate with an SAP back end. You can code in your favorite COM-enabled scripting language and use two ways: on the one hand the SAP GUI Scripting to communicate via SAP GUI for Windows with an SAP system, and on the other hand the COM Connector (CCo) to communicate via SAP NetWeaver RFC library with an SAP application server.

CCo is an ideal complementation to SAP GUI Scripting in this application area. You can e.g. use the wide range of thousands of remote-enabled function modules from an SAP system. Use the transaction code BAPI to open the BAPI explorer and find a lot in the alphabetical hierarchy tree.

Enrich your SAP GUI Scripting operation processes. Get information easy and fast via CCo RFC interface in your scripting environment. Combine the best of both worlds.

 

Hint: CCo has at the moment experimental character. Don't use it in production environments.

 

Hint: CCo needs SAP RFC SDK, you find it here.

 

Download

You find CCo here: http://cco.stschnell.de

 

2013/05/05:

  • New Version 0.50 is available. A lot of methods needs no longer pointer, now it is possible to set the arguments direct.
  • ABAP examples are now included.

 

Comments are welcome.

 

Cheers

Stefan

VBS & Enjoy transactions

$
0
0

Hi Guys,

 

I have a question regarding so called "enjoy transactions".

Is there any way to automate this type of transactions using vbscript?

In my case I'm trying to automate PO creation using ME21N(ME21 is not applacable) and the problem is always changing SAPLMEGUI:0010

For example below SAPLMEGUI: is 0013

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]")

I've found several threads for this issue in SCN but there are not solutions for them.

 

Please advise if vbs is applicable for these transactions.

If yes please provide an example.

 

Thank you in advance!    

 

Regards

Guero

Support on VB script for report

$
0
0

Hi,

 

I have recorded and created a VB script to pull a daily report in VIM analytics, there are around 6 different reports which i need to pull on a daily basis.

 

Once the script run's it will take me till export to excel and give me the path to save, i need to give the name of the file and save, then it will run automatically for next report again till export to excel. and so on...

 

Can i get some loop coding, where the script should save all the excel files automatically in a specific folder, instead of asking file names every time.

 

So, once i run the script it should end after saving all the file.

 

Attach is the script details

 

Thanks in advance

 

Baig

Installing SAPRFC

$
0
0

Hello, recently I started working on a PHP application that is going to extract data from SAP and searching the Web I found the SAPRFC extension. So my problem came when I tried to configure the extension to work. The documentation that comes with the file is too vague and reading online I didn't a solution that worked. So after getting it to work, I decided to create a guide for any other person that is having the same problem I had.

 

Software Needed

  • Wampserver v2.1e - I used Wampserver since it more easy to configure and it has a neat tray icon that it's really usefull. (Download)
  • Wampserver PHP Addon - For SAPRFC to work you need a specific version of PHP. For me, 5.2.8 was the one that worked (Download)
  • Wampserver APACHE Addon - Same thing goes for APACHE, you need an specific version. I used 2.0.54. (Download)
  • SAPRFC - Download the latest one (Download)
  • And lastly, you need to have the librfc32.dll file on your c:/Windows/System32/ folder. This file is copied by SAPGUI when you install it, so I recommend you do that. Install SAPGUI.

OS Enviroment

  • This worked for me on Windows XP, 7 and 8.

Installation Steps

  1. Install Wampserver. The install the PHP Addon and the APACHE addon. The installation process is pretty straight foward, so after everything is installed you have to activate the APACHE and PHP version that we're going to use. Left click on the Wampserver tray icon and in Apache->Version select 2.0.54, wait for the service to restart then in PHP->Version select 5.2.8. Go to localhost in your browser and check that the version in APACHE and PHP are selected.
  2. Open the SAPRFC zip file and copy the file php_saprfc_528.dll and place it in C:\wamp\bin\php\php5.2.8\ext. Change the name to php_saprfc.dll.
  3. Left click on the Wampserver tray icon and PHP->php.ini to edit the PHP configuration file and add the following line extension=php_saprfc.dll, save and close the file. Then left click on Restart All Services.
  4. And if everything went well you should see in your localhost page the saprfc extension loaded. If not, check your apache error log file to see any error.

So hope this worked for me and I hope it works for you. If you know a better way of doing this, please share. Good luck and happy programming!!

How to Use Different Active Scripting Engines with SAP GUI Scripting

$
0
0

Hello community,

 

since Windows Scripting Host (WSH) 2.0 offers Microsoft with the Windows Script File (WSF) the possibility to combine different scripting languages in one script file. The WSF files containes an Extensible Markup Language (XML) structure with one package tag and different job tags. Below the job tag we can define different script sections with different scripting languages. Here an easy exmaple how to combine VBScript and JScript:

 

<?xml version="1.0" standalone="yes"?>
<package id="test">
  <comment>
    This is a test script
  </comment>
  <job id="001">


    <runtime>
      <description>
        This script shows the using of VBScript and JScript in one
        script file
      </description>
      <example>
        wscript Test.wsf
      </example>
    </runtime>


    <script language="JScript">
      <![CDATA[
//-Begin----------------------------------------------------------------

 

  function JSHelloWorld() {
    return("Hello World from JScript");
  }

 

//-End------------------------------------------------------------------
      ]]>
    </script>


    <script language="VBScript">
      <![CDATA[
'-Begin-----------------------------------------------------------------

 

  MsgBox "Hello World from VBScript"

  MsgBox JSHelloWorld()

 

'-End-------------------------------------------------------------------
      ]]>
    </script>


  </job>
</package>

 

 

Now an example how to use the shift operators from JScript inside VBScript:

 

<?xml version="1.0" standalone="yes"?>
<package id="shift">
  <comment>
    This is a test script
  </comment>
  <job id="001">


    <runtime>
      <description>
        This script shows the using of JScript shift operators with
        VBScript
      </description>
      <example>
        wscript Shift.wsf
      </example>
    </runtime>


    <script language="JScript">
      <![CDATA[
//-Begin----------------------------------------------------------------

 

  function ShiftLeft(Value, Shift) {

    //-Variables--------------------------------------------------------
      var Result;

    Result = Value << Shift
    return(Result);
  }

 

  function ShiftRight(Value, Shift) {

    //-Variables--------------------------------------------------------
      var Result;

    Result = Value >> Shift
    return(Result);
  }

 

//-End------------------------------------------------------------------
      ]]>
    </script>


    <script language="VBScript">
      <![CDATA[
'-Begin-----------------------------------------------------------------

 

  MsgBox CStr(ShiftLeft(14, 2))                 '1110 << 2 = 111000 (56)
  MsgBox CStr(ShiftRight(14, 2))                '1110 >> 2 =     11 ( 3)

 

'-End-------------------------------------------------------------------
      ]]>
    </script>


  </job>
</package>

 

 

It is also possible to implement your SAP GUI script, from the SAP GUI Scripting recorder, inside the VBScript section and to combine it with a JScript section too.

 

<?xml version="1.0" standalone="yes"?>
<package id="test">
  <comment>
    This is a test script
  </comment>
  <job id="001">


    <runtime>
      <description>
        This script shows the using of SAP GUI Scripting as VBScript
        and JScript in one script file
      </description>
      <example>
        wscript SAPGUIScript.wsf
      </example>
    </runtime>


    <script language="JScript">
      <![CDATA[
//-Begin----------------------------------------------------------------

 

  function getJScriptEngine() {
    return ScriptEngine();
  }

 

//-End------------------------------------------------------------------
      ]]>
    </script>


    <script language="VBScript">
      <![CDATA[
'-Begin-----------------------------------------------------------------

 

  MsgBox ScriptEngine()

 

  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

 

  session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "001"
  session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "bcuser"
  session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "minisap"
  session.findById("wnd[0]/usr/txtRSYST-LANGU").text = "EN"
  session.findById("wnd[0]").sendVKey 0

 

  MsgBox getJScriptEngine()

 

'-End-------------------------------------------------------------------
      ]]>
    </script>


  </job>
</package>

 

 

On this way you can use different Active Scripting Engines with SAP GUI Scripting. So you can mix, beside VBScript and JScript, e.g. PerlScript or OOREXX. You can use the best from each scripting language. And you have the possibility to use great archives from a few scripting languages. Use existing and consolidated solutions, it is often not necessary to invent the wheel again.

 

Cheers
Stefan

vbscript / enjoy transactions problems

$
0
0

Hi Guys,

 

I have a question regarding so called "enjoy transactions".

Is there any way to automate this type of transactions using vbscript?

In my case I'm trying to automate PO creation using ME21N (ME21 is not applicable) and the problem is always changing SAPLMEGUI:0015.

The number vary between 10 and 20 in case below is SAPLMEGUI:0013

  1. session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211/ctxtMEPO1211-BANFN[13," & cstr(x) & "]")

I've found several threads for this issue but without concrete answer or solution.

 

Please If you solve this problem provide an example of the script.

 

Thank you!

 

BR

Guero

Gui navigation - entering data through VBA

$
0
0

Hello,

 

I started a project just yesterday after realizing I can control SAP through VBA.  I've been doing pretty good figuring things out with the awesome answers provided here to other people's questions.  I have the automated login as well as 2 of the 3 total major functions I wish to accomplish all figured out.  A good lot of it comes from recording scripts to see how things are done.  I've ran into a minor snag that I had a question about and not sure where to turn for this one, so figured I'd ask the professionals.

 

In my office, we have 2 different computers.  PC1 is set to a screen resolution of 1024x768.  PC2 is set to 1280x1024.

 

On PC1 when manually navigating the GUI to a particular SAP screen I have 4 rows of a data input table with 1 more row hidden that I have to scroll down one click to get to the last row.  On PC2 at the higher screen resolution, I don't have to scroll, it shows all 5 rows.  I'm doing all of my scripting/recording/testing on PC1. 

 

This is a small snippet from that script on PC1.

 

'Travel Time

session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,0]").Text = "60"

'Time Onsite

session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,3]").Text = "240"

 

'scroll 1 for Mileage

session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS").verticalScrollbar.Position = 1

session.findById("wnd[0]/usr/tabsTB_CLOSER/tabpTB_CLOSER_FC2/ssubTB_CLOSER_SCA:SAPMZCS_CALL_CLOSER:0220/tblSAPMZCS_CALL_CLOSERTC_OPERATIONS/txtG_WRK_OPERATION-ISMNW[3,3]").Text = "48"

 

I left a couple comments in to refer to them by their name.

 

After the initial recording and looking at it.  I expected the mileage line to be...

 

.../txtG_WRK_OPERATION-ISMNW[3,4]").Text = "48"

 

but it wasn't.    If I do the same thing on PC2, then that is exactly what the mileage line is, but because I scrolled down one notch it's [3,3] just like the Time Onsite line, which tells me that the reference is to what is on-screen and not a direct label to that entry.  I double checked that by recording again and this time before making that 5th line entry, I scrolled down far enough so it was in the 1st position and sure enough, it recording it as [3,0].

 

Now to the pertinent question.  Can I use [3,4] in the script even though technically that position is off-screen or will I end up having to add screen resolution checking to ensure things get done the right way no matter the screen resolution?

 

I would test it, but I have to keep my testing to a minimum as I only have access to the live database and I do have to be careful what I'm doing with the live data.

 

Thanks, Much Appreciated.

RJ


SAPRFC Installation - My Experience

$
0
0

Hi, I finally got SAPRFC working and I wanted to share my experience for anyone who might find it usefull, since it took me a lot of searching and reading.

 

Software Needed

  • Wampserver - It can be the latest one (Link)
  • Wampserver PHP 5.1.1 Add-on - This is the version of PHP that worked for me (Link)
  • Wampserver APACHE 2.0.54 Add-on - This is the version of APACHE that worked for me (Link)
  • You should have SAP GUI installed, if not, you have to download the librfc32.dll file and put it in your Windows/system folder.
  • And of couse SAPRFC v1.4.1-5.1.1 (Link)

Installing

  1. Install Wampserver, Wampserver PHP Add-on and the Wampserver APACHE addon, in that order. When all is installed, start wampserver and in the wampserver tray icon left click then go to Apache->Version->2.0.54, it should restart the service. Then do the same but PHP->version->5.1.1, and there will be another restart.
  2. Unzip SAPRFC to the c:/wamp/www/ folder and move the php_saprfc.dll file to c:/wamp/bin/php/php5.1.1/ext/.
  3. Open php.ini and add the line extension=php_saprfc.dll.
  4. Click on the Wampserver tray icon and restart all services.
  5. Check your http://localhost page and check that the saprfc appears on the loaded extensions list.
  6. If it doesn't appear, check you apache_error.log (You can do this left clicking on the Wampserver tray icon on Apache->Apache error log).

 

So this was the method I used to get SAPRFC up and running. I you know a better way, please share it. So, hope this helps!

Multiple Lines in ALV Grid Not Saving

$
0
0

Hello beautiful people!

 

I have an editable ALV grid, and when i save multiple lines at once, on the LAST row of data is saved.

 

LOOP AT tb_dirty.

           READ TABLE <fs_table> INTO <fs_struc> INDEX tb_dirty-LINE.

 

           MODIFY (g_struct_name) FROM <fs_struc>.

           commit work and wait.

ENDLOOP.

 

I have tried this code by replacing the field symbols with actual typed variables.  This code works for single lines.

 

When debugging, the sy-subrc = 0 after the MODIFY.

 

I am at my wits end and my blonde hair is turning brown from the amount of thought-power I've expended on this problem!  LOL

 

Please help.  THANKS!!!!!

 

-Tif

Opening SAP using macro

$
0
0

Hi everyone,

with the code i was able to open a connection to SAP .

 

 

Set sap = CreateObject("SapAutoGui.Event")

 

      host = "test12"
    sapNr = "90"
    mandant = "800"
    user =" test1"
    Password = "pass"
      
 
    bOK = sap.Connect(host , sapNr ,SapGuiActiveX Or SapGuiFront Or SapGuiFullMenu)
    OKCheck bOK, "Error in opening connection"
    
    iCtrl = sap.FindByField("RSYST-MANDT", 0, SapEdit)
    bOK = sap.SetControlValue(iCtrl, mandant)
    OKCheck bOK, "Error in setting text value"

    iCtrl = sap.FindByField("RSYST-BNAME", 0, SapEdit)
    bOK = sap.SetControlValue(iCtrl, user )
    OKCheck bOK, "Error in setting text value"

    iCtrl = sap.FindByField("RSYST-BCODE", 0, SapPassword)
    
    bOK = sap.SetControlValue(iCtrl, Password)
    OKCheck bOK, "Error in setting text value"

    bOK = sap.SetCursorByControl(iCtrl)
    OKCheck bOK, "Error in setting cursor position"

    bOK = sap.SendEvent
    OKCheck bOK, "Error in sending default key"

 

but since SNC is active, i can't open sap

how do I make a connection to SAP  when SNC = true

Can anyone help me?


Thanks,

saad

T-code KSII script to post despite errors

$
0
0

Hello scripting family!

I currently run SAP transaction KSII - Price Calculation.  I have a script in place to run t-code KSII as a "Test Run", then, i select the back button and when the pop-up comes up to ask if I'd like to post the Price Calculation, my script selects Yes.  Then when the pop-up comes up that says that the Price Calc has posted, my script presses the Enter button.  But, if there is an error an extra pop-up box comes up that says "Do you want to post despite errors?".  But, my script is set up to just hit enter because it expects the pop-up that tells me that it posted.  Does anyone know of a code that will do the following:

 

IF a pop-up box comes up that says "Do you want to post despite errors", THEN select YES.  IF NOT, then continue with the next code (or just press enter). 

 

Any help is greatly appreciated!!  :-)

 

Thanks,

Chris

Need to read the contents of an ID using VBS

$
0
0

Hello everyone,

 

I have the following script that i have in place but it still needs one last part in order to be completed, the script goes into transaction YSNBIL, once it places the needed service orders and executes the transaction, i need to first do a quick validation inside the transaction, i need to check that all service orders displayed have yellow or green traffic light, if one service order has red traffic light, the script needs to stop, i have been able to work with traffic lights before inside a shell container without any problem, but when i check the contents of the this transaction i get nothing, i do the following line of code with VBS.

 

MsgBox session.findbyid("wnd[0]/usr/lbl[3,14]").text

 

i get nothing, that is the ID that i get from the scripting wizzard.

 

Any ideas what i can do to know if the traffic light is yellow, green or red in order for the script to continue?

 

Thanks in advance!

SAP GUI Scripting Wizard Tool

$
0
0

here is  a SAP hit tool ( like the SAP wizard) for anyone doing SAP automation  windows 7.

 

http://www.autoitscript.com/forum/topic/149540-sapwizardudf/

 

This lets you click on a control on any SAP GUI and highlights

it just like the wizard did and tells you the control path.

 

The SAP wizard has problems on windows 7 (http://scn.sap.com/thread/2006892) due to its use of Office Assistants Agents which are no longer supported in windows 7.

 

Note, GUI Scripting needs to be turned on see your system admin (or see transaction rz11 to turn on)

 

Note, This tool is written in Auto IT automation tool language..you will need to  compile it.

 

Enjoy

 

 

tags SAP GUI scripting wizard not working

 

also see The this excellent tool Script tracker..

http://scn.sap.com/docs/DOC-32728#comment-349789

 

here is  a SAP hit tool ( like the SAP wizard) for anyone doing SAP automation  windows 7.

 

http://www.autoitscript.com/forum/topic/149540-sapwizardudf/

Sap script- t-code AS02

$
0
0

Hello Everyone,

 

I am a real beginner in the VBA & SAP Scripting.

 

Below is my VBA Script  for changing the asset master data in t-code AS02.

 

It works really fine but I would like to make it better.

 

First thing I would like to do is to  create a loop which will make possible to change lot of  assets numbers which will be filled in the excel sheet Do you have any suggestions ?

 

The second thing I would like to do is to make visible in the excel  (where script is run) the SAP output message  after the change is done  -  for instance      “Asset number XXXX has been changed” or if for instance sth went wrong – “Asset number does not belong to selected company code” etc

 

Thank you in advance for any help.

 

Regards

MJ

 

Private Sub CommandButton1_Click()
If Not IsObject(Application1) Then
   Set SapGuiAuto = GetObject("SAPGUI")
   Set Application1 = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
   Set Connection = Application1.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 Application1, "on"
End If
Set xclapp = CreateObject("Excel.Application")
Set xclwbk = xclapp.Workbooks.Open("c:\Users\Public\AS02.xlsm")
Set xclsht = xclwbk.Sheets("Sheet1")

For i = 2 To xclapp.ActiveCell.SpecialCells(11).Row
For j = 1 To xclapp.ActiveCell.SpecialCells(11).Column
If j = 1 Then Asset = xclsht.Cells(i, j).Value
If j = 2 Then Company = xclsht.Cells(i, j).Value
If j = 3 Then Zmiana = xclsht.Cells(i, j).Value
Next
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/n as02"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtANLA-ANLN1").Text = Asset
session.findById("wnd[0]/usr/ctxtANLA-BUKRS").Text = Company
session.findById("wnd[0]/usr/ctxtANLA-BUKRS").SetFocus
session.findById("wnd[0]/usr/ctxtANLA-BUKRS").caretPosition = 4
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLA-TXA50").Text = Zmiana
session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLA-TXA50").SetFocus
session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA1:SAPLAIST:1140/txtANLA-TXA50").caretPosition = 3
session.findById("wnd[0]/tbar[0]/btn[11]").press

Next
MsgBox "All " & CStr(xclapp.ActiveCell.SpecialCells(11).Row - 1) & " Excel rows have been processed."

Set xclwbk = Nothing
Set xclsht = Nothing
xclapp.Quit
Set xclapp = Nothing

End Sub


How can I execute 6 sessions in parallel?

$
0
0

Hi

 

I've been working on this for a couple of weeks. I've searched the internet (including scn.sap.com ), asked people and have come up empty.

this site/discussion area has been a great help, but I can't find a way to execute multiple sessions at once.

 

here's the scenario.

I have 6 custom reports that I run daily that take 30 minutes to run serially. If I run multiple sessions in parallel, It takes 5 to 10 minutes.

 

Using excel/VBA, I have  connected to SAP, started 6 sessions (session.createsession), each session navigates to its custom report screen, set variant and now want to run them at the same time/in parallel/asynchronous/concurrently...

 

I've tried "SendVKey 8" and .Press (execute button), but they execute one at a time instead of all at once.

 

Here's a test with 2 sessions. control isn't returned each step is complete.

 

With SAPConnObj

  .Children(0).FindById("wnd[0]").Restore  'make active

  .Children(0).FindById("wnd[0]").SendVKey 8

  '.Children(0).FindById("wnd[0]/tbar[1]/btn[8]").Press

 

  .Children(3).FindById("wnd[0]").Restore  'make active

  .Children(3).FindById("wnd[0]").SendVKey 8

  '.Children(3).FindById("wnd[0]/tbar[1]/btn[8]").Press

End With

 

I can't believe I'm the only one that wants to do this.

If I can't run them in parallel, can I run them in the background?

that may accomplish the same thing.

 

Any help/code would be appreciated.

 

Regards,

Steve

Beginner Help With GUI Script To Save File Automatically

$
0
0

Hello all,

 

I'm so excited this morning after discovering that SAP had this powerful scripting capability this whole time and I had no idea.  I've been playing around with it this morning and see so many possibilities.  But I'm definitely new with it, and need some quick help.

 

One thing I need to do is run a transaction and have it output as a file saved on a shared drive automatically.  This could be whether local file or opening it as a spreadsheet and saving it.  But starting with the latter, I've gotten SAP to run the transaction and open the spreadsheet, but that is where it ends.  How do I make the script then save that file with a given name and path automatically?  From there, I could get the script to run at predetermined times, and then the output file would be available to use by others when they need it.  Any help with this seemingly simple initial step would be greatly appreciated!!

 

Thanks so much in advance!

 

Jeremy

How to Manipulate Logon Pad Options with VBScript

$
0
0

I have a need to "walk" my way through the SAP Logon 720 logon pad with VBScript techniques.  Is this possible using the same methods used when navigating the SAP GUI during a session?  What I'd like to do when the logon pad is visible is select a particular connection, click the Edit button, click the Network tab, and then select either the High Speed or Low Speed options under Network Setttings.  I've recorded my steps while performing transactions during a session with the script recorder (I understand and can code this script pretty well) and would like to do the same while in the Logon pad.  If the recorder isn't available for recording while in the Logon Pad, where I can I find documentation to understand how to apply VBScript to accomplish what I need?

 

SAP Logon Network Settings.png

SAPNWRFC for Ruby on AIX fails IOT trap (core dumped)

$
0
0

Hi Piers,

 

first of all thanks a million for the SAPNWRFC binding you wrote for Ruby. I really appreciate your efforts there. Here in Component Validation we use Ruby for an internal backup tool that helps us archiving and quickly cross-restoring SAP systems (ABAP and JAVA stacks) within our heterogeneous Unix/Linux server environment. Being able to do RFC connects (Unicode!) would really be an additional driving argument pro Ruby.

 

The gem is working fine so far on Linux, Solaris and HPUX IA64. On AIX however it makes the interpreter crash. While compiling with xlc runs ok with all the NWRFCSDK libs properly linked etc. the Ruby interpreter instantly aborts with an IOT trap (core dumped) when creating an RFC connection handle:

 

This is what the core file says:

 

dbx AIX-1.9.3-p194/bin/ruby core

Type 'help' for help.

[using memory image in core]

reading symbolic information ...warning: no source compiled with -g

IOT/Abort trap in pthread_kill at 0x9000000007ecd30 ($t1)

0x9000000007ecd30 (pthread_kill+0xb0) e8410028 ld   r2,0x28(r1)

IOT/Abort trap in pthread_kill at 0x9000000007ecd30 ($t1)

0x9000000007ecd30 (pthread_kill+0xb0) e8410028 ld   r2,0x28(r1)

(dbx) where

pthread_kill(??, ??) at 0x9000000007ecd30

_p_raise(??) at 0x9000000007ec5e4

  1. raise.raise(??) at 0x9000000000384e8

abort() at 0x9000000000536e4

rb_bug(0x1001f203c, 0x110020b18, 0x8ffffffffffffac1, 0xf00000002ff48000, 0x1000b2ae0, 0xa00000000000d032, 0xf1000a02003cbc00, 0xf000000030018f20) at 0x10005514c

sigsegv(0xb0000000b, 0x1101c7e50, 0x1101c7ba0) at 0x1000b2b80

_STL::_Rb_tree<int,_STL::pair<const int,RfcConverter*>,_STL::_Select1st<_STL::pair<const int,RfcConverter*> >,_STL::less<int>,_STL::allocator<_STL::pair<const int,RfcConverter*> > >::_M_insert(_STL::_Rb_tree_node_base*,_STL::_Rb_tree_node_base*,const _STL::pair<const int,RfcConverter*>&,_STL::_Rb_tree_node_base*)(??, ??, ??, ??, ??, ??) at 0x90000000255ba24

_STL::_Rb_tree<int,_STL::pair<const int,RfcConverter*>,_STL::_Select1st<_STL::pair<const int,RfcConverter*> >,_STL::less<int>,_STL::allocator<_STL::pair<const int,RfcConverter*> > >::insert_unique(const _STL::pair<const int,RfcConverter*>&)(??, ??, ??) at 0x90000000255b7ac

_STL::_Rb_tree<int,_STL::pair<const int,RfcConverter*>,_STL::_Select1st<_STL::pair<const int,RfcConverter*> >,_STL::less<int>,_STL::allocator<_STL::pair<const int,RfcConverter*> > >::insert_unique(_STL::_Rb_tree_iterator<_STL::pair<int,RfcConverter*>,_STL::_Nonconst_traits<_STL::pair<int,RfcConverter*> > >,const _STL::pair<const int,RfcConverter*>&)(??, ??, ??, ??) at 0x900000002559ec8

RfcConverter::getConverter(const unsigned short*,const unsigned short*,short,unsigned int)(??, ??, ??, ??) at 0x9000000025570c0

RfcConverter::utf8Tosapuc(const unsigned short*,const unsigned char*,unsigned int,unsigned short*,unsigned int*,unsigned int*)(??, ??, ??, ??, ??, ??) at 0x9000000025571ac

  1. nrfc.RfcUTF8ToSAPUC(??, ??, ??, ??, ??, ??) at 0x900000002401570

u8to16(0x1103ea1a0) at 0x900000000cfaa00

SAPNW_RFC_HANDLE_new(0x1105aae90, 0x1103d8dd8) at 0x900000000cfde50

call_cfunc(0x9001000a0437378, 0x1105aae90, 0x100000001, 0x100000001, 0x110065830) at 0x10006d1fc

vm_call_cfunc(0x110060c30, 0x110164bc8, 0x100000001, 0x1105aae90, 0x0, 0x11072f510) at 0x10006ff30

vm_call_method(0x110060c30, 0x110164bc8, 0x100000001, 0x0, 0x0, 0x3e8, 0x11072f510, 0x1105aae90) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

vm_call0(0x110060c30, 0x1103d8dd8, 0x1c8, 0x100000001, 0x1100657e0, 0x1105612f0) at 0x10006dc78

rb_call0(0x1103d8dd8, 0x1c8, 0x100000001, 0x1100657e0, 0x100000001, 0x6) at 0x10006e344

rb_call(0x1103d8dd8, 0x1c8, 0x100000001, 0x1100657e0, 0x100000001) at 0x10006e3c8

rb_funcall2(0x1103d8dd8, 0x1c8, 0x100000001, 0x1100657e0) at 0x10006c778

rb_obj_call_init(0x1103d8dd8, 0x100000001, 0x1100657e0) at 0x1000c0728

rb_class_new_instance(0x100000001, 0x1100657e0, 0x110588098) at 0x100064714

call_cfunc(0x1100246b0, 0x110588098, 0xffffffffffffffff, 0x100000001, 0x1100657e0) at 0x10006d1a4

vm_call_cfunc(0x110060c30, 0x110164cd0, 0x100000001, 0x110588098, 0x0, 0x1101d6310) at 0x10006ff30

vm_call_method(0x110060c30, 0x110164cd0, 0x100000001, 0x0, 0x0, 0x3e8, 0x1101d6310, 0x110588098) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

eval_string_with_cref(0x110197290, 0x110337370, 0x1101969f8, 0x0, 0x1101961c0, 0x100000001) at 0x100078eb0

eval_string(0x110197290, 0x110337370, 0x1101969f8, 0x1101961c0, 0x100000001) at 0x1000792e0

rb_f_eval(0x400000004, 0x110065750, 0x110197290) at 0x1000801b0

call_cfunc(0x11002c0c0, 0x110197290, 0xffffffffffffffff, 0x400000004, 0x110065750) at 0x10006d1a4

vm_call_cfunc(0x110060c30, 0x110164e30, 0x400000004, 0x110197290, 0x0, 0x1101f2590) at 0x10006ff30

vm_call_method(0x110060c30, 0x110164e30, 0x400000004, 0x0, 0x8, 0xb20, 0x1101f2590, 0x110197290) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

invoke_block_from_c(0x110060c30, 0x110165118, 0x110199ef0, 0x0, 0x0, 0x0, 0x0) at 0x10006c424

vm_yield(0x110060c30, 0x0, 0x0) at 0x100079c08

rb_yield_0(0x0, 0x0) at 0x100079c6c

loop_i() at 0x100081734

rb_rescue2(0x11002c390, 0x0, 0x0, 0x0, 0x1101b4390, 0x0, 0x110065620, 0x0) at 0x1000bd794

rb_f_loop(0x110199ef0) at 0x1000817f4

call_cfunc(0x11002c138, 0x110199ef0, 0x0, 0x0, 0x110065620) at 0x10006d1cc

vm_call_cfunc(0x110060c30, 0x1101650f0, 0x0, 0x110199ef0, 0x110165118, 0x1101f3190) at 0x10006ff30

vm_call_method(0x110060c30, 0x1101650f0, 0x0, 0x110165118, 0x8, 0xb50, 0x1101f3190, 0x110199ef0) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

invoke_block_from_c(0x110060c30, 0x110165220, 0x110199ef0, 0x100000001, 0xfffffffffffb060, 0x0, 0x0) at 0x10006c424

vm_yield(0x110060c30, 0x100000001, 0xfffffffffffb060) at 0x100079c08

rb_yield_0(0x100000001, 0xfffffffffffb060) at 0x100079c6c

catch_i(0x46250e, 0x0) at 0x10008197c

rb_catch_obj(0x46250e, 0x11002c3a8, 0x0) at 0x10007a444

rb_f_catch(0x100000001, 0x1100655e0) at 0x100081a2c

call_cfunc(0x11002c108, 0x110199ef0, 0xffffffffffffffff, 0x100000001, 0x1100655e0) at 0x10006d1a4

vm_call_cfunc(0x110060c30, 0x1101651f8, 0x100000001, 0x110199ef0, 0x110165220, 0x1101f2d90) at 0x10006ff30

vm_call_method(0x110060c30, 0x1101651f8, 0x100000001, 0x110165220, 0x8, 0xb40, 0x1101f2d90, 0x110199ef0) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

invoke_block_from_c(0x110060c30, 0x1101653d8, 0x1103c0f08, 0x100000001, 0xfffffffffffd410, 0x0, 0x0) at 0x10006c424

vm_yield(0x110060c30, 0x100000001, 0xfffffffffffd410) at 0x100079c08

rb_yield_0(0x100000001, 0xfffffffffffd410) at 0x100079c6c

catch_i(0x39d50e, 0x0) at 0x10008197c

rb_catch_obj(0x39d50e, 0x11002c3a8, 0x0) at 0x10007a444

rb_f_catch(0x100000001, 0x110065570) at 0x100081a2c

call_cfunc(0x11002c108, 0x1103c0f08, 0xffffffffffffffff, 0x100000001, 0x110065570) at 0x10006d1a4

vm_call_cfunc(0x110060c30, 0x1101653b0, 0x100000001, 0x1103c0f08, 0x1101653d8, 0x1101f2d90) at 0x10006ff30

vm_call_method(0x110060c30, 0x1101653b0, 0x100000001, 0x1101653d8, 0x8, 0xb40, 0x1101f2d90, 0x1103c0f08) at 0x1000700e0

vm_exec_core(0x110060c30, 0x0) at 0x1000747c0

vm_exec(0x110060c30) at 0x10007806c

rb_iseq_eval_main(0x11039fab0) at 0x10007fd48

ruby_exec_internal(0x11039fab0) at 0x1000bf0f4

ruby_exec_node(0x11039fab0) at 0x1000bf180

ruby_run_node(0x11039fab0) at 0x1000bf958

main(0x400000004, 0xffffffffffffb58) at 0x1000004e8

(dbx)

 

 

Any suggestion would be appreciated.

 

Kind regards,

Norman

SAP Web Service Call via javascript

$
0
0

I spent a lot fo time in testing a SAP Web Service via javascript.

Here is an example for calling a SAP Web Service called Z_MATANF_INTRANET_AUFTR via javascript:

 

function callSAPService() {

try {
var xmlhttp =new ActiveX Object("MSXML2.XMLHTTP.3.0");
var action
action = "http://www.sap.com/Z_MATANF_INTRANET_AUFTR";
var sURL= "http://brvsapp1v1.egv.at:8000/sap/bc/soap/rfc?services=Z_MATANF_INTRANET_AUFTR%3Fsap-client%3D011"
xmlhttp.Open("POST", sURL,false);
xmlhttp.setRequestHeader("SOAPAction", action);
xmlhttp.setRequestHeader("Content-Type", "text/xml");

var SOAPEnvelope = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' "
SOAPEnvelope += "xmlns:urn='urn:sap-com:document:sap:rfc:functions'>"
SOAPEnvelope += "<soapenv:Header/>"
SOAPEnvelope += "<soapenv:Body>"
SOAPEnvelope += "<urn:Z_MATANF_INTRANET_AUFTR>"<!--You may enter the following 5 items in any order-->
SOAPEnvelope += "<DATAB>2010-07-01</DATAB>"
SOAPEnvelope += "<KOKRS>0001</KOKRS>"
SOAPEnvelope += "<ZAUFTR>"<!--Zero or more repetitions:-->
SOAPEnvelope += "<item>"
SOAPEnvelope += "</item>"
SOAPEnvelope += "</ZAUFTR>"
SOAPEnvelope += "<ZKOSTL>"<!--Zero or more repetitions:-->
SOAPEnvelope += "<item>"
SOAPEnvelope += "</item>"
SOAPEnvelope += "</ZKOSTL>"
SOAPEnvelope += "<ZVORG>"<!--Zero or more repetitions:-->
SOAPEnvelope += "<item>"
SOAPEnvelope += "</item>"
SOAPEnvelope += "</ZVORG>"
SOAPEnvelope += "</urn:Z_MATANF_INTRANET_AUFTR>"
SOAPEnvelope += "</soapenv:Body>"
SOAPEnvelope += "</soapenv:Envelope>"
xmlhttp.Send(SOAPEnvelope);
}
catch (e) {
....
}

var xmlDoc=new ActiveX Object("MSXML2.DOMDocument.3.0");
xmlDoc.async=false;

var tmpXML = xmlhttp.responseXML.xml

.....

}

 

Edited by: Rainer Barta on Jul 14, 2010 5:38 PM

Viewing all 522 articles
Browse latest View live


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