Page 1 of 1

Generating dynamic sort card

PostPosted: Mon Oct 19, 2015 12:31 pm
by Papya01234
Hi,

I am creating a dynamic sort which also needs to remove the duplicates.


OUTFIL REMOVECC,                                                   
  HEADER1=('  SORT FIELDS=COPY ',/,                                 
    '  INCLUDE COND=((1,1,BI,NE,1,1,BI),OR,'),                     
  BUILD=(C'   (4,4,PD,EQ,',1,7,C',AND,244,1,CH,EQ,C''',8,1,C'''),OR,
               ',80:X),                                             
  TRAILER1=('    (1,1,BI,NE,1,1,BI))',                             
                  SUM FIELDS=NONE)       


However I tried to check without SUM FIELDS=NONE and its working.

Please suggest me where I am doing wrong.

Regards,
Balu

Re: Need help in generating dynamic sort card

PostPosted: Mon Oct 19, 2015 2:26 pm
by BillyBoyo
To use SUM, you need to use SORT or MERGE, not COPY. If your data is in sequence, your can use MERGE with a single input (SORTIN01).

As an alternative, you can use the OUTFIL reporting functions, with REMOVECC, NODETAIL, SECTIONS and HEADER3.

Re: Need help in generating dynamic sort card

PostPosted: Mon Oct 19, 2015 2:39 pm
by Papya01234
Sorry for the incomplete information mentioned in my previous question.

I am creating a dynamic sort which fetches the data from a PS file

I have a file of 80 byte length from which the data is being picked for creating the dynamic sort.
This is the SYSIN I have used:

//SYSIN DD *                                                           
  OPTION COPY                                                           
  OUTFIL REMOVECC,                                                     
    HEADER1=('  SORT FIELDS=(4,4,PD,A) ',/,                                   
      '  INCLUDE COND=((1,1,BI,NE,1,1,BI),OR,'),                       
    BUILD=(C'   (4,4,PD,EQ,',1,7,C',AND,244,1,CH,EQ,C''',8,1,C'''),OR, *
                 ',80:X),                                               
    TRAILER1=('    (1,1,BI,NE,1,1,BI))')                               
/*                                                         


This is the output that I have got.

SORT FIELDS=(4,4,PD,A)                             
INCLUDE COND=((1,1,BI,NE,1,1,BI),OR,         
 (4,4,PD,EQ,1234563,AND,244,1,CH,EQ,C'P'),OR,
 (4,4,PD,EQ,1234563,AND,244,1,CH,EQ,C'P'),OR,
 (4,4,PD,EQ,1239261,AND,244,1,CH,EQ,C'P'),OR,
 (4,4,PD,EQ,AJU5672,AND,244,1,CH,EQ,C'3'),OR,
  (1,1,BI,NE,1,1,BI)) 


Now since this SYSIN might result in duplicates I want to put one more condition as
SUM FIELDS = NONE

Can you please let me know where I can add this condition.

Regards,
Balesh GG

Re: Generating dynamic sort card

PostPosted: Mon Oct 19, 2015 3:00 pm
by NicC
topic split and coded.

Re: Generating dynamic sort card

PostPosted: Mon Oct 19, 2015 3:26 pm
by BillyBoyo
Do you need to SORT the data because it is out of sequence, or just because you want to use SUM?

Just have the SUM statement, pretty much as you have the SORT statement.

Ideally the order would be INCLUDE, SORT, SUM. However, SORT is clever enough to know things only work in one order, so it is only the human reader who is confused.

INCLUDE COND=/OMIT COND= runs first, to limit the amount of data being processed.

Then INREC.

Then SORT.

Then SUM.

Then OUTREC.

The OUTFIL, which can be multiple.

There are also options, which can be specified via OPTION card or PARM=. Consult your documentation for the full details.

Re: Generating dynamic sort card

PostPosted: Mon Oct 19, 2015 4:08 pm
by Papya01234
I am creating this dynamic sort card one one field. But the file which I will be using for this sort will be having thie field with many combination.

My input to the created dynamic sort will be mentioned below.

1234563, 'P' ABCD
1234563, 'P' PQRS
1234563, 'P' MNOP
1239261, 'P' ABCD
1235672, '3' XYZA

and If I am using the dynamic sort created as mentioned earlier I will get the output as

1234563, 'P' ABCD
1234563, 'P' PQRS
1234563, 'P' MNOP
1239261, 'P' ABCD
1235672, '3' XYZA

But I am looking for output like:

1234563, 'P' ABCD
1239261, 'P' ABCD
1235672, '3' XYZA

can you please help in getting this thing done ?

//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(' SORT FIELDS=(4,4,PD,A) ',/,
' INCLUDE COND=((1,1,BI,NE,1,1,BI),OR,'),
BUILD=(C' (4,4,PD,EQ,',1,7,C',AND,244,1,CH,EQ,C''',8,1,C'''),OR, *
',80:X),
TRAILER1=(' (1,1,BI,NE,1,1,BI))')
/*

Re: Generating dynamic sort card

PostPosted: Mon Oct 19, 2015 5:57 pm
by BillyBoyo
//SYSIN DD *
 OPTION COPY
 OUTFIL REMOVECC,
        HEADER1=(' SORT FIELDS=(4,4,PD,A) ',/,
                 ' SUM FIELDS=NONE',/,
                 ' INCLUDE COND=((1,1,BI,NE,1,1,BI),OR,'),
        BUILD=(C' (4,4,PD,EQ,',1,7,C',AND,244,1,CH,EQ,C''',8,1,C'''),OR, *
                ',80:X),
        TRAILER1=(' (1,1,BI,NE,1,1,BI))')
/*


I haven't tried it, but it should be close.

As I said, it would be better to have INCLUDE, SORT, SUM. This would require the INCLUDE part from the HEADER1, and to move the SORT and SUM to after what you have already in the TRAILER1, which also supports the slash-operator (/).

Re: Generating dynamic sort card

PostPosted: Wed Oct 21, 2015 9:47 am
by Papya01234
Thank you so much, It worked.

Regards,
Balesh GG.

Re: Generating dynamic sort card

PostPosted: Wed Oct 21, 2015 4:02 pm
by BillyBoyo
Well, you were basically there yourself. Can I assume you found the code somewhere, it basically worked, but you didn't know why/how? If so, we can explain.

Re: Generating dynamic sort card

PostPosted: Thu Oct 22, 2015 4:39 pm
by Papya01234
I found the code in this portal itself but which was not fit for my requirement and Since I was not aware of slash-operator (/) It was difficult for me add more conditions such as removing duplicates and adding conditional operators in Build. So I tried but was not successful. It was a great information from you guys.

Regards,
Balesh GG