Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Check count and format
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Mon Feb 08, 2010 3:13 pm    Post subject: Check count and format
Reply with quote

Hi

I have the following requirement.

Input file (last line is the trailer) LRECL = 43

20100202XXXXXXXXXXX 2010020200
20100202XXXXXXXXXXX 2010020201
20100202XXXXXXXXXXX 2010020202

20100202NUMBER OF RECORDS: 00003

Output required (LRECL = 43)

If 41:2 = 00,
Format it to the below and repeat it thrice in the output file
AAAAA 20100202 XXXXXXXXXXX 2010020200 1010
If 41:2 = 01,

Format it to the below and write once on the output file
BBBBB 20100202 XXXXXXXXXXX 2010020201 1020

If 41:2 = 02,
Format it to the below and write once on the output file
CCCCC 20100202 XXXXXXXXXXX 2010020202 1030

Also, I need to check the number of records in the input file and match with the one in the trailer already present (in this case 3).
If the counts donot match, then I need to issue a bad return code.

Please help
Also, let me know should you require further details
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Feb 09, 2010 12:14 am    Post subject:
Reply with quote

It's not clear what you want the output to look like. Do you only have one each of the 00, 01 and 02 record or can you have multiple instances of each? Do you only have one NUMBER OF RECORDS record or can you have more than one?

Please show a better example of the records in your input file and what you expect for output. Give the starting position, length and format of each relevant field in the input records and output records.

Is a "bad return code" anything other than 0 or what?
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Wed Feb 10, 2010 5:42 pm    Post subject: more details as requested
Reply with quote

Apologies for the late reply.
there are multiple instances for each of the records mentioned in the input file above.(00,01,02)
There is just one "Number of records" field at the end.
The output file should be
1:5 - AAAAA
6:1 - SPACE
7:8 - DATE from 1:8 of input
15:1 - space
16:11 - 'XXXXXXXXXXX'
27:1 - SPACE
28:8 - DATE from 1:8 of input
36:2 - 00 from the input 41:2
38:4 - 1010 hard code

There is also one small reqmnt as mentioned in the prev post

When 41:2 = '00'
Repeat the output record thrice
Make sure the last field '1010' is incremented by 1 everytime

For example if 41:2 = '00'
AAAAA 20100202 XXXXXXXXXXX 2010020200 1010
AAAAA 20100202 XXXXXXXXXXX 2010020200 1011
AAAAA 20100202 XXXXXXXXXXX 2010020200 1012

For other identifiers (01,02 etc) , the records should not be repeated.should be 1 output record for every single record.

I want to do this via Sort (am holding syncsort in my office)
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2163
Location: @my desk

PostPosted: Wed Feb 10, 2010 7:03 pm    Post subject:
Reply with quote

Quote:
For other identifiers (01,02 etc) , the records should not be repeated
jammy_27,

What about the last field in the above case? Will it be hardcoded as '1010' ?Your initial post says '1020' and '1030' for '01' and '02' records respectively.
Quote:
16:11 - 'XXXXXXXXXXX'
And your input file has an "XXXXXXXXXXX" field having length=11. Is this the same field you are writing in the output here? If yes, what's its starting position?Is there any way to identify your trailer record?.e.g. "NUMBER" at pos-9
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Wed Feb 10, 2010 7:33 pm    Post subject:
Reply with quote

for 41:2 = 01
the last field would be 1020
and for 41:2=02
the last field would be 1030
Yeah, XXXXXXXXXX is the same as in input.start postion in input is 9

The trailer record can be identified by "NUMBER OF RECORDS: 00003"
start position of this is 11.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 10, 2010 10:14 pm    Post subject:
Reply with quote

jammy_27,

The following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=Your input fb 43 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  OMIT COND=(9,18,CH,EQ,C'NUMBER OF RECORDS:')                   
  INREC IFTHEN=(WHEN=(41,2,CH,EQ,C'00'),                         
  BUILD=(C'AAAAA',X,1,8,X,9,11,X,1,8,41,2,C'10103')),             
  IFTHEN=(WHEN=(41,2,CH,EQ,C'01'),                               
  BUILD=(C'BBBBB',X,1,8,X,9,11,X,1,8,41,2,C'10201')),             
  IFTHEN=(WHEN=(41,2,CH,EQ,C'02'),                               
  BUILD=(C'CCCCC',X,1,8,X,9,11,X,1,8,41,2,C'10301'))             
  SORT FIELDS=COPY                                               
  OUTFIL REMOVECC,IFOUTLEN=41,                                   
  IFTHEN=(WHEN=(42,1,ZD,EQ,3),BUILD=(1,41,/,1,40,                 
         +1,ADD,41,1,ZD,EDIT=(T),/,1,40,+2,ADD,41,1,ZD,EDIT=(T))),
  TRAILER1=(7,8,C'NUMBER OF RECORDS: ',TOT=(42,1,ZD,M11,LENGTH=8))
