Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

downloading multiple company code reports using SAP script

0 Likes
747

Hello Experts,

I've a very little knowledge about SAP script recording and hence need your help writing a script to automate a report downloading.

I've around 40 company codes whose asset history report needs to be downloaded every month. I need to download each company's asset history file and save it in a folder. most of the parameters under asset history sheet will be same but only co. code will change.

I am pasting the code below. could you please tell me is there any way to change the code to download each report separately, rename it to match the co.code and save it in a desired folder??

Your help will be highly appreciated

thank you !

Praveen

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 = "/nS_ALR_87011990 "
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/chkPA_XGBAF").selected = true
session.findById("wnd[0]/usr/ctxtBERDATUM").text = "09/30/2018"
session.findById("wnd[0]/usr/ctxtSRTVR").text = "0003"
session.findById("wnd[0]/usr/chkPA_XGBAF").setFocus
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[2]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[1]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[2]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[2]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[2]").sendVKey 4
session.findById("wnd[3]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[3]/usr/ctxtDY_PATH").caretPosition = 0
session.findById("wnd[3]").sendVKey 4  
1 REPLY 1
Read only

mmcisme1
Active Contributor
0 Likes
587

I did a quick search on:

sap IsObject(WScript) loop

I think this message would help you out. You really need to do a loop in the code. Since that isn't possible take a look at this post.