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

Can presence of a field be checked using SORT?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Mon Sep 10, 2007 2:00 pm
Reply with quote

Hi ALL,

The problem I am facing now is as follows:

There are two fields/cols in a file. The requirement demands that if the second field is present then insert a hyphen between the two fields, else output the number as it is.

E.g.:
Code:

FIELD1  FIELD2  REQ.OUTPUT
100     A       100-A
1234    TER     1234-TER
6543    PUT     6543-PUT
3984            3984



Here Field1 is 8 char in length and Field2 is 4 char in length.

I believe IFTHEN needs to be used but I am new to SORT/SYNCTOOL.

THANK YOU ALL for your time on this.
Back to top
View user's profile Send private message
ashokm

New User


Joined: 28 Feb 2006
Posts: 11
Location: Chennai,India

PostPosted: Mon Sep 10, 2007 2:55 pm
Reply with quote

Hi Balimanja,


Here the JCL :

//SPLIT1R EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=XXXXX.ICE.INPUT,DISP=SHR
//SORTOUT DD DSN=XXXXX..ICE.OUTPUT,DISP=SHR
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(1,12,SQZ=(SHIFT=LEFT,PREBLANK=C' '))
/*

Ashok M
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Sep 10, 2007 2:59 pm
Reply with quote

ashokm,

Quote:
I believe IFTHEN needs to be used but I am new to SORT/SYNCTOOL.


Your solution uses ICEMAN (DFSORT product). But the original post says balimanja needs a solution using syncsort.
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Mon Sep 10, 2007 3:53 pm
Reply with quote

Thanks Murali & Ashok

Ashok,

I tried your code but I am getting a syntax error.

Code:
OPTION COPY
INREC OVERLAY=(1,12,SQZ=(SHIFT=LEFT,PREBLANK=C' '))
                    *


Need help,

Thanks again
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Sep 10, 2007 4:14 pm
Reply with quote

balimanja,

If your shop contains a SYNCSORT product, try with the following code.
The following code works fine for non-spaces values of field-1
Code:
// EXEC PGM=SORT                                                     
//SYSOUT DD SYSOUT=*                                                   
//SORTIN DD *                                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
100     A                                                               
1234    TER                                                             
6543    PUT                                                             
3984                                                                   
/*                                                                     
//SORTOUT DD SYSOUT=*                                                   
//SYSIN DD *                                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 OPTION COPY                                                           
 INREC IFTHEN=(WHEN=(9,4,CH,EQ,C' '),BUILD=(1,8)),                     
       IFTHEN=(WHEN=(8,1,CH,NE,C' '),BUILD=(1,8,C'-',9,4)),             
       IFTHEN=(WHEN=(7,1,CH,NE,C' '),BUILD=(1,7,C'-',9,4)),             
       IFTHEN=(WHEN=(6,1,CH,NE,C' '),BUILD=(1,6,C'-',9,4)),             
       IFTHEN=(WHEN=(5,1,CH,NE,C' '),BUILD=(1,5,C'-',9,4)),
       IFTHEN=(WHEN=(4,1,CH,NE,C' '),BUILD=(1,4,C'-',9,4)),
       IFTHEN=(WHEN=(3,1,CH,NE,C' '),BUILD=(1,3,C'-',9,4)),
       IFTHEN=(WHEN=(2,1,CH,NE,C' '),BUILD=(1,2,C'-',9,4)),
       IFTHEN=(WHEN=(1,1,CH,NE,C' '),BUILD=(1,1,C'-',9,4))
 OUTFIL IFOUTLEN=80

Output:
Code:
100-A   
1234-TER
6543-PUT
3984


If your post relates to a SYNCSORT, please post under JCL forum. This area is for DFSORT/ICETOOL and not for SYNCSORT.
Back to top
View user's profile Send private message
ashokm

New User


Joined: 28 Feb 2006
Posts: 11
Location: Chennai,India

PostPosted: Mon Sep 10, 2007 4:15 pm
Reply with quote

Hi,

That JCL removes all the spaces.This is one what you expect .

//SPLIT1R EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=XXXXX.ICE.INPUT,DISP=SHR
//SORTOUT DD DSN=XXXX.ICE.OUTPUT,DISP=SHR
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,12,SQZ=(SHIFT=LEFT,MID=C'-'))
/*

Ashok M
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Sep 10, 2007 5:27 pm
Reply with quote

murmohk1: When execute ICEMAN in my shop, it is an alias for SYNCTOOL.
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Mon Sep 10, 2007 5:49 pm
Reply with quote

Shankar,

The code you posted, is it complete? I am getting error. Please let me know.

Thank you
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 5:57 pm
Reply with quote

balimanja wrote:
The code you posted, is it complete? I am getting error. Please let me know.
It would help greatly if you posted the sysout with the error. Very few here a that good at mind reading.... icon_wink.gif
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Sep 10, 2007 6:37 pm
Reply with quote

balimanja

The code i posted was ran successfully with syncsort for z/os 1.2.3
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Sep 10, 2007 6:58 pm
Reply with quote

There is no /* after the instream data. Else, Please post the error info.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Mon Sep 10, 2007 7:21 pm
Reply with quote

Aaru wrote:
There is no /* after the instream data.
Huh? icon_confused.gif
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Mon Sep 10, 2007 7:41 pm
Reply with quote

CICS Guy,

That was a Typo icon_sad.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Sep 10, 2007 9:24 pm
Reply with quote

Quote:
Ashok,

I tried your code but I am getting a syntax error.


SQZ is a DFSORT function. It is NOT supported by Syncsort.
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Tue Sep 11, 2007 11:03 am
Reply with quote

Shankar/Frank,

Isn't there any alternative?
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Sep 11, 2007 11:14 am
Reply with quote

balimanja,
Quote:
The code you posted, is it complete? I am getting error. Please let me know.

The code i posted was ran successfully with syncsort for z/os 1.2.3.
If you face any problem with that code, please post the full sysout messages that starts from SYSIN.
Quote:
Isn't there any alternative?

The before posted frank words are true.
If i find anything which fulfill your requirements, i will come up with the code.
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Tue Sep 11, 2007 11:28 am
Reply with quote

Thank You Shankar,

Here is what I get:
Code:
SYSIN    :                                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
                                                                       *
 OPTION COPY                                                           
 INREC IFTHEN=(WHEN=(9,4,CH,EQ,C' '),BUILD=(1,8)),                     
       IFTHEN=(WHEN=(8,1,CH,NE,C' '),BUILD=(1,8,C'-',9,4)),             
       IFTHEN=(WHEN=(7,1,CH,NE,C' '),BUILD=(1,7,C'-',9,4)),             
       IFTHEN=(WHEN=(6,1,CH,NE,C' '),BUILD=(1,6,C'-',9,4)),             
       IFTHEN=(WHEN=(5,1,CH,NE,C' '),BUILD=(1,5,C'-',9,4)),             
       IFTHEN=(WHEN=(4,1,CH,NE,C' '),BUILD=(1,4,C'-',9,4)),             
       IFTHEN=(WHEN=(3,1,CH,NE,C' '),BUILD=(1,3,C'-',9,4)),             
       IFTHEN=(WHEN=(2,1,CH,NE,C' '),BUILD=(1,2,C'-',9,4)),             
       IFTHEN=(WHEN=(1,1,CH,NE,C' '),BUILD=(1,1,C'-',9,4))             
 OUTFIL IFOUTLEN=80                                                     
     SORT FIELDS=COPY                                                   
WER275A  NO KEYWORDS FOUND ON CONTROL STATEMENT                         
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                           
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                           


By the way, why is there an asterisk present in the end of the column margin??
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Tue Sep 11, 2007 11:29 am
Reply with quote

Disregard the SORT FIELDS=COPY statement it was added by mistake.
Back to top
View user's profile Send private message
balimanja

New User


Joined: 14 Aug 2007
Posts: 40
Location: Bangalore

PostPosted: Tue Sep 11, 2007 12:01 pm
Reply with quote

Shankar,

It is working great. The problem was with the column margin present after the SYSIN DD *.


Thank You.

and Thanks to Ashok, Frank and to all who replied.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top