Page 1 of 1

Concatenate records using MID

PostPosted: Thu Oct 24, 2013 9:02 pm
by Prakash88
Hi.
I tried using syncsort to achieve below result. My objective is to concatenate records.

//STEP1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
    76940 43-188     2009-07-28
    76940 43-1889   2009-07-28
    76940 43 18898 2009-07-28
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC FIELDS=(1,17,SQZ=(SHIFT=LEFT,MID=C'_'),18,11)
OUTREC BUILD=(1,28,SQZ=(SHIFT=LEFT,MID=C'#'))
/*

Expected output:
76940_43-188#2009-07-28
76940_43-1889#2009-07-28
76940_43 18898#2009-07-28


Output i am getting:
76940_43-188@#2009-07-28
76940_43-1889@#2009-07-28
76940_43_18898@#2009-07-28



But MID command places _ delimiter on all spaces. I dont want to get _ as part of value when using MID syntax. Please help me on this.

Re: Concatenate records using MID

PostPosted: Thu Oct 24, 2013 9:33 pm
by dick scherrer
Hello,

Suggest you re-post correcting the errors in the data and make sure you use the Code tag for readability and to preserve alignment.

But MID command places _ delimiter on all spaces. I dont want to get _ as part of value when using MID syntax.
Because you told the code to do so . . .

There seems to be an inconsistency with the dash and underscore . . .

Re: Concatenate records using MID

PostPosted: Fri Oct 25, 2013 10:22 am
by Prakash88
Thanks Dick for the reply.
Third input - 76940 43 18898 2009-07-28
Second field has space as part of value. I dont want to place _ when a field has space as part of value.Just want to concatenate three fields with _ delimiter. Is there any way to achieve this ?.

Re: Concatenate records using MID

PostPosted: Mon Oct 28, 2013 12:39 am
by dick scherrer
Hello,

You need to post the current code. If the code specifies a "_", why would it not appear in the output?

Re: Concatenate records using MID

PostPosted: Mon Oct 28, 2013 12:59 am
by BillyBoyo
If you intention is to get a #-delimited output, try specifying MID=C' ' (ie a blank) on the first SQZ. Your second SQZ will then get # between each field.