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
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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?
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)
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
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
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.
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
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
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
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)
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
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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
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.
"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.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
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.
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"
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
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?
Arun,
I dnt need the trailer record on my output file
I have added an omit condition on top to remove the trailer.
Also, my input wont have blank records.