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

How to update trailer count


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

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Wed Mar 20, 2013 4:11 pm
Reply with quote

Hi All,

I have below records in my input file

10 - Header record
20 - Detail record
90 - Trailer record

Input file Details -
RECFM=FB,LRECL=1300,BLKSIZE=27300


Input file data -

1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90

Here I want count total total number of detail records, and want to write in trailer record from 3rd position as below -

Required file output data -

1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90000000003
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90000000006


I am trying below condition but it is not giving expected results -

SORT FIELDS=COPY
OUTREC IFOUTLEN=1300,
IFTHEN=(WHEN=INIT,OVERLAY=(1301:SEQNUM,9,ZD,START=0)),
IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(3:1301,9))

Above SORT is giving as below result, but is is not expected -

1000220130320
20 21400 PUNE
20 21500 MUMBAI
20 21600 PUNE
90000000005
1000120130320
20 21700 PUNE
20 21800 MUMBAI
20 21900 PUNE
20 22000 PUNE
20 23000 PUNE
20 24000 PUNE
90000000012


Thanks in advance.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 20, 2013 4:19 pm
Reply with quote

Try with IFTHEN=(WHEN=GROUP, with the 10 marking the start of the group and the 90 the end. PUSH a SEQ after the "end" of your fixed records.

Then IFTHEN=(WHEN=(logexp to identify the "trailer" and OVERLAY the count, modified appropriately, from the extension to where you want it on the trailer.

You can use IFOUTLEN=1300 to ensure that the extension is not actually written. IFOUTLEN is not a condition, it means "set the output length to <value> after all the IFTHENs are completed.
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Wed Mar 20, 2013 4:35 pm
Reply with quote

Hi Bill,

Thanks for your help, Could you please explain 1st line, I got meaning of 2nd line but, about first line I am not clear, I am not aware
how to make a group.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Mar 20, 2013 6:25 pm
Reply with quote

There are examples in the DFSORT manuals, and many here.

Code:
10
20
20
20
20
90
10
20
20
90
10
90


You have "groups" of records, with 10 defining the "start" and 90 defining the "end". PUSH, which is used with WHEN=GROUP, can be used to "overlay" a sequence within the group. When you later identify the 90 record, the sequence on that record includes the count for 10, any/all 20s and 90. So you can put a count onto the 90, using OVERLAY to where you want, and in the form that you want, from where you PUSHED the sequence number and subtracting 2.
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Thu Mar 21, 2013 5:41 pm
Reply with quote

Hi Bill,

I am using below sort card but getting error -

Code:
//SYSIN     DD  *                                     
  SORT FIELDS=COPY                                   
  OUTREC IFOUTLEN=1300,                               
  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'2'),         
                             END=(1,1,CH,EQ,C'9'),   
                             PUSH=(3:1301,9)),       
  IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(3:1301,9))     
/*                                                   


I am getting below error

Code:
SYSIN :                                                             
  SORT FIELDS=COPY                                                   
  OUTREC IFOUTLEN=1300,                                             
  IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'2'),                         
                             END=(1,1,CH,EQ,C'9'),                   
                             PUSH=(3:1301,9)),                       
  IFTHEN=(WHEN=(1,1,ZD,EQ,9),OVERLAY=(3:1301,9))                     
WER276B  SYSDIAG= 3067073, 7080498, 7080498, 3993075                 
WER164B  8,864K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,   
WER164B     0 BYTES RESERVE REQUESTED, 992K BYTES USED               
WER146B  32K BYTES OF EMERGENCY SPACE ALLOCATED                     
WER108I  SORTIN   : RECFM=FB   ; LRECL=  1300; BLKSIZE= 27300       
WER230A  OUTREC   FIELD OUTSIDE RANGE                               
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                       
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                       

Could you please suggest where I am wrong ?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Mar 21, 2013 6:41 pm
Reply with quote

Topic moved to the correct home of SYNCSORT topics
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Mar 21, 2013 6:56 pm
Reply with quote

Here is a hint:
Code:
WER230A OUTREC FIELD OUTSIDE RANGE.

And please learn to use BBcode Tags. I've edited it.
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Thu Mar 21, 2013 7:41 pm
Reply with quote

Hi Anuj,

Sorry for not using BBcodes.

I am not able to find out what length should I provide in PUSH and OVERLAY, I know that it is causing out of range issue in PUSH=(3:1301,9) & OVERLAY=(3:1301,9).


Can you please suggest what value should I provide ?
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Thu Mar 21, 2013 8:28 pm
Reply with quote

Sandip,

In your sort card you are not using the SEQ while forming the group.Please try below mentioned Sort Card.

Code:
 
 SORT FIELDS=COPY                                                       
 OUTREC IFOUTLEN=1300,                                                 
        IFTHEN=(WHEN=GROUP,BEGIN=(1,2,ZD,EQ,10),                       
               END=(1,2,ZD,EQ,90),                                     
               PUSH=(1301:SEQ=9)),                                     
        IFTHEN=(WHEN=(1,2,ZD,EQ,90),                                   
              OVERLAY=(3:1301,9,ZD,ADD,-2,LENGTH=9,EDIT=(TTTTTTTTT)))   

 


Output:

Code:

1000220130320     
20 21400 PUNE     
20 21500 MUMBAI   
20 21600 PUNE     
90000000003       
1000120130320     
20 21700 PUNE     
20 21800 MUMBAI   
20 21900 PUNE     
20 22000 PUNE     
20 23000 PUNE     
20 24000 PUNE     
90000000006       
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 22, 2013 4:47 am
Reply with quote

sandip_mainframe,

It is much better to use the full "record code" for your selection.

Your PUSH was copy data to column 3 before anything was put in the source location. As Sai pointed out, what you needed there was to PUSH the SEQ.

From Sai's example, SUB,+2 will work as well, and perhaps will be easier to understand. The tests I tend to make as CH, rather than ZD.
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 63
Location: pune

PostPosted: Fri Mar 22, 2013 2:06 pm
Reply with quote

Hi Sai/Bill/Anuj,

It's working as per my expectations. Thanks a lot for your time, help and explanations provided.

It's nice to see functionality working.... :-)
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 To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
Search our Forums:

Back to Top