Insert all records from a file before a line in another file



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Insert all records from a file before a line in another file

Postby rookie1 » Fri Jul 19, 2013 5:48 pm

I've two flat files similar similar in properties say file A and file B

File A

12345 6789
78787 6789
AAAAA

File B

77777777777777777777777777
88888888888888888888888888

I want to insert all records from File B to file A when you find character 'A' in coulmn number 1 of file A (before the record AAAA ) and get it in a new file


Output :
12345 6789
78787 6789
77777777777777777777777777
88888888888888888888888888
AAAAA


Inserting before record AAAA is a bit tricky.Is it possible
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Insert all records from a file before a line in another file

 

Re: Insert all records from a file before a line in another

Postby BillyBoyo » Fri Jul 19, 2013 6:48 pm

Yes, it is possible. A JOINKEYS should do it. What is the RECFM/LRECL of your input files and output file?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Insert all records from a file before a line in another

Postby rookie1 » Fri Jul 19, 2013 6:54 pm

RECFM=FB, LRECL = 80
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Insert all records from a file before a line in another

Postby rookie1 » Sat Jul 20, 2013 12:31 pm

Hi Billy or anybody

Can you let me know if this is feasible..
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Insert all records from a file before a line in another

Postby BillyBoyo » Sun Jul 21, 2013 12:02 am

I'd already indicated that it was feasible. When and whether I or anyone else provides code for it is up to us and our available time.

Now you should study this, and explain back to us how it works. If you have difficulties, say what you have done and what problem you have, and someone will assist. When they have time available.


//INSERT EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
  JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
  JOIN UNPAIRED,F1,F2,ONLY
  REFORMAT FIELDS=(F1:1,80,?,F2:1,80)
                                                 
  INREC IFTHEN=(WHEN=(81,1,CH,EQ,C'1'),
                    BUILD=(1,80)),
               IFTHEN=(WHEN=NONE,
                    BUILD=(82,80))
                                                 
//INA      DD *
1
2
3
A
8
9
//INB      DD *
4
5
6
7
//JNF1CNTL DD *
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),
                PUSH=(81:ID=1))
//JNF2CNTL DD *
 INREC OVERLAY=(81:C'0')


1
2
3
4
5
6
7
A
8
9
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Insert all records from a file before a line in another

Postby rookie1 » Mon Jul 29, 2013 1:10 pm

Thanks for your response!

But I'm using SYNCSORT and it doesn't recognise '?' operator.

I'll post the question in SYNCSORT forum and see if it's feasible.

Thanks again for your time and response!
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Insert all records from a file before a line in another

Postby NicC » Mon Jul 29, 2013 2:24 pm

A pity you did not specify your sort product before so that people would not spend time giving a solution that is wrong for you.

Your new topic has been deleted and the original moved.
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: Insert all records from a file before a line in another

Postby rookie1 » Mon Jul 29, 2013 9:18 pm

yeah thats my mistake..but eager to learn if this can be done by syncsort..

thank you..
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Insert all records from a file before a line in another

Postby BillyBoyo » Mon Jul 29, 2013 10:02 pm

Have a look at examples here using FILL= on the REFORMAT statement. Since you seem to have text everywhere, use FILL=X'FF' or X'00'. Then you can test the, in the RFORMAT record, the first byte of data from F1 and the first byte of data from F2. Takes the place of the ? in DFSORT.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Insert all records from a file before a line in another

Postby rookie1 » Mon Jul 29, 2013 10:37 pm

The contents of file B are dynamic. I only know before which particular record from file A, all dynamic records from file B has to be inserted.


Thank you.
rookie1
 
Posts: 7
Joined: Fri Jul 19, 2013 5:37 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post