Ways to merge the parts of different rows in the single row.

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
ashank.agarwal@tcs.com
Member
Posts: 2
Joined: Thu Feb 26, 2015 1:28 pm

Ways to merge the parts of different rows in the single row.

Post by ashank.agarwal@tcs.com » Thu Feb 26, 2015 1:36 pm

Input
====
ABCD sdfsdf klsdfsdf
dfsdfs 12345 dfsdfdf
sdfsdf sdfsdf ******

BDCF dfsdffl dfsdfsdf
sdfsd 67893 dfgdfgd
asdas sdfsd $$$$$

Output
====
ABCD,12345,******
BDCF,67893,$$$$$

Hi All,

I am pretty new to DFsort and been working for just last week. I couldn't find the exact same query, have pasted the required results here.

This is ths sort card, but not giving the desired results


SORT FIELDS=(COPY)
OUTREC FIELDS=(1:5,35,38:30,13,55:35,17)

But i need to use this conditional outrec so that part from different rows is merged into songle row.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Thu Feb 26, 2015 4:13 pm

OUTREC has no special power. It is the same as INREC (assuming DFSORT), but operates after SORT/MERGE. Without SORT/MERGE, use INREC.

FIELDS is old and overloaded. Use BUILD instead. BUILD is a synonym for FIELDS, so operation is 100% identical, but it is not overloaded: when you see BUILD on INREC, OUTREC and OUTFIL it is less confusing than seeing FIELDS, FIELDS and OUTREC, and also seeing FIELDS on SORT/MERGE, REFORMAT, SUM, etc.

Those are tips. They don't affect what you want.

Assuming that you can guarantee groups of three records (or four if that blank is really there), it is WHEN=GROUP that you want.

You'll need to temporarily add a sequence number to the record. When it is exactly divisible by three (or four) , WHEN=GROUP to identify that and PUSH the data you want from the first record at to an extension of the record, with RECORDS=3.

When it is divisible by three (or four) with remainder one, WHEN=GROUP to identify that and PUSH the data you want from the second record to a separate extension.

When it is divisible with remainder two, use BUILD to format the output that you want from the three pieces of data that you have access to at the time: the third record; the data PUSHed from the first record; the data PUSHed from the second record.

Use OUTFIL INCLUDE=/OMIT= to select the third record of each group. If there is a blank record that you need, you can either INCLUDE=/OMIT= that as well, or generate it on a BUILD in OUTFIL using the slash operator (/).

Look for the DFSORT Getting Started manual, it is aimed exactly at people in your situation and has many useful examples. Full details of everything are in the DFSORT Application Programming Guide.

Josdirut
Member
Posts: 2
Joined: Fri Mar 13, 2015 8:41 am
Contact:

Post by Josdirut » Fri Mar 13, 2015 9:03 am

It is very interesting yet to forward the message.

ashank.agarwal@tcs.com
Member
Posts: 2
Joined: Thu Feb 26, 2015 1:28 pm

Post by ashank.agarwal@tcs.com » Mon Mar 23, 2015 12:52 pm

Thanks William for useful insights and suggestions. I was side tracked untill i came across again same task last week.

I got around the situation using the ICETOOL. Again it was first attempt for me in ICETOOL but it's really useful. I used temp seq no. and ID field before creating Output. And the actual data pos i gave in WITH parameters. I needed a CSV output, so added a , after each block while creating outrec.

//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(120,2,ZD) KEEPNODUPS WITHANY -
WITH(68,20) WITH(89,17) USING(CTL1)
/*
//CTL1CNTL DD *
INREC IFOUTLEN=133,
IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(120:ID=2,131:SEQ=1)),
IFTHEN=(WHEN=(131,1,ZD,EQ,2),BUILD=(68:30,20,120:120,2)),
IFTHEN=(WHEN=(131,1,ZD,EQ,3),BUILD=(89:35,17,120:120,2))
OUTFIL FNAMES=OUT,BUILD=(1,87,C',',89,17,C',',107,27)


Thanks,
Ashank

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others