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

Merge 1 field onto another record


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

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Fri Feb 04, 2011 11:41 pm
Reply with quote

Code:

AA2830                        RAA2830004
AA2830                        RAA2830005
AA2830                        RAA2830009
AA2830                        RAA2830013
AA2832                        RAA2832001
AA2834                        RAA2834001
AA2834                        RAA2834002

i have the above file with customer number and then an invoice number.
i will need to take a 'new' customer number and place it into the middle of the 2 fields.
where i get that new number from only occurs once in another file. like this:

Code:

AA2830     AA2834
AA2832     AA2834
AA2834     AA2834
AA2847     AA2847
AA2853     AA2853
AA2854     AA2854
AA2855     AA2855

the number on the right has to go into every record that has the number on the left. got 3 people looking into as how we can do this and we are stuck. we believe we tried every splice combo in the book. 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: Sat Feb 05, 2011 12:04 am
Reply with quote

It's not clear from your description what you want to do exactly.

Please show the expected output for your input example.

Give the RECFM and LRECL of the input files.

Give the starting position, length and format of each relevant field.

I suspect JOINKEYS would be a better choice for this then SPLICE.
Back to top
View user's profile Send private message
madmartinsonxx

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Sat Feb 05, 2011 12:13 am
Reply with quote

lrecl of both files is 20
recfm is fb
records should look like following on output:
Code:

AA2830     AA2834          RAA2830004
AA2830     AA2834          RAA2830004
AA2830     AA2834          RAA2830004
AA2830     AA2834          RAA2830004
AA2832     AA2834          RAA2832001


1st field is 10 bytes. 2nd field from 2nd file i need to merge is 10 bytes.
the 3rd field, invoice number is 10 bytes on the 2nd file in pos 12.

we dont have joinkeys as we are only at level 'G' not 'H'.
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: Sat Feb 05, 2011 12:55 am
Reply with quote

It would have been nice if you'd spent more time to describe your requirement accurately. The positions and LRECL you indicate conflict.
The example you show is not very good and the output shown does not match the input.

Quote:
we dont have joinkeys as we are only at level 'G' not 'H'


JOINKEYS only requires level 'G', not level 'H' so I'll assume you can use it.

Here's a DFSORT job that will do what I think you want. I assumed your input fields were each 10 bytes so they start at 1 and 11 in the input file and should start at 1, 11 and 21 in the output file. I also assumed the records in each input file were already in order by the first field.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/20)
//IN2 DD DSN=...  input file2 (FB/20)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN DD *
  JOINKEYS F1=IN1,FIELDS=(1,10,A),SORTED
  JOINKEYS F2=IN2,FIELDS=(1,10,A),SORTED
  REFORMAT FIELDS=(F1:1,10,F2:11,10,F1:11,10)
  OPTION COPY
