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

How to check if in correct SAP system

$
0
0

Hi,

 

I'm having trouble with my script in picking the correct system to run. For example I have A6P430 and ANP430 system open at the same time. When I run my macro it choose the wrong system.

 

Im using SSO to open sap. Would it be better to include sap logon before macro code?

 

 

Please try to improve my script. Thank you.

 

What I have is this:

 

Public SapGuiAuto, WScript, msgcol

Public objGui  As GuiApplication

Public objConn As GuiConnection

Public objSess As GuiSession

Public objSBar As GuiStatusbar

Public objSheet As Worksheet

Dim W_System

 

 

 

Function Attach_Session() As Boolean

Dim il, it

Dim W_conn, W_Sess

 

If W_System = "" Then

   Attach_Session = False

   Exit Function

End If

 

If Not objSess Is Nothing Then

    If objSess.Info.SystemName & objSess.Info.Client = W_System Then

        Attach_Session = True

        Exit Function

    End If

End If

 

If objGui Is Nothing Then

   Set SapGuiAuto = GetObject("SAPGUI")

   Set objGui = SapGuiAuto.GetScriptingEngine

End If

 

For il = 0 To objGui.Children.Count - 1

    Set W_conn = objGui.Children(il + 0)

    For it = 0 To W_conn.Children.Count - 1

        Set W_Sess = W_conn.Children(it + 0)

        If W_Sess.Info.SystemName & W_Sess.Info.Client = W_System Then

            Set objConn = objGui.Children(il + 0)

            Set objSess = objConn.Children(it + 0)

            Exit For

        End If

    Next

Next

 

If objSess Is Nothing Then

   MsgBox "No active session to system " + W_System + ", vbCritical + vbOKOnly"

   Attach_Session = False

   Exit Function

End If

 

If IsObject(WScript) Then

   WScript.ConnectObject objSess, "on"

   WScript.ConnectObject objGui, "on"

End If

 

Set objSBar = objSess.findById("wnd[0]/sbar")

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

Attach_Session = True

 

 

End Function

 

 

Here is how I call the system:

 

Sub StartExtractA6P()

Dim currentline As Integer

 

  

    W_System = "A6P430"

    RunGUIScriptA6P currentline

     

 

End Sub


How to keep line breaks when copying text?

$
0
0

I have created a VBA script to copy sales texts from orders through VA03

The script is copying the texts, but is not keeping the line break that exists in SAP. Is there something I can do to keep the line breaks when text is copied to excel?

Below you have the piece of the code that is copying from SAP and storing the text in a variable

 

objSess.FindById("wnd[0]").Maximize

objSess.FindById("wnd[0]/usr/ctxtVBAK-VBELN").Text = ""

objSess.FindById("wnd[0]/tbar[0]/okcd").Text = "/nva03"

objSess.FindById("wnd[0]").sendVKey 0

objSess.FindById("wnd[0]/usr/ctxtVBAK-VBELN").Text = W_OrderNumber

objSess.FindById("wnd[0]/usr/ctxtVBAK-VBELN").caretPosition = 9

objSess.FindById("wnd[0]").sendVKey 0

objSess.FindById("wnd[0]/mbar/menu[2]/menu[1]/menu[10]").Select

objSess.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\09/ssubSUBSCREEN_BODY:SAPMV45A:4152/subSUBSCREEN_TEXT:SAPLV70T:2100/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").SelectItem W_Text, "Column1"

objSess.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\09/ssubSUBSCREEN_BODY:SAPMV45A:4152/subSUBSCREEN_TEXT:SAPLV70T:2100/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").EnsureVisibleHorizontalItem W_Text, "Column1"

objSess.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\09/ssubSUBSCREEN_BODY:SAPMV45A:4152/subSUBSCREEN_TEXT:SAPLV70T:2100/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[0]/shell").DoubleClickItem W_Text, "Column1"

objSheet.Cells(iRow, 6).WrapText = True

objSheet.Cells(iRow, 6) = objSess.FindById("wnd[0]/usr/tabsTAXI_TABSTRIP_HEAD/tabpT\10/ssubSUBSCREEN_BODY:SAPMV45A:4152/subSUBSCREEN_TEXT:SAPLV70T:2100/cntlSPLITTER_CONTAINER/shellcont/shellcont/shell/shellcont[1]/shell").Text

objSess.FindById("wnd[0]/tbar[0]/btn[3]").press

objSess.FindById("wnd[0]/tbar[0]/btn[3]").press

 

Thanks,

Francine

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.

Simple copy/paste from Excel to SAP spreadsheet

$
0
0

I am new to SAP and need to copy/paste a block of cells from an Excel spreadsheet into a SAP spreadsheet. At the moment I have an Excel macro that does everything except paste the selected data into the SAP spreadsheet - for this I need the user to select the destination cell and then do a Ctrl +  V.

 

 

