Quantcast
Channel: SCN : Discussion List - Scripting Languages
Viewing all 325 articles
Browse latest View live

Scripting not working since upgrade to Windows 7

$
0
0

A few days ago my pc was upgraded to Windows 7, since then however I can no longer use any scripts.

Sap version: SAP 720

 

When doubleclicking on a script or dragging a script onto SAP nothing happens at all.

When starting a script using for example the GuiXT code 'Image (Toolbar) img Start=Script' I immediately receive the following error:

Untitled.png

This script (see below) should return the total number of rows in a grid and the number of rows selected.

The error always points to the line where GetObject("SAPGUI") is located, also in other transactions.

Apart from this I also don't have the 'Script development tools' anymore, which is apparently due to the missing of the windows agent. Is there a solution apart from installing this?

 

Can somebody help me resolve this?

 

The script

Dim rows
Dim aw

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
set session = application.ActiveSession


On error resume next
Set GRID1 = session.FindById("wnd[0]/usr/cntlCONTAINER/shellcont/shell")
Set GRID1 = session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell")

GRID1.setCurrentCell -1,""
selection = GRID1.SelectedRows

'Bereken aantal geselecteerde rijen
Dim selected
selected = 0
If selection<>"" Then
Dim start_pos, current_pos, reeks_pos, range, aantalKommas
'selection="1,3,5-10,12,15,20,21"
'selection="1,4,5"
'Initialize
start_pos = 1
range = 0
aantalKommas = 0
Do
  current_pos = instr(start_pos , selection , "," , 1)  '2
  'msgbox "Current: " & current_pos
  If current_pos<>0 Then
   aantalKommas = aantalKommas + 1
   'msgbox aantalKommas,,"Aantal komma's"
  End If
  reeks_pos = instr(start_pos , selection , "-" , 1)   '6
  'msgbox "Reeks: " & reeks_pos
  If current_pos>reeks_pos And reeks_pos<>0 Then
   under = Mid(selection,start_pos,(reeks_pos-start_pos))
   upper = Mid(selection,reeks_pos+1,(current_pos-reeks_pos))
   range = upper-under+range
   'msgbox "Under: " & under & chr(13) & "Upper: " & upper & chr(13) & "Range: " & range
  Else
   If current_pos = 0 and reeks_pos <> 0 Then
    under = Mid(selection,start_pos,(reeks_pos-start_pos))
    upper = Mid(selection,reeks_pos+1,len(selection))
    range = upper-under+range
   End If
  End If
  start_pos = current_pos + 1
Loop While instr(start_pos , selection , "," , 1)<>0 Or instr(start_pos , selection , "_" , 1)<>0
'Msgbox aantalKommas+1+range,,"Aantal rijen"
selected = aantalKommas+1+range
End If

'Aantal rijen
rows = GRID1.RowCount
Msgbox "Totaal: " & rows & chr(13) & "Geselecteerd: " & selected, ,"Aantal Rijen"


SAP VBScript and the Easy Access Screen

$
0
0

Hello All. I am recording SAP vbScripts and have found that I can't use them unless I am at the Easy Access Screen (the screen you get when you first login to SAP). However, I am not always at the Easy Access Screen when I need to run the script.

 

I've tried creating adding several "Back" (or F3) entries in the script to get to the E.A.S., but sometimes there is a message box which that triggers after pressing the back button and the script errors out. Does anybody know if there is a solution to this?

 

Also, I don't want to record a script going back to the E.A.S. because I could be at any transaction at the time of running the script.

 

Thanks in advance.

Running a VB script in SAP

$
0
0

Hi ,

 

I would like to know if it is possible to run a .VBS file through SAP. Currently I am using the GUI_EXEC function module to execute a .bat file located in my system.

However I would like to make a job which will run and execute the .VBS script automatically.

 

Thanks & Regards,

 

Aditya

Turn off message "Script is trying to connect to SAPGui"

$
0
0

Hi again everyone.

I have small simple question.

When I connect through Excel VBA to sap:

 

Dim App, Connection, session As Object

Set sapguiauto = GetObject("SAPGUI")

Set App = sapguiauto.GetScriptingEngine

Set Connection = App.Children(0)

Set session = Connection.Children(0)


The message, see attachement, pops up - you just have to click ok or press enter. I tried Sendkeys and application.displayalerts but neither of it works.

Is there a way, how to jump it over/ skip it/ press the OK button via script.

