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

How to insert a record between 2 records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Tue Apr 13, 2010 7:53 pm
Reply with quote

I have a file with 3 records. I want to insert a record between 1st record and second record say for example,

00001A1234
00003D1234
00004E1234

I want to insert a record 00002B1234 between 00001A1234 & 00003D1234.

Thanks,
Murali.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 13, 2010 9:42 pm
Reply with quote

Hello,

With that kind of a question, you should not expect anything useful. . . icon_neutral.gif

You need to provide something for people to work with. . .

Quote:
I want to insert a record 00002B1234 between 00001A1234 & 00003D1234.
All i can suggest is "go for it".
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Tue Apr 13, 2010 10:15 pm
Reply with quote

Dick,

I can do that in COBOL, but which utility in JCL will help me to do the job? please suggest.
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: Tue Apr 13, 2010 10:29 pm
Reply with quote

Quote:
I can do that in COBOL


You can do WHAT in COBOL. You haven't explained what you want to do clearly. Do you want to insert a new record after the record that has 00001A1234 starting in position 1, or do you want to insert a new record before the record that has 00003D1234 starting position 1, or do you want to insert a record between two records only if the two records have 00001A1234 and 00003D1234, or do you want to insert a record after the first record regardless of what's in the first record, or ?

You have to clearly explain the rules for what you want to do before anyone can help you. We don't know WHAT you did in COBOL so that doesn't help us.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Apr 13, 2010 10:43 pm
Reply with quote

Probably use a method similar to how you would do it with COBOL.
What sort?
Is there a sequence in the larger input?
Is the sixth character of the larger input always ascending and missing the sixth character of the one record?
Is it always (or only) one record between the first and second?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Apr 13, 2010 11:16 pm
Reply with quote

Hello,

Quote:
I can do that in COBOL
Only because you know what you "have" and what you "want" . . . We have no way to know.

We have some very good cobol, assembler, easytrieve, etc developers who contribute to the forum and from the information posted, none could "do that".

Quote:
I want to insert a record 00002B1234
Where did this "record" come from? Is it in another file? Is it entered from some user's screen/panel? Is it some hard-coded value?
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Wed Apr 14, 2010 4:29 pm
Reply with quote

Hi Dick,

I am having two PS files, file-1 having many recrods out of that i have to extract 00002B1234 from 1st position and i have to insert the record in the file-2 in position 1 after 00001A1234 and before 00003D1234. This i have to acheive through JCL. Hope i have explained clearly.

How to acheive this through JCL>
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Apr 14, 2010 4:37 pm
Reply with quote

You could start by using your sort product to extract the 0002b1234 record from file-1 to a workfile. what you do next depends on the typeoffile file-2is - is VSAM, you could REPRO the record into file-2 from workfileor, if PS, you could use SORT to do what you want.

Garry.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Apr 14, 2010 4:44 pm
Reply with quote

No, unfortunately you have not explained clearly. You say you want to do this with JCL.

Once more let us clarify exactly what JCL is.
it is Job Control Language.

By itself it does nothing. It is used to invoke the chosen program and to define which datasets are to be used by the DD names associated with the chosen program.

JCL does not have magical powers that solve all problems, JCL is merely the vehicule for telling the processor which program you want it to execute.

You need to tell us which program / utility that you wish to use. You also need to provide a whole lot more information than you already have.

If you want to use a sort product solution, the first thing is to determine your sort product and its release level by running a simple sort step shown below, you will be able to find out.

If the messages start with ICE then your product is DFSORT and the topic will be moved to that forum by a moderator. Please also post the output of the complete line which has a message code ICE201I, as this will enable our DFSORT experts to determine which release of DFSORT that you have installed. This may also affect the solution offered.

If the messages start with WER or SYT then the product is SYNCSORT and the topic will remain in the JCL forum. Please also post the information telling which version of SYNCSORT is installed, as this may also affect the solution offered.

Code:
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  SORT     FIELDS=COPY


And the standard questions are .........................
DSORG, RECFM and LRECL of both files.
The position, length and format of the key field that you wish to take from file 1

Please supply ALL of the above information if you would like a quicker solution.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 14, 2010 7:33 pm
Reply with quote

Hello,

Quote:
file-1 having many recrods out of that i have to extract 00002B1234 from 1st position
You still have not explained where the 00002B1234 value originates. . .

You have also not provided the other requested details needed for someone to help.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 10:53 am
Reply with quote

File-1

DSORG=PS, RECFM=FB and LRECL=80

record starting position 1 length 10

Record to be fetched from file-1 is 00002B1234


File-2

DSORG=PS, RECFM=FB and LRECL=80

To be inserted in
record starting position 1 length 10

in between record 00001A1234 & 00003D1234.

Utility to be used is SORT.

I know that JCL needs program to execute. Forgot to mention the utility is SORT. Please provide the solution.

[/u]
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Apr 15, 2010 11:25 am
Reply with quote

Please read my post again, and supply the requested details of the sort product and release level.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 11:47 am
Reply with quote

This is the message i got from the sysout

Code:

********************************* TOP OF DATA ***************************
 SYNCSORT FOR Z/OS  1.3.2.1R    U.S. PATENTS: 4210961, 5117495   (C) 2007
                                               AETNA INC   z/OS   1.11.0
 SYNCSORT LICENSED FOR CPU SERIAL NUMBER 29A41, MODEL 2097 752           
 PARMTBLE : BMSG,CORE=MAX                                               
 SYSIN :                                                                 
Back to top
View user's profile Send private message
khannay2k

New User


Joined: 24 Feb 2005
Posts: 28
Location: Bangalore

