微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何使用 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)。

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。