BTW: when I had older version of SAP - pre 7 version I think, It worked without note.

SAP.png

Thanks for your advices.

SAP GUI Scripting uses wrong Theme

$
0
0

Hi

I'm using SAP GUI Scripting for automating SAP GUI 720 from another application. It's a c# application that uses Interop.SAPFEWSELib. A user marks one or many documents ids in one system, clicks a button and the SAP GUI is opened showing a list of documents in SAP DMS.

This is all working fine but the SAP GUI does not look the same when using the GUI Scripting as when opened the normal way. It does not have the correct theme, SAP Signature Theme. It looks like it is using the Classic Theme. When running under Windows 7 the SAP GUI is even worse. Buttons and tabs are invisible.

Is there some way to change so it uses the SAP Signature Theme or another theme when SAP GUI Scripting is used?

Gunnar

Reading out grid to excel

$
0
0

Hello,

 

As I'm new to scripting in SAP (and programming in general) I'm trying to read out an sap grid to excel.

Below is my code which is (partly) working, however it only fills 96 lines in excel.

I tried 'SapGuiGridScrollToRow' to scroll every 90 lines read because I thought it had to do with some 'preloading' of the grid. However this function always gives me an error, so I put it in comments.

 

Is there a limit on the number of lines that can be read from a grid?

How can I overcome this?

Are there more efficient ways to do this?

 

Dim xclRow
Dim sapRow
Dim artNr

'Excel
Set xclapp = CreateObject("Excel.Application")
Set xclwbk = xclapp.Workbooks.Add()
'     With xclwbk
'        .Title = "ArtSer"
'        .SaveAs Filename = "artser.xls"
'    End With
Set objSheet = xclwbk.Sheets(1)

xclapp.Visible = true

objSheet.cells(1,1) = "Artikelnummer" 'MATNR
objSheet.cells(1,2) = "Serienummer" 'SERNR

xclRow = 2


     'session.findbyId(wnd[0]------).Value = objsheet.cells(1,1).value 'for example Never use the Range Object---

'SAP
sapRow = 0

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 = "iq09"
session.findById("wnd[0]").sendVKey 0
     'Artikelnummer Fabricom     artNr = Inputbox("Geef een artikelnummer:","Artikelnummer")     session.findById("wnd[0]/usr/ctxtMATNR-LOW").text = artNr     session.findById("wnd[0]/usr/ctxtMATNR-LOW").setFocus     'session.findById("wnd[0]/usr/txtMATNR-LOW").caretPosition = 6     session.findById("wnd[0]").sendVKey 8

Set GRID1 = session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell")
'msgbox(GRID1.rowcount)

for sapRow = 0 to GRID1.rowCount - 1
'session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").GetCellValue(sapRow,"MATNR")<>""
objSheet.cells(xclRow,1) = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").GetCellValue(sapRow,"MATNR")
objSheet.cells(xclRow,2) = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").GetCellValue(sapRow,"SERNR")
'sapRow = sapRow+1
xclRow = xclRow+1

'If sapRow Mod 90 Then
'     SapGuiGridScrollToRow "wnd[0]/usr/cntlGRID1/shellcont/shell", sapRow
'End If

next

MsgBox("Done")

 

SAP RFC Can't find interface name IT_ZZTABLE

$
0
0

Hi,

 

I have created a connection to call a web service from php using saprfc connector.

 

But whenever I try to call FM (i.e. using web service) I am getting following error.

 

Warning: CALDBG: Can't find interface name IT_ZZTABLE, __cal_set().

 

Please find below my code:

 

"Local Interface:
*"  IMPORTING
*"     VALUE(IT_ZZTABLE) TYPE  TT_ZZTABLE //It is of table type.
*"  EXCEPTIONS
*"      ERROR_OCCURRED


