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

Excel VBA (SAP.Functions) Not working with SAP GUI 7.40

$
0
0

have a Excel VBA which connects to SAP, pulls some data and does some processing on it. It was working fine with SAP GUI 7.20. But it stopped working when I installed SAP GUI 7.40. My code is as below :

Dim obBAPICall AsObject  ' * Create objectSet obBAPICall = CreateObject("SAP.Functions")..

I get following error :

1.png

I've already gone through some weblinks and I believe I've all the required references. (In fact, I've added many more in order to troubleshoot the problem).

2.png

My SAP GUI version is :



3.png

 

For your information -

Following code does not have any problem :

Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")

 

Any help is highly appreciated.

Thank you.


Attaching document via script

$
0
0

Related to my last question...

 

We attach scanned images to many of our SAP documents via a script.  We know the path name and the filename of the attachment, but we still have to manually find the document in a browse window and confirm it.  Is it possible to have the script attach the scanned image to a given SAP document directly in the script with no user interaction?

 

Also, is it possible to download all the attachments from a given SAP document to our file server without user interaction?

 

We are using VBA scripting in Excel for these scripts.

 

Thanks,

Tyler

Carriage Return on SAP Security Audit Log

$
0
0

Hi,

 

Would like to ask if anyone can help me write a Unix script that will break the Security Audit log into one security entry per line or insert a carriage return per entry which will be written to a new log file? We need to setup log file monitoring via RZ20 in Security Audit log file to monitor and capture specific pattern but we are having problem capturing accurate and correct entries in the log due to the nature of Security Audit log file that has no carriage return or line separator.

 

Thanks.

Rupert

VBA code to get client and system of current SAP window

$
0
0

Hi Gurus,

 

I am creating a tool to automate sap process but i have access to various sap system. Now, i need to know if i am working with a correct SAP system.

Can you help me figure out the code to detect the system of current sap window? See attached.

 

Thank you in advance.

 

regards,

Mike

Adding a variable in the sap script code

$
0
0

Hi All,

 

Below is a part of my excel macro:

 

For i = 0 To 6

session.findById("wnd[1]/usr/tabsTAB_STRIP/tabpSIVA/ssubSCREEN_HEADER:SAPLALDB:3010/tblSAPLALDBSINGLE/ctxtRSCSEL_255-SLOW_I[1,i]").Text = Plant(i)

 

Next

 

I am using a variable " i " instead of [1,0]").Text , [1,1]").Text  etc of the macro. But it is not working.

 

Can someone let me know what correction is

sapnwrfc a PHP extension for the NW RFC SDK

$
0
0

Hello all -

 

I am looking for help with testing and improving a new PHP RFC extension, sapnwrfc.

 

This is designed to take advantage of the NetWeaver RFC SDK, and hopefully will help deal with unicode issues.

 

The code is available at http://www.piersharding.com/download/php/sapnwrfc/

 

And the primary problems are with:

 

 

  • determining the build process for win32

 

  • robustly testing the parameter calling interface.

 

In the source archive available above, there are sketchy build instructions in INSTAL, and in the unit_tests directory, are examples.

 

A starting point would be to get the build going and just run those tests.

 

Cheers,

Piers Harding.

SAPGUI Script in C# not working

$
0
0

Hey guys,

 

     I'm coding C# to automate some SAPGUI scripting, and I have this wired problem...

      Below is the code piece

 

 

               GuiApplication guiApp = (GuiApplication)System.Activator.CreateInstance(Type.GetTypeFromProgID("SapGui.ScriptingCtrl.1"));

               

                GuiConnection guiConn = guiApp.OpenConnection("MYSYSTEM", true, true);

 

               

                GuiSession guiSession = (GuiSession)guiConn.Sessions.Item(0);

                GuiFrameWindow guiWindow = guiSession.ActiveWindow;

 

                GuiTextField client = (GuiTextField)guiWindow.FindByName("RSYST-MANDT", "GuiTextField");

                GuiTextField login = (GuiTextField)guiWindow.FindByName("RSYST-BNAME", "GuiTextField");

                GuiTextField pass = (GuiTextField)guiWindow.FindByName("RSYST-BCODE", "GuiPasswordField");

                GuiTextField language = (GuiTextField)guiWindow.FindByName("RSYST-LANGU", "GuiTextField");

                client.SetFocus();

                client.Text = "XXX";

                login.SetFocus();

                login.Text = "XXXXXXX";

                pass.SetFocus();

                pass.Text = "XXXXXXX";

                language.SetFocus();

                language.Text = "XX";

 

This code piece worked 100% fine a week ago, but it's not working now... The problem now is that guiConn.Session contains no items after OpenConnection. I'm coding in Visual Studio 2008, I don't think I did any change to my VS project.

 

