0% found this document useful (0 votes)
176 views4 pages

VBSCRIPT for GDG File Management

This script processes a text file containing GDG file names, creates any missing GDGs, and writes a report. It: 1. Opens the input text file and output report file. 2. Loops through each GDG name, checks if it exists, creates it if not. 3. Writes a status message to the report for each GDG. 4. Closes the files and notifies the user when complete.

Uploaded by

Naresh Reddy Kp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views4 pages

VBSCRIPT for GDG File Management

This script processes a text file containing GDG file names, creates any missing GDGs, and writes a report. It: 1. Opens the input text file and output report file. 2. Loops through each GDG name, checks if it exists, creates it if not. 3. Writes a status message to the report for each GDG. 4. Closes the files and notifies the user when complete.

Uploaded by

Naresh Reddy Kp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

[PCOMM SCRIPT HEADER]

LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)
dim FileSys, InFile, TS, Region, FileName, TempStr, chkFileName, GDGFileName, Sr
chPos, RC, TSOCmd, RC2, GDGFlag, OutFile, OutFileName, ErrFlag
dim ActResult
REM This line calls the macro subroutine
subSub1_
sub subSub1_()
Call Setup
set FileSys = CreateObject("Scripting.FileSystemObject")
set InFile = FileSys.GetFile("gdg.txt")
OutFileName = "gdg-" + CStr(DatePart("m", Now)) + Cstr(DatePart("d", Now)) +
CStr(DatePart("h", Now)) + CStr(DatePart("n", Now)) + CStr(DatePart("s", Now)) +
".txt"
set OutFile = FileSys.CreateTextFile(OutFileName, True)
set TS = InFile.OpenAsTextStream(1,-2)
Do Until TS.AtEndOfStream
RC = ""
RC2 = ""
GDGFlag = ""
GDGFileName = ""
ErrFlag = 0
GDGFileName = TS.ReadLine
TempStr = Split(GDGFileName, ".", 3)
Region = TempStr(0)
FileName = TempStr(2)
RC = CheckFileExists(GDGFileName)
if RC <> "OK" then
GDGFlag = CreateGDG(Region, FileName)
if GDGFlag <> "OK" then
MSGBOX("WARN!!!")
ErrFlag = 1
Exit Sub
else
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.Wait(3000)
RC2 = CheckFileExists(GDGFileName)
if RC2 <> "OK" then
RC2 = ""
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.Wait(6000)
RC2 = CheckFileExists(GDGFileName)
if RC2 <> "OK" then
MSGBOX("ERROR!!!2")
ErrFlag = 2
Exit Sub
else
RC2 = "OK"
end if
else
RC2 = "OK"

end if
end if
end if
if RC <> "OK" And GDGFlag <> "OK" then
OutFile.Write(GDGFileName + " --> GDG Base not created due to an e
rror." + vbCr + vbLf)
else
if RC <> "OK" And RC2 <> "OK" then
OutFile.Write(GDGFileName + " --> GDG Base created, but
not verified due to an error." + vbCr + vbLf)
else
if RC <> "OK" then
OutFile.Write(GDGFileName + " --> GDG Base creat
ed and verified." + vbCr + vbLf)
else
OutFile.Write(GDGFileName + " --> GDG Base alrea
dy exists." + vbCr + vbLf)
end if
end if
end if
REM
MSGBOX(Region & "+" & FileName & "=" & RC & "-" & GDGFlag & "%" & RC2)
Loop
TS.Close
OutFile.Close
MSGBOX("Process Complete! Please check " + OutFileName + " for the report.")
end sub

sub Setup()
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "TSO EXEC 'TBTA.S'"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
end sub
Function CheckFileExists(chkFileName)
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
TSOCmd = "TSO CHKDSN " & chkFileName
autECLSession.autECLPS.SendKeys TSOCmd
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLOIA.WaitForInputReady
if trim(autECLSession.autECLPS.GetText(3,2,2)) <> "OK" And trim(autECLSe
ssion.autECLPS.GetText(4,2,2)) <> "OK" then
CheckFileExists = "ERROR"
else
CheckFileExists = "OK"
end if
autECLSession.autECLPS.SendKeys "[enter]"
end Function
Function CreateGDG(iRegion, iFileName)
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"

autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "r"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 2,14,"08","3c",3,10000
autECLSession.autECLPS.WaitForCursor 2,15,10000
autECLSession.autECLOIA.WaitForAppAvailable
ActResult = trim(autECLSession.autECLPS.GetText(1,57,23))
if trim(autECLSession.autECLPS.GetText(1,57,23)) <> "Event disabled/not
done" And trim(autECLSession.autECLPS.GetText(2,57,23)) <> "Event disabled/not d
one" And trim(autECLSession.autECLPS.GetText(1,57,23)) <> "Event refreshed" And
trim(autECLSession.autECLPS.GetText(2,57,23)) <> "Event refreshed" then
CreateGDG = "ERR"
msgbox("Warn1")
Exit Function
end if
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLPS.SendKeys "[tab]"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "c"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 21,13,"08","3c",3,10000
autECLSession.autECLPS.WaitForCursor 21,14,10000
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys iRegion
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 21,13,"08","3c",3,10000
autECLSession.autECLPS.WaitForCursor 21,14,10000
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[eraseeof]"
autECLSession.autECLPS.SendKeys iFileName
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 2,14,"08","3c",3,10000
autECLSession.autECLPS.WaitForCursor 2,15,10000
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "COMPLETE"
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"
autECLSession.autECLPS.WaitForAttrib 2,14,"08","3c",3,10000
autECLSession.autECLPS.WaitForCursor 2,15,10000
autECLSession.autECLOIA.WaitForAppAvailable
autECLSession.autECLOIA.WaitForInputReady

if trim(autECLSession.autECLPS.GetText(1,57,23)) <> "Event rescheduled"


then
CreateGDG = "ERR"
msgbox("Warn2")
Exit Function
else
CreateGDG = "OK"
end if
end Function

You might also like