Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
466

When you have a list of sometimes hundreds of .SAR and .CAR files to import into SPAM and SAINT wouldn't it be nice to automate the import process?

Well I sure got sick of it today, command lineing in CAR and SAR files one by one, there has to be an easier way methinks.

So I put on my SysAdmin hat and wrote out a small VB Script file to automate it for me, seems to work fine as new support packs turned up in the "New" Queue so here it is below:

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "D:\USR\SAP\trans"

Set objFolder = objFSO.GetFolder(objStartFolder)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")


Set colFiles = objFolder.Files
For Each objFile in colFiles
IF objFile.TYPE = "SAR File" THEN
      Wscript.Echo objFile.Name
  Set objExec = WshShell.Exec("sapcar -xvf " & objFile.Name)
  x = objExec.StdOut.ReadLine
  Wscript.Echo x
  objFSO.DeleteFile(objFile.Name)
END IF

IF objFile.TYPE = "CAR File" THEN
      Wscript.Echo objFile.Name
  Set objExec = WshShell.Exec("sapcar -xvf " & objFile.Name)
  Y = objExec.StdOut.ReadLine
  Wscript.Echo Y
  objFSO.DeleteFile(objFile.Name)
END IF
Next

Hope this helps,

Cheers

1 Comment