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

Re: Need to read the contents of an ID using VBS

$
0
0

Thanks for your reply, and indeed it contained the following text "@09@" for yellow, now the following problem that i have is how to make it work on vbs, if i use the wizard to know the ID where the traffic lights are i have the following ID session.findbyid("wnd[0]/usr/lbl[3,14]").

 

I tried doing the following to know if in reality it is yellow:

 

If session.findbyid("wnd[0]/usr/lbl[3,14]").text = "@09@" Then MsgBox "Yellow"

 

When i run that part of the code i get nothing, so it makes me believe that the coordinates 3, 14 doesnt contain "@09@", is there an easy way to read those ID's in a different way and not in a coordinates.


Re: Sap script- t-code AS02

$
0
0

Hi MJ MJ,

 

1. Whenever an error occurs, an error message from Windows Script Host is reported. Take a close look at the faulty line.

 

2. It could be that the script has to wait a little until the message appears.

. . .

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

wscript.sleep 1000

On Error Resume Next
xclsht.Cells(i, 4).Value = session.findById("wnd[0]/sbar").Text
On Error GoTo 0

Next

. . .

 

Regards,

ScriptMan

Re: Sap script- t-code AS02

$
0
0

 

 

 

 

Re: How can I execute 6 sessions in parallel?

$
0
0

Hello Steve,

 

as far as I know is VBA single threaded and it is not possible to run multiple threads or processes.

 

I think one way is to code six different VBScript files with your code. Start each from Excel with the VBA command Shell, here an example:

 

Shell "wscript.exe MyScript1.vbs"

Shell "wscript.exe MyScript2.vbs"

etc. etc. etc.

 

Let us know if it works.

 

Cheers

Stefan

Re: Sap script- t-code AS02

$
0
0

Hi MJ MJ,

 

then you did accomplished already a lot. You could still try the following.

 

for example:

. . .

MsgBox "All " & CStr(imax - imin + 1) & " Excel rows have been processed."

End If

xclapp.ScreenUpdating = true

xclapp.ActiveWorkbook.Save

Set xclwbk = Nothing

. . .

 

Regards,

ScriptMan


Re: How can I execute 6 sessions in parallel?

$
0
0

Hi Stefan,

 

Thanks for the reply. I asked Scriptman offline and he provided some code to get me started. i haven't had time to test it but plan to this week. I'll reply back with the results when I'm done. I hoped there would be an easier way, but the work around may work.

 

I also thought about using APIs to get around it but didn't see anything to get me started.

 

thanks again for the reply. This forum and its contributors are great resource.

 

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

Re: Beginner Help With GUI Script To Save File Automatically


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, all 64bit. 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

Re: How to Manipulate Logon Pad Options with VBScript

$
0
0

Hello Garry,

 

Sorry for the late answer. I was on holiday.

Thank you for the information regarding the WMI option.

 

I made a test with the following code.

If the saplogon is not active, the error is caught and then i launch the saplogon via "sapstart"  command.

It works for me.

Hope it will help you.

 

    If Not IsObject(Application) Then

        On Error GoTo AutomationErr
       
        Set SapGuiAuto = GetObject("SAPGUI")
        Set Application = SapGuiAuto.GetScriptingEngine
        GoTo next:
       
AutomationErr:

 

        Path = "C:\Program Files (x86)\SAP\SapSetup\setup\SapStart.exe " + "/sal=" + Chr(34) + "C:\Program Files (x86)\SAP\SapSetup\setup\SAL\SapLogon.s8l" + Chr(34)
        shell Path
        
next:

 

    End If

Re: SAP Web Service Call via javascript

$
0
0

Hi Rainer,

How do you pass SAP user id and password ?

Transfer Data From Excel to SAP

$
0
0

Hi Team,

 

While working on T-code VA02 i want to transfer the values provided in Excel to SAP.

think i got values in a1, b1 and so on..by name Billing plan,Value

I want to go to   the line item  and then the billing tab and under that tab the values should be entered based on the Excel Column names.

and in SAP  to go to next line item i am using Shift+ F7 to go up..it should go automatically till the value is blank..Please do let me know how ?

 

Also after updation i want to add/delete a specific column only.. Is it possible..

If nothing to pullout in sap

$
0
0

Hi everyone,

 

I have an inquiry on my project. I recorded a script that it will pull out the information I needed in every country we handle. But I dunno how to set if error message to my script.. after DO_QUERY to sap then error message pop up.... Its because nothing to pull out no data from that country that I need.

 

Can you please help me with do_query result is blank then Message SAP did not pull out anything from COUNTRY

 

session.findById("wnd[0]/usr/cntlCLFRM_CONTAINER/shellcont/shell/shellcont[1]/shell/shellcont[0]/shell/shellcont[1]/shell").pressButton "DO_QUERY"

 

after that line...

 

 

Thanks

Tina

How to read the record file programmatically

$
0
0

Hi all,

I'm new to SAP and SAP GUI Scripting.

 

I've 2 questions that need your expertise to enlighten me.

 

1. session.RecordFile = "myfile"                <- this will created under SapWorkDir

Q: Is there a way to know exact directory based on the variable SapWorkDir without hardcode it?

I need to use program to read this "myfile". Main reason no hardcode, I may have different SAP Gui Clients on different environments (XP, Win7 etc)

 

