问题描述
一个数据集中有许多报告。我只需要第一个报告到另一个数据集。我们如何使用 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
解决方法
如果报告的大小是固定的,您可以使用带有 COPY
和 STOPAFT=
选项的排序:
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)。
所有解决方案都将单个报告复制到另一个数据集。在标题中,您写了多个数据集。我相信您会使用上述单一报告解决方案找到解决方案。