Append BODY data-area field into HEADER & BODY



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Append BODY data-area field into HEADER & BODY

Postby Grahamm » Fri Oct 22, 2010 8:02 pm

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?
Grahamm
 
Posts: 10
Joined: Tue Oct 19, 2010 8:30 pm
Has thanked: 0 time
Been thanked: 0 time

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

 

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

Postby Frank Yaeger » Fri Oct 22, 2010 10:33 pm

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.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

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

Postby NicC » Fri Oct 22, 2010 11:22 pm

When I first read this the first 3 lines of output DID have 23 at the end.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

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

Postby Grahamm » Mon Oct 25, 2010 3:20 pm

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?
Grahamm
 
Posts: 10
Joined: Tue Oct 19, 2010 8:30 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Grahamm » Mon Oct 25, 2010 3:31 pm

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: :)
Grahamm
 
Posts: 10
Joined: Tue Oct 19, 2010 8:30 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby Frank Yaeger » Tue Oct 26, 2010 1:20 am

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)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

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

Postby Grahamm » Tue Oct 26, 2010 8:38 pm

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.
Grahamm
 
Posts: 10
Joined: Tue Oct 19, 2010 8:30 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post