如何使用 JCL 将单个数据集中的报告拆分为多个数据集

How to split the reports in a single dataset to Multiple Datasets uisng JCL

一个数据集中有很多报告。我需要单独向另一个数据集报告第一份报告。使用JCL如何实现?

下面是数据集的示例。我的要求是只整理R0A报表下的记录

---Report - R0A---
List of Payments
Date : 23/07/2021
Name Payment-Amt Due-Date
AAAA  233.04     15/08/2021
BBBB   38.07     16/08/2021
---Report - R0B---
List of Payments
Date : 23/07/2021
Name Payment-Amt Due-Date
AAAA  233.04     15/08/2021
BBBB   38.07     16/08/2021
---Report - R0C---
List of Payments
Date : 23/07/2021
Name Payment-Amt Due-Date
AAAA  233.04     15/08/2021
BBBB   38.07     16/08/2021

如果报告的大小是固定的,您可以使用带有 COPYSTOPAFT= 选项的排序:

SORT FIELDS=COPY,STOPAFT=6

如果您需要第一个以外的报告,您可以添加 SKIPREC= 选项。例如。要获取第三份报告,请指定:

SORT FIELDS=COPY,SKIPREC=12,STOPAFT=6

如果报告的长度不同,您可以运行一个简单的 REXX。

/* REXX - NOTE This is only a skeleton. Error checking must be added.     */
/*             This code has not been tested, so thorough testing is due. */

"ALLOC F(INP) DS('your.fully.qualed.input.data.set.name') SHR"
"EXECIO * DISKR INP ( STEM InpRec. FINISH"
"FREE F(INP)"

TRUE  = 1
FALSE = 0

ReportStartIndicator = "---Report"
ReportName           = "- R0B---"
ReportHeader         = ReportStartIndicator ReportName
ReportCopy           = FALSE

do ii = 1 to InpRec.0 while ReportCopy = FALSE
  if InpRec.ii = ReportHeader
  then ReportCopy = TRUE
  end

if ReportCopy 
then do
  OutRec.1 = InpRec.ii
  Outcnt   = 1

  do jj = ii + 1 to InpRec.0 while ReportCopy = TRUE
    if word( InpRec.jj, 1 ) = ReportStartIndicator /* Start of next report? */
    then ReportCopy = FALSE
    else do
      OutCnt        = OutCnt + 1
      OutRec.Outcnt = InpRec.jj
      end
    end

  "ALLOC F(OUT) DS('your.fully.qualed.output.data.set.name')" ,
      "NEW CATLG SPACE(......) RECFM(....) LRECL(....)"
  "EXECIO" OutCnt "DISKW OUT ( STEM OutRec. FINIS"
  "FREE F(OUT)"

  say "Done copying report." OutCnt "records have been copied."
  end
else do
  say "Report" ReportName "not found."
  exit 16
  end

正如 REXX 中的评论所写,我还没有测试过这段代码。此外,还需要添加错误检查,尤其是对于 TSO HOST 命令(ALLOC、EXECIO、FREE)。

所有解决方案都将 单个 报告复制到另一个数据集。在标题中,你写了to multiple datasets。我相信您会使用上述 单一报告 解决方案找到解决方案。