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

Merging records and calculating TOTALS - SyncSort


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Mon Mar 25, 2013 12:34 pm
Reply with quote

Hi All,

I have divided the requirement into 3 parts. RQ#1, RQ#2 and RQ#3.

This thread is attached with the 2 files named "Input.txt" and "Merge Records - Example.xls".
Input.txt is the actual input in text format, whose columns are of fixed length as shown below.
Merge Records - Example.xls has 4 worksheets namely "Input", "RQ1 Output", "RQ2 Output" and "RQ3 Output".

The input file has some sample records whose structure is as follows: The file is attached in the form of notepad.
Code:
COL1      --   1,20
COL2   --   21,20
COL3   --   168,10
COL4   --   41,10
COL5   --   149,5
COL6   --   111,10
COL7   --   101,10
COL8   --   121,20
COL9   --   141,8
COL10   --   154,8
COL11   --   162,6
COL12   --   51,50


RQ#1: Sort the records in a user specific order for COL1.
Required order of COL1 is ** EVALUATIONE, POPULAR, CONTRIBUTION, TOSS and others if any **


RQ#2: Add COL11 together and concatenate COL12 values if all other COL's (COL1 to COL10) are identical.
While concatenating the trailing spaces for COL12 need to be elimited and COL12 length should be increased from 50 to 200.

RQ#3: Add a new row for every set of COL1, COL2 and COL3 and give a name to the set as 'TOTAL : ' SUM(COL11)
Also add an empty row after every TOTAL. This is for better readability of the report.
The string 'TOTAL' starts at position 110 and the SUM(COUNT) starts from position at 121.

Code'd, attachments deleted
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: Mon Mar 25, 2013 1:00 pm
Reply with quote

Please don't post attachments. Many people are not allowed to download, and most people won't bother.

If you have something to show, use the Code tags and the Preview button, please.
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: Mon Mar 25, 2013 1:19 pm
Reply with quote

What we want is sample input which accurately reflects the possibilities of your data, not all your data. And the expected output for that input, and the output you have received from what you have attempted, and the Control Cards which generated that output.
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Mon Mar 25, 2013 2:16 pm
Reply with quote

Sample Input File:
Code:
CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     MT   N/A       6899                                  20130306000150ALTER
CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     PAN  N/A       4664                                  20130306001265ALTER
CONTRIBUTION        OUTCIRCLE           SENT      ALTER     MT   N/A       6899                                  20130306000150SMS
CONTRIBUTION        OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001265ALTER
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  N/A       4664      TP6                         20130306000010T
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  2430      N/A       TP6                         20130306000061A
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306002074A
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306000478T
EVALUATIONE         OUTCIRCLE           NOT SENT  EVENT     AEN  4664      N/A       TP6                         20130306000022E
EVALUATIONE         OUTCIRCLE           NOT SENT  SCHEDULED AEN  2430      2430      TP6                         20130306000009S
EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664                                  20130306000002A
EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664      TP6                         20130306000461A
EVALUATIONE         OUTCIRCLE           SENT      SCHEDULED AEN  4664      4664      TP6                         20130306000702S
GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130306000173LOGGING EXECUTION STAT
GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130307000005LOGGING EXECUTION STAT
POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130305000006FOCUS
POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130306000015FOCUS
POPULAR             OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001266ALTER
POPULAR             OUTCIRCLE           SENT      FOCUS     PFN  N/A       7826                                  20130306000049FOCUS
POPULAR             OUTCIRCLE           SENT      FOCUS     PFN  N/A       7826                                  20130306000022RWF
TOSS                OUTCIRCLE           I         AUMT           4700                                            20130305084208N/A
TOSS                OUTCIRCLE           I         AUMT           4700                                            20130306012519N/A
TOSS                OUTCIRCLE           N         AUMT           3543      N/A       CH                  0000000020130305999999VSK.QATLAS.MAINT.TOPR.CONS.PUBSUB
TOSS                OUTCIRCLE           N         AUMT           3543      N/A       CH                  9999999920130305999999TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130305019553TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130306003740TP6.RWF.OUT
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130306045274N/A
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130307004418N/A
TOSS                OUTCIRCLE           Y         EVBR      N/A  4664      4664      CH                  TOPRMOBL20130305000012TSS.G9999.TP6.EVENTS.P70Q
TOSS                OUTCIRCLE           Y         EVBR      N/A  4664      4664      CH                  TOPRMOBL20130305000012TSS.G9999.TP6.EVENTS.XFER.P70Q