Is it possible to add some code to the macro that would select the SAP cell and do a paste? Thanks for any guidance.

Attaching documents in FB03

$
0
0

Hello Dears,

 

I hope you can help me with my problem.

 

I am trying to do a VBA macro in Excel and goal is to attach a file in a document number.

I have recorded a script in SAP and edited it, but the pop-up box won't direct to my file path and I have to click the attachment everytime the macro runs.

 

Here's the script of my macro.

______

 

 

Sub Picture1_Click()

'

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 = Connect

ion.Children (0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session, "on"

   WScript.ConnectObject application, "on"

End If

 

 

LG = 3

 

 

Do While Range("A" & LG) > ""

 

 

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

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

session.findById("wnd[0]/usr/txtRF05L-BELNR").Text = Range("A" & LG)

session.findById("wnd[0]/usr/ctxtRF05L-BUKRS").Text = Range("B" & LG)

session.findById("wnd[0]/usr/txtRF05L-GJAHR").Text = Range("C" & LG)

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_PCATTA_CREA"

 

 

LG = LG + 1

Loop

 

 

MsgBox UCase(Environ("username")) & ": Done attaching."

 

 

End Sub

 

___

 

I hope you can help me so I won't have to attach manually in SAP.

 

Thanks!

If function to ignore sap script trying to attach

$
0
0

Hi, does anyone have the script to ignore this message if a user has not set in GUI settings?

Connecting from excel

Help Needed With Scripting and Error Messages

$
0
0

    I am working to build a script to change orders in SAP using Java. I begun by recording steps and combining them.  I am having issues with the Warning and Error Messages.  Can someone help me write language to have the script enter through the warnings or errors if they pop up, but move to the next step if nothing pops up?? Some orders have the message, some do not, some have multiples... etc...

 

Thanks!!

Synchronization issue with SAP session1 and session2 using QTP/UFT automation

$
0
0

Hi Guys,

 

I am using UFT to automate SAP application. My scenario is to automate the SAP Mail creation using the SWBP transaction. During the execution of the script while clicking the New Message button then new SAP session should open and need to compose the mail. But, got the error New Message button during the execution. Below is my script


'Creating a description object for SAP session

  Set sSAPSession = Description.Create()

  'Add descriptions and properties for SAP session

  sSAPSession("guicomponenttype").value = "12"

  sSAPSession("name").value = "ses\[0\]"

 

SAPGuiSession(sSAPSession).SAPGuiWindow("name:=wnd[0\]","type:=GuiMainWindow").SAPGuiOKCode("name:=okcd","type:=GuiOkCodeField").Set "SBWP"

  SAPGuiSession(sSAPSession).SAPGuiWindow("name:=wnd\[0\]","type:=GuiMainWindow").SAPGuiButton("name:=btn\[0\]","type:=GuiButton").Click

  SAPGuiSession(sSAPSession).SAPGuiWindow("guicomponenttype:=21","transaction:=SBWP").SAPGuiButton("name:=btn\[16\]","text:=New message").Click

 

  SAPGuiSession("guicomponenttype:=12","name:=ses\[1\]").SAPGuiWindow("guicomponenttype:=21","text:=Create Document and Send").Activate

 

 

 

=========Error during the runtime =======

Cannot find the "[ SAPGuiWindow ]" object's parent "[ SAPGuiSession ]" (class SAPGuiSession). Verify that parent properties match an object currently displayed in your application.

 

 

Line (20): "SAPGuiSession("guicomponenttype:=12","name:=ses\[1\]").SAPGuiWindow("guicomponenttype:=21","text:=Create Document and Send").Activate".

 

=====================================

 

Please give u r suggestions to resolve the issue ..

 

Thanks

kathirvel Nagaraj


Insert the record de CEP always the last lin

$
0
0

Hi, people!

I would like to make a loop to insert several records , however the record should be inserted at the end of the table.

 

 

Code:

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]/usr/ctxtADRCITYD-CITY_CODE").text = "4313"

session.findById("wnd[0]/usr/ctxtADRCITYD-COUNTRY").text = "br"

session.findById("wnd[0]/usr/ctxtADRCITYD-COUNTRY").setFocus

session.findById("wnd[0]/usr/ctxtADRCITYD-COUNTRY").caretPosition = 2

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

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

 

 

 

help-->"I would like to insert the record 35118-000 always the last line"

 

 

 

session.findById("wnd[0]/usr/tblSAPLSZRLPCD/ctxtADRPCDCITY-POST_CODE[0,6]").text = "35118-000"

session.findById("wnd[0]/usr/tblSAPLSZRLPCD/ctxtADRPCDCITY-POST_CODE[0,6]").setFocus

