在大型机中使用 DFSORT 实用程序进行乘法除法

Multiplication division using DFSORT utility in Mainframe

有两个文件 FILE1.DATA 和 FILE2.DATA 在大型机中使用 DFSORT 计算百分比(FILE2 中记录的 FILE1/Number 中的记录数)*100。如果超过阈值 (90%),则设置 Return 代码。

//********Extracting Unique records data*****************
//SORTT000 EXEC PGM=SORT   
//SYSOUT   DD  SYSOUT=*    
//SORTIN   DD  DSN=SAMPLE.DATA1,DISP=SHR 
//SORTOUT  DD  DSN=FILE1.DATA,                          
//             SPACE=(2790,(5376,1075),RLSE),                    
//             UNIT=TSTSF,                                       
//             DCB=(RECFM=FB,LRECL=05,BLKSIZE=0),                
//             DISP=(NEW,CATLG,DELETE)                           
//SYSIN    DD  *                                                 
 SORT FIELDS=(10,5,CH,A) 
 OUTREC FIELDS=(1:10,5)  
 SUM FIELDS=NONE         
/*                  
//************Getting count of records*****************     
//STEP001  EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*         
//DFSMSG   DD SYSOUT=*                                    
//SYSOUT DD SYSOUT=*                                      
//SYSPRINT DD SYSOUT=*                                    
//IN1      DD DISP=SHR,DSN=FILE1.DATA
//IN2      DD DISP=SHR,DSN=FILE2.DATA
//OUT1     DD DSN=FILE1.DATA.COUNT,    
//            SPACE=(2790,(5376,1075),RLSE),      
//            UNIT=TSTSF,                         
//            DCB=(RECFM=FB,LRECL=06,BLKSIZE=0),  
//            DISP=(NEW,CATLG,DELETE)     
//OUT2     DD DSN=FILE2.DATA.COUNT,  
//            SPACE=(2790,(5376,1075),RLSE),      
//            UNIT=TSTSF,                         
//            DCB=(RECFM=FB,LRECL=06,BLKSIZE=0),  
//            DISP=(NEW,CATLG,DELETE)    
//TOOLIN   DD *                                           
   COUNT FROM(IN1)  WRITE(OUT1) DIGITS(6)                   
   COUNT FROM(IN2)  WRITE(OUT2) DIGITS(6)                    
/*      
//*******Calculating percentage and if above 90% setting RC 04*****                                                  
//STEP002  EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=FILE2.DATA.COUNT,DISP=SHR                
//         DD DSN=FILE1.DATA.COUNT,DISP=SHR                
//SORTOUT  DD DSN=FILE.DATA.COUNT.OUT,     
//            SPACE=(2790,(5376,1075),RLSE),      
//            UNIT=TSTSF,                         
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0),  
//            DISP=(NEW,CATLG,DELETE)                    
//SETRC    DD SYSOUT=*                                               
//SYSIN    DD *                                                      
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,6,X,6X'00',SEQNUM,1,ZD,80:X)),    
  IFTHEN=(WHEN=(14,1,ZD,EQ,2),OVERLAY=(8:1,6))                       
  SORT FIELDS=(7,1,CH,A),EQUALS                                      
  SUM FIELDS=(8,4,BI,12,2,BI)                                        
  OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,                 
                 (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT))

  OUTFIL FNAMES=SETRC,NULLOFL=RC4,INCLUDE=(23,6,CH,GT,C'090.00')          
  OUTFIL BUILD=(05:C'TOTAL NUMBER RECRODS IN FILE2        : ',1,6,/, 
                05:C'TOTAL NUMBER RECRODS IN FILE1        : ',8,6,/, 
                05:C'PERCENTAGE                           : ',23,6,/,
               80:X)                                                
//*                                                                  
  1. 我面临的问题是数据集 FILE1.DATA.COUNT 和 FILE1.DATA.COUNT 正在创建 15 个记录长度,尽管提到了 LRECL 6。(注意,这是在第一个答案已经写好了,现在与上面的代码无关。
  2. 我们可以将这两个步骤合二为一吗?
  3. 这个(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X, (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT))具体是什么意思?

你第一个问题的答案只是你没有告诉 ICETOOL 的 COUNT 运算符你希望输出数据有多长,所以 它想出了自己的数字。

这来自 DFSORT 应用程序编程指南:

WRITE(countdd) Specifies the ddname of the count data set to be produced by ICETOOL for this operation. A countdd DD statement must be present. ICETOOL sets the attributes of the count data set as follows:

v RECFM is set to FB.

v LRECL is set to one of the following:

– If WIDTH(n) is specified, LRECL is set to n. Use WIDTH(n) if your count record length and LRECL must be set to a particular value (for example, 80), or if you want to ensure that the count record length does not exceed a specific maximum (for example, 20 bytes).

– If WIDTH(n) is not specified, LRECL is set to the calculated required record length. If your LRECL does not need to be set to a particular value, you can let ICETOOL determine and set the appropriate LRECL value by not specifying WIDTH(n).

并且:

DIGITS(d)

Specifies d digits for the count in the output record, overriding the default of 15 digits. d can be 1 to 15. The count is written as d decimal digits with leading zeros. DIGITS can only be specified if WRITE(countdd) is specified.

If you know that your count requires less than 15 digits, you can use a lower number of digits (d) instead by specifying DIGITS(d). For example, if DIGITS(10) is specified, 10 digits are used instead of 15.

If you use DIGITS(d) and the count overflows the number of digits used, ICETOOL terminates the operation. You can prevent the overflow by specifying an appropriately higher d value for DIGITS(d). For example, if DIGITS(5) results in overflow, you can use DIGITS(6) instead.

并且:

WIDTH(n)

Specifies the record length and LRECL you want ICETOOL to use for the count data set. n can be from 1 to 32760. WIDTH can only be specified if WRITE(countdd) is specified. ICETOOL always calculates the record length required to write the count record and uses it as follows:

v If WIDTH(n) is specified and the calculated record length is less than or equal to n, ICETOOL sets the record length and LRECL to n. ICETOOL pads the count record on the right with blanks to the record length.

v If WIDTH(n) is specified and the calculated record length is greater than n, ICETOOL issues an error message and terminates the operation.

v If WIDTH(n) is not specified, ICETOOL sets the record length and LRECL to the calculated record length.

Use WIDTH(n) if your count record length and LRECL must be set to a particular value (for example, 80), or if you want to ensure that the count record length does not exceed a specific maximum (for example, 20 bytes). Otherwise, you can let ICETOOL calculate and set the appropriate record length and LRECL by not specifying WIDTH(n).

你的第二个问题,是的,可以一步完成,大大简化了。

事实是,它可以通过做其他事情来进一步简化。具体还有哪些取决于您的实际任务,我们不知道,我们只知道您为您的任务选择的解决方案。

例如,您想知道一个文件何时在另一个文件大小的 10% 以内。如果不需要 on-the-dot 准确性,一种方法是与管理您的存储的技术人员交谈。告诉他们你想做什么,他们可能已经有一些你可以用来做的东西(讨论这个时,请记住,这些在技术上是 数据集 ,而不是文件)。

或者,某些东西之前已经读取或写入了这些文件。如果最后一个这样做的程序还没有产生它所拥有的 read/written 的计数(在我看来,标准的良好做法,以及程序协调)然后修改程序现在就这样做。那里。魔法。你有你的计数。

将这些计数安排在它们自己的数据集中(最好使用 record-types、headers/trailers,更标准的良好做法)。

采取两个计数中较大的(期望值)的一步,"work out" 00% 是什么(除了简单的减法,使用正确的数据不需要任何东西)并生成 SYMNAMES 格式文件(fixed-length 80 字节记录)带有一个 SORT-symbol 作为具有该值的常量。

第二步使用 INCLUDE/OMIT 与第二个符号 record-count 相比,使用 NULLOUT 或 NULLOFL。

以上几种解决方案的优点是基本上使用的资源很少。在大型机上,客户为资源付费。您的客户可能不会很高兴在年底发现他们已经支付阅读费用和 "counting" 7.3m 记录只是为了让您可以设置 RC。

好的,也许 7.3m 并没有那么大,但是,当您有了 "solution" 时,下一个人将使用 100,000 条记录,下一个将使用 1,000,000 条记录。全部设置一个RC。 运行 其中任何一个(即使是 10,000 条记录的示例)都将超过 "Mainframe" 解决方案的成本 运行 在接下来的 15 年以上每天 运行。

第三个问题:

 OUTREC OVERLAY=(15:X,1,6,ZD,DIV,+2,M11,LENGTH=6,X,
                (8,6,ZD,MUL,+100),DIV,1,6,ZD,MUL,+100,EDIT=(TTT.TT)) 

OUTREC 在 SORT/MERGE 和 SUM(如果存在)之后处理,否则在 INREC 之后处理。请注意,这些在 JCL 中指定的物理顺序不会影响它们的处理顺序。

OVERLAY 表示“用这些 data-manipulations 更新当前记录中的信息(BUILD 总是创建当前记录的新副本)。

15:在记录中是 "column 15"(位置 15)。

X 插入一个空格。

1,6,ZD 表示 "the information, at this moment, at start-position one for a length of six, which is a zoned-decimal format".

DIV 是分区。

+2 是一个数字常量。

1,6,ZD,DIV,+2 表示“从位置 1 开始取 six-digit 数,并将其除以二,得到 'result',这将被放置在下一个可用位置(在您的情况下为 16)。

M11 是 built-inedit-mask。有关该掩码是什么的详细信息,请在手册中查找,因为届时您会发现其他有用的 pre-defined 掩码。用它来格式化结果。

LENGTH=6 将结果限制为六位数。

至此,前六位的数字将除以二,(被掩码)视为六位无符号zoned-decimal,从位置16开始。

语句的其余元素类似。括号以正常方式影响数字运算符的 "precedence"(查阅手册以熟悉优先级规则)。

EDIT=(TTT.TT) 是一个 used-defined 编辑掩码,在本例中插入一个小数点,t运行 覆盖其他现有的 left-most 数字,并且必要时有重要的前导零。