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

need SORT card for writing incrementing seq on condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nagesh D

New User


Joined: 07 Apr 2011
Posts: 3
Location: Hyd, India

PostPosted: Tue Sep 13, 2011 4:49 pm
Reply with quote

Hi,

Require a SORT card for below requirement, preferrably a single card.

Input:
A
B
C
A
C
A
A

Output:
A 01
B 01
C 01
A 02
C 02
A 03
A 04

the sequence number should increment only when the first char is 'A', and the same sequence should be continued with the next records until it finds an 'A' where it gets incremented.

The SORT card which I tried for this requirment.

SORT FIELDS=COPY
OUTREC IFOUTLEN=80,
OUTREC IFOUTLEN=80,
IFTHEN(WHEN=INIT,BUILD=(1,80)),
IFTHEN(WHEN=(1,1,CH,EQ,C'A'),OVERLAY= (51:SEQNUM,8,ZD,START=1))

The above card is incrementing the sequence only when it finds A, but could not build the logic to copy that sequence to the next records with first char other than A.

The above SORT cards output looks like

A 00000001
B
C
A 00000002
C
A 00000003
A 00000004

Thanks.
Back to top
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Tue Sep 13, 2011 6:18 pm
Reply with quote

this can be achieved by When=Group.

Code:


//SYSIN    DD *                                                   
  OPTION COPY                                                     
  OUTREC IFTHEN(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'A'),PUSH=(3:SEQ=2))
 
Back to top
View user's profile Send private message
Nagesh D

New User


Joined: 07 Apr 2011
Posts: 3
Location: Hyd, India

PostPosted: Tue Sep 13, 2011 8:06 pm
Reply with quote

thanks THINKSRINII,

it worked.. tried understanding your SORT card, where I felt BEGIN and PUSH as new terms.

From the IBM manuals I got what BEGIN does, but could not get a clear idea of PUSH.

The below is from manual:

"A BEGIN=(logexp) or END=(logexp) parameter is satisfied when the
| logical expression evaluates as true. You define how the records in a
| group are to be changed using the PUSH parameter"

Could some one add on what exaclty PUSH does, and what all we can do with PUSH.

thanks
Back to top
View user's profile Send private message
THINKSRINIII
Warnings : 1

New User


Joined: 09 Jan 2009
Posts: 88
Location: India

PostPosted: Tue Sep 13, 2011 9:33 pm
Reply with quote

Hi Nagesh,

When=Group is to handle a group of records.
Records are grouped together based on conditions given in Begin or End.
Push is used to push data to all the records that are grouped together.

It is just an equivalent to Build.. It will build the same to all the grouped records.

Let me know if this clarifies your doubt.
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: Tue Sep 13, 2011 11:05 pm
Reply with quote

Quote:
It is just an equivalent to Build.. It will build the same to all the grouped records.


Actually, PUSH is more like OVERLAY than BUILD. It will only PUSH fields from the first record of the group to the indicated positions of the other records of the group. It will NOT affect positions not specified in PUSH.

For example, PUSH=(11:SEQ=2) would overlay positions 11-12 with a sequence number, but not affect positions 1-10 or 13-n.
Back to top
View user's profile Send private message
Nagesh D

New User


Joined: 07 Apr 2011
Posts: 3
Location: Hyd, India

PostPosted: Wed Sep 14, 2011 8:04 pm
Reply with quote

Thanks THINKSRINII..

Thanks Frank...

We can close this topic as the query is answered..and thanks all for the quick update
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
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
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top