I tried guiConn.Children, it contains no items either.

 

Please help!!!

 

Thanks,

Shu

BAPI connection & citrix

$
0
0

Hi All,

 

I have a macro which works fine when I run it from my local computer. Unfortunately, it fails to connect to SAP when I try to run it from SAP as a citrix application.

 

What I mean by "Citrix application" is that I open SAP from the Citrix website. Next, I upload the Excel file with macro to SAP. Lastly, I open and run the macro from SAP. This has always worked for VBA/SAP Script macro's.

 

Any ideas?

 

Code:

Function Logon_SAP()

   

Dim wsS As Worksheet

 

 

Set wsS = ThisWorkbook.Worksheets("Settings")

Set oSAP = CreateObject("SAP.Functions")

 

 

With oSAP.Connection

    .system = wsS.Cells(3, 6)

    .client = wsS.Cells(3, 1)

    .user = wsS.Cells(3, 2)

    .Password = wsS.Cells(3, 3)

    .Language = wsS.Cells(3, 4)

    .hostname = wsS.Cells(3, 5)

    .systemnumber = wsS.Cells(3, 7)

   

    If .Logon(1, True) = False Then

        MsgBox "Could not connect to SAP using provided details", vbCritical, "BAPI connection error"

        End

    Else

        MsgBox ("Connection OK.")

    End If

End With

 

 

End Function


Issues running a macro

$
0
0

Hi everyone.

 

Sometimes, when I run a macro on determinated computers, It will throw an error message saying that vba can't find an object.

If I logout and login again into SAP, the macro will run without any issue.

 

Does anyone know why this happends and how can be fixed? I won't get this error on most of the computers but is annoying for the people who has one of the rest.

 

Thanks in advance for your help and support.

 

Best Regards

 

Vic

script for attaching file/doc automatically

$
0
0

Hi


I am new to scripting  and I would like to if there is a script for attaching file/doc automatically to the master article in mm43 or mm03


Please share as it would be very useful



FB03 Exporting of attachment

$
0
0

Hi guys!

 

I am currently developing a macro tool wherein I can export the attachment of a document using FB03 and saving it in a specific folder.

I was able to create one but I have the following problem:

> I don't know why there is an error with the path of the file whenever I try to link specific paths to a cell from my excel. But when I input the path directly to the VBA, it works. (hope this question was clear. )

> I am a VBA beginner so I would like to loop this macro and I want it to perform the export for a list of documents and not just one.

> Is it possible for me to insert the exported file into the excel sheet next to the document number?

 

Hope I was clear with what intend to do...Please help.

 

THANK YOU SO MUCH!!

 

 

Below are the details that I have in my Excel sheet

 

ABC
1Destination FileC:\Users\LIX2628\Desktop\PUll outs export\
2 Document NumberCo. CodeYear
1200072996u0012014

 

 

And below is the script that I used.

 

Sub FB03export()

 

 

Dim application

 

 

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]").resizeWorkingPane 196, 15, False

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nfb03"

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

session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Cells(3, 2).Value

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Cells(3, 3).Value

session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Cells(3, 4).Value

session.findById("wnd[0]/usr/txtRF05L-GJAHR").SetFocus

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

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

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_VIEW_ATTA"

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

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

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").contextMenu

session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").selectContextMenuItem "%BDS_START_BDN"

session.findById("wnd[0]/shellcont[1]/shell").selectedNode = "Doc-00000001"

session.findById("wnd[0]/mbar/menu[0]/menu[6]").Select

session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").Text = "C:\Users\LIX2628\Desktop\PUll outs export\"

session.findById("wnd[1]/usr/sub:SAPLSPO4:0300/ctxtSVALD-VALUE[0,21]").caretPosition = 42

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

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

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

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

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

 

 

End Sub

Mass composite role assignment to users.

$
0
0

Hi Team,

 

I am trying to write a vb script for assignment of composite roles to users but facing issues for selecting a particular absolute row.

Can any one suggest a script for this.

 

We are going to perform this during our cut over activity.


Regards,

Khagendra

VBA Code to get the text value of an icon

$
0
0

Good day everyone.

 

I'm currently doing a macro to get the status of hundreds of purchase requisition thru tcode ME53N. My problem now is i can't get the text the value

of an icon if the PR is released already or not. Can anyone help me with this please? Below is my code:

 

 

Sub checkPRstatus()

 

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

 

 

Windows("checkPRstatus.xlsb").Activate

    Dim i As Integer

   

     i = 12

    Dim j As Integer

   

    Dim strwf As String

   

    ActiveSheet.Range("C" & i).Select

   

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

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nME53N"

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

 

 

Do While ActiveSheet.Range("C" & i) <> ""

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

session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/radMEPO_SELECT-BSTYP_B").Select

