IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Copying one filed of a file to other


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Mon Nov 17, 2008 1:33 pm
Reply with quote

Hi all,

I faced one new problem while doing my work. Please help me out.

I am having two files.

FILE 1
Code:

---------------
--------------   These four are the header lines
--------------
--------------
a 3 ram
b 4 shyam
c 5 Ravi
-----------   trailer line


FILE 2

Code:

a 7
b 8
c 9

Could you please tell me how to get the following output,

Code:

---------------
--------------   These four are the header lines
--------------
--------------
a 7 3 ram
b 8 4 shyam
c 9 5 Ravi
-----------   trailer line



I suppose i am clear with my problem. Please tell me if anybody can help me out.

Thanks in advance
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Nov 17, 2008 11:19 pm
Reply with quote

Is that what your records really look like? If not, please show an example of input and output records with the real records.

Do you always have 4 header lines? Do you always have 1 trailer line?

Do you always have 4 data records in each file or can you have more or less?

Do you want to "match" the data records by the key (e.g. 'a' of input file1 with 'a' of input file2, etc) or by the data record number (e.g. data record 1 of input file1 with data record 1 of input file2, etc)?

What is the RECFM and LRECL of input file1? What is the RECFM and LRECL of input file2? What is the starting position, length and format of each relevant field?
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Nov 18, 2008 9:56 am
Reply with quote

Hi Frank,

Thanks for your reply.

Please have a look to my requirement,

Input file1 :- (Lrecl = 80, FB)

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7
       ;     ;     ; aaaaaaa              ;                  ;         ;       
       ;     ;     ;  bbbbb                ;                  ;         ;       
       ;     ;     ;   ccc                   ;                  ;         ;       
       ;     ;     ;    d                     ;                  ;         ;       
       ;     ;     ;                           ;                  ;         ;       
Numb ;MORE ;PT   ;FIRST NAME     ;LAST NAME         ;SSN      ;
11111;0009 ;0005 ;JIM            ;ROSling           ;111111111;
11111;0009 ;0005 ;Jack           ;mariot            ;222222222;
11111;0010 ;0001 ;DICK           ;Marvlet           ;333333333;
11111;0010 ;0001 ;BARRY          ;MALSE             ;444444444;
11111;0010 ;0001 ;JOHN           ;Rabbock           ;555555555;
TOT   :0005


Here the key values are from pos 1 to 5 and 53 to 63.

Similarly i am having one more input file. Such as below,

File 2( Lrecl = 60, FB )
Code:


----+----1----+----2----+----3
Numb ;SSN      ;amt
11111;111111111;000030   
11111;222222222;000050
11111;333333333;000095
11111;444444444;000078
11111;555555555;000094



Here the keys are 1 to 5 and 7 to 15.


If file2 (1 to 5) value = file1( 1to 5) and File 2(7 to 15) value = File 1( 53 to 63)
then it will populate the records in a new file where lrecl = 100, FB,

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
       ;     ;     ; aaaaaaa              ;                  ;         ;       
       ;     ;     ;  bbbbb                ;                  ;         ;       
       ;     ;     ;   ccc                   ;                  ;         ;       
       ;     ;     ;    d                     ;                  ;         ;       
       ;     ;     ;                           ;                  ;         ;     
Numb ;MORE ;PT   ;amt      ;FIRST NAME     ;LAST NAME         ;SSN      ;
11111;0009 ;0005 ;000030 ;JIM            ;ROSling             ;111111111;
11111;0009 ;0005 ;000050 ;Jack           ;mariot              ;222222222;
11111;0010 ;0001 ;000095 ;DICK           ;Marvlet             ;333333333;
11111;0010 ;0001 ;000078 ;BARRY          ;MALSE               ;444444444;
11111;0010 ;0001 ;000094 ;JOHN           ;Rabbock             ;555555555;
TOT   :0005


We always have aheader line of 6 line and a trailer of 1 line in the first file and only one header line in the second file.

We can have more than 4 records.

The Data records need to match by the Key only.

I suppose i m clear with my requirement. Please help in solving this prob

Thanks in advance
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 19, 2008 12:20 am
Reply with quote

Is this line actually in file2?

Code:

Numb ;SSN      ;amt   
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Wed Nov 19, 2008 11:28 am
Reply with quote

H Frank,

The line that u r asking is a header one.
Yes it was the only one header line that is present in the File 2.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Nov 20, 2008 12:01 am
Reply with quote

Ok. Your positions seem a little off

Quote:
File 2(7 to 15) value = File 1( 53 to 63)


7-15 is 9 bytes and 53-63 is 11 bytes so these don't match up. Instead, I assumed the SSN in File1 was from 54-62.


Here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/60)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/100)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(101,8,ZD) ON(1,5,CH) ON(64,9,CH) -
  KEEPNODUPS WITH(19,9) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(1,5,CH,EQ,C' '),OVERLAY=(101:SEQNUM,8,ZD)),
    IFTHEN=(WHEN=(1,7,CH,EQ,C'TOT   :'),OVERLAY=(101:8C'9')),
    IFTHEN=(WHEN=NONE,
      BUILD=(1,18,28:18,63,101:8C'7'))
/*
//CTL2CNTL DD *
  INREC BUILD=(1,6,19:17,9,64:7,9,101:8C'7')
/*
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,BUILD=(1,100)
/*


Here's the input file1 records I used:

Code:

       ;     ;     ; aaaaaaa              ;                  ;
       ;     ;     ;  bbbbb                ;                  ;
       ;     ;     ;   ccc                   ;                  ;
       ;     ;     ;    d                     ;                  ;
       ;     ;     ;                           ;                  ;
Numb ;MORE ;PT   ;FIRST NAME     ;LAST NAME         ;SSN      ;
11111;0009 ;0005 ;JIM            ;ROSling           ;111111111;
11111;0009 ;0005 ;Jack           ;mariot            ;222222222;
11111;0010 ;0001 ;DICK           ;Marvlet           ;333333333;
11111;0010 ;0001 ;BARRY          ;MALSE             ;444444444;
11111;0010 ;0001 ;JOHN           ;Rabbock           ;555555555;
TOT   :0005


Here's the input file2 records I used:

Code:

Numb ;SSN      ;amt
11111;111111111;000030
11111;222222222;000050
11111;333333333;000095
11111;444444444;000078
11111;555555555;000094


Here's the output the job produced:

Code:

        ;     ;     ; aaaaaaa              ;                  ;               
        ;     ;     ;  bbbbb                ;                  ;               
        ;     ;     ;   ccc                   ;                  ;             
        ;     ;     ;    d                     ;                  ;           
        ;     ;     ;                           ;                  ;           
 Numb ;MORE ;PT   ;amt      ;FIRST NAME     ;LAST NAME         ;SSN      ;     
 11111;0009 ;0005 ;000030   ;JIM            ;ROSling           ;111111111;     
 11111;0009 ;0005 ;000050   ;Jack           ;mariot            ;222222222;     
 11111;0010 ;0001 ;000095   ;DICK           ;Marvlet           ;333333333;     
 11111;0010 ;0001 ;000078   ;BARRY          ;MALSE             ;444444444;     
 11111;0010 ;0001 ;000094   ;JOHN           ;Rabbock           ;555555555;     
 TOT   :0005                                                                   
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top