$_InputParams = array(array("IT_ZZTABLE", array("PARAM1"=>$PARAM1,"PARAM2"=>$PARAM2,"PARAM3"=>$PARAM3));


 

for($i=0; $i<count($_InputParams); $i++)

    {

   $subParam = $_InputParams[$i];
   saprfc_import($fce, $subParam[0], $subParam[1]);

     }

Any help is appreciated.


Thanks,

Vikrant.

How to find which users has used external scripting

$
0
0

I want to find out the users who used the scripting for doing any mass changes activity.


Check other Modus is aktually opend, and close Modus

$
0
0

Hello,

 

does everyon know a possibility to check if an other Modus is aktually opend.

And if an other Modus is open how can i close the Modus.

I cant find any documentation.Modus.jpg

 

 

Regards,

Emil

How can i check the right list

$
0
0

Hello, dear helpers,

 

If the User has opend session.FindById("wnd[0]/usr/cntlCC_REP_****/shellcont/shell/shellcont[1]/shell") - This is the wrong list.
and  the User has marked lines in the wrong list there is an error in this Code

 

selrows = session.FindById("wnd[0]/usr/cntlCC_REP_****/shellcont/shell/shellcont[0]/shell").selectedRows

 

error:"The control could not be found by id."

 

How can i check the right list?

 

look at shellcont[0]  / shellcont[1] in the code

 

One solution is with "On Error Resume Next"

but i looking for a direck Check, similar as

 

myfindbyid= session.getFindbyIdName

 

Regards,

Emil

GuiXT Copytext or VBScript - not allowing to paste values to multiple selection

$
0
0

Hello Guru's of Scripting.

We have a requirement to download inspection lot information for 4500+ plants using transaction QA33. We cannot use all plants at a time to get result output. I would like to run this report in parts. example: 20 plants at a time.

QA33 screen with plant selection:

2-19-2014 9-17-06 AM.jpg

Multiple selection for plant:

2-19-2014 9-18-01 AM.jpg

 

Here is my code so far:

_______________________________________________________________________________________________________________________________**********************************************************************************************************************************************************************************

//Counter

Set V[i] 1

//Input file that contains more than 4500 plants

Parameter mat_file1 "C:\Documents and Settings\Desktop\ip2.txt"

//Intermediate file to copy 20 plants at a time

Parameter mat_file3 "C:\Users\Desktop\myfile.txt"

 

 

//create myfile.txt text file on C:\Users\Desktop\ location before running program

  OpenFile "&U[mat_file3]" -Output

  OpenFile "&U[mat_file1]"

 

 

 

 

 

 

 

label Read_File

  ReadFile "&U[mat_file1]" C

 

 

if not Q[ok]

    CloseFile "&U[mat_file1]"

    CloseFile "&U[mat_file2]"

    CloseFile "&U[mat_file3]"

    Return "Job done!" "&U[mat_file1]"

  endif

 

 

// loops

//1st loop to make sure the total no of records do not exceed 4500

If V[i<4500]

AppendFile "&U[mat_file3]" C

Set V[i] "&V[i]" + 1

//Checking to make sure we append only 20 plants at a time.

//These 20 plants are added to myfile.txt

if V[i=21]

//myfile has 20 file it goes to transaction qa33 screen

Goto next_step

endif

goto Read_File

endif

 

 

 

 

 

 

label next_step

 

 

//Deletes default values from selection fields

Set F[%_QL_ENSTD_%_APP_%-TEXT] ""

Set F[%_QL_ENSTD_%_APP_%-TO_TEXT] ""

Set F[Plant] ""

Set F[Maximum No. of Hits] ""

 

 

 

 

// Inspection Lot Selection

Screen RQEEAL10.1000

//Clicked on multiple selection button

  Enter "=%043"       // Multiple selection.6

 

 

 

// Multiple Selection for Order

 

 

Screen SAPLALDB.3000

//This is equivalent to clicking on delete button from multiple selection

Enter "/16" //delete contents

 

 

// Multiple Selection for Plant

 

 

Screen SAPLALDB.3000

 

//Copy 20 plants from myfile to text t1

Copytext fromFile="&U[mat_file3]" toText="t1"

//Copy those 20 plants from t1 to clipboard

Copytext fromText="t1" -toclipboard

//Next step is to click on paste icon on dynamic selection

Enter "/24" //copy from clipboard

 

 

// Multiple Selection for Material

Screen SAPLALDB.3000

  Enter "/8"

 

 

// Inspection Lot Selection

Screen RQEEAL10.1000

  Enter "/8"       // Execute

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSLVC_FULLSCREEN.0500

  Enter "/Menu=1,4,3"       // Local file...

 

// Save list in file...

Screen SAPLSPO5.0110

  Set R[Spreadsheet] "X"

  Enter

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSFES.0200

  Set F[DY_PATH] "C:\Users\Desktop"

  Set F[DY_FILENAME] "temp.txt"

  Enter "/7"       // Extend

 

 

// Display data for inspection lot: Worklist for Inspection Lots

Screen SAPLSLVC_FULLSCREEN.0500

  Enter "/3"

 

 

Set V[i] 1

//OpenFile "&U[mat_file3]" -Output

Set V[t2] ""

Copytext fromText="t2" toFile="C:\Users\Desktop\myfile.txt"

// Display data for inspection lot: Worklist for Inspection Lots

 

 

CloseFile "&U[mat_file3]" -Output

 

 

 

 

 

 

//Screen SAPLSLVC_FULLSCREEN.0500

//  Enter "/nqa33"

goto Read_File

 

******************************************************************************************************************************************************************************____________________________________________________________________________________________________________________________

 

 

 

 

Problem part of the code:

 

Copytext fromFile="&U[mat_file3]" toText="t1"

 

Copytext fromText="t1" -toclipboard

 

Enter "/24" //copy from clipboard


When I debug this code ..I see empty value for t1 or clipboard.

I have tried several Copytext options but no solution so far.

Please help me with this issue.

GuiXT solution OR VBScript but I want it to be able to paste 20 values.

I really appreciate you'r time and effort in this regard.


SAP Krazy



How to populate internal table( varaible of ABAP table type) in Excel VBA?

$
0
0

Hi,

 

I am trying to update a database table from excel using a VBA Macro.

I am able to connect to SAP and able to read data from SAP using a RFC. Similarly after updating certain values, i want to update a table in SAP.

 

Below are the steps I am doing  apart from basic settings.

 

  1. Getting the reference of the SAP TABLE type from RFC fucntion module

' Call RFC

Set MyFunc = R3.Add("UPDATE_TVARVC_VIA_RFC")

 

' Get reference and Values TVARVC

Set oParam4 = MyFunc.Tables("TVARVC")   

 

   2. Loop over the active cells and populate oParam4

 

          " add values as below

    oParam4.Rows.Add

    oParam4.Value(1, "NAME") = ..................

    oParam4.Value(1, "TYPE") = ..................

    oParam4.Value(1, "NUMB") = ..................

  Do it for all columns in the table line.

 

 

My query is how to identify active cells and make the above code dynamic in step 2.

 

 

Thanks in Advance,

 

Best,

Aneel

VBS Script to enter data by scrolling the label.

$
0
0

Hi Experts,

 

A newbie here.

 

I am writing a script to enter multiple roles in the user's roles tab through script. I am able to achieve it partially but it stops when it comes to scroll to the next page & take the roles from excel sheet.

 

Below is my code, please take a look & advise to achieve this.

 

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 ExcelApp, ExcelWorkbook, ExcelSheet, Row ,Col

 

Set ExcelApp=CreateObject("Excel.Application")

Set ExcelWorkbook=ExcelApp.Workbooks.Open("C:\Users\KH269140\Desktop\ie_data.xls")

Set ExcelSheet=ExcelWorkbook.WorkSheets(2)

 

Row=1

Col=0

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu01"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/ctxtUSR02-BNAME").text = "test"

