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

Inserting records based on conditions


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

New User


Joined: 10 Jun 2015
Posts: 51
Location: India

PostPosted: Wed Feb 22, 2017 1:33 pm
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: 2455
Location: Hampshire, UK

PostPosted: Wed Feb 22, 2017 2:28 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 22, 2017 2:30 pm
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: 51
Location: India

PostPosted: Wed Feb 22, 2017 2:56 pm
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: 2455
Location: Hampshire, UK

PostPosted: Wed Feb 22, 2017 4:12 pm
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: 2481
Location: @my desk

PostPosted: Wed Feb 22, 2017 9:02 pm
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: 51
Location: India

PostPosted: Wed Feb 22, 2017 10:19 pm
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: 2481
Location: @my desk

PostPosted: Wed Feb 22, 2017 10:21 pm
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: 51
Location: India

PostPosted: Wed Feb 22, 2017 10:51 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Feb 22, 2017 11:49 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top