//*
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Wed Feb 10, 2010 10:41 pm    Post subject: Reply to: Check count and format
Reply with quote

thank u so much for the reply.
I will be trying this first thing tomorrow.

Also, I wanted to ask one more thing
wat would this do - OUTFIL REMOVECC,IFOUTLEN=41, ?
is it becoz the increment was happening in the field at the end?

one more regarding the increment
what if the increment is happening somwhere in the middle of the record
something like this

AAAAA 20100202 XXXXXXXXX01 2010020200 1010
AAAAA 20100202 XXXXXXXXX02 2010020200 1011
AAAAA 20100202 XXXXXXXXX03 2010020200 1012

reduced the X count by 2 each and put the increment there.
Could you please help.

Thanks
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 10, 2010 10:58 pm    Post subject:
Reply with quote

jammy_27 wrote:
wat would this do - OUTFIL REMOVECC,IFOUTLEN=41, ?
is it becoz the increment was happening in the field at the end?


Not really. IFOUTLEN sets the output file LRECL to 41.(since that is what you desired layout mapped). I added extra fields at the end to set the total number of records as the '00' is repeated thrice.

jammy_27 wrote:
what if the increment is happening somwhere in the middle of the record something like this


you can change the position where you want to on the Build statement of OUTFIL

jammy_27 wrote:
reduced the X count by 2 each and put the increment there.
Could you please help.


You don't want to consider the repeated lines as part of the count?

I suggest you start over and explain all the rules involved along with a sample data of both input and desired output. Please don't change the requirements between posts
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Wed Feb 10, 2010 11:01 pm    Post subject:
Reply with quote

