【问题标题】:How to split the reports in a single dataset to Multiple Datasets uisng JCL如何使用 JCL 将单个数据集中的报表拆分为多个数据集
【发布时间】:2021-07-26 13:39:42
【问题描述】:

一个数据集包含许多报告。我需要将第一份报告单独发送到另一个数据集。我们如何使用 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

【问题讨论】:

  • 请编辑您的问题并将示例数据重新格式化为code,以便保留换行符。
  • 请移除 JCL 标签。您无法通过 JCL 实现任何数据操作;您总是需要诸如排序程序之类的工具。您将需要 JCL 将该工具作为批处理作业运行,但这并不会使该问题成为 JCL 问题。

标签: sorting jcl


【解决方案1】:

如果报告的大小是固定的,您可以使用带有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)。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-23
    • 2018-01-21
    • 2021-10-06
    • 2020-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多