2. If above solution does not work

I know another alternative, using "_Change" event to record it myself. Is there any good sample?

 

Hope i can get some hints from you guys.

 

Cheers

Sato

Re: How to read the record file programmatically

$
0
0

Hello Eric,

at first welcome.

 

You can get the SAP work directory inside SAP GUI Scripting with the following code:

 

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

  '-Directives----------------------------------------------------------
    Option Explicit
  '-Variables-----------------------------------------------------------
    Dim SAPInfo, strResult
  Set SAPInfo = CreateObject("Sapgui.InfoCtrl.1")

  If IsObject(SAPInfo) Then
    strResult = SAPInfo.GetSapWorkDir()

    MsgBox strResult, vbOkOnly, "SAP Work Directory"
    Set SAPInfo = Nothing
  End If
'-End-------------------------------------------------------------------

 

Look also here: How to use SAPInfo Control module inside SAP GUI Scripting

 

You find an example for the change event here: https://service.sap.com/sap/support/notes/1441550, it is in VB classic.

 

Let us know your results.

 

Cheers

Stefan


Re: Save roport as file via Windows explorer

$
0
0

Hello Evgeniy,

 

I have tried it with transaction code SE80 and download a source, to get the same dialog as you. SAP GUI Scripting records the activities of this dialog in my case ditto not.

 

So I try different ways like this

 

session.findById("wnd[0]/mbar/menu[3]/menu[10]/menu[4]/menu[1]").select

Set wsh = CreateObject("WScript.Shell")

wsh.SendKeys "Test.abap{ENTER}"

 

and this

 

session.findById("wnd[0]/mbar/menu[3]/menu[10]/menu[4]/menu[1]").select

Set autoit = CreateObject("AutoItX3.Control")
autoit.Sleep 500
autoit.WinActivate "Speichern unter", ""
autoit.Send "Test.abap{ENTER}"

 

to fill the dialog, but without success.

 

If you find a stable solution, let us know. It is an interesting problem.

 

Cheers

Stefan

Re: If nothing to pullout in sap

$
0
0

Hello Maria,

 

first of all you should perhaps tell us if that is a special Transaction your working with or is it standard SAP

 

Next thing i assume is that SAP gives a feedback in the Statusline ()
for e,g,  0 Records have been selected (or anything like it ?)

 

If that is the case just click the Statusbar and there should Popup a WIndow with a Message and an ID.

 

With this "ID" you can get a simple Errorhandler-

If session.findbyid("wnd[0]/usr/sbar").MessageId <> 3 '(only asExample here should stand the ID you got from above ...     
else

End if

 

greetings

Thomas Bräutigam

Re: How to read the record file programmatically

$
0
0

Dear Stefan,

You are right. But the documentation says otherwise.

 

My environment.

Window 7 and window server 8

SAP GUI : 720 Final Release

Family : 64 bits

 

 

The result of "strResult" is C:\Users\<login name>\Documents\SAP

I assume this is SapWorkDir

 

 

I used the SAP GUI Script  (using AutoIt scripting)

 

 

$file = $application.Utils().OpenFile("TEST_1")

$application.Utils().Write($file, "hello world")$application.Utils().CloseFile($file)

$application.Utils().CloseFile($file)

; Yes the file created C:\Users\<login name>\Documents\SAP

 

 

But (recording)

$session.TestToolMode = 1

$session.SaveAsUnicode = True

$session.Recordfile = "Test_IE07"

$session.Record=True

; It will create the file in this directory C:\Users\<login name>\AppData\Roaming\SAP\SAP GUI\Scripts\

;According the doc - (chm file) - under "RecordFile"

;A simple way to record a script it to set the recordFile property to a valid filename and then enable the record property. A Visual Basic Script file of the given name will be created in the SapWorkDir on the client PC

 

 

Why the RecordFile (stated in SapWorkDir) but checked, created in C:\Users\<login name>\AppData\Roaming\SAP\SAP GUI\Scripts\

and not C:\Users\<login name>\Documents\SAP

 

 

Hope you can further assists.

 

 

Best Regards,

Sato

Re: How to read the record file programmatically

$
0
0

I think i found the answer in SAP's doc

From the pdf doc on page 9.

It stated

 

 

SAP GUI Scripts

Windows XP:

C:\Documents and Settings\<username>\Application Data\SAP\SAP GUI\Scripts

Windows Vista/7:

C:\Users\<username>\AppData\Roaming\SAP\SAP GUI\Scripts

 

Started from SAP GUI Window - 7.20 onward.The local working directory SAPWORKDIR is obsolete and a new Windows-compliant structure is used.

Re: Not able to display data from standard table in SAP Script

$
0
0

Hi Nikhil,

 

              We can`t put any breakpoints in SAP Scripts, to debug a script just go to SE71 initial screen and in the menu option click Utilities-> Activate debugger.

  1. Activate the debugger by choosing Utilities
  2. ®Activate debugger in the
    Form: Request screen. You can then generate printer output in dialog.
    A dialog box containing the default breakpoints appears.
    • Track each call of a SAPscript function module, each INCLUDE call, and each
      warning in the debugger.


To switch off the debugger, choose Debugger -> Exit in the debugger window.

Viewing all 1708 articles
Browse latest View live


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