Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
SUB MAIN()
Dim ImpApp As Object
DIM Imprep AS OBJECT
Dim ImpCat As Object
Dim ImpUsr as Object
Dim errors(1 To 3, 1 To 10) as Variant
'Next line uses global variables to build the connect string
DfltCnStr$ = "DSN="+DSN_NM$+"; UID="+DBUID$+"; PWD="+Mix(CPRPwd,"D")+"; SERVER="+DFLTDB$
On error goto ErrorRtn
Set ImpApp = CreateObject ("CognosImpromptu.Application")
IF NOT ImpApp.DatabaseConnected THEN
goto Finish
ELSE
Set ImpCat = ImpApp.activecatalog
Set ImpUsr = ImpCat.activeUserClass
Set ImpRep = ImpApp.activedocument
P1$= Environ("UNAME") 'Use your local environmental variable for user logon name here.
P2$=UCase(ImpRep.name) 'Report File Name - no path
P3$=UCase(ImpRep.title) 'Report Long Name or Comments
P6$=UCase(ImpRep.path) 'Report Path
C2$=UCase(ImpCat.filename) 'Catalog full name with path
C4$=ImpUsr.name 'User Class Name
strt% = 1
Do
position=InStr(strt%,C2$,"\")
If position=0 then
Exit Do
End If
position=position+1
strt%=position
C1$=UCase(Mid(C2$,position)) 'Catalog Filename without Path on last pass
Loop
k=len(C2$)
C5$ = UCase(Mid(C2$,1,strt%-1)) 'Catalog Path without Filename
STARTQRY = TIMER
rcnt = ImpApp.activedocument.retrieveall+1
ENDQRY = TIMER
P4x=0.001
P7=0.001
DIFF = CSTR(ENDQRY - STARTQRY)
P4x = P4x + VAL(DIFF)
P4 = CStr(P4x)
P5 = CStr(rcnt)
connection = SQLOpen(DfltCnStr$, outputStr, prompt:=5)
If connection < 1 Then
MsgBox "ODBC Connection Cannot be Established!"
goto finish
end if
Qry1 = "BEGIN ADD_REPORT_HISTORY('"+P1$+"','"+P2$+"','"+P3$+"',"+P4+","+P5+",'"+C1$+"'); END;"
retcode = SQLExecQuery(connection,Qry1)
if retcode = -1 then
SQLError destination:=errors
if errors(1,1) <> 0 then
errmsg$ = errors(1,3)
msgbox errmsg$,0,"SQL Error!"
Goto Finish
end if
end if
goto Finish
END IF
'Finish the routine
'------------------
Finish:
retcode = SQLClose(connection)
Exit Sub
'Error routine
'-------------
ErrorRtn:
goto Finish
End Sub