BUILD in SORT - Reformatting file data using Syncsort

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

BUILD in SORT - Reformatting file data using Syncsort

Post by goldyroshan » Thu Apr 05, 2012 1:52 am

What i need to achieve : if the 1st byte of input file is equal to 'M', then move data from 1st byte of input file to 1st byte of output file having length = 244, followed by 'XXXXXX' from 245th byte.
otherwise if the 1st byte of input file is not equal to 'M', then dont move any data.

I am using the following Syncsort card to achieve reformatting of data.

Code: Select all

  OPTION COPY
  OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'M'),
                BUILD=(1:1,244,C'XXXXXX',251:251,0)),
              IFTHEN=(WHEN=(1,1,CH,NE,C'M'),
               BUILD=(1:1,0))

Can someone please help me? I have already gone through various online forums as well as DFSORT manuals, but could not figure out what to do. :(

The error that i am getting:-
WER271A OUTREC STATEMENT : NUMERIC FIELD ERROR

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Apr 05, 2012 4:02 pm

Somehitng does not match up - why are you using this:

Code: Select all

251:251,0)),
- mentioning this means, in the output at position 251, get the data from input starting from 251st postion and of length 0 -- which does not make sense and you get an error.

What length do you want for the output and what do you want to have at 251st position, a zero, or something from input?
Regards,
Anuj

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Thu Apr 05, 2012 6:39 pm

Anuj Dhawan wrote:Somehitng does not match up - why are you using this:

Code: Select all

251:251,0)),
- mentioning this means, in the output at position 251, get the data from input starting from 251st postion and of length 0 -- which does not make sense and you get an error.

What length do you want for the output and what do you want to have at 251st position, a zero, or something from input?
@Anuj,
You are right, that is what even i figured out eventually. I was able to remove this error but I am not getting the desired output.
Basically I want to replicate the below logic into a SORT JCL (i.e. FILEAID needs to be replaced with SORT).

PS005 EXEC PGM=FILEAID,
DD01 DD DSN=i/p file,
FILE DD DSN=o/p file
SYSIN DD *
$$DD01 USER PADCHAR=C' ',
IF=(001,EQ,C'M'),
MOVE=(001,244,001),
MOVE=(245,C'XXXXXX'),
MOVE=(251,0,251),
WRITE=FILE,
IF=(001,NE,C'M'),
MOVE=(001,0,001),
WRITE=FILE
/*


Please help me with the sort card that I used above or maybe you could suggest some other way to achieve this. TIA!
Logically yours,
:-) GRS :-)

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Thu Apr 05, 2012 9:09 pm

goldyroshan wrote:
Anuj Dhawan wrote:Somehitng does not match up - why are you using this:

Code: Select all

251:251,0)),
- mentioning this means, in the output at position 251, get the data from input starting from 251st postion and of length 0 -- which does not make sense and you get an error.

What length do you want for the output and what do you want to have at 251st position, a zero, or something from input?
@Anuj,
You are right, that is what even i figured out eventually. I was able to remove this error but I am not getting the desired output.
Basically I want to replicate the below logic into a SORT JCL (i.e. FILEAID needs to be replaced with SORT).

PS005 EXEC PGM=FILEAID,
DD01 DD DSN=i/p file,
FILE DD DSN=o/p file
SYSIN DD *
$$DD01 USER PADCHAR=C' ',
IF=(001,EQ,C'M'),
MOVE=(001,244,001),
MOVE=(245,C'XXXXXX'),
MOVE=(251,0,251),
WRITE=FILE,
IF=(001,NE,C'M'),
MOVE=(001,0,001),
WRITE=FILE
/*


Please help me with the sort card that I used above or maybe you could suggest some other way to achieve this. TIA!
@Anuj - I actually can't understand the significance of MOVE=(251,0,251),
in the previous snippet (AS-IS scenario using PGM=FILEAID) :-
$$DD01 USER PADCHAR=C' ',
IF=(001,EQ,C'M'),
MOVE=(001,244,001),
MOVE=(245,C'XXXXXX'),
MOVE=(251,0,251),
WRITE=FILE,
IF=(001,NE,C'M'),
MOVE=(001,0,001),
WRITE=FILE

Well, I tried using the following SORTCARD, it seems to be working. Let me know your thoughts on this:-

OPTION COPY
OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'M'),
BUILD=(1:1,244,C'XXXXXX',251:251,750)),
IFTHEN=(WHEN=(1,1,CH,NE,C'M'),
BUILD=(1:1,1000))

N.B. : LRECL of output file is 1000
Logically yours,
:-) GRS :-)

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 9:57 pm

<< Content deleted By Admin >>

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