Page 1 of 1

Overlay position in record dependent on preceding record

PostPosted: Thu Dec 24, 2009 1:59 am
by Kevin Jenkins
Answer not jumping out of manual at me. Latest maintenance level is UK90013 July 2008.

I have a RECFM=FA,LRECL=133 input file that I need to perform two operations on.
1. If position 1 is a hyphen and position 1 in the preceding record was a 1, then position 1 in the current record should be overlaid with 0 (zero).
2. Data beginning at position 30 to the end of record is shifted to position 2.

Achieving point 2 is straightforward enough, but I can't get my head around how to deal with point 1.

Grateful for help to solve.

regards, Kevin

Thought I was on the right lines with the following, but this is only fine when position 1=1 occurs on an odd number line with hyphen in position 1 on the next line. When the sequence is the other way round it  does not work.

//DFS1CNTL DD *                                     
  INREC IFTHEN=(WHEN=GROUP,RECORDS=2,               
                  PUSH=(134:ID=3,138:SEQ=1,140:1,1)),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'-',               
                      AND,140,1,CH,EQ,C'1'),         
                  OVERLAY=(140,1,2,139))             


Example of Input ...
1                             AAA
-                             BBB
0                             CCC
0                             DDD
-                             EEE
0                             FFF
0                             GGG
1                             HHH
-                             III
0                             JJJ
                              KKK
4                             LLL
0                             MMM

Example of output (record length will be 80) ...
1 AAA
0 BBB position 1 overlaid
0 CCC
0 DDD
- EEE 
0 FFF
0 GGG
1 HHH
0 III position 1 overlaid
0 JJJ
  KKK
4 LLL
0 MMM

Re: Overlay position in record dependent on preceding record

PostPosted: Thu Dec 24, 2009 3:06 pm
by Kevin Jenkins
Some tweaking to do with the output record length, but I think I have found the answer myself.

//DFS1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,                                       
          RECORDS=2,                                             
          BEGIN=(1,1,CH,EQ,C'1'),                                 
          END=(1,1,CH,EQ,C'-'),PUSH=(134:ID=3,138:SEQ=1,140:1,1)),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'-',                             
                      AND,140,1,CH,EQ,C'1'),                     
                  OVERLAY=(1:C'0',2,139))                         
  OUTFIL INCLUDE=ALL,BUILD=(1,1,30,104,35X)                       
  OPTION COPY