Output File looks like:

Code:
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  N/A       4664      TP6                         20130306000010T
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  2430      N/A       TP6                         20130306000061A
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306002552A,T
                                          TOTAL  :   2623

EVALUATIONE         OUTCIRCLE           NOT SENT  EVENT     AEN  4664      N/A       TP6                         20130306000022E
EVALUATIONE         OUTCIRCLE           NOT SENT  SCHEDULED AEN  2430      2430      TP6                         20130306000009S
                                          TOTAL  :     31

EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664                                  20130306000002A
EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664      TP6                         20130306000461A
EVALUATIONE         OUTCIRCLE           SENT      SCHEDULED AEN  4664      4664      TP6                         20130306000702S
                                          TOTAL  :   1165

POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130305000006FOCUS
POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130306000015FOCUS
                                          TOTAL  :     21

POPULAR             OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001266ALTER
POPULAR             OUTCIRCLE           SENT      FOCUS     PFN  N/A       7826                                  20130306000071FOCUS,RWF
                                          TOTAL  :   1337

CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     MT   N/A       6899                                  20130306000150ALTER
CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     PAN  N/A       4664                                  20130306001265ALTER
                                          TOTAL  :   1415

CONTRIBUTION        OUTCIRCLE           SENT      ALTER     MT   N/A       6899                                  20130306000150SMS
CONTRIBUTION        OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001265ALTER
                                          TOTAL  :   1415

TOSS                OUTCIRCLE           I         AUMT           4700                                            20130305084208N/A
TOSS                OUTCIRCLE           I         AUMT           4700                                            20130306012519N/A
                                          TOTAL  :  96727

TOSS                OUTCIRCLE           N         AUMT           3543      N/A       CH                  0000000020130305199998VSK.QATLAS.MAINT.TOPR.CONS.PUBSUB,TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130305019553TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130306003740TP6.RWF.OUT
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130306045274N/A
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130307004418N/A
                                          TOTAL  : 272983

TOSS                OUTCIRCLE           Y         EVBR      N/A  4664      4664      CH                  TOPRMOBL20130305000024TSS.G9999.TP6.EVENTS.P70Q,TSS.G9999.TP6.EVENTS.XFER.P70Q
                                          TOTAL  :     24
 
GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130306000173LOGGING EXECUTION STAT
GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130307000005LOGGING EXECUTION STAT
                                          TOTAL  :    178   
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: Mon Mar 25, 2013 3:55 pm
Reply with quote

venkata.ravi,

Just getting the information out of you is becoming a very extended process.

Is that the smallest amount of data which represents your file?

How do you want to supply the "outsorting" values?

What do you mean by "concatenating COL 12", and the other processing for COL 12?

Your third requirement is very simple with OUTFIL reporting, have a look at SECTIONS and TRAILER3.
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Mon Mar 25, 2013 4:42 pm
Reply with quote

Hi Bill,

I'm sorry for the inconvenience caused with the insufficient information. I prepared the excel sheet with the example for each RQ specified above, but you removed them and suggested to provide only the sample input data.

RQ#2: Concatenation of COL12 means,
Let's consider the records from the input file
Code:
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306002074A
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306000478T


These two records looks same all the way from COL1 to COL10, but the COL12 has different values in them. Now, I like to merge those records in the following way.
Code:
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306002552A,T


Note: Values in COL12 'A' and 'T' are concatenated together with ',' as a seperator by removing the trailing spaces. Besides this the COL11 values 2074 and 478 are added and resulted 2552 in the merged record.
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: Mon Mar 25, 2013 4:51 pm
Reply with quote

Well, you can leave everything in spreadsheets and full copies of your file, provide no descriptions of mappings from input to output, and do whatever you actually want. You'll just vastly reduce your chance of any useful replies. Up to you.

In addition to the other unanswered questions, how many records can be consolidated in the way you have described.

What are the RECFM and LRECL of your files? Is your final output for printing?
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Mon Mar 25, 2013 5:16 pm
Reply with quote

RECFM of both the input and output files are FB.
LRECL of Input file is 177
LRECL of Output file is 327.

Quote:
how many records can be consolidated in the way you have described.

