<<

INTERNET, INTRANET AND THE WEB Paper P317

Web Based Report Ordering combined with Base/SAS® Mainframe Batch Processing Andre Brainard, Systems Engineering Services Corp., Reston, VA

THE FRONT-END - A WEB BASED ABSTRACT The Web browser, e-mail and spreadsheet were the This paper presents a web-based on-demand report three tools chosen to meet the front-end user interface ordering system that uses UNIX System Services (USS) requirements for several reasons: and WebSphere to update and report data stored on an • On an enterprise level these familiar and friendly IBM OS/390 mainframe. The business user issues a tools were already in place and being used on a request from a desktop PC and gets the results delivered daily basis by the business areas. via e-mail and imbedded URL hyperlinks. • Little or no training would be necessary for the users and no installation or maintenance would be required for the users' PCs. INTRODUCTION • The use of HTML and JavaScript would allow the technician to easily develop input forms for the The Management Analytics Reporting System (MARS) query selection criteria. was developed in response to a need for a centralized • E-mail would provide both the automated reporting system that would allow business users to notification and delivery of the query results via request ad-hoc reports in an automated fashion. imbedded URL hyperlinks. • Business users agreed that it would be desirable Prior to the implementation of this system, ad-hoc to receive the query results in spreadsheet form, reporting relied upon informal request procedures which would facilitate viewing, printing, and between business users and an often limited number of further analysis. technical resource personnel. This approach made the process more error prone and time consuming. In addition, users from different business areas often THE BACK-END - BASE/SAS AND OS/390 duplicated requests, which resulted in higher costs and times,inconsistent results. The back-end tools and environment chosen were Base/SAS running on an OS/390 Enterprise Server (formerly known as the mainframe) with MVS, OpenMVS, NEW SYSTEM REQUIREMENTS UNIX System Services (USS), and WebSphere.

A new system would require the following capabilities: SAS batch processing running in the 05/390 MVS • The ability for users corporate wide to access the environment would provide the flexibility and power to report ordering facility process large volume data on multiple platforms residing • The ability for the user to specify varied and in diverse storage form using a variety of access multiple selection criteria such as date ranges, protocols. SAS also would provide the ability to easily .customer identification, and product identification sort, merge, and summarize large volume complex data. • The ability to query large volume mainframe data stored on multiple mediums including DASD and The robust OS/390 MVS environment would provide the magnetic tape necessary system memory, disk workspace and • The ability to query data stored in various forms processing power to accomplish complex queries in a including relational , VSAM files, GDG reasonable time frame. 05/390 USS and WebSphere flat files, and IMS database would provide the critically important bridge between the • The ability to query data residing on multiple mainframe environment and the corporate wide intranet. platforms including mainframe and UNIX. • The ability to query data using different access SAMPLES OF CRITICAL CODE protocol such as Sybase, UDBIDB2, IMS, VSAM, SAS, flat files, GDG datasets, and PDS datasets The body of this paper provides samples of the front-end • The ability to leverage reuse of legacy mainframe JavaScript code, the back-end MVS JCL with associated ad-hoc reporting code including COBOL, SAS, PROCS, and the back-end Base/SAS code necessary for and SAS format libraries the development of a similar web-based on-demand • The ability to provide automated delivery of the report ordering system. ordered report results to the user • The ability to provide automated notification of The complete REXX COl script will be provided upon failures request.

JAVASCRIPT CALL OF WEBSERVER CGI SCRIPT

303 INTERNET, INTRANET AND THE WEB

