View previous topic :: View next topic
|
Author |
Message |
Nagesh D
New User
Joined: 07 Apr 2011 Posts: 3 Location: Hyd, India
|
|
|
|
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 |
|
|
THINKSRINIII Warnings : 1 New User
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
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 |
|
|
Nagesh D
New User
Joined: 07 Apr 2011 Posts: 3 Location: Hyd, India
|
|
|
|
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 |
|
|
THINKSRINIII Warnings : 1 New User
Joined: 09 Jan 2009 Posts: 88 Location: India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
Nagesh D
New User
Joined: 07 Apr 2011 Posts: 3 Location: Hyd, India
|
|
|
|
Thanks THINKSRINII..
Thanks Frank...
We can close this topic as the query is answered..and thanks all for the quick update |
|
Back to top |
|
|
|