Yes, the actul length of COL12 is 50 characters. But, in reality the actual data in that column will be varies from 1 to 25 characters, rest of them are just spaces. So, to accommodate the concatenated values the length of the COL12 in the output file will be increased from 50 to 200.

In my example, I just mentioned only 2 identical records with different COL12 values. But In pracice, there might be more than two records, we need to consolidate/merge them into a single record.
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: Mon Mar 25, 2013 5:33 pm
Reply with quote

So a maximum of four records can be concatenated?
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Mon Mar 25, 2013 5:39 pm
Reply with quote

Ofcourse, Yes.
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Tue Mar 26, 2013 9:42 pm
Reply with quote

Hi Bill,

Can you please provide us sort card for this requirement ?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Mar 26, 2013 11:03 pm
Reply with quote

Quote:
Can you please provide us sort card for this requirement ?

since You are not the topic starter why do You meddle?
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Wed Mar 27, 2013 3:57 am
Reply with quote

Venkata Ravi,

I used DFSORT for your requirement. You can search for equivalent SYNCSORT command to achieve the result using SYNCSORT.


Code:
//STEP0100 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN        DD DSN=<Input Dataset>,DISP=SHR                       
//OUT       DD DSN=<Output Dataset>,                                 
//             DISP=(NEW,CATLG,DELETE),                                 
//             UNIT=SYSDA,                                             
//             SPACE=(CYL,(100,200),RLSE),                             
//             DCB=(LRECL=802,RECFM=FB)                                 
//TOOLIN   DD *                                                         
  SPLICE FROM(IN) TO(OUT) ON(1,121,CH) WITHANY KEEPNODUPS USING(CTL1) -
  WITH(201,200) WITH(401,200) WITH(601,200)                             
//*                                                                     
//CTL1CNTL DD *                                                         
  SORT FIELDS=(1,121,CH,A)                                             
  INREC IFTHEN=(WHEN=INIT,                                             
       OVERLAY=(801:SEQNUM,2,ZD,RESTART=(1,121))),                     
       IFTHEN=(WHEN=(801,2,ZD,EQ,02),                                   
       OVERLAY=(201:1,200)),                                           
       IFTHEN=(WHEN=(801,2,ZD,EQ,03),                                   
       OVERLAY=(401:1,200)),                                           
       IFTHEN=(WHEN=(801,2,ZD,EQ,04),                                   
       OVERLAY=(601:1,200))                                             
  OUTFIL IFTHEN=(WHEN=(201,200,CH,EQ,C' ',AND,                         
                       401,200,CH,EQ,C' ',AND,601,200,CH,EQ,C' '),     
         BUILD=(1:1,200)),                                             
         IFTHEN=(WHEN=(1,200,CH,NE,C' ',AND,                           
                     201,200,CH,NE,C' ',AND,                           
                     401,200,CH,EQ,C' ',AND,                           
                     601,200,CH,EQ,C' '),                               
         BUILD=(1:1,121,                                               
              122:122,6,ZD,ADD,322,6,ZD,EDIT=(TTTTTT),                 
              128:128,50,178:C',',179:328,50,                           
              802:X)),                                                 
         IFTHEN=(WHEN=(1,200,CH,NE,C' ',AND,                           
                     201,200,CH,NE,C' ',AND,                           
                     401,200,CH,NE,C' ',AND,601,200,CH,EQ,C' '),       
         BUILD=(1:1,121,                                               
              122:122,6,ZD,ADD,(322,6,ZD,ADD,522,6,ZD),EDIT=(TTTTTT),   
              128:128,50,178:C',',179:328,50,229:C',',                 
              230:528,50,802:X))                               