session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-BANFN").Text = ActiveSheet.Range("C" & i).Value

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

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3102/tabsREQ_HEADER_DETAIL/tabpTABREQHDT2").Select

 

 

session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3102/tabsREQ_HEADER_DETAIL/tabpTABREQHDT2/ssubTABSTRIPCONTROL3SUB:SAPLMERELVI:1102/cntlRELEASE_INFO_REQHD/shellcont/shell").currentCellColumn = "ICON"

 

 

ActiveSheet.Range("D" & i) = (session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0010/subSUB1:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3102/tabsREQ_HEADER_DETAIL/tabpTABREQHDT2/ssubTABSTRIPCONTROL3SUB:SAPLMERELVI:1102/cntlRELEASE_INFO_REQHD/shellcont/shell").currentCellColumn = "ICON").IconName()

 

 

Loooop:

i = i + 1

Loop

 

 

MsgBox Environ("username") & ": Done!"

 

 

 

 

End Sub

 

PR.JPG

VB coding req for GUITableControl

$
0
0

HIi,

 

I want to run a VB scrift in sap screen, with GUItablecontol field.

 

Below is code of the tabel

 

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

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

 

i want to run a loop in order to serach a value in the all the lines.

 

Please help me in this issue!

 

Regards

Victor

(VB.net) how to press a pressToolbarButton ??

$
0
0

Hello,

 

I access to sap with scripting routine, but, i can't press a "pressToolbarButton", example:

 

     session.findById("wnd[0]/usr/cntlPEDI_HDR_CONTAINER/shellcont/shell").pressToolbarButton "CRE_DTL"    (FROM SCRIPT RECORD)

 

¿How to translate this in vb.net? and i tried with this:

 

     session.findById("wnd[0]/usr/cntlPEDI_HDR_CONTAINER/shellcont/shell").pressToolbarButton("CRE_DTL")

 

but not work.

 

Thank you.


Need help with Excel macro - Exporting SAP data to Excel - Can't control Save As dialogue box

$
0
0

I want to create an Excel macro that exports columns of data from SAP, exports it to Excel, and then manipulates the data into a pivot table.

 

I have successfully created this macro, except I had to split it into 2 pieces because I cannot control the Save As dialogue box when trying to export the data to excel. The script recorder does not record clicks and actions on the Save As dialogue box.  I have tried SendKeys with no avail.

 

Please look at my video to see how the macro currently runs:

www.youtube.com/watch?v=0kr0SE1HJtA

 

How do I create a script that automates clicking 'Save As' and then overwrites the previous file within the Save As dialogue box?

 

Thanks,

James

Save SAP-generated pdf to filesystem

$
0
0

Hello, I am accesing sap from excel-vba and, at some place, a pdf-document is generated and opened in Adobe-Reader. Now, I need to access Adobe Reader and save the pdf-doc. Has anyone already solved this task? I'd be very happy about any help you can give me! Cheers, Stefan

List/Export/Spreadsheet on Script Recording Not saving file name

$
0
0

Hi everyone.

I need help .

I'm trying to run a complet list from SAP automatically.

But I'm stuck in the option

List/Export/Spreadsheet.

 

I need the code for write in the windows popup Save As (from VBS script)

I'm trying save like .MHTML because my other file was created with this type of file.

I'm running the Script Recording option, but is not recording the name placed .Name not saved.jpg

[VBA] Reading data in non-editable fields

$
0
0

Hi everyone,

 

I'm looking for a way for my VBA script to read the content of greyed out fields in VA01.

Example:

 

1.PNG

 

Normally I am able to find the path by recording myself editing the cell content in SAP:

 

session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,1]).Text = "1"

Afterwards I can simply fill an Excel cell with the data:

 

Sheets("X").Cells(y, z) = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV45A:4401/subSUBSCREEN_TC:SAPMV45A:4900/tblSAPMV45ATCTRL_U_ERF_AUFTRAG/ctxtRV45A-MABNR[1,1]).Text

 

However, this method does not work for the locked fields that I cannot edit since they won't show up in my recording.

Even when I check what table the desired data lies in and replace "RV45A-MABNR" with the correct table and [1,1] with right position I get nothing.

How can I work around that? Your help would be greatly appreciated.

Scripts to save a PDF copy of a doc from SAP screen to our desktop.

$
0
0

Hi All,

 

I am trying to save PDF copy of invoice from VF03 screen in SAP to my desktop.

When i record the scripts for the navigation which i do...it records the script till the print preview screen as attached and i am not able to proceed further to save it in my desktop.

Invoice print preview screen.JPG

Can you please help me get the VB scripts until it saves it in desktop.

 

I appreciate your help your quick help.

 

 

Thanks,

Karthik

Viewing all 325 articles
Browse latest View live


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