Page 1 of 1

joining info into one record

PostPosted: Tue Oct 22, 2013 6:31 pm
by ottoelflaco
Hi experts!!

Could you tell me how can I do the next?:

In (key in position 1,3):
111AA
111  BBBB
222CC
222  AAAA 


Out
111AABBBB
222CCAAAA 


I can do this exercise with numbers using SUM FIELDS...but with chars?, I m trying to do. Is there other way to do it?

My english is very poor. I hope that you understand my requirements


Regards!! :!:

Re: joining info into one record

PostPosted: Tue Oct 22, 2013 6:49 pm
by BillyBoyo
Are the records always in pairs? If so, look at IFTHEN=(WHEN=GROUP and some examples of transferring data from one record to another.

If not, please show a representative sample input and expected output.

Re: joining info into one record

PostPosted: Wed Oct 23, 2013 3:54 pm
by ottoelflaco
Hi,

Thank you Billy, it works. I did this:
//SORT12   EXEC PGM=SORT,REGION=2M,COND=(0,NE)         
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
111AA                                                   
111  BBBB                                               
222CC                                                   
222  AAAA                                               
333DD                                                   
333  AAAA                                               
//SORTOUT  DD DSN=DES.IS.LR.BDK.JCJCL10.SORT12,         
//            DISP=(,CATLG,CATLG),                     
//            SPACE=(TRK,(100,225),RLSE),               
//            DCB=(RECFM=FB,LRECL=20,BLKSIZE=0,DSORG=PS)
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  INREC IFOUTLEN=20,                                   
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(10:4,2)),     
  IFTHEN=(WHEN=INIT,                                   
  OVERLAY=(4:10,2))                                     


I get this out:
111AA    AA
111AABBBBAA
222CC    CC
222CCAAAACC
333DD    DD
333DDAAAADD


Now I only need filter the space in position 6.

Only one question more, how can I filter in the same step??, If I add INCLUDE COND=(6,1,CH,NE,C' ') to the code, of this way:
SORT FIELDS=COPY                                 
INREC IFOUTLEN=20,                               
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(10:4,2)),
IFTHEN=(WHEN=INIT,                               
OVERLAY=(4:10,2))                               
INCLUDE COND=(6,1,CH,NE,C' ')                   


The out is the next
111  BBBB
222  AAAA
333  AAAA



, anybody can help me with this doubt...

Re: joining info into one record

PostPosted: Thu Oct 24, 2013 4:03 pm
by ottoelflaco
Now :D

SORT FIELDS=COPY                                       
INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(10:4,2)),
      IFTHEN=(WHEN=INIT,OVERLAY=(4:10,2))             
OUTFIL INCLUDE=(6,1,CH,NE,C' ')                       

Re: joining info into one record

PostPosted: Fri Oct 25, 2013 8:44 pm
by ottoelflaco
I won´t open a new topic for this,...because is related. If moderador consider that is better a new topic, I ll open it.. sorry if not OK

A new requeriment, this is interesting for me!

-key: position(1,3)
-Values are in pair in position(4,8), and the values are in pair: 'AA', 'BB', 'CC', 'DD'.....
Can I get the last value ordered descending of pair AA,BB,CC?

Is hard for me explain it. I ll try with example:
111AA  AAAA
111  BBBB 
111CC     
222  CC  BB
222CCAABBBB
222DDAA  DD
222AA  AAAA
333  AA  CC
333
444EEGGFF
444AARREE
444  XX 
555AACCDDRR


My desired output would be:
111CCBBBBAA
222DDCCBBDD
333  AA  CC
444EEXXFF 
555AACCDDRR


I wish my explanataion is OK..

Sorry for my poor english :(

Regards!!

Re: joining info into one record

PostPosted: Sat Oct 26, 2013 5:36 pm
by NicC
What are your rules for getting the output from the input? I just tried one in my head for the records beginning 111 ut it did not work for records beginning 222.

Re: joining info into one record

PostPosted: Sun Oct 27, 2013 5:48 pm
by ottoelflaco
NicC I m trying to get the last value of position (4,2) (6,2) (8,2) (10,2) for each key.

For example for key '111':
- the last value in position (4,2) ordering desc -->CC.
- the last value in position (6,2) ordering desc -->BB.
...
...

For example, key '222':
- the last value in position (4,2) ordering desc --> DD.
- the last value in position (6,2) ordering desc --> CC.
...
...

I can do this exercise in four steps, doing IFTHEN=GROUP for each value in position (4,2) (6,2)... But I am asking for my knowledge if is posible do it with other solution.

Sorry my english :(..

Thxx
Regards!!