Page 1 of 1

Append BODY data-area field into HEADER & BODY

PostPosted: Fri Oct 22, 2010 8:02 pm
by Grahamm
Take this simple made-up data:-

Input:
HEADER001package 0001      aaaaaaa
BODY 123ab23-05-2010       aaaaaaa
BODY i/23416-07-2010       aaaaaaa
HEADER002package 0002      bbbbbbb
BODY ERC5s05-11-2010       bbbbbbb
HEADER003package 0003      cccccccc
BODY TYR$b14-11-2010       ccccccc
BODY ee33416-11-2010       ccccccc
BODY 445ab23-12-2010       ccccccc
BODY GGF5416-07-2010       ccccccc

etc, etc

It consists of a Header record and then one or more Body records.
What I need to do is somehow append the 'day' out of the 1st BODY record after a position on all HEADER & BODY records.
This will be sorted on at a later date :lol:

Expected Output:
HEADER001package 0001      aaaaaaa
BODY 123ab23-05-2010       aaaaaaa
BODY i/23416-07-2010       aaaaaaa
HEADER002package 0002      bbbbbbb05
BODY ERC5s05-11-2010       bbbbbbb05
HEADER003package 0003      ccccccc14
BODY TYR$b14-11-2010       ccccccc14
BODY ee33416-11-2010       ccccccc14
BODY 445ab23-12-2010       ccccccc14
BODY GGF5416-07-2010       ccccccc14
etc, etc

The position of the field to append to is column 27 and length 7 so needs appending at position 34 on all records.
The 'dd' is in column 10 of the BODY.

I am sure there is a function(s) somewhere that can do this, but the question is what?

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Fri Oct 22, 2010 10:33 pm
by Frank Yaeger
Your description doesn't match your example. The columns are off. Also, shouldn't the first three output records have 23 appended at the end? Please clarify.

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Fri Oct 22, 2010 11:22 pm
by NicC
When I first read this the first 3 lines of output DID have 23 at the end.

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Mon Oct 25, 2010 3:20 pm
by Grahamm
I too thought it did have 23 appended, but whatever I have re-supplied the Input & Output expectations.

INPUT:

HEADER001package 0001 aaaaaaa
BODY 123ab23-05-2010 aaaaaaa
BODY i/23416-07-2010 aaaaaaa
HEADER002package 0002 bbbbbbb
BODY ERC5s05-11-2010 bbbbbbb
HEADER003package 0003 ccccccc
BODY TYR$b14-11-2010 ccccccc
BODY ee33416-11-2010 ccccccc
BODY 445ab23-12-2010 ccccccc
BODY GGF5416-07-2010 ccccccc


OUTPUT:
HEADER001package 0001 aaaaaaa23
BODY 123ab23-05-2010 aaaaaaa23
BODY i/23416-07-2010 aaaaaaa23
HEADER002package 0002 bbbbbbb05
BODY ERC5s05-11-2010 bbbbbbb05
HEADER003package 0003 ccccccc14
BODY TYR$b14-11-2010 ccccccc14
BODY ee33416-11-2010 ccccccc14
BODY 445ab23-12-2010 ccccccc14
BODY GGF5416-07-2010 ccccccc14

If anyone can suggest something/feature to use to achieve this I would be most grateful?

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Mon Oct 25, 2010 3:31 pm
by Grahamm
Apologies Frank, I didn't read your reply correctly when I responded last.

1) Shouldn't the first three output records have 23 appended at the end?
Yes, see the previous post with sample INput/Output again.

2) Your description doesn't match your example. The columns are off. Also, Please clarify.
Correct again.
The position to append the date to is column 35 on all records.
The 'dd' to append from is in column 11 (length 2) of the BODY.

I hope that is now a complere response. :oops: :)

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Tue Oct 26, 2010 1:20 am
by Frank Yaeger
Here's a DFSORT/ICETOOL job that will do what you asked for:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (FB/34)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output (FB/36)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY JKFROM TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'H'),
    PUSH=(37:ID=8,45:SEQ=8))
  OUTFIL FNAMES=T1
  OUTFIL FNAMES=T2,INCLUDE=(45,8,ZD,EQ,2),
    BUILD=(1:37,8,9:11,2)
/*
//CTL2CNTL DD *
  JOINKEYS F1=T1,FIELDS=(37,8,A),SORTED,NOSEQCK
  JOINKEYS F2=T2,FIELDS=(1,8,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,34,F2:9,2)
/*

Re: Append BODY data-area field into HEADER & BODY

PostPosted: Tue Oct 26, 2010 8:38 pm
by Grahamm
Frank

Another excellent job, all coded and again works 100% :D 8-)
I am quite happy to say I understood the job fully, these jobs are giving me good exposure to using JOINKEYS and ICETOOL.
In fact, as I mentioned, above was just some sample data I knocked up to attempt to demonstrate what I needed to do hoping that there was a function available to do it. I then took your JCL sample and re-worked this over my actual requirements and again it worked first time.

//TOOLIN    DD    *                                               
COPY FROM(IN) USING(CTL1)                                   
COPY JKFROM TO(OUT) USING(CTL2)                             
/*                                                           
//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'K'),           
    PUSH=(1001:ID=8,1009:SEQ=8))                             
  OUTFIL FNAMES=T1                                           
  OUTFIL FNAMES=T2,INCLUDE=(1009,8,ZD,EQ,2),                 
    BUILD=(1:1001,8,9:02,2)                                 
/*                                                           
//CTL2CNTL DD *                                             
  JOINKEYS F1=T1,FIELDS=(1001,8,A),SORTED,NOSEQCK           
  JOINKEYS F2=T2,FIELDS=(1,8,A),SORTED,NOSEQCK               
  REFORMAT FIELDS=(F1:1,620,F2:9,2,F1:623,378)               
/*


Excellent job thanks.