570 likes | 829 Views
EMEA Natural Programmers User Group Manipulating the Natural Source Area. Ralph Zbrog LEN C ONSULTING LLC. RGZbrog@ZZUtils.com. June 2004. Manipulating the Natural Source Area. Overview. Uses of the Source Work Area. SAG user exits. Uses of the Source Work Area. Editing Natural objects.
E N D
EMEA Natural Programmers User GroupManipulating the Natural Source Area Ralph Zbrog LEN CONSULTING LLC RGZbrog@ZZUtils.com June 2004
Manipulating the Natural Source Area Overview Uses of the Source Work Area SAG user exits
Uses of the Source Work Area Editing Natural objects On-line debugging Debugging NATRJE Utility customization As a temp file
Uses of the Source Work Area On-line Debugging Write trace data within an on-line module • Printer (0) for production report • INPUT/REINPUT Appends to current contents of SWA Potential NAT0886 ESIZE overflow error
Uses of the Source Work Area On-line Debugging Sample code > run > + Program NC-SW-01 Lib ZZUTILS All ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0140 0150 0160 0170 0180 0190 0200 ....+..Current Source Size: 209 Char. Free: 223600 ...+... S 13 L 1
Uses of the Source Work Area On-line Debugging Report Page 1 05/02/04 14:26:43 Start End NEXT e LIB=ZZUTILS
Uses of the Source Work Area On-line Debugging Result > > + Program NC-SW-01 Lib ZZUTILS All ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 Page 1 05/02/04 14:27:14 0000 0000 AbCdEf 1 0000 AbCdEf 2 0000 AbCdEf 3 0000 AbCdEf 4 ....+..Current Source Size: 380 Char. Free: 223429 ...+... S 20 L 1
Uses of the Source Work Area On-line Debugging After ENTER > > + Program NC-SW-01 Lib ZZUTILS All ....+....1....+....>>> Source has been updated <<<..+.Mode Structured. 0010 DEFINE DATA LOCAL 0020 1 #I (I4) 0030 END-DEFINE 0040 * 0050 FORMAT (3) LS=70 0060 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0070 * 0080 WRITE 'Start' 0090 FOR #I = 1 4 0100 WRITE (3) 'AbCdEf' #I 0110 END-FOR 0120 WRITE 'End' 0130 END 0000 */ 0000 PAGE 1 05/02/04 14:27:14 0000 ABCDEF 1 0000 ABCDEF 2 0000 ABCDEF 3 0000 ABCDEF 4 0010 ....+..Current Source Size: 376 Char. Free: 223433 ...+... S 19 L 1
Uses of the Source Work Area On-line Debugging SET TYPE T; EX NC-SW-01 > > + Text Lib ZZUTILS All ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0000 */ 0000 Page 1 05/02/04 14:28:50 0000 0000 AbCdEf 1 0000 AbCdEf 2 0000 AbCdEf 3 0000 AbCdEf 4 0010 0020 0030 0040 0050 0060 0070 0080 0090 0100 0110 0120 0130 ....+..Current Source Size: 171 Char. Free: 223638 ...+... S 7 L 1
Uses of the Source Work Area On-line Debugging Save results for comparison or later review Allows scan and page-up/page-down Doesn’t interfere with production output or logic
Uses of the Source Work Area Questions?
Uses of the Source Work Area Debugging NATRJE JCL submitted to internal reader via NATRJE Some errors result in no JES listings • Invalid JOB card • Invalid password • Invalid account codes
Uses of the Source Work Area Debugging NATRJE ZZTDOC ZZTDOC LEN Consulting LLC 05/02/2004 17:52 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: _ Library: ________ Member: ________ Type: _ PDS: ____________________________________________ New: Env: _ Library: ________ Member: ________ PDS: ____________________________________________ Set: Library: ________ Member: ________ Listing: Compare: _ Context: __ Delta: _ Summary: _ Ada Cmd: _ ILRC: _ Type: _ Print: ID: ________ Class: _ Hold: _ Copies: _ Sysout: _ File: Disp: _ Name: ______________________________________________________ Job: Suffix: _ Account: ________ Info: ____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area
Uses of the Source Work Area Debugging NATRJE ZZTDOC > > + Text Lib ZZUTILS Top ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 //RGZTDOC JOB (abcdef,abcd,RGZ),'TDOC: XXCUSTOM', 0020 // MSGLEVEL=(1,1), 0030 // USER=STRGZ,PASSWORD=$JPSWD$, 0040 // MSGCLASS=N,NOTIFY=RGZ 0050 //*MAIN JOBAFF=MPM,CLASS=X 0060 //FORM OUTPUT FORMS=LASER 0070 * 0080 * 0090 //******** NATURAL OLD SOURCE ******** 0100 //NATOLDP0 EXEC NATBT, 0110 // TIME=50,SYSOUT=X, 0120 // PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0' 0130 //CMPRINT DD SYSOUT=X,OUTPUT=*.FORM 0140 //CMWKF01 DD DSN=&&OLDLST0,DISP=(NEW,PASS,DELETE), 0150 // UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5)) 0160 //SYSIN DD * 0170 %* 0180 LOGON ZZUTILS 0190 %U 0200 %D ....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57 L 1
Uses of the Source Work Area Debugging NATRJE ZZTDOC > > + Text Lib ZZUTILS ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0210 %Q 0220 ZZPUNCH ZZUTIL,ZZCUSTOM,ZZCUSTOM,N,N,N,N 0230 %K03 0240 FIN 0250 /* 0260 //* 0270 //* 0280 //******** NATURAL NEW SOURCE ******** 0290 //NATNEWP0 EXEC NATBT, 0300 // TIME=50,SYSOUT=X, 0310 // PRM='IM=D,AUTO=ON,MADIO=0,MAXCL=0,MT=0' 0320 //CMPRINT DD SYSOUT=X,OUTPUT=*.FORM 0330 //CMWKF01 DD DSN=&&NEWLST0,DISP=(NEW,PASS,DELETE), 0340 // UNIT=SYSDA,RECFM=FB,LRECL=133,SPACE=(CYL,(5,5)) 0350 //SYSIN DD * 0360 %* 0370 LOGON ZZUTILS 0380 %U 0390 %D 0400 %Q ....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57 L 21
Uses of the Source Work Area Utility Customization ZZTDOC ZZTDOC LEN Consulting LLC 05/02/2004 17:52 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: _ Library: ________ Member: ________ Type: _ PDS: ____________________________________________ New: Env: _ Library: ________ Member: ________ PDS: ____________________________________________ Set: Library: ________ Member: ________ Listing: Compare: _ Context: __ Delta: _ Summary: _ Ada Cmd: _ ILRC: _ Type: _ Print: ID: ________ Class: _ Hold: _ Copies: _ Sysout: _ File: Disp: _ Name: ______________________________________________________ Job: Suffix: _ Account: ________ Info: ____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area
Uses of the Source Work Area Utility Customization ZZTDOC ZZTDOC LEN Consulting LLC 05/02/2004 17:54 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: P Library: ZZUTIL__ Member: ________ Type: N PDS: RALPH.PROD.JCL______________________________ New: Env: D Library: ZZUTIL__ Member: ________ PDS: RALPH.DEVL.JCL______________________________ Set: Library: ________ Member: ________ Listing: Compare: C Context: 10 Delta: N Summary: N Ada Cmd: Y ILRC: Y Type: L Print: ID: LASER___ Class: X Hold: Y Copies: 1 Sysout: N File: Disp: O Name: RALPH.TDOCLIST________________________________________ Job: Suffix: T Account: 123456__ Info: 1234 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area
Uses of the Source Work Area Utility Customization ZZTDPMNT ZZTDPMNT LEN Consulting LLC 05/02/2004 18:03 Natural Utilities ZZUtils v2.1 Technical Walkthrough Documentation - Profile Maintenance *** Profile maintenance will overwrite the Natural source work area *** Action: U (A,I,R,U,.) Library: ZZUTIL__ Profile: RALPH___ Module Type: N Default: ZZUTIL RALPH Old: Nat Lib: ZZUTIL__ Environment: P (DIUP) 3GL PDS: RALPH.PROD.JCL______________________________ New: Nat Lib: ZZUTIL__ Environment: D (DIUP) 3GL PDS: RALPH.DEVL.JCL______________________________ List: Compare: C (F|C) Context: 10 Delta: N Summary: N Adacmd: Y ILRC: Y Src/Cmpl: L (C|L|S) Print: ID: LASER___ Copies: 1 Class: 2 Hold: Y Sysout: N File: Disp: O DSN: RALPH.TDOCLIST________________________________________ (N|O|X) Job: Class: X Suffix: T Account: 123456__ Info: 1234____ Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Actn Help Auth Exit
Uses of the Source Work Area Utility Customization ZZTDPROF > > + Text ZZTDPROF Lib ZZUTILS Top ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0010 ZZTDOC Profile 0020 Profile ZZTDPROF 0030 Library ZZUTIL 0040 * 0050 Module Type N 0060 Old Environment P 0070 New Environment D 0080 Old Library PRODLIB 0090 New Library DEVLLIB 0100 Old 3GL PDS PROD.APP.JCL 0110 New 3GL PDS DEVL.APP.JCL 0120 List Type L 0130 Compile Type DAC 0140 Compare Type F 0150 Context 10 0160 Delta N 0170 Summary N 0180 Adacmd Y 0190 ILRC Y 0200 Xref N ....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57 L 1
Uses of the Source Work Area Utility Customization ZZTDPROF > > + Text ZZTDPROF Lib ZZUTILS ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0210 Copycode N 0220 Printer LASER 0230 Copies 1 0240 Output Class X 0250 Hold Y 0260 Sysout N 0270 File Disposition N 0280 DSN 0290 Job Class X 0300 Job Suffix T 0310 Account 123456 0320 Info 1234 0330 * 0340 Old Copybook 01 0350 Old Copybook 02 0360 Old Copybook 03 0370 Old Copybook 04 0380 Old Copybook 05 0390 Old Copybook 06 0400 Old Copybook 07 ....+..Current Source Size: 1254 Char. Free: 222267 ..+... S 57 L 21
Uses of the Source Work Area Utility Customization ZZTDPROF > > + Text ZZTDPROF Lib ZZUTILS Bot ....+....1....+....2....+....3....+....4....+....5....+.Mode Structured. 0410 Old Copybook 08 0420 Old Copybook 09 0430 Old Copybook 10 0440 New Copybook 01 0450 New Copybook 02 0460 New Copybook 03 0470 New Copybook 04 0480 New Copybook 05 0490 New Copybook 06 0500 New Copybook 07 0510 New Copybook 08 0520 New Copybook 09 0530 New Copybook 10 0540 * 0550 Updated by RALPH 0560 Updated on 10/25/2003 0570 Updated at 17:31:58 0580 0590 0600 ....+..Current Source Size: 1266 Char. Free: 222255 ..+... S 60 L 41
Uses of the Source Work Area Utility Customization Retrieve text member into array USR1057N Parse array entries into keyword/value Present values to user Validate new values Write keywords/values to SWA Store SWA as text member USR2019N • “Replace” option
Uses of the Source Work Area Utility Customization ZZTDOC ZZTDOC LEN Consulting LLC 05/02/2004 17:54 Natural Utilities ZZUtils v2.1 Generate Code Walkthrough Document Profile: ZZUTIL/RALPH Old: Env: P Library: ZZUTIL__ Member: ________ Type: N PDS: RALPH.PROD.JCL______________________________ New: Env: D Library: ZZUTIL__ Member: ________ PDS: RALPH.DEVL.JCL______________________________ Set: Library: ________ Member: ________ Listing: Compare: C Context: 10 Delta: N Summary: N Ada Cmd: Y ILRC: Y Type: L Print: ID: LASER___ Class: X Hold: Y Copies: 1 Sysout: N File: Disp: O Name: RALPH.TDOCLIST________________________________________ Job: Suffix: T Account: 123456__ Info: 1234 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12--- Vrfy Help Auth Exit SetV MPswd Membr JCL Sub Set Verification will clear the editor work area
Uses of the Source Work Area Simple Code Example: Modify a Source Module ZZL1057 S 1 ZZ1057 S 2 OBJECT-KEY 3 LIBRARY A8 3 OBJECT-NAME A32 3 OBJECT-TYPE A2 2 INPUTS 3 OPT-ACCESS A1 3 OPT-UNUSED-1 L 3 OPT-UNUSED-2 A1 3 OPT-LINE-NUM A1 3 OPT-UNUSED-3 L 3 OPT-REDEF-DIR L 3 OPT-UNUSED-4 A1 3 OPT-AMOUNT I2 3 OPT-LINESIZE I2 2 INPUT-OUTPUTS 3 INT-HANDLE I4 3 NEXT-SEQ I4 3 NEXT-NUM I2
Uses of the Source Work Area Simple Code Example ZZL1057 2 OUTPUTS 3 RETURNED I2 3 SRC-NUM I2 (1:60) 3 SRC-TEXT A1 (1:60,1:72) R 3 SRC-TEXT 4 DIR-OBJNAME A32 4 DIR-LIBRARY A8 4 DIR-OBJTYPE A2 4 DIR-OBJKIND A1 4 DIR-DBID A5 4 DIR-FNR A5 4 DIR-DATN A8 4 DIR-TIMN A7 4 DIR-USERID A8 4 DIR-PROGMODE A1 4 DIR-SRCSIZE A10 4 DIR-GPSIZE A10 4 DIR-UNIQUE-ID A32 4 DIR-DDM-DBID A5 4 DIR-DDM-FNR A5
Uses of the Source Work Area Simple Code Example ZZL1057 4 DIR-NATVERS A4 4 DIR-NATSM A2 4 DIR-INIT-USER A8 4 DIR-TID A8 4 DIR-TRANS-NAME A8 4 DIR-OPSYS A8 4 DIR-TPSYS A8 4 DIR-USED-GDA A8 R 3 SRC-TEXT 4 SRC-GROUP (1:60) 5 SRC-LINE A72 3 SRC-SEQ I4 (1:60) 3 SRC-LONG A1 (1:60)
Uses of the Source Work Area Simple Code Example ZZL1057 2 USR1057N 3 EXTENDED-DATA A1 (1:28) R 3 EXTENDED-DATA 4 VERSION I1 4 V1-NSC-CKECK A1 4 V2-DBID N5 4 V2-FNR N4 4 V2-PSW A8 4 V2-CIP N8 4 V2-SYSFILE A1
Uses of the Source Work Area Simple Code Example ZZL2019 1 ZZ2019 2 SYSTEM-FILE A1 2 DBID N5 2 FNR N5 2 PASSWORD A8 2 CIPHERCODE N8 2 OBJECT-CLASS I1 2 LIBRARY A8 2 OBJECT-NAME A32 2 OBJECT-TYPE A2 2 OBJECT-KIND A1 2 OPT-ACCESS A1 2 OPT-ET L 2 OPT-REPLACE A1 2 OPT-SESNUM B2 2 OPT-BUFFNAME A8 2 OPT-NSC-CHECK A1 2 EDIT-MODE A1 2 EXTENDED-DATA A1 (1:2) INIT <H'02', 'Y'>
Uses of the Source Work Area Simple Code Example NC-SW-02 0010 DEFINE DATA 0020 LOCAL USING ZZL1057 /* Retrieve source 0030 LOCAL USING ZZL2019 /* Save source 0040 LOCAL USING USR-MSG /* Data for message exchange 0050 LOCAL USING USR-FLD /* Description of the field in error 0060 LOCAL 0070 1 #MAINFRAME (A16) CONST <'MAINFRAME'> 0080 1 #USR1057 (A8) CONST <'USR1057N'> 0090 1 #REAL 0100 2 #MACHINE-CLASS (A16) INIT <*MACHINE-CLASS> 0110 * 0120 1 #PLIB (A8) INIT <'BOSTON'> 0130 1 #PMOD (A8) INIT <‘NC-SW-03'> 0140 * 0150 1 #SET-UPPER (L) 0160 1 #I (I4) 0170 END-DEFINE 0180 * 0190 FORMAT PS=23 LS=80 0200 *
Uses of the Source Work Area Simple Code Example NC-SW-02 0210 DEFINE PRINTER (1) OUTPUT 'SOURCE' 0220 * 0230 * 0240 RESET ZZ1057.USR1057N 0250 ASSIGN ZZ1057.VERSION = 2 0260 ASSIGN ZZ1057.V2-SYSFILE = 'U' /* FUSER 0270 ASSIGN ZZ1057.OBJECT-TYPE = 'T' /* Text 0280 ASSIGN ZZ1057.OPT-LINE-NUM = 'Y' 0290 ASSIGN ZZ1057.OPT-REDEF-DIR = FALSE 0300 ASSIGN ZZ1057.OPT-AMOUNT = 60 /* Source block 0310 ASSIGN ZZ1057.OPT-LINESIZE = 72 0320 * 0330 ASSIGN ZZ2019.SYSTEM-FILE = 'U' /* FUSER 0340 ASSIGN ZZ2019.OBJECT-TYPE = 'T' /* Text 0350 ASSIGN ZZ2019.OPT-ACCESS = 'W' /* Write 0360 ASSIGN ZZ2019.OPT-REPLACE = 'Y' 0370 ASSIGN ZZ2019.OPT-NSC-CHECK = 'N' 0380 *
Uses of the Source Work Area Simple Code Example NC-SW-02 0390 REPEAT 0400 INPUT (AD=MDLT'_' IP=F SG=F ZP=F) 0410 *PROGRAM (CD=NE) 0420 10T 'LEN Consulting LLC' (CD=TU) 0430 64T *DAT4I (AD=O) 0440 *TIME (AL=5) 0450 / 10T 'Read/Edit/Update FUSER' 0460 /// 5X 'Library:' #PLIB 0470 // 5X ' Module:' #PMOD 0480 /* 0490 IF #PLIB = '.' 0500 OR #PMOD = '.' 0510 THEN 0520 STOP 0530 END-IF 0540 /* 0550 ASSIGN ZZ1057.LIBRARY = #PLIB 0560 ASSIGN ZZ1057.OBJECT-NAME = #PMOD 0570 ASSIGN ZZ1057.OPT-ACCESS = 'O' /* Open FUSER module 0580 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD
Uses of the Source Work Area Simple Code Example NC-SW-02 0590 IF NAD-MSG.MSG-NR = 1006 0600 THEN 0610 REINPUT 'Module not found' MARK *#PMOD 0620 END-IF 0630 ASSIGN ZZ1057.OPT-ACCESS = 'R' /* Read into array 0640 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD 0650 /* Update 0660 SET CONTROL 'Z' /* Clear Work area 0670 FOR #I = 1 ZZ1057.RETURNED 0680 IF ZZ1057.SRC-LINE (#I) = '*/' 0690 THEN 0700 ESCAPE TOP 0710 END-IF 0720 IF ZZ1057.SRC-LINE (#I) = 'UPPER CASE' 0730 THEN 0740 WRITE (1) NOTITLE 0750 'lower case' 0760 RESET #SET-UPPER 0770 ESCAPE TOP 0780 END-IF
Uses of the Source Work Area Simple Code Example NC-SW-02 0790 IF ZZ1057.SRC-LINE (#I) = 'lower case' 0800 THEN 0810 WRITE (1) NOTITLE 0820 'UPPER CASE' 0830 ASSIGN #SET-UPPER = TRUE 0840 ESCAPE TOP 0850 END-IF 0860 IF #SET-UPPER 0870 THEN 0880 EXAMINE SRC-LINE (#I) TRANSLATE INTO UPPER CASE 0890 ELSE 0900 EXAMINE SRC-LINE (#I) TRANSLATE INTO LOWER CASE 0910 END-IF 0920 WRITE (1) NOTITLE 0930 ZZ1057.SRC-LINE (#I) 0940 WRITE 0950 ZZ1057.SRC-LINE (#I) 0960 END-FOR
Uses of the Source Work Area Simple Code Example NC-SW-02 0970 IF #REAL.#MACHINE-CLASS <> #MAINFRAME 0980 THEN 0990 ASSIGN ZZ1057.OPT-ACCESS = 'C' /* Close 1000 CALLNAT #USR1057 ZZ1057 NAD-MSG NAD-FLD 1010 END-IF 1020 /* 1030 ASSIGN ZZ2019.LIBRARY = #PLIB 1040 ASSIGN ZZ2019.OBJECT-NAME = #PMOD 1050 CALLNAT 'USR2019N' ZZ2019 NAD-MSG NAD-FLD /* Save source 1060 END-REPEAT 1070 END
Uses of the Source Work Area Simple Code Example NC-SW-03 before 0010 UPPER CASE 0020 * 0030 RAINING CATS AND DOGS 0040 GIVE HIM THE BOOT 0050 FACE THE MUSIC 0060 DRESSED TO THE NINES 0070 PUT TWO AND TWO TOGETHER 0080 HE LAID AN EGG 0090 WALK ON EGG SHELLS 0100 I SMELL A RAT 0110 CAT GOT YOUR TONGUE? 0120 LET THE CAT OUT OF THE BAG 0130 SPILL THE BEANS 0140 YOU SAY POTATO, I SAY POTATO
Uses of the Source Work Area Simple Code Example NC-SW-03 after 0010 */ 0020 lower case 0030 * 0040 raining cats and dogs 0050 give him the boot 0060 face the music 0070 dressed to the nines 0080 put two and two together 0090 he laid an egg 0100 walk on egg shells 0110 i smell a rat 0120 cat got your tongue? 0130 let the cat out of the bag 0140 spill the beans 0150 you say potato, i say potato
Manipulating the Natural Source Area Questions?
Uses of the Source Work Area Editing Natural Objects Build your own editor based on SAG editor API • Custom edit commands Dynamic code generation • Load prototype from text member • Execute editing commands • Stow and execute SAG-L archive: http:\\listserv.uark.edu/archives/sag-l.html
Uses of the Source Work Area As a Temp File Load SWA via WRITE or user exit Read line by line USR2014N
Uses of the Source Work Area As a Temp File NC-SW-04 – USR2014N control block 0010 * Use SWA as a TEMP file 0020 * 0030 * Data definitions as in USR2014P: 0040 * 0050 DEFINE DATA LOCAL 0060 1 C-SCRMAX (I01) CONST <10> /* Maximum number of lines 0070 1 C-SCRLEN (I01) CONST <72> /* Length of data area 0080 1 C-PRFLEN (I01) CONST <06> /* Length of prefix area 0090 1 SHOW-PREFIX-AREA (L) CONST <FALSE> 0100 LOCAL 0110 1 CONTROL-BLOCK 0120 2 ED-SESNUM (B02) /* Number of session (0-50) 0130 2 ED-LOGFLAG (A01) /* Logical name in use 0140 2 ED-LOGNAME (A08) /* Logical name of the session 0150 2 ED-REQUEST (A04) /* Editor request 0160 2 ED-LIBRARY (A08) /* Unused 0170 2 ED-MEMBER (A08) /* Unused 0180 2 ED-RECLEN (B02) /* Maximum length of each line 0190 2 ED-PRFLEN (B02) /* Length of a prefix line on screen 0200 2 ED-SCRLEN (B02) /* Length of a single line on screen
Uses of the Source Work Area As a Temp File NC-SW-04 0210 2 ED-SCRNUM (B02) /* Number of lines on screen 0220 2 ED-SCRMAX (B02) /* Maximum number of lines on screen 0230 2 ED-RENUM (B01) /* Unused 0240 /* 0250 2 ED-MCMND (A50) /* Main command: command line 0260 2 ED-SCMND (A08) /* Secondary command: PF-key 0270 2 ED-CAREA (B02) /* Cursor area 0280 2 ED-CROW (B02) /* Cursor row 0290 2 ED-CCLM (B02) /* Cursor column 0300 /* 0310 2 ED-RECTOP (B02) /* Unused 0320 2 ED-NEW-RECTOP (B04) /* Line number of new first line on screen 0330 2 ED-RECNUM (B02) /* Unused 0340 2 ED-NEW-RECNUM (B04) /* Number of lines in the source area 0350 2 ED-FILECHG (B01) /* Indicator if source area has been mod. 0360 2 ED-SRAUSED (B04) /* Used source area in bytes 0370 2 ED-SRAFREE (B04) /* Unused source area in bytes 0380 2 ED-FLINE (A80) /* Message test. Explanation for 0390 /* ED-MSGNUM or ED-ERRNUM 0400 2 ED-MSGNUM (B02) /* Message number
Uses of the Source Work Area As a Temp File NC-SW-04 0410 2 ED-ERRNUM (B02) /* Error number 0420 2 ED-DUMMY (A32) /* Used for enhancements 0430 2 REDEFINE ED-DUMMY 0440 3 ED-DSTYPE (A01) /* Type of session 0450 3 ED-RECMAX (B02) /* Target session for CSES request 0460 /* 0470 1 CB-ALIN /* Attributes of prefix area 0480 2 CB-ALIN-V (N01/1:C-SCRMAX) 0490 1 L-PREFIXES /* Prefix area 0500 2 L-PREFIX-MAX (1:C-SCRMAX) 0510 3 L-PREFIX (A06) /* Length must be equal C-PRFLEN 0520 3 REDEFINE L-PREFIX 0530 4 L-PREFIX-A1 (A01/1:C-PRFLEN) 0540 /* 0550 1 CB-ADAT /* Attributes of data lines 0560 2 CB-ADAT-V (N01/1:C-SCRMAX) 0570 1 L-DATA-LINES /* Data lines 0580 2 L-DATA-MAX (1:C-SCRMAX) 0590 3 L-DATA (A72) /* Length must be equal C-SCRLEN 0600 3 REDEFINE L-DATA
Uses of the Source Work Area As a Temp File NC-SW-04 0610 4 L-DATA-A1 (A01/1:C-SCRLEN) 0620 * 0630 LOCAL 0640 1 C-SESNUM (B2) 0650 1 ERROR-NUMBER (N4) 0660 * --------------------------------------------------------------------- 0670 1 #I (I4) 0680 1 #ED-SCRNUM (I4) 0690 1 #RECNUM (I4) 0700 1 #LINES (P7) 0710 1 #WORK (A72) 1 REDEFINE #WORK /* WORK record 0720 2 #W (A2) 0730 2 FILLER 1X 0740 2 #ALPHA (A69) 0750 1 #WORDS (P7) 0760 END-DEFINE
Uses of the Source Work Area As a Temp File NC-SW-04 – populate SWA 0770 * Initialize the SWA 0780 SET CONTROL 'Z' /* Clear SWA 0790 FORMAT (3) LS=72 0800 DEFINE PRINTER (3) OUTPUT 'SOURCE' 0810 WRITE (3) NOTITLE '09 The quick brown fox jumps over the lazy dog.' 0820 WRITE (3) NOTITLE '07 A penny saved is a penny earned.' 0830 WRITE (3) NOTITLE '06 That"s all water under the bridge.' 0840 * 0850 * 0860 ASSIGN ED-SESNUM = 0 /* Open a free session 0870 ASSIGN ED-LOGFLAG = 'N' 0880 ASSIGN ED-DSTYPE = 'N' /* NATURAL SWA 0890 ASSIGN ED-RECLEN = 100 0900 ASSIGN ED-SCRMAX = 10 0910 ASSIGN ED-SCRNUM = 10 0920 ASSIGN ED-SCRLEN = C-SCRLEN 0930 ASSIGN ED-PRFLEN = C-PRFLEN 0940 *
Uses of the Source Work Area As a Temp File NC-SW-04 – open 0950 ASSIGN ED-REQUEST = 'OPEN' /* Open session 0960 CALLNAT 'USR2014N' 0970 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 0980 IF ED-ERRNUM <> 0 0990 THEN 1000 ERROR-NUMBER := ED-ERRNUM /* Error number in decimal form 1010 WRITE 'Error occurred during OPEN processing:' (I) 1020 / '=' ERROR-NUMBER 1030 / '=' ED-FLINE (AL=65) 1040 STOP 1050 END-IF 1060 ASSIGN C-SESNUM = ED-SESNUM /* Session number returned from OPEN 1070 ASSIGN #RECNUM = ED-NEW-RECNUM /* Number of lines in SWA 1080 * 1090 *
Uses of the Source Work Area As a Temp File NC-SW-04 – “READ WORK” 1100 ASSIGN ED-REQUEST = 'GETL' /* Get lines 1110 FOR #I = 1 #RECNUM /* READ WORK ... 1120 ASSIGN ED-NEW-RECTOP = #I 1130 CALLNAT 'USR2014N' 1140 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 1150 ASSIGN #WORK = L-DATA (1) 1160 DISPLAY 1170 'SWA/Line' #I (EM=ZZ9) 1180 '/Words' #W 1190 '/Line' #ALPHA (AL=50) 1200 IF #W IS (N2) 1210 THEN 1220 ADD 1 TO #LINES 1230 ADD VAL (#W) TO #WORDS 1240 END-IF 1250 END-FOR 1260 * 1270 *
Uses of the Source Work Area As a Temp File NC-SW-04 – “end-of-data” & “CLOSE WORK” 1280 WRITE 1290 /// #RECNUM (SG=F NL=3) 'source lines' 1300 // #LINES (SG=F NL=3) 'lines processed' 1310 / #WORDS (SG=F NL=3) 'words' 1320 * 1330 ASSIGN ED-REQUEST = 'CLSS' /* Close session 1340 CALLNAT 'USR2014N' 1350 CONTROL-BLOCK CB-ALIN L-PREFIX-A1(*,*) CB-ADAT L-DATA-A1(*,*) 1360 SET CONTROL 'Z' /* Clear SWA 1370 END
Uses of the Source Work Area As a Temp File NC-SW-04 – report Page 1 05/02/04 14:28:50 SWA Line Words Line ---- ----- -------------------------------------------------- 1 */ 2 09 The quick brown fox jumps over the lazy dog. 3 07 A penny saved is a penny earned. 4 06 That’s all water under the bridge. 4 source lines 3 lines processed 22 words
Uses of the Source Work Area Questions?
SAG User Exits Storing Natural source Retrieving Natural source Editing the SWA Miscellaneous