Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to insert a record between 2 records
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 236

PostPosted: Tue Apr 13, 2010 7:53 pm    Post subject: How to insert a record between 2 records
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

Site Director


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

PostPosted: Tue Apr 13, 2010 9:42 pm    Post subject:
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: 236

PostPosted: Tue Apr 13, 2010 10:15 pm    Post subject: Reply to: How to insert a record between 2 records
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 Moderator


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

PostPosted: Tue Apr 13, 2010 10:29 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Tue Apr 13, 2010 10:43 pm    Post subject:
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

Site Director


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

PostPosted: Tue Apr 13, 2010 11:16 pm    Post subject:
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: 236

PostPosted: Wed Apr 14, 2010 4:29 pm    Post subject:
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

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Apr 14, 2010 4:37 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Wed Apr 14, 2010 4:44 pm    Post subject:
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

Site Director


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

PostPosted: Wed Apr 14, 2010 7:33 pm    Post subject:
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: 236

PostPosted: Thu Apr 15, 2010 10:53 am    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 15, 2010 11:25 am    Post subject:
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: 236

PostPosted: Thu Apr 15, 2010 11:47 am    Post subject:
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    Post subject: Reply to: How to insert a record between 2 records
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: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 15, 2010 12:51 pm    Post subject: Re: Reply to: How to insert a record between 2 records
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: 236

PostPosted: Thu Apr 15, 2010 2:56 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Thu Apr 15, 2010 4:55 pm    Post subject:
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: 236

PostPosted: Thu Apr 15, 2010 7:52 pm    Post subject:
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

Site Director


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

PostPosted: Thu Apr 15, 2010 8:33 pm    Post subject:
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us