session.findById("wnd[0]/usr/tblSAPLSZRLPCD/ctxtADRPCDCITY-POST_CODE[0,6]").caretPosition = 0

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

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

 

 

 

 

 

 

 

 

thank you!

 

 

Alysson

Paralellism

$
0
0

I'm working with two different sessions to insert data.

 

 

 

A VBA archive insert data in the ME01 transaction trough the session 1

 

 

 

and

 

 

 

at the same time another VBA archive inserts data trough the session 2.

 

 

 

But, the performance is not so good. It starts very fast and after some minutes get slow and the saplogon process CPU consumption increases too much.

 

 

 

I changed to the Classic theme and had I selected slow connection in the properties, what make it better, but it´s not the sufficient.

 

 

 

Looking to the records at the database, two registers are saved at the same second, but I´m not sure if they are really parallel.

Recording SAP Script via Excel VBA

$
0
0

Hi,

 

Just a question, if I wanted to record a SAP Script VB, without having to go into SAP and click on Alt+12 -> Script Recording and playback -> Record button, is it possible to do this via Excel VBA only?

 

For example, I have my SAP window open, but I switch to excel, click on the excel macro for the VB script, it then switches to SAP and begins recording. The resulting code is then pasted or written onto the excel sheet. Is this possible?

 

Julius

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

SAP 740 Gui automation problem

$
0
0

Hello,

 