session.findById("wnd[0]/usr/ctxtUSR02-BNAME").caretPosition = 4

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[1]/btn[18]").press

session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpACTG").select

 

Do Until ExcelSheet.Cells(Row,1).Value=""

 

 

MsgBox "Value:" &Col

 

session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpACTG/ssubMAINAREA:SAPLSUU5:0106/tblSAPLSUU5TC_AGR/ctxtUSAGR-AGR_NAME[1,"& Col &"]").text = ExcelSheet.Cells(Row,1).value

session.findById("wnd[0]").sendVKey 0

 

Col=Col+1

 

if Col>12 Then

 

session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpACTG/ssubMAINAREA:SAPLSUU5:0106/tblSAPLSUU5TC_AGR").verticalScrollbar.position = 12

 

Col=1

 

End if

 

Row=Row+1

Loop

 

session.findById("wnd[0]").sendVKey 11

 

ExcelApp.Quit

Set ExcelApp=Nothing

Set ExcelWorkbook=Nothing

Set ExcelSheet=Nothing

Set ExcelSheet1=Nothing

 

Any help will be great.

 

Thanks,

Khagendra

automate BOM creation with script

$
0
0

Hi all

I'like to create an Excel macro that would upload a BOM for a specific equipment using SAP Script.

where i'm struggling right now is on determining the first available position in the ib02 tab

ib02.jpg

 

in the example the first line available for insertion of a new item would be the 53 one.

 

When i ran the script recorder i get the following code