. The front-end JavaScript does the following: II DISP=(NEW.PASS.DELETE). • Establishes input variables from Web page forms II SPACE=(TRK.1).UNIT=SYSDA. II DCB=(LRECL=80.BLKSIZE=0.RECFM=FB) • Perfonns minimal validations IISYSPRINT DD SYSOUT=* • Assembles a delimited parameter list to be IISYSIN DD DUMMY passed to the mainframe CGI script • Substitutes imbedded space characters with a "+" in the parameter list THE TARGET JCl STRUCTURE • If all data is valid. calls mainframe CGI script residing on the 05/390 OpenMVS webserver The following mainframe batch language (JCl) example would be stored as a member of an function submitJobO 05/390 MVS mainframe Partitioned Data Set (PDS) { var valid Data = true; library. The JBS bind statement is essential to insure that the JES binds these jobs to the appropriate MVS var e = document.forrns[O).seller; environment. in this case production. var seller = e. value; If (seller == HH) {var seller = '''';} IlMARS0001 JOB (OOO.RK),'MARS"CLASS=M.MSGCLASS=P II"+JBS BIND SERVER.USSM2 if (valid Data && seller != ..... && II" (isNaN(seller) II seller. length != 6 II seller < "000001")) II*"" ESTABLISH INPUT WEB PARMS ... { alert("Enter a valid Seller Numbe~1; var validData = false;} IIJSOO EXEC WEBPARMS «== anchor for cgi script II" var parrnList = "1" + "MARS.CNTL(MARS001)" + II*"" SAS QUERY PROCESSING ... "7" + "MARSoo01" + "?" + startdate + IIJS10 EXEC SAS "1" + enddate + "1" + seller + "1" + reportby; IISYSIN DD DSN=MARS.SOURCE(MARS001S). DISP=SHR IIJOBINFO DD' out = .. "; II replace this IIWEBPARMS DD DSN=&&WEBPARMS.DISP=SHR add = "+"; II with this IIOMVSXFER DD DSN=&&OMVSXFER. DISP=(NEW.PASS). temp = ... + parrnList; II temporary holder II UNIT= ....SPACE= .... DCB=( ...... ) while (temp.indexOf(out»-1) IIEMAILTO DD DSN=&&EMAILTO. DISP=(NEW.PASS), {pos= temp.indexOf(out); II UNIT= .... SPACE= .... DCB=( ...... ) temp = ". + (temp.substring(O. pos) + add + II*"" INSERT DO STATEMENT(S) FOR ANY INPUT FILES temp.substring«pos + out.length). temp.length)); } • II" II*"" XFER RESULTS TO WEBSERVER USING OPUT ... var parmString = temp; IIJS20 EXEC WEBDATA.COND=(4.LT) var webServer = ''http://omvs2.company.com/cgi-binl"; IISYSTSIN DD DSN=&&OMVSXFER.DISP=SHR var cgiScript = ·'webparrns.cgi"; Ir II*"" SEND EMAIL QUERY RESULTS TO USER ... if (validData) {alert("Your query resu~s will be sent via e­ IIJS30 EXEC SENDMAIL.COND=(4.LT) mail."); IISYSTSIN DD DSN=&&EMAILTO.DISP=SHR window.open(webServer + cgiScript + parrnString) } II" II*"" Optional Failure Notification !lOBS here (refer laterr.

THE CGI SCRIPT EDIT AND JOB SUBMISSION

The called CGI script written in the REstructured eXtended eXecutor (REXX) language perfonns the THE STORED JCL PROCEDURES following: • Retrieves the targeted mainframe job from the The following three mainframe JCl procedures will need specified MVS library to reside as members of the production OS/390 MVS • Edits the JCl scanning for the anchor point PROC library. statement "IIJSOO EXEC WEBPARMS" which is replaced with the following JCl and the II*"" PROC: WEBPARMS'" parameters passed by the JavaScript IIWEBPARMS PROC IIWEBPARMS EXEC PGM=IEBGENER • Submits the edited Jobstream to the OS/390 IISYSUT1 DD DUMMY MVS Job Entry System (JES) internal reader IISYSUT2 DD DSN=&&WEBPARMS. DISP=(NEW.PASS). • Returns notification of either success or failure to II UNIT=SYSDA. SPACE=(80.(1.1». requesting user DCB=(BLKSIZE=O.DSORG=PS) IISYSPRINT DO SYSOUT=* II*"" THE FOLLOWING INSERTED BY CGI SCRIPT -­ IISYSIN DD DUMMY IIWEBPARMS EXEC PGM=IEBGENER IISYSUT1 DD * II*"" PROC: WEBDATA'" LlBRARY(JOBNAME) IIWEBDATA PROC USERID IIWEBDATA EXEC PGM=IKJEFT01 CCYVMMDD IISYSPROC DD DISP=SHR.DSN=SYS2.CLlST HH:MM:SS IISYSTSPRT DD SYSOUT=* Parrn(s) each on separate line. start cc 2. max 70 char IISYSPRINT DD SYSOUT=' I" IISYSTSIN DD Dl:lMMY <== USER OVERRIDES IISYSUT2 DD DSN=&&WEBPARMS

304 INTERNET, INTRANET AND THE WEB

11*"* PROC: SENDMAIL­ IF _N_ = 3 THEN DO; ,. DATE STAMP CCYYMMDD" IISENDMAIL PROC INPUT@2 IN_DATE $8.; 'ISENDMAIL EXEC PGM=IKJEFT01 CALL SYMPUT('IN_DATE',IN_DATE); IfSYSPROC DO DISP=SHR,DSN=SYS2.CLlST END; IfSYSTSPRT DO SYSOUT=" IF _N_ = 4 THEN DO; ,. TIME HH:MM:SS "I 'ISYSPRINT DO SYSOUT=" INPUT@2 IN_TIME $8.; 'ISYSTSIN DO DUMMY <== USER OVERRIDES CALL SYMPUT('IN_TIME' ,IN_TIME); END; ,1* PURPOSE: TO SEND E-MAIL FROM THE MAINFRAME IF _N_ = 5 THEN DO; r MARS REPORT-ID ./ ,1* ------INPUT @2 MARS_ID $8.; ,1* SYSTSIN DO MUST BE OVERRIDDEN BY USER SYSTSIN CAll SYMPUT('MARSJD',MARS_ID); ,1* WITH EITHER A REAL OR TEMPORARY DSN. END; ,1* TEMPLATE OF SYSTSIN INPUT AS FOLLOWS: ,1* ------.----- ,. - USER INPUT PARAMETERS FOLLOW - ./ ,1* SENDMAIL TO([email protected]) + IF N = 6 THEN DO; ,. BEGIN DATE ./ ,1* CC([email protected])+ -- INPUT @2 IN_BEGOT $8.; ,1* SUBJECT(SUBJECT MATTER) + CAll SYMPUT('IN_BEGDT,IN_BEGDT); ,1* DATASET(,DSN FOR E-MAIL BODY') + END; ,1* BATCH IF _N_ = 7 THEN DO; ,. END DATE"' "" .. "Ii 11 .. 6"" ".... ,," "" .. ,," ....********_**_-.--**** ...... ".. ".... _••• *****_ INPUT @2 IN_ENDDT $8.; CAll SYMPUT('IN_ENDDT,IN_ENDDT); END; IF _N_ = 8 THEN DO; 1* Seller Number" THE SAS QUERY INPUT PART 1 - PICKUP SYSTEM ASSIGNED JOB-ID @002 FOR_SLR $6.; CALL SYMPUT('FOR_SLR',FOR_SLR); END; The first section of code performs the initialization IF _N_ = 9 THEN DO; 1* Report-By Offering ./ necessary to support the remaining processing. In order INPUT to provide the pertinent job identification information in the @002 RPT_BY $3.; e-mail notification, the MVS JOB-ID is picked up from the CALL SYMPUT('RPT_BY' ,RPT_BY); Job File Control Block (JFCB) by using a dummy DO JCL END; statement. IF ENDPARMS THEN DO; 1* Verify Parm Count "/ IF _N_ < 9 THEN ABORT ABEND 255; STOP; r INITIALIZE: PICKUP JOB-ID EXECUTION INFO "/ END; DATA_NULL_; RUN; INFILE JOBINFO JFCB=JFCB; JOB_ID=' ,. IF INDEX(JFCB:.JOB') THEN PART 3 - MAIN DATA QUERY PROCESSING JOBJD='J'IISUBSTR(JFCB,(INDEX(JFCB,'.JOB'»+4,5); CALL SYMPUT('JOB_ID',JOB_ID); RUN; This section should include the queries, data extracts, sorting, merging and summarization to produce the specific request results. The power of SAS batch mainframe processing allows tremendous flexibility to PART 2 - WEB PARMS INTO GLOBALS access diverse and large sources of data residing on DASD, magnetic tape, and remotely via SAS/Connect. As part of initialization, this code inpuls each Web parameter and converts it into a global variable to enable r PROCESS: QUERY and DATA EXTRACT"/ usage by the processing code sections that follows. Adding PUT PARMVAR= statements for each input parm ,. PROCESS: SORT, MERGE, SUMMARIZE, ETC. "/ would provide a nice audit trail in the SASLOG file. DATA RESULTS; r INITIALIZE: INPUT WEB PARMS AS GLOBAL VARIABLES ./ PART 4 - ALLOCATE OUTPUT RESULTS FILE DATA NULL; INFILE-WEBPARMS MISSOVER END=ENDPARMS; IF _N_ = 1 THEN DO; r LIBRARY(MEMBER) "/ This code allocates the output file dynamically in the SAS INPUT @2 JOB_RUN $50.; code in order to generate a unique "DELETE.USERID."· L_PAREN=INDEX(JOB_RUN,"('1; DSN thus avoiding duplicate DSN conflicts. R_PAREN=INDEX(JOB_RUN, H)"); JOB_LNTH=(R_PAREN - L_PAREN) -1; Important reminders: JOB_NAME=SUBSTR(JOB_RUN,L_PAREN+1,JOB_LNTH); • The OPUT transfer command must reference a CALL SYMPUT('JOB_RUN',JOB_RUN); system catalogued dataset. CALL SYMPUT('JOB_NAME',JOB_NAME); • Use of delete.userid. catalogued datasets are END; permitted for any user-id with only minimal IF _N_ = 2 THEN DO; r MAINFRAME USER-ID ., security access. INPUT @2 USER_ID $7.; CALL SYMPUT('USER_ID',USER_ID); • Use of delete.userid. datasets facilitates END; automatic file cleanup by MVS.

305 INTERNET, INTRANET AND THE WEB

• Be sure to allow both an adequate logical record PART 7 - GENERATE E-MAIL NOTIFICATION length (LRECL=) and an adequate DASD file space (SPACE=) as output needs dictate. This final section of the SAS Query program code generates the e-mail that serves as the notification and 1* INITIALIZE: ALLOCATE UNIQUE DSN RESULTS FILE" delivery vehicle of the query results. Assuming a DATA NULL; successful query, the body of the e-mail will contain an MARS=DAT =-'''DELETE.&SYSUID.. D&RUN_JDAY .. T'' II imbedded hyperlink which the business user will click-on COMPRESS("&RUN_TIME", ':') II to conveniently have the results delivered directly in ".&MARS_ID .. DAT'"; spreadsheet form. MARS_OAT = UPCASE(COMPRESS(MARS_DAT)); CALL SYMPUT('MARS_DAT',MARS_DAn; Important points: RUN; • The SENDMAIL command must reference a system catalogued dataset for the e-mail body DATA_NULL_; • The e-mail body DSN must exist after the job FILENAME &MARS_ID &MARS_DAT NEW completes and be available to the queued DISP=(NEW,CATLG,DELETE) SPACE=(TRK,(100,10),RLSE) SENDMAIL (up to 2 minutes) UNIT=SYSDA LRECL=800 BLKSIZE=O RECFM=FB DSORG=PS; RUN; 1* GENERATE ROUTING AND BODY OF E-MAIL MESSAGE"' DATA_NULL_; MARS_MSG = '·DELETE.&SYSUID.. D&RUN_JDAY.. T" II PART 5 - GENERATE OUTPUT .CSV RESULTS COMPRESS("&RUN3IME",':') II ".&MARS ID .. MSG'''; MARS_MSG = U-PCASE(COMPRESS(MARS_MSG»; This code generates the output results data as a Comma CALL SYMPUT('MARS_MSG',MARS_MSG); Seperated Values (CSV) file. The .CSV file type RUN; extension is critical for enabling the Web browser to recognize this file type belongs to the spreadsheet DATA_NULL_; application. When the user clicks on the results_file.csv FILENAME EBODY &MARS_MSG NEW hyperlink, inserted into the body of the e-mail, the browser DISP=(NEW,CATlG,DELETE) SPACE=(TRK,(1,1 ),RLSE) will pass the .CSV file from the Webserver directly into the UNIT=SYSDA LRECL=100 BLKSIZE=O RECFM=FB spreadsheet application. DSORG=PS; DATA NULL; 1* OUTPUT RESULTS AS COMMA DELIMITED FILE ., FILE EMAILTO NOPRINT; DATA_NULL_; USER_ID = PUT("&USER_ID",$MARSUSR.); SET RESULTS; IF USER 10 = 'MISSING' FILE &MARS ID NOPRINT; THEN EMAIL_TO= [email protected] .. ; PUT ",'" comma delimHed output '"'' ELSE EMAIL30=USER_IDII.. @company.com.. ; RUN; MARS_MSG = TRIM("&MARS_MSG"); PUT" SENDMAIL TO(" EMAIL_TO +(-1) ") +"; PUT" CC([email protected]) +"; PART 6 - GENERATE FILE TRANSFER COMMANDS IF USER 10 = 'MISSING' THEN PUT" SUBJECT("ERROR" id: &USER_ID " ''missing from MARS e-mail user table) +.; The following SAS code will generate the OPUT command ELSE IF &TRANOUT > 0 necessary for transferring the MVS output results over to THEN PUT" SUBJECT("SUCCESS" YOUR MARS0001 the OpenMVS USS WebSphere area. The new file RESULTS ARE READY) +"; resides as an HFS file under WebSphere available for ELSE PUT" SUBJECT("NOTICE" NO RESULTS RETURNED user access via the imbedded URL in the e-mail body, FOR MARS0001) +"; PUT" DATASET(" MARS_MSG +(-1) .) +"; 1* OUTPUT COMMAND FILE FOR XFER TO WEBSPHERE ., PUT" BATCH"; DATA_NULL_; DATA_NULL_; MARS_CSV = "&SYSUID._d&RUN_JDAY._t" II FILE EBODY NOPRINT; COMPRESS("&RUN_TIME",':') II "_&MARS_ID .. csv"; SETCDW]HA; MARS_CSV = LOWCASE(COMPRESS(MARS_CSV»; IF N = 1 THEN DO; CALL SYMPUT('MARS_CSV',MARS_CSV); PUT • Analytics " Reporting" System" /; PUT MARS_CSV=; ~anagement PUT "OS/390 ENTERPRISE SERVER: " RUN; "MVS JOBNAME=&SYSJOBID JOBID=&JOB_ID USERID=&SYSUID"; DATA NULL; REQ_DATE = INPUT("&IN_DATE",VYMMDD8.); IF &TRANOUT = 0 THEN STOP; PUT ·SUBMITIED ON: " REQ..DATE WEEKDATE29." OUT_UNIX = TRIM("&MARS_CSV"); at: &IN_TIME" FILE OMVSXFER NOPRINT; " by USER-IO: &USER_ID" /; PUT" oput &MARS OAT +'" PUT" 'Iulmarslprodlreports/~ndemandf' OUT UNIX +(-1) ..... PUT "REPORT: "MARS0001" REPORT TITLE" /; IF INPUT("&FOR_SLR",$1.) ne '.. then do; SELLER = TRIM(PUT("&FOR_SLR",$SLRNAM.)); PUT 'FOR SELLER: ' SELLER; end;

IF INPUIT&RPT BY" $1.) NE 'M

306 INTERNET, INTRANET AND THE WeB

THEN BYDESC = CONCLUSION TRIM(PUT(INPUTC'&RPT_BY",$3.),$RPTBY.)); ELSE BYDESC = 'All Flow Offerings'; The MARS project provides an enterprise level solution PUT 'REPORT-BY: ' BYDESC; PUT "PERIOD: &BEG_DATE TO &END_DATE "; that has not only brought ad-hoc reporting under control, CUR_DATE = TODAY(); but also has established a new technical infrastructure PUT "STATUS AS OF:" CUR_DATE MMDDVY10.1; paradigm. Centralizing ad-hoc reporting on the corporate intranet opens it to the widest possible audience, while at IF & TRANOUT > 0 THEN DO; the same time dramatically reducing future development PUT "CLICK ON LINK TO VIEW RESULTS:"; costs. Accessibility of existing ad-hoc reports encourages PUT "htlp:llomvs2.company.com/marsreportsp/&MARS_CSV" their reuse and helps to avoid duplication. With the /. , business user now able to independently order ad-hoc END; reports using flexible selection criteria, the need for doing ELSE DO; PUT -NOTICE· NO RESULTS RETURNED FROM THIS "what if scenarios has been made easier and faster. And QUERY!" I; finally, the new technical architecture and toolset END; improves the collaborative JADIRAD approach to meet RUN; future ad-hoc reporting needs.

JOB FAILURE NOTIFICATION - JCL CODE ACKNOWLEDGMENTS Add the following jobs steps to the end of the targeted Thanks to William A. Mitchell, lead Tech Analyst, Freddie JCl for the purpose of generating and sending e-mail Mac Corporation, Maclean, VA for developing the REXX notification of a job failure. Inclusion of job speCific CGI script and for providing invaluable technical support. information, i.e. Job name and system assigned Job-ID, will help with providing efficient production support. Thanks to Michael G. Sadof, a SAS Quality Partner, MGS II" Associates, Bethesda, MD for encouraging me to present II""· HANDLE JOB FAILURE NOTIFICATION­ this paper. IIJC01 IF ABEND=TRUE OR RC > 4 THEN II" SAS, BASEISAS are registered trademarks or II""" CREATE E-MAIL NOTIFICATION OF JOB FAILURE ... trademarks of SAS Institute, Inc. in the USA and other IIJS40 EXEC SAS countries. ® indicates USA registration. IISYSIN DO DSN=MARS.SOURCE(MARS911S).DISP=SHR IIJOBINFO DO' IIWEBPARMS DO DSN=&&WEBPARMS.DISP= DISP=SHR IBM, OS1390, REXX, and WebSphere are registered IINOTIFY DO DSN=&&NOTIFY.DISP=(NEW.PASS). trademarks or trademarks of International Business II UNIT= ... ,SPACE= .... DCB=( ...... ) Machines Corporation in the USA and other countries. II" /1""" SEND E-MAIL NOTIFICATION OF JOB FAILURE ... CONTACT INFORMATION IIJS50 EXEC SENDMAIL IISYSTSIN DO DSN=&&NOTIFY.DISP=SHR II" For those interested in attaining full version copies of the IIJC01 ENDIF code, including the REXX CGI script, please make request to the e-mail address that follows.

JOB FAILURE NOTIFICATION - SAS CODE

The SAS program MARS911 S code necessary for IIM=·.. Andre W. Brainard, 'IIInfao6 generating the e-mail notification of job failure is easily e-mail: [email protected] replicated from the first and last sections of the Systems Engineering Services Corp. MARS001 S SAS Query program code. On the Web at: http://www.sese.com

SASNOTIFY Part 1 - Pickup System Assigned Job-ID Copy the ·Part 1- Pickup Job-Ie" SAS code from the MARS001S SAS Query program above.

Part 2 - Web Parms Into Globals Copy the ·Part 2 - Web Parms into Globals· SAS code from the MARSOO!S SAS Query program above.

Part 3 - Generate E-mail Notification Copy the ·Part 7 - Generate Delivery E-mair SAS code from the MARSOO! S SAS Query program above and then modifY the subject and body to announce job failure along with action to be taken and relevant contact information.

307