small correction..
the increment may not start from 1 in the current position (after x's)
would seqnum and start logic work here?

Please help
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Feb 10, 2010 11:08 pm    Post subject:
Reply with quote

Hello,

Please review:
Quote:
I suggest you start over and explain all the rules involved along with a sample data of both input and desired output. Please don't change the requirements between posts
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Wed Feb 10, 2010 11:13 pm    Post subject:
Reply with quote

apologies for creating the confusion
We are in process of designing interfaces with new systems in place.(so we have sequence changes in between as well for other interfaces)

please let me know if i need to open a new post for this change
(i am using the same example as above, since i can replicate your logic in the other interface that needs an increment in between.Hope you dont mind)

if 41:2=0
AAAAA 20100202 924XXXXX 637 2010020200 1010
AAAAA 20100202 925XXXXX 638 2010020200 1010
AAAAA 20100202 926XXXXX 639 2010020200 1010

At this moment I would need the increment to happen at both the places.
The increments are hardcoded to start from 924 and 637 respectively.
positions of other fields remain the same
the start position of the first increment series(924) = 16
XXXXX starts from 19 and is 5 in length
a space at 24:1
and an increment series (637) at 26:3

For 41:2=1and 41:2=02, there would be just one output record so i can format the same way as you have done above

kindly let me know if anything more is required
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 10, 2010 11:45 pm    Post subject: Reply to: Check count and format
Reply with quote

Jammy_27,

*Sigh* You are simply wasting my time as well as your time . Did you read my post ? once again

skolusu wrote:
I suggest you start over and explain all the rules involved along with a sample data of both input and desired output. Please don't change the requirements between posts


The sample you show is output , where are the numbers 924 and 637 coming from INPUT file? what is the position and format of these numbers in INPUT? Are they ZD or PD or BI numbers?

Use code tags to post the input data and desired output. Unless you provide complete details I am not going to spend any more time on this
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Thu Feb 11, 2010 12:50 am    Post subject: sorry for the trouble - reqmnt reposted afresh
Reply with quote

sorry to have troubled you
Below is the fresh stuff

Input file (last line is the trailer) LRECL = 44

20100202XXXXXXXXXXX 2010020200
20100202XXXXXXXXXXX 2010020201
20100202XXXXXXXXXXX 2010020202

20100202NUMBER OF RECORDS: 00003

Output required (LRECL = 44)

If 41:2 = 00,
Format it to the below and repeat it thrice in the output file
AAAAA 20100202 924XXXXX 637 2010020200 1010
AAAAA 20100202 925XXXXX 638 2010020200 1010
AAAAA 20100202 926XXXXX 639 2010020200 1010

The output file structure
1:5 - AAAAA
6:1 - SPACE
7:8 - DATE from 1:8 of input
15:1 - space
16:3- 924 (hardcoded value which gets incremented in the next two repeated records for41:2=00
19:5 - XXXXX (9:5 of input)
24:1 - space
25:3 - 637 (hardcodedvalue which gets incremented in the next two repeated records for41:2=00
28:1 - space
29:8 - DATE from 1:8 of input
37:2 - 00 from the input 41:2
39:1- space
40:4 - 1010 hard code which remains constant for the next two repeated records

If 41:2 = 01,

Format it to the below and write once on the output file
BBBBB 20100202 927XXXXX 640 2010020201 1020

output structure same as 41:2=00 above
927 and 640 are hardcoded values
1020 is also hardcoded

If 41:2 = 02,
Format it to the below and write once on the output file
CCCCC 20100202 928XXXXX 641 2010020200 1030

928 and 641 are hardcoded values
1030 is also hardcoded
output structure same as 41:2=00 above

Also, I need to check the number of records in the input file and match with the one in the trailer already present (in this case 3).
If the counts donot match, then I need to issue a bad return code

Also the input records can be repeated with the same set as i have put in the example of input record above.The count will change accordingly.

Please help.
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Thu Feb 11, 2010 1:01 am    Post subject:
Reply with quote

"The count will change accordingly."
realised the above sentence might create slight confusion
by count i mean the trailer count

Although the 42:1='00'/ '01'/'02' records can be repeated in the input file, the desired output will always be the same for each as I have mentioned above.

Thanks in advance
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Feb 11, 2010 4:33 am    Post subject: Reply to: Check count and format
Reply with quote

Jammy_27,

You still did not answer my question of considering the repeated lines as part of the count to be validated on the last record.

For ex you show input of 3 recors (1 - 00 record, 1 - 01 record and 1 -02 record ) and the trailer has a count of 3. Since you write 2 additional records of 00 type record your output record count is 5. Now do you validate the 5 against the trailer record or do you just consider the input record count of 3 recors before repetition?

Anyway here is my take on it , This job does NOT consider the repeated lines as part of count validation on the trailer record. It repeats the 00 records thrice and formats the records accordingly.

If the count does not match the input count, then the job sets a return of code of 4.


Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DSN=Your input FB 44 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                               
//SETCODE  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,44,SEQNUM,5,ZD,START=0)),         
  IFTHEN=(WHEN=(41,2,CH,EQ,C'00'),                                   
  BUILD=(C'AAAAA',X,1,8,X,C'924',9,5,X,C'637',X,1,8,41,2,X,C'1010')),
  IFTHEN=(WHEN=(41,2,CH,EQ,C'01'),                                   
  BUILD=(C'BBBBB',X,1,8,X,C'927',9,5,X,C'640',X,1,8,41,2,X,C'1020')),
  IFTHEN=(WHEN=(41,2,CH,EQ,C'02'),                                   
  BUILD=(C'BBBBB',X,1,8,X,C'928',9,5,X,C'641',X,1,8,41,2,X,C'1030')) 
                                                                     
  SORT FIELDS=COPY                                                   
                                                                     
  OUTFIL IFOUTLEN=44,                                                 
  IFTHEN=(WHEN=(1,5,CH,EQ,C'AAAAA'),BUILD=(1,44,/,1,15,               
  +1,ADD,16,3,ZD,EDIT=(TTT),19,6,+1,ADD,25,3,ZD,EDIT=(TTT),28,17,/,   
  1,15,+2,ADD,16,3,ZD,EDIT=(TTT),19,6,+2,ADD,25,3,ZD,EDIT=(TTT),     
  28,17))                                                             
                                                                     
  OUTFIL FNAMES=SETCODE,NULLOFL=RC4,                                 
  INCLUDE=((28,5,CH,EQ,45,5,CH),AND,9,18,CH,EQ,C'NUMBER OF RECORDS:')
//*


I am sure the next q would be " how would 01& 02 records start with a new counter number instead of hard coding at pos 16 and 25 with the last value from 00 records"
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2163
Location: @my desk

PostPosted: Thu Feb 11, 2010 10:04 am    Post subject: Re: more details as requested
Reply with quote

jammy_27 wrote:
I want to do this via Sort (am holding syncsort in my office)
Cant this topic be moved to the JCL forum, since the OP uses SyncSort and NOT DFSORT.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 11, 2010 10:25 am    Post subject: Reply to: Check count and format
Reply with quote

Hi Arun,

Good catch - it has been moved icon_smile.gif

d
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2163
Location: @my desk

PostPosted: Thu Feb 11, 2010 10:38 am    Post subject:
Reply with quote

Thanks Dick. Anyways Kolusu's Solution seems to be good enough to run on SyncSort shops as well. icon_biggrin.gif
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2163
Location: @my desk

PostPosted: Thu Feb 11, 2010 10:55 am    Post subject:
Reply with quote

Jammy_27,

Do you have blank records in your input file as shown in your sample?

The solution provided by Kolusu writes the trailer record as it is to the output file with input record count which is most likely to be lesser than the output record count. Do you need a trailer record to be written in the output file?
Back to top
View user's profile Send private message
jammy_27

New User


Joined: 06 Aug 2009
Posts: 17
Location: USA

PostPosted: Thu Feb 11, 2010 3:20 pm    Post subject:
Reply with quote

this works absolutely fine for me.
Thank you so much
The count which u assumed was correct.I dnt need the repeated ones.Sorry to have missed that out.

And yeah, once again sorry for the trouble i created above but thanks so much
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us