/*


For your input example, SORTOUT would have:

Code:

AA2830    AA2834    RAA2830004       
AA2830    AA2834    RAA2830005       
AA2830    AA2834    RAA2830009       
AA2830    AA2834    RAA2830013       
AA2832    AA2834    RAA2832001       
AA2834    AA2834    RAA2834001       
AA2834    AA2834    RAA2834002       


If that's not what you want, then you need to do a better job of explaining what you do want.
Back to top
View user's profile Send private message
madmartinsonxx

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Sat Feb 05, 2011 1:00 am
Reply with quote

Code:

  COPY FROM(XREFIN) TO(OUT2) USING(CTL4)                                 
  COPY FROM(SLSIN)  TO(OUT2) USING(CTL2)                                 
  SPLICE FROM(OUT2) TO(OUT3) -                                           
         ON(001,010,CH) -                                               
         WITH(030,011) WITHALL                                           
  COPY FROM(OUT2) TO(OUT4)                                               
 //*                                                                     
 //CTL5CNTL  DD *                                                       
  OUTFIL BUILD=(001,010,012,010,030,010)                                 
 //CTL2CNTL  DD *                                                       
  SORT FIELDS=(009,10,CH,A)                                             
  INCLUDE COND=(009,4,CH,NE,C'NONE',AND,009,007,CH,NE,C'GENERIC',AND,   *
                009,008,CH,NE,C'MULTIPLE')                               
  OUTREC FIELDS=(009,10,20X,103,10)                                     
 /*                                                                     
 //CTL4CNTL  DD *                                                       
  SORT FIELDS=(001,10,CH,A)                                             
  OUTREC FIELDS=(001,010,1X,011,010,20X)                                 
 /*                                                                     


ty very much frank. i will outline things more clearly. i got it to work 'finally' with the above after trying all morning. we are jumping for joy.
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: Sat Feb 05, 2011 1:19 am
Reply with quote

I still think JOINKEYS would be a better choice. If you would actually take the time to explain exactly what you're trying to do, I could show you how to use JOINKEYS to do it (or SPLICE if you really can't use JOINKEYS).

Your job is confusing and not well coded. Why do you have CTL5CNTL when you aren't USING it? Why are you copying from OUT2 to OUT4? I suspect you don't really need to use SORT with the COPY operators since SPLICE will do the sort anyway. What is in 103,10?
Back to top
View user's profile Send private message
madmartinsonxx

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Sat Feb 05, 2011 1:47 am
Reply with quote

Frank,
CTL5 was left in from an earlier try. My apologizies. And, yes, I do have joinkeys. Am not sure why it isn't in the manual i have for this tool but i tried it and it does connect.

in the XREFIN file are 2 cust nums. OLD cust num (1,10) and NEW cust num (11,10). in the SLSIN file are OLD custnums (9,10) and the invoice num (103,10). I have to match the from the SLSIN cust num to the XREFIN cust num to get the NEW cust num and report as:

old custnum, new custnum, invoice num
Code:

AA2830    AA2834    RAA2830004       


for each record on the SLSIN file. We are doing a 3rd mock conversion as we speak so i will use what I have for now to keep rockin' , but, I will readdress the JOINKEY when time allows. It looks pretty slick. Ty again.
Back to top
View user's profile Send private message
madmartinsonxx

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Sat Feb 05, 2011 1:54 am
Reply with quote

Frank,
didnt answer the COPY question. I do that so I have the output to look at when it is in the SDSF queue. I don't have to go out and create a cataloged file and use browse to look at it. The output is readily available when I go to check the job.
Back to top
View user's profile Send private message
madmartinsonxx

New User


Joined: 10 Dec 2010
Posts: 96
Location: Massachusetts

PostPosted: Sat Feb 12, 2011 3:22 am
Reply with quote

Code:

 * MATCHES FROM PREVIOUS STEP                             
  JOINKEYS FILE=F1,FIELDS=(001,010,A),SORTED               
 * CUSTOMER NUMBERS FROM THE TEXT FILE                     
  JOINKEYS FILE=F2,FIELDS=(001,010,A),SORTED               
  JOIN UNPAIRED,F1,F2                                     
 * REPORT FIELDS, F1 NEW SAP CUSTNUM, F2 OLD CUSTNUM       
  REFORMAT FIELDS=(F1:01,10,F2:01,10,?)                   
 * CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)       
  OPTION COPY                                             
 * NEW SAP CUSTNUM                                         
  OUTFIL FNAMES=F1ONLY,INCLUDE=(21,1,CH,EQ,C'1'),         
     BUILD=(01,10)                                         
 * OLD CUSTNUM                                             
  OUTFIL FNAMES=F2ONLY,INCLUDE=(21,1,CH,EQ,C'2'),         
     BUILD=(011,10)                                       
 * NEW SAP CUSTNUM THEN OLD CUSTNUM                       
  OUTFIL FNAMES=(BOTH,BOTHJKE6),INCLUDE=(21,1,CH,EQ,C'B'),
     BUILD=(01,10,011,10)                                 


Frank was right. I had to do the JOINKEY process twice to mash everything down to its lowest common denominator but the above code will handle this situation every time i need it i believe. I had to tinker with it some to understand it functionality. Thanks again.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top