I`m recently having a problem with SAP automation. I normally use RFC to connect to SAP using Access VBA, which has been great for our department.

 

The thing is, now the company is changing from ASP to AMP and I have to "adapt" our Access Tools, but when I try changing the server in my code the SAP does not even open.

 

Do you know why or what can I do?

 

Here is my code:

 

Set SAP = CreateObject("SapAutoGui.Event")

 

If not SAP.Connect("Server", "00", SapGuiMerlin or SapGuiFront or SapGuiFullMenu) Then

     MsgBox "Error in opening connection to SAP/R3."

End

End if

 

Thank you very much for any info.

Copy SAP FIELDS TO EXCEL

$
0
0

Hi,

 

I have a situation in my work, i would like to copy a SAP field value to Exel. Kindly help me out.

 

i would like to copy the Capitalisation date of a particular asset to the Excel. Tried to save the Field in a variable and want to have the same in Excel.

 

Below is the script i have it.. KINDLY HELP ME OUT ( I AM VERY NEW TO SAPGUI SCRIPT I DONT HAVE THE ACCESS TO REPORTS AND SE16N)

 

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]/usr/ctxtANLA-ANLN1").text = strAsset

session.findById("wnd[0]/usr/ctxtANLA-ANLN2").text = "0"

session.findById("wnd[0]/usr/ctxtANLA-BUKRS").text = strCc

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/subAREA3:SAPLAIST:1142/ctxtANLA-AKTIV").setFocus

Cell = session.findById("wnd[0]/usr/subTABSTRIP:SAPLATAB:0100/tabsTABSTRIP100/tabpTAB01/ssubSUBSC:SAPLATAB:0200/subAREA3:SAPLAIST:1142/ctxtANLA-AKTIV").setFocus

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

What are the differences in VBA methods to connect to SAP GUI

$
0
0

Hi,

 

I am trying to use MS Excel VBA to connect to SAP GUI and run a recorded *.vbs script, but there are a number of ways of doing this and I should like to understand what the differences are, and therefore, hopefully figure out which one is best.

 

I have seen:

 

Set SAP = CreateObject("SAP.Functions")

 

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

 

Set SapGuiAuto = GetObject("sapgui")

 

Set Application = SapGuiAuto.GetScriptingEngine

 

For my intended use, i.e. using MS Excel VBA to connect to SAP GUI and run a recorded *.vbs script, is there a best syntax to use.  At the moment my code looks (snippet) as follows:

 

Dim SAP As Object

Dim SAPGui As Object

Dim SAPCon As Object

Dim SAPSession As Object

Dim SAPTaskID As Double

Dim SAPLogonPad As String

Dim WSHShell

 

Shell "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe", vbNormalFocus

On Error Resume Next

Set WSHShell = CreateObject("WScript.Shell")

  Do Until WSHShell.AppActivate("SAP Logon ")

    Application.Wait Now + TimeValue("0:00:01")

  Loop

Set WSHShell = Nothing

 

If Err <> 0 Then

    Err = 0

    SAPTaskID = Shell(SAPLogonPad, vbMinimizedNoFocus)

    If Err <> 0 Then

        MsgBox "Cannot start SAPLOGON", vbCritical, "SAPLogon Failed"

    Else

        'MsgBox "SAP Logon activated " & SAPTaskID, vbInformation, "SAP Running"

    End If

End If

On Error Resume Next

If SAPGui Is Nothing Then

   Set SAP = GetObject("sapgui")

   Set SAPGui = SAP.GetScriptingEngine

End If

On Error Resume Next

If SAPCon Is Nothing Then

   Set SAPCon = SAPGui.OpenConnection(sysName, True)

Else

  'Ready to call if the SAPCon object already declared from previous run

End If

On Error Resume Next

If SAPSession Is Nothing Then

Set SAPSession = SAPCon.Children(0)

    With SAPSession

        .findById("wnd[0]/usr/txtRSYST-MANDT").Text = client

        .findById("wnd[0]/usr/txtRSYST-BNAME").Text = user

        .findById("wnd[0]/usr/pwdRSYST-BCODE").Text = password

        .findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"

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

    End With

Else

  'Ready to call the Session already running from previous call to this script

End If

'

'Execute the script

'

Shell "wscript " & path & "\sap.vbs", vbNormalFocus

 

It works but not sure how robust/clean this approach is.  Whether there is a more direct way to do this.  The Shell to execute the *.vbs is important as I do not want to code the *.vbs into the VBA.  My users need to be able to create/edit any *.vbs and have this VBA run it.

 

Regards,

 

Jonathan


SAP GUI for massive process

$
0
0

Hi

I was trying to create a SAP Gui script to run a process for many materials.

see below I created it for one material, but to run in simultaneously for 2 material  I just repeated the code..

but how can I run just once the code N amount of time and It gets values from some table.

note that I used to to it using Excel SAP gui scritp, but it was easy because it just created an additional table to populate values tu run for many items

 

thanks

 

this is just and example for one time run

 

 

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

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

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = "96148673"

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 8

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

session.findById("wnd[1]/usr/tblSAPLMGMMTC_VIEW").getAbsoluteRow(0).selected = true

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

session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").text = "0302"

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").text = ""

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").setFocus

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").caretPosition = 0

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

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

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

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

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = "96279413"

session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 8

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

session.findById("wnd[1]/usr/tblSAPLMGMMTC_VIEW").getAbsoluteRow(0).selected = true

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

session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").text = "0302"

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").text = ""

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").setFocus

session.findById("wnd[1]/usr/ctxtRMMG1-LGORT").caretPosition = 0

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

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

Copy data from Excel and run the Loop

$
0
0

Good afternoon everyone,


I need to finish a script that will take the data from the Excel A1 column, copy a given time, execute the transaction E41C, save the changes made and start the process again withthe value of the next active cell, to complete the loop.


Example:


1. Open E41C transaction

2. Insert the ConjContr. copied from Excel

3. I make the modifications in the transaction and saved

4. Restart the process, but copying the value of the next active cell, to finish with all the data of the column A1.


Attached is the pictures to assist with any questions.

 

 

Thank you very much!

Export attachments from SAP

$
0
0

Hi Team,

 

Happy Christmas to All.

 

I want to automatically download the attachment from SAP which are uploaded through T-code FB03.

I have recorded below script for downloading the attachments but save as doalog box is not getting recorded.

 

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

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

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 "%ATTA_EXPORT"

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

 

 

Could somone help me to get the script for downloading attachments from SAP T-code Fb03.

 

Thanks for your support.

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

Excel VBA Single Sign On script

$
0
0

Hi folks,

 

I've been searching these forums with not much luck - most scripts seem to be using a form of connection with SAP that involves hard coding one's username and password, either into the excel spreadsheet or into the VBA itself. I'm trying to find some sort of way to utilize the "SAP Logon 740" launcher that is prompting me to input an environment (think "PRD" or "QRA"), which will then either automatically roll out the SAP session if only one client exists for that environment, or prompt another selection for the client within an SAP session. As this second step is inside an active SAP session, I've been able to record and run a script to select the proper client. I just need to be able to utilize single sign on from the launcher to kick off a session for a given environment - it's really just highlighting one text search field and inputing a passed string variable.

 

Capture.JPG

 

Launching the application isn't a problem, but since I cannot figure out a way to record a macro with the launcher itself I can't get from point A (launching the application) to point C (being able to execute my macros). Point B, navigating to the proper environment/client, is not something I'm able to find good logic for.

 

Appreciate your help experts - this is important as our sessions seem to get bogged down after running macros for 40-50 iterations. Whether that's due to behind the scenes transaction tracking or something else, we find that refreshing the session manually every 10-15 minutes significantly speeds up our net processing. We're hoping to automate this refreshing process so this will be a large upgrade to our overall macro performance. Appreciate urgent guidance on this and I will do my best to be timely in my response to assistance.

 

Thanks,

Jon

Viewing all 325 articles
Browse latest View live


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