/*                                                             
//*                                                           
//STEP020 EXEC PGM=SORT                                       
//SYSPRINT  DD SYSOUT=*                                       
//SYSOUT    DD SYSOUT=*                                       
//SORTIN    DD DSN=<Output Dataset>,                         
//             DISP=SHR                                       
//SORTOUT   DD DSN=<Final Dataset>,                       
//             DISP=(NEW,CATLG,DELETE),                       
//             UNIT=SYSDA,                                     
//             SPACE=(CYL,(100,200),RLSE),                     
//             DCB=(*.SORTIN,LRECL=327,RECFM=FB)               
//SYSIN  DD  *                                                 
 SORT FIELDS=(328,1,ZD,A,1,50,CH,A)                           
 INREC IFTHEN=(WHEN=INIT,                                     
       BUILD=(1:1,127,128:128,200,SQZ=(SHIFT=LEFT),328:C'5')),
       IFTHEN=(WHEN=(1,1,CH,EQ,C'E'),                         
       OVERLAY=(328:C'1')),                                   
       IFTHEN=(WHEN=(1,1,CH,EQ,C'P'),                         
       OVERLAY=(328:C'2')),                                       
       IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),                             
       OVERLAY=(328:C'3')),                                       
       IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),                             
       OVERLAY=(328:C'4'))                                         
 OUTFIL FNAMES=SORTOUT,REMOVECC,                                   
 SECTIONS=(1,50,                                                   
 TRAILER3=(110:C'TOTAL     :',121:TOT=(122,6,ZD,EDIT=(TTTTTTT)),/,
           1:327X))                                               
/*                                       



Output:
Code:

EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  N/A       4664      TP6                         20130306000010T
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  2430      N/A       TP6                         20130306000061A
EVALUATIONE         INCIRCLE            RECEIVED  AUMT      AEN  4664      4664      TP6                         20130306002552A,T
                                                                                                             TOTAL     :0002623

EVALUATIONE         OUTCIRCLE           NOT SENT  EVENT     AEN  4664      N/A       TP6                         20130306000022E
EVALUATIONE         OUTCIRCLE           NOT SENT  SCHEDULED AEN  2430      2430      TP6                         20130306000009S
                                                                                                             TOTAL     :0000031

EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664                                  20130306000002A
EVALUATIONE         OUTCIRCLE           SENT      AUMT      AEN  4664      4664      TP6                         20130306000461A
EVALUATIONE         OUTCIRCLE           SENT      SCHEDULED AEN  4664      4664      TP6                         20130306000702S
                                                                                                             TOTAL     :0001165

POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130305000006FOCUS
POPULAR             INCIRCLE            RECEIVED  FOCUS     PFC  N/A       4664                                  20130306000015FOCUS
                                                                                                             TOTAL     :0000021

POPULAR             OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001266ALTER
POPULAR             OUTCIRCLE           SENT      FOCUS     PFN  N/A       7826                                  20130306000071FOCUS,RWF
                                                                                                             TOTAL     :0001337

CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     MT   N/A       6899                                  20130306000150ALTER
CONTRIBUTION        INCIRCLE            RECEIVED  ALTER     PAN  N/A       4664                                  20130306001265ALTER
                                                                                                             TOTAL     :0001415

CONTRIBUTION        OUTCIRCLE           SENT      ALTER     MT   N/A       6899                                  20130306000150SMS
CONTRIBUTION        OUTCIRCLE           SENT      ALTER     PAN  N/A       4664                                  20130306001265ALTER
                                                                                                             TOTAL     :0001415

TOSS                OUTCIRCLE           I         AUMT           4700                                            20130305084208N/A
TOSS                OUTCIRCLE           I         AUMT           4700                                            20130306012519N/A
                                                                                                             TOTAL     :0096727

TOSS                OUTCIRCLE           N         AUMT           3543      N/A       CH                  0000000020130305999999VSK.QATLAS.MAINT.TOPR.CONS.PUBSUB
TOSS                OUTCIRCLE           N         AUMT           3543      N/A       CH                  9999999920130305999999TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130305019553TP6.RWF.OUT
TOSS                OUTCIRCLE           N         AUST           3543      N/A       CH                  9999999920130306003740TP6.RWF.OUT
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130306045274N/A
TOSS                OUTCIRCLE           N         EVBR           2430      2430      CH                          20130307004418N/A
                                                                                                             TOTAL     :2072983

TOSS                OUTCIRCLE           Y         EVBR      N/A  4664      4664      CH                  TOPRMOBL20130305000024TSS.G9999.TP6.EVENTS.P70Q,TSS.G9999.TP6.EVENTS.XFER.P70Q
                                                                                                             TOTAL     :0000024

GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130306000173LOGGINGEXECUTIONSTAT
GENERIC LOG MSGSERV OUTCIRCLE                     CEBODLWR                 N/A                           CEBODLWR20130307000005LOGGINGEXECUTIONSTAT
                                                                                                             TOTAL     :0000178


Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 27, 2013 5:00 am
Reply with quote

saiprasadh wrote:
Venkata Ravi,

I used DFSORT for your requirement. You can search for equivalent SYNCSORT command to achieve the result using SYNCSORT.


Saiprasadh,

I really appreciate your enthusiasm to help but you need to understand DFSORT a little bit more to post solutions on behalf of DFSORT.

INREC is processed even before SORT happens, so your Job will NOT work if the data is NOT sorted. You already have the data sorted on the key (1 thru 127) and hence your job worked even though you are using INREC to number the duplicates. Jumble up the data and see how the job fails.

The order of DFSORT processing is explained here

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA60/1.5.4

And for the record the above solution can be achieved easily without splice and another pass of data.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Wed Mar 27, 2013 6:31 am
Reply with quote

Skolusu,

Thanks for pointing out my mistake.
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 Mar 27, 2013 6:42 pm
Reply with quote

Well, there's still no answer to the "outsorting" for the first part of the requirement.

If you look at OUTFIL SECTIONS that should be able to give you the summed value of COL 11 (you'll need NODETAIL). You can have multiple "breaks", so you can do your COL1-3 total as well (it should come first).

The "consolidation" you can do with WHEN=GROUP, and a sequence number. Then a GROUP for for different sequence numbers to put the data into extended areas of the record, then what Sai has provided to "squeeze" the results appropriately.

Here is an example of using the GROUP to consolidate data. There are others. Search for GROUP and RECORDS, for instance.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Mar 27, 2013 8:32 pm
Reply with quote

Hi Venkat,

Try this...

Code:

//STEP01 EXEC PGM=SORT                         
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD DISP=(NEW,PASS),SPACE=(CYL,1),DSN=&&OUT1                 
//SORTIN   DD DISP=SHR,DSN=<<input file>>                       
//SYSIN   DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(190:SEQNUM,2,ZD,RESTART=(1,122))),   
        IFTHEN=(WHEN=(1,1,CH,EQ,C'E'),                                 
               OVERLAY=(178:C'1')),                                     
               IFTHEN=(WHEN=(1,1,CH,EQ,C'P'),                           
               OVERLAY=(178:C'2')),                                     
               IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),                           
               OVERLAY=(178:C'3')),                                     
               IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),                           
               OVERLAY=(178:C'4')),                                     
               IFTHEN=(WHEN=(1,1,CH,EQ,C'G'),                           
               OVERLAY=(178:C'5'))                                     
  SORT FIELDS=(178,1,A,01,20,A,21,20,A,41,10,A,51,10,A,61,5,A,         
          66,10,A,76,10,A,86,20,A,106,8,A,114,8,A,190,2,D),FORMAT=CH   
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(190,2,ZD,EQ,+2),PUSH=(200:128,30),   
                 END=(190,2,ZD,EQ,+1))                                 
//*                                                                     
//STEP02 EXEC PGM=SORT                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SORTOUT  DD DISP=(NEW,PASS),SPACE=(CYL,1),DSN=&&OUT2                 
//SORTIN   DD DISP=SHR,DSN=&&OUT1                                       
//SYSIN   DD *                                                         
  SORT FIELDS=(178,1,A,01,20,A,21,20,A,41,10,A,51,10,A,61,5,A,         
          66,10,A,76,10,A,86,20,A,106,8,A,114,8,A,190,2,A),FORMAT=CH   
  OUTREC OVERLAY=(190:2X,231:97X)
//*                                                                     
//STEP03 EXEC PGM=SORT                                                 
//SYSPRINT DD SYSOUT=*                                                 
//SYSOUT   DD SYSOUT=*                                                 
//SORTOUT  DD SYSOUT=*                                                 
//SORTIN   DD DISP=SHR,DSN=&&OUT2                                       
//SYSIN   DD *                                                         
  SORT FIELDS=(178,1,A,01,20,A,21,20,A,41,10,A,51,10,A,61,5,A,         
             66,10,A,76,10,A,86,20,A,106,8,A,114,8,A),FORMAT=CH         
  SUM FIELDS=(122,6,ZD)                                                 
  OUTREC IFTHEN=(WHEN=(200,1,CH,NE,C' '),                               
                 BUILD=(1,154,C',',200,30,97X)),                       
         IFTHEN=(WHEN=(178,1,CH,NE,C' '),                               
               OVERLAY=(178:1X))                                       
  OUTFIL REMOVECC,SECTIONS=(1,50,TRAILER3=(44:C'TOTAL     :',           
                    57:TOT=(122,6,ZD,EDIT=(IIIIT)),/,327X)),           
         FINDREP=(IN=C' ',OUT=C'',STARTPOS=129)


Thanks
-3nadh
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Mar 27, 2013 10:33 pm
Reply with quote

bodatrinadh,

Did you get a chance to read about what I wrote about INREC processing before SORT and numbering the duplicate records?

www.ibmmainframes.com/viewtopic.php?p=309767#309767
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Thu Mar 28, 2013 10:23 am
Reply with quote

Hi Skolusu,

I saw the comments which you replied to saiprasad...

But the input given by TS is a sorted one..And i assumed the same.

Yes, You are right. If the data is jumbled, my sort code won't work. It needs little modification.



Thanks
-3nadh
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Thu Mar 28, 2013 11:10 am
Reply with quote

Hi saiprasadh and SKolusu,
Thanks for inputs using DFSORT. But I have only SYNCSORT at my site.

Please provide me sort card using SYNCSORT.

It would be even helpful, if I can get the syncsort manuals. I referred their website syncsort.com as well, But couldn't get any doc.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Thu Mar 28, 2013 11:25 am
Reply with quote

Venkat,

I think you didn't check my code...
It is a syncsort solution and It is tested on SYNCSORT 1.4.0.1R

Thanks
-3nadh
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: Thu Mar 28, 2013 1:27 pm
Reply with quote

venkata.ravi,

Did you just get tired of me asking questions, so decided to ignore any more? If so, you'd best go with -3nadh's three-step solution (I assume you don't feel inclined to work on Sai's solution either). If your data is not in the order required, you could always add another SORT step.

The requirement for the outsorting may dictate the solution for whole thing (do you want it "dynamic", or does it only change rarely so can be done by code updates?). If you are still not keen to answer that, then it makes no nevermind to me.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Mar 28, 2013 3:03 pm
Reply with quote

How about asking around your place of work for the manuals? If your place is licensed then it has manuals. They can probably order more as well if the manuals are 'lost'.
Back to top
View user's profile Send private message
venkata.ravi

New User


Joined: 09 May 2005
Posts: 30
Location: Hyderabad

PostPosted: Thu Mar 28, 2013 3:04 pm
Reply with quote

Hi trinadh,
Your code is fantastic. The resultant file format looks good to me except 2 minor changes.
1. While concatenating COL12 values, we are totaling COL11 values. Here, there is a possibility for the COL11 gets overflow and the actul value gets truncated. I would like to increase COL11 from 6 digits to 7 digits.
Ex:

Input
Code:
COL11 COL12
-----------
999991 ABC
023123 DEF


Output
Code:
COL11 COL12
-----------
023114 ABC, DEF      <<-- Here the value gets truncated


2. COL12 values are getting concatenated even though they are identical. In this case only COL11 values should be added together and to leave COL12 as it is.
Ex:

Input
Code:
COL11 COL12
-----------
001201 ABC
023123 ABC

024567 DEF
000023 DEF
000013 PQR

Output
Code:
COL11 COL12
-----------
024324 ABC

024603 DEF,PQR      <<--  DEF should not repeat here


Hi Bill,
I am not tired with your questions.
The outsorting order is fixed. Trinadh has covered it in the first step. It's fine. As Sai's solution is based on DFSORT, I couldn't test it with my inputs.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 29, 2013 12:00 am
Reply with quote

bodatrinadh wrote:
Hi Skolusu,

I saw the comments which you replied to saiprasad...

But the input given by TS is a sorted one..And i assumed the same.

Yes, You are right. If the data is jumbled, my sort code won't work. It needs little modification.


bodatrinadh,

Apart from the SORTED vs UNSORTED output, there is one more issue with the job. As OP wanted the sort sequence to be "Required order of COL1 is ** EVALUATIONE, POPULAR, CONTRIBUTION, TOSS and others if any ** " You are only considering the first byte to determine the Sequence, if COL1 has the following data
Code:

E
EA
EB
EC
P1
P2
P3
....


You will have incorrect results. You need to validate all the 20 bytes and add the sorting indicator.

You are only considering E, P, C, T, G as the only valid alphabets that would get the sorting sequence. If you have data other than those values byte 178 would be a space and they would get sorted First before numbers 1,2,3,4,5

Your shop may have OPTION EQUALS as default, and you are getting the results in the right order you have , however if NOEQUALS is the default, then your test results will be unpredictable.
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 -> SYNCSORT Goto page 1, 2  Next

 


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 Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top