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

merging two differenet rows


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

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Tue Mar 12, 2013 2:47 am
Reply with quote

Hi ,
I have two rows in a file RL 80 bytes fixed

Code:
1st row -  a b c d e f g h i j   k l m n o p q...
2nd row -       3   5          x      x

Out put should look like
Code:
a b 3 d 5 f g h i x k x m n o p q....


Basicaly what i am trying to do is replace certain positions in record one with values from record 2.

I think SPLICE has an opion to append at the end and create a single record, but i need to replace the values in middle.

Please let me know if my ask is not clear.

Code'd
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Mar 12, 2013 3:42 am
Reply with quote

Hi,

it's certainly not clear to me.

I assume you mean you have 2 records in a file.

You haven't explained which bytes are to be replaced in record 1 by which bytes in record 2.

This will get you started

Code:
//* COMBINE 2 80 BYTE RECORDS INTO SINGLE 160 BYTE RECORD             
//S1       EXEC  PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=...  INPUT FILE (FB/80)                             
//OUT      DD DSN=...  OUTPUT FILE (FB/160)                           
//TOOLIN DD *                                                         
RESIZE FROM(IN) TO(OUT) TOLEN(160)                                   
/*                                                                   


All you now need to do is re-BUILD your OUTREC record.


Gerry
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: Tue Mar 12, 2013 6:22 am
Reply with quote

When posting you must use the Code tags and the Preview button so that you can present your data in the best way.

"Guessing" from what you have provided, I think something like this:

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(41:SEQNUM,1,ZD)),
        IFTHEN=(WHEN=GROUP,BEGIN=(41,1,CH,EQ,C'2'),
                 RECORDS=1,
                 PUSH=(42:1,40)),
        IFTHEN=(WHEN=GROUP,BEGIN=(41,1,CH,EQ,C'1'),
                 RECORDS=2,
                 PUSH=(1:1,40)),
        IFTHEN=(WHEN=(41,1,CH,EQ,C'2'),
                 OVERLAY=(5:46,1,9:50,1,21:62,1,25:66,1))
        OUTFIL INCLUDE=(41,1,CH,EQ,C'2'),BUILD=(1,40)
//SORTIN   DD *
A B C D E F G H I J   K L M N O P Q...
    3   5           X   X


Which produces this:

Code:

A B 3 D 5 F G H I J X K X M N O P Q...


It will be important for you to understand the Control Cards, so I have made the understanding "easier" by using 40-byte records.

Start by commenting-out the OUTFIL, you'll see this:

Code:
A B C D E F G H I J   K L M N O P Q...  1                         
A B 3 D 5 F G H I J X K X M N O P Q...  2    3   5           X   X


The "1" as the last non-blank on the first record is the sequence number added in the WHEN=INIT. Each record will receive a sequence number, you can see the "2" in the same position on the second record.

The first WHEN=GROUP operates on the 2nd record, and only that record. It's purpose is to take the data from the 2nd record, and copy it starting at position 42. Reason being, we're just about to overwrite it.

The second WHEN=GROUP operates on both records, triggered by identifying the first record. It puts the data from 1 for a length of 40, to column 1: in the record. For the first record, this simply copies the data over itself. The important part is the second record, where the data from the first record is put at column 1:, overwriting the original content (which is why we first saved it at position 42).

The second record thus contains all the data, separated by the sequence number "2".

The final IFTHEN identifies the second record by the sequence number, and OVERLAYs the required data belonging to the second record to the required positions in the data from the first record.

The purpose of the OUTFIL is to only include the second record (the first being now redundant) and to cut the record down to the correct size with the required data, using BUILD (in this example a length of 40).

Experiment by continuing to leave the OUTFIL commented, and removing first one, then the other, of the WHEN=GROUPs, so you get the idea of how it is working and why it has to be like that.

Then, and only then, "correct" the code for 80-byte records (just add 40 to everything, pretty-much) and test, and hand it over to the next stage of your development.

What you learn from the process will help you develop your own solutions and understand other solutions which you may be able to apply to your future requirements.

Read-up on the functions used in the DFSORT manuals. Experiment. Read again, and repeat until you understand. If still unclear, ask, someone will be here to answer.
Back to top
View user's profile Send private message
cvishu

Active User


Joined: 31 Jul 2007
Posts: 136
Location: india

PostPosted: Tue Mar 12, 2013 7:08 am
Reply with quote

Thank you both for your resposne. Bill thanks for the detailed explanation , i will try to execute it and let you know .
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 To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts How to compare two rows of same table DB2 11
Search our Forums:

Back to Top