************************************************************

session.findById("wnd[0]/tbar[0]/okcd").text = "/nib02"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 7

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 14

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 21

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 28

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 35

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 42

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 49

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 56

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 63

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 70

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 76

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 69

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 62

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 61

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 60

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 59

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 58

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 57

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 56

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 55

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 54

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT").verticalScrollbar.position = 53

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-POSTP[1,2]").setFocus

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-POSTP[1,2]").caretPosition = 0

 

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-POSTP[1,2]").text = "I"

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK[2,2]").text = "TEST_1117"

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK[2,2]").setFocus

session.findById("wnd[0]/usr/tabsTS_ITOV/tabpTCMA/ssubSUBPAGE:SAPLCSDI:0152/tblSAPLCSDITCMAT/ctxtRC29P-IDNRK[2,2]").caretPosition = 9

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/usr/subPOS_PHPT:SAPLCSDI:0830/txtRC29P-MENGE").text = "1"

session.findById("wnd[0]/usr/subPOS_PHPT:SAPLCSDI:0830/txtRC29P-MENGE").caretPosition = 1

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[0]/btn[11]").press

********************************************************************************************************************

 

 

thanks a lot for your input

Save SAP report in Excel format into specified drive

$
0
0

Hi Team,

 

I am new to SAP scripting and i have recorded below SAP Script to download a report from SAP in Excel format at specified format.

Here issue is that i am not able to record the Save as dialogue where the file needs to be saved automatically.

 

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 = "/nfbl3n"

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/tbar[1]/btn[17]").press

session.findById("wnd[1]/usr/txtENAME-LOW").text = "10290492"

session.findById("wnd[1]/usr/txtENAME-LOW").setFocus

session.findById("wnd[1]/usr/txtENAME-LOW").caretPosition = 8

session.findById("wnd[1]").sendVKey 8

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellColumn = "TEXT"

session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "0"

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[3]/menu[1]").select

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[0,0]").select

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[1]/tbar[0]/btn[0]").press

 

Can anyone of you help me to provide script for the same so that report is automatically saved in specified path.

 

Thanks


How to execute one sap gui script in different SAP system component versions.

$
0
0

Hi Experts,

 

I am having a task to write a script which can be executed in different SAP systems , explained as below.

 

I have created a script to do password reset for mass users in one system (TC6) & it's working fine. But when i load same script in other system(QR5) to do the same activity , the system unable to execute the same script.

 

One thing i found that by comparing in the two systems that the screen-ids in QR5 system is different than TC6 system.

 

My question

 

1-> why it is different even though the scripting language is same.

2-> How can i overcome it & make a common script for all the systems.

 

Please help me to resolve this.

 

Thanks in Advance,

Khagendra

How to make Excel VBA monitor SAP GUI Events?

$
0
0

Dear Community,

 

Is it possible to make VBA monitor events raised by SAP GUI such as CreateSession or DestroySession event?

 

From the SAP GUI Scripting API, we know that this is possible in VBS and the procedure is pretty straightforward but VBA is not as straightforward as VBS.

 

I think Class Module is the way to go but so far I have not found any reference on how to connect to other objects which is not Office-related.

 

Any help or tips will be very much appreciated. In the mean time, I'll continue experimenting and will post if I've figure it out.

 

Thanks,

Sayuti

p/s: Sorry moderator if this is a redundant post, but due to bad internet connection, I'm not sure whether my earlier post on this topic went through or not.

Problem with the RFC Connection Object

$
0
0

Good day together,

 

i work since two days on a problem - without any solution. Iam sure the solution is kind of easy, maybe one codeline.

 

I build up my RFC Connection with my Access-AddIn. In this Addin i have a simple module:

 

Public rfcLogon As Object

Public rfcConnection As Object

Public rfcFunctions As Object

Public rfcDataTable As Object

 

 

 

 

Function setRfcConnection() As Boolean

    On Error Resume Next

   

    Set rfcLogon = CreateObject("SAP.Logoncontrol.1")

    Set rfcConnection = rfcLogon.NewConnection

   

    rfcConnection.ApplicationServer = "XXXX"

    rfcConnection.System = "XXXXX"

    rfcConnection.SystemNumber = 46

    rfcConnection.User = "XXXXX"

    rfcConnection.Password = "XXXXXX"

    rfcConnection.Client = "470"

    rfcConnection.Language = "DE"

   

    setRfcConnection = rfcConnection.Logon(0, True)

    If Not setRfcConnection Then qp.RFC.rfcConnection.LastError