PostPosted: Thu Apr 15, 2010 12:03 pm
Reply with quote

Try this.

Code:
//SORT    EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=INPUT1,DISP=SHR

//              DD DSN=INPUT2,DISP=SHR

//SORTOUT  DD DSN=OUTPUT,DISP=(,CATLG,DELETE),   
//            SPACE=(27920,(10,1),RLSE),UNIT=SYSDA,       
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920)       

//SYSIN   DD  *                                           
     SORT FIELDS=(1,10,BI,A)                             
//*
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Apr 15, 2010 12:51 pm
Reply with quote

khannay2k wrote:
Try this.

Yeah, you might as well, because khannay2k certainly has not.

All this code does is to put WHOLE of file 1 with file2. This is NOT the requirement. Please read carefully what is required before posting erroneous solutions.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 2:56 pm
Reply with quote

If SORT doesn't help, will ICETOOL/FILEAID will do the job?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 4:55 pm
Reply with quote

pkmurali wrote:
File-1
DSORG=PS, RECFM=FB and LRECL=80
record starting position 1 length 10
Record to be fetched from file-1 is 00002B1234

File-2
DSORG=PS, RECFM=FB and LRECL=80
To be inserted in
record starting position 1 length 10
in between record 00001A1234 & 00003D1234.

Utility to be used is SORT.

I know that JCL needs program to execute. Forgot to mention the utility is SORT. Please provide the solution.
Is the record in file-1 defined by its position (first record) in the file or by its key value (00002B1234)?
Are the two records in file-2 defined by their position (the first and second record) or by their key values (00001A1234 & 00003D1234)?
You must choose one or the other.
1) The first record in file-1 inserted between the first and second record in file-2.
2) The record with the value 00002B1234 in file-1 inserted between the two records with the values 00001A1234 & 00003D1234 in file-2.
Pick one or the other and more specific questions will follow.
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 7:52 pm
Reply with quote

00001A1234
00003D1234
are values in file-2

00002B1234

is value in file-1

Quote:

You must choose one or the other.
1) The first record in file-1 inserted between the first and second record in file-2.
2) The record with the value 00002B1234 in file-1 inserted between the two records with the values 00001A1234 & 00003D1234 in file-2.


Option 2 is my requirement.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 15, 2010 8:33 pm
Reply with quote

Hello,

If the record to be "inserted" is the only record in file1, use the posted suggestion from khannay2k .
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Thu Apr 15, 2010 9:05 pm
Reply with quote

If your File-1 file and File-2 file -- both -- have many records and
you only want one record 00002B1234 from File-1, YOU CANNOT DO IT WITH --JCL--. What you CAN DO is create 2 steps BOTH using the SORT utility.

1. First step: Use the SORT utility and the command INCLUDE -- (you have to refer to the Sort manual) the record with the value '00002B1234' creating YOUR FIRST WORK FILE containing ONE RECORD.

2. Second step: NOW you can use the solution that khannay2k
gave you --simply sorting 2 files together
the SORT FIELDS=(1,10,BI,A) will place your record in its proper sequence
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 9:05 pm
Reply with quote

Since the values are sequential sort will do the job, but if the value is not 00002B1234 say 223411B1234 instead of 00002B1234 how to utilize the sort utility, in such case it fails my requirement.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 9:13 pm
Reply with quote

pkmurali wrote:
Since the values are sequential sort will do the job, but if the value is not 00002B1234 say 223411B1234 instead of 00002B1234 how to utilize the sort utility, in such case it fails my requirement.
So you are saying that option 2 is not what you want?
Quote:
You must choose one or the other.
1) The first record in file-1 inserted between the first and second record in file-2.
2) The record with the value 00002B1234 in file-1 inserted between the two records with the values 00001A1234 & 00003D1234 in file-2.

How about The first record in file-1 inserted between the two records with the values 00001A1234 & 00003D1234 in file-2?
Or how about option 1?
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 271

PostPosted: Thu Apr 15, 2010 9:23 pm
Reply with quote

I need option2 with this value 223411B1234 from file-1 to be inserted in file-2 between 00001A1234 & 00003D1234.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 9:34 pm
Reply with quote

pkmurali wrote:
I need option2 with this value 223411B1234 from file-1 to be inserted in file-2 between 00001A1234 & 00003D1234.
As asked before, does file-1 contain only the one record, whatever the value?
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Thu Apr 15, 2010 9:57 pm
Reply with quote

Based on the information provided so far, try this SyncSort for z/OS job and let us know whether or not it provides the desired output:
Code:
//STEP1 EXEC PGM=SORT                                           
//SYSOUT  DD SYSOUT=*                                           
//SORTIN  DD DSN=FILE1,DISP=SHR                                                 
//SORTOUT DD DSN=&&TEMP1,DISP=(NEW,PASS)
//SYSIN   DD *                                                 
   INCLUDE COND=(1,11,CH,EQ,C'223411B1234')                     
   SORT FIELDS=COPY                                             
/*                                                                         
//STEP2 EXEC PGM=SORT                                           
//SYSOUT  DD SYSOUT=*                                           
//SORTIN  DD DSN=&&TEMP1,DISP=(OLD,PASS)                         
//        DD DSN=FILE2,DISP=SHR                                                 
//SORTOUT DD SYSOUT=*                                           
//SYSIN   DD *                                       
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
         IFTHEN=(WHEN=(1,11,CH,EQ,C'223411B1234'),   
         OVERLAY=(81:C'00000003'))                         
   SORT FIELDS=(81,8,CH,A),EQUALS                   
   OUTREC BUILD=(1,80)                               
/*   
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 -> JCL & VSAM

 


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 Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top