cancel
Showing results for 
Search instead for 
Did you mean: 

SAPCRIPT save without format

svyatoslav
Explorer
0 Kudos

Hi, I have a problem, I'm writing a script to save an attachment from VF03, this script takes information from excel, but I have a problem when the script goes into the application and tries to export the SAP, take some number from excel and replace this number with the file name without format,

in the application there can be two formats .zip or .pdf, but I can not know what format will be now. Is there any problem with copying the format from the file name, inserting text from Excel and the insertion format?

Maybe there is still some solution?


My goal is to save the document with the correct name from the table and with the correct extension

My 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






Dim objExcel, objWorkbook, objSheet, i


Set objExcel = CreateObject("Excel.Application")


Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Z003S0BF\Desktop\My_scripts\VF03_mass_download\Book3.xlsx")


Set objSheet = objWorkbook.Sheets("Sheet1")


For i = 2 to objSheet.UsedRange.Rows.Count




COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2
COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3






session.findById("wnd[0]/tbar[0]/okcd").text = "VF03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").text = COL1
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").caretPosition = 10
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").selectedRows = "0"
session.findById("wnd[1]/usr/cntlCONTAINER_0100/shellcont/shell").pressToolbarButton "%ATTA_EXPORT"
session.findById("wnd[2]/usr/ctxtDY_PATH").text = COL3
session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = COL2
session.findById("wnd[2]/usr/ctxtDY_PATH").setFocus
session.findById("wnd[2]/usr/ctxtDY_PATH").caretPosition = 67
session.findById("wnd[2]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press


next


msgbox "Process Complete"
script_man
Active Contributor

An example of the relevant Excel data would be helpful.

By the way, the following commands can / must be deactivated:

'session.findById("wnd [2]/usr/ctxtDY_PATH").setFocus
'session.findById("wnd [2]/usr/ctxtDY_PATH").caretPosition = 67

Especially if the length of COL3 is < 67.

svyatoslav
Explorer
0 Kudos

Thanks very much

0 Kudos

Hi sir

Could you please help how to export excel from GUI scripting......j did till recording and I don't to exit in note pad pls expert help

Accepted Solutions (0)

Answers (1)

Answers (1)

daniel_mccollum
Active Contributor
0 Kudos

assuming I understand what you are wanting...

COL2 = session.findById("wnd[2]/usr/ctxtDY_FILENAME").text + COL2 
session.findById("wnd[2]/usr/ctxtDY_FILENAME").text = COL2

you may need to concatenate a slash in there too.