End Function

 

 

Sub closeRfcConnection()

    If rfcConnection Is Nothing Then Exit Sub

    rfcConnection.Logoff

    Set rfcLogon = Nothing

    Set rfcConnection = Nothing

End Sub

 

 

 

When i start a procedure like this:

 

Sub Test()

    qp.RFC.setRfcConnection

    qp.RFC.closeRfcConnection

 

 

    qp.RFC.setRfcConnection

End Sub

 

 

 

 

... i get an error at the second call of setRfcConnection from the RFC:

 

 

Error Group

 

 

RFC_ERROR_SYSTEM_FAILURE

 

 

Message

 

 

>>> RfcOpenEx ...

Got following connect_param string:

   USER=ME_CPIC CLIENT=470 LANG=DE PASSWD=******* <<< RfcOpenEx failed

 

 

 

I cant start a new Connection until i close Access and start it again. My first thoughts were this is because I did not reset the Object, but I did. Although I tried the .Logoff-Method. No solution :-/

 

Thanks a lot for any ideas and help.

SAP CRM VBA Excel Macro, No data return

$
0
0

Dear experts and everyone else that feels in the mood to contribute,

 

I've been looking into some basic scripting when it comes to SAP and Excel. My legs are still unstable and I would see myself being in the start of a wonderful learning experience.

 

I've managed to establish a connection between MS Excel VB and SAP CRM Sandbox system using various forum posts and example codes from sdn. My next step would be to call a certain Function Module, pass some input parameters and then present the Export variables in a Excel sheet.

 

By looking at examples of this i've establish a theory but alas it does not work, hence I am asking for guidance on what I am doing wrong and how I could continue my newly started adventure.

 

As of now my code looks like this:

 

Sub CallFunctionModule()

 

'Declare the objects and variables

Dim functionCtrl As Object             'Function Control (Collective object)

Dim sapConnection As Object         'Connection object

Dim theFunc As Object                 'Function object

Dim Returnvalue As Boolean       'Used to check if data is returned

'Create a function object

 

Set functionCtrl = CreateObject("SAP.Functions")

Set sapConnection = functionCtrl.Connection

 

'**********************************************

'Create Server object and Setup the connection (The connection seems to be establish in a correct manner)

'**********************************************

sapConnection.Client = "000"

sapConnection.user = "USERID"

sapConnection.Language = "EN"

sapConnection.SystemNumber = "00"

sapConnection.Destination = "DEST"

sapConnection.System = "SYSTEM"

If sapConnection.logon(0, False) <> True Then

    MsgBox "No connection to R/3!"

    Exit Sub                                           'End program

End If

 

'*****************************************************

'Call function moduole

'*****************************************************

'Reference to a function object

Set theFunc = functionCtrl.Add("FUNC_MOD_NAME")

 

'Determine the import parameters for the function call

theFunc.exports("IMPORT1") = "1234"

theFunc.exports("IMPORT2") = "456"

Returnvalue = theFunc.Call

 

If Returnvalue = True Then

    MsgBox "SAP Data Found"

Else

    MsgBox theFunc.Exception

End If

 

End Sub

 

As of now I seemingly establish a connection and I am able to call the function module. But every time ReturnValue = false.

If I run the function module in SAP transaction SE37 with same parameters it executes successfully and export is created.

If I change the data for functionCtrl.Add("FUNC_MOD_NAME") or theFunc.exports("IMPORT1") i'll get error messages which to me would indicate that I am finding the function module and correctly refeering to the import parameters.

 

What am I missing here? Why is theFunc.Call always returning false? Does this mean I am not getting data or is there some other way of determining if data is correct? If I check declarations of Import parameters in the function modules I see they are declared as NUMC (Character string with only digits) which should accept String as valid input?

 

Any help on this is appriciated since i'm very much enjoying this new found playground.

 

Best Regards,

Ernst

Open excel with SAP Credentials

$
0
0

I am working on an excel application that will enable changes in SAP PI/XI. When the user opens the excel file, the file will prompt for a SAP UserID and Password. The user will typein their SAP User ID and Password and these credentials should be validated against sap (maybe using SAP Logon Control???). If ok the excel file will open else it will says invalid user id pass.

 

Please let me know if this is doable.

 

Thanks

Viewing all 325 articles
Browse latest View live


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