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
 

 

Inserting records based on conditions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Wed Feb 22, 2017 1:33 pm    Post subject: Inserting records based on conditions
Reply with quote

Hi All

My input data set 1 example
Code:
AAA
BBB
CCC
DDD


Input data set 2
Code:
1234
4567
7890
&&&££££
Xxxxxxxx


Output data set should be
Code:
AAA
1234
4567
7890
BBB
&&&££££
CCC
Xxxxxxxx
DDD


Basically after a occurrence of input dat set 1 I want to add records of input data set 2.
It will be a great help if you can give some hint to achieve this.

Sorry I am unable to use code tags here.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1788
Location: UK

PostPosted: Wed Feb 22, 2017 2:28 pm    Post subject:
Reply with quote

You can easily use the code tags - either hand-craft them or use the full editor and the facilities that it provides.

I do not understand the logic - after the first record from data set 1 you add 3 record from data set 2, after the second record from data set 1 you have indicated oe record from data set 2 and ditto for the third record. Why 3 - 1- 1? What rules?

I will code your original post for you.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Feb 22, 2017 2:30 pm    Post subject: Reply to: Inserting records based on conditions
Reply with quote

Why would you be unable to use the code tags?

There has to be some condition under which you'd know what records go where. I can't discern the condition from the data sample, other an "numbers only" after A, "not letters or numbers" after B and "letters only" after C.

Even if that is what you want, is your data "regular" within that (no other mixtures possible) and is your data "in order" within that?

Or some completely different conditions?
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Wed Feb 22, 2017 2:56 pm    Post subject:
Reply with quote

Thanks for the reply!!!

My requirement is to add records first 10 from data set 2 once it finds AAA in data set 1.Then add next 10 record a from data set 2 once it finds BBB in data set 2.


So out will like
Code:

AAA
1st 10 record of data set 2
BBB
Next 10 record of data set 2


For sake of simplicity I have given the above data in post1 but unfortunately I ended up in confusing you.
Hope I am clear now
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1788
Location: UK

PostPosted: Wed Feb 22, 2017 4:12 pm    Post subject:
Reply with quote

I have corrected your code tags - end tags are denoted by a '/' between the '[' and the 'code'. Using the full editor buttons this will be done automatically for you. Use the 'Preview' button to check your post before submitting it. I have also changed your 'file' to 'data set' as you are dealing with data sets on the mainframe - not files.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2276
Location: @my desk

PostPosted: Wed Feb 22, 2017 9:02 pm    Post subject:
Reply with quote

vickey_dw wrote:
Hope I am clear now
There are more questions.

How many such records ('AAA', 'BBB'....) do you have in data set-1? Is that a fixed number?. Can the values change during each run?
What about the attributes (RECFM,LRECL..) for data set-1 and data set-2?
Does anything exist in your actual data that helps identify the first record of either input data set?
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Wed Feb 22, 2017 10:19 pm    Post subject:
Reply with quote

only two AAA and BBB records are there in the dataset 1.
Dataset two has 20 records out of which first 10 i need to copy after AAA and next 10 after BBB.
These values wont change in run time also.

Dataset1,Dataset 2 and outfile all have LRECL 80 and RECFM is FB
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2276
Location: @my desk

PostPosted: Wed Feb 22, 2017 10:21 pm    Post subject:
Reply with quote

Thanks. Can you try answering the questions you skipped?
Back to top
View user's profile Send private message
vickey_dw

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Wed Feb 22, 2017 10:51 pm    Post subject:
Reply with quote

I think i missed below question

Quote:
Does anything exist in your actual data that helps identify the first record of either input data set?


Dataset 1 can be identified with first record as AAA
Dataset 2 can have anything not sure how to identify here as it can have any random value.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Feb 22, 2017 11:49 pm    Post subject: Reply to: Inserting records based on conditions
Reply with quote

JOINKEYS.

Use JNF1CNTL, INREC, WHEN=INIT to assign a sequence number to each (of the two) record.

Use JNF2CNTL, INREC, WHEN=GROUP, RECORDS=10 to assign ID for each group.

The key is the sequence and ID.

SORTED,NOSEQCK

REFORMAT contains all original data for F1 and F2.

In the main task, INREC, WHEN=GROUP, RECORDS=10, append a SEQ.

OUTFIL, IFTHEN=(WHEN=(logical expression to test for one in the SEQ-field appended, BUILD with the slash-operator (/) to output two records (from the F1 and the F2 parts of the REFORMAT record). WHEN=NONE to just BUILD from from the F2 part of the REFORMAT record.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


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