需要一组记录副本

时间:2019-01-22 08:13:48

标签: cobol mainframe

输入文件1 [VB 1504字节]

HEADER REC  2000A .....  REC1...。  REC2 ...  2300 ...  REC3 ...  REC4...。  。  。  RECN ......  2000A  REC1...。  REC2 ...  2300 ...  REC3 ...  REC4...。  。  。  RECN ...

FILE2 [10字节FB]  1234567891  9876544211

我要复制记录,其中文件2中的10个BYtes键与从2300开始的记录中存在的10个字节键匹配。键位置[15:10]

如果键匹配,则复制记录从2000A开始到下一个2000A记录。

任何建议....

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我从您的问题中了解到的是,您需要VB1504文件中的记录,这些记录以2300开头并与FB10中的密钥匹配。 您将需要DFSORT / ICETOOL连接操作。 假设给定职位; FILE1为FB10,FILE2为VB1504; JCL和SYSIN卡一起是这样-

//JOBNAME  JOB 'DFSORT JOIN',CLASS=A,MSGCLASS=A,
//         NOTIFY=&SYSUID
//*
//SORTJOIN EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//FILE1    DD DISP=SHR,DSN=FILE1
//FILE2    DD DISP=SHR,DSN=FILE2
//SORTOUT  DD DSN=OUTPUT.FILE,
//         DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
//         SPACE=(CYL,(10,10),RLSE),DCB=*.FILE2
//SYSIN    DD *
  JOINKEYS FILE=FILE1,FIELDS=(01,10,CH,A)
  JOINKEYS FILE=FILE2,FIELDS=(19,10,CH,A),
           INCLUDE=(05,04,ZD,EQ,2300)
  REFORMAT FIELDS=(F2:01,1504)
  OPTION   COPY
/*

这将为您提供VB1504文件中的非重复记录,其中记录以2300开头并与密钥匹配。 如果要复制记录,则将OPTION COPY更改为OPTION EQUALS

答案 2 :(得分:0)

方法1:

Open files.
Process header for 'File 1'.
Load 'File 2' into a 'lookup table'.
For each '2000A group' in 'File 1' until 'end of file'.  
    Set a 'record counter' to zero.  
    Load all records into a 'buffer table', until another '2000A' record
        or end of file is found, counting the number of records.  
    Locate the '2300' record in the 'buffer table'. (The location may be saved
        while loading the 'buffer table'.)  
    Search the 'lookup table' for a value matching the value in
        the '2300' record.  
    If a match is found.  
        Write the 'buffer table' to the output file.  
End of for each.
Close files.

或者,如NicC建议的那样,

方法2:

Open files.
Process header for 'File 1'.
Load 'File 2' into a 'lookup table'.
For each '2000A group' in 'File 1' until 'end of file'.  
    Set the 'buffer table' 'record counter' to zero.  
    Load records into a 'buffer table', counting the number of records,
        until the '2300' record is found.  
    Search the 'lookup table' for a value matching the value in
        the '2300' record.  
    If a match is found.  
        Write the 'buffer table' to the output file.  
        Write the '2300' record to the output file.  
        Copy records from the input file to the output file until another
            '2000A' record is found or end of file.  
    Else.
        Skip records from 'File 1' until another '2000A' record is found
            or end of file.  
    End of if.  
End of for each.
Close files.

选择哪种方法可能取决于要保存在“缓冲区表”中的记录数。方法1使用两个例程:Load 'buffer table'Write 'buffer table'。方法2使用四个例程:Load 'buffer table'Write 'buffer table'Copy 'File 1'Skip 'File 1' records(尽管Copy 'File 1'可以有'Skip flag'来防止写入记录) 。这没什么区别。