|
View previous topic :: View next topic
|
| Author |
Message |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
hello everybody.
I need a hand.
I have two input files, with the same key and I have to create two output files.
all files (both input and output files) have the following characteristics:
Record format. . . : FB
Record length. . . : 290
the key is on three fields with the following characteristics:
Field 1: length 8 from position 14 (it is a field packed)
Field 2: length 10 from position 38 (it's a date)
Field 3: length 10 from position 58 (it's a date)
Input file 1
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-03-31
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-02-28
XXXXXXXX ...... ...... 2010-02-28 ..... 2010-02-28
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31
XXXXXXXX ...... ...... 2010-01-31 ..... 2009-12-31
Input file 2
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-02-28
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31
Output file 1
XXXXXXXX ...... ...... 2010-02-28 ..... 2010-02-28
XXXXXXXX ...... ...... 2010-01-31 ..... 2009-12-31
Output file 2
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-03-31
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-02-28
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31
I hope is not complicated.
In the first output file i will have to put all records that do not exist in the input file 2 and with the date (the key field n ° 3) lower than a reference date that I define as a parameter (for example defines that the reference date is 2010-02-28).
In the second file I'll put all the records that exist in the input file 2 + all records with the date (the key field n ° 3) greater than the date defined by me.
I hope it is all clear |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
theone1987,
Is the combination of field1 + field2 + field 3 unique? or do you have duplicates in both files? It would be a good idea if you showed the displayable field1 (packed decimal field) values also |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| Skolusu wrote: |
theone1987,
Is the combination of field1 + field2 + field 3 unique? or do you have duplicates in both files? It would be a good idea if you showed the displayable field1 (packed decimal field) values also |
I did not understand what you mean, sorry |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| theone1987 wrote: |
| Skolusu wrote: |
theone1987,
Is the combination of field1 + field2 + field 3 unique? or do you have duplicates in both files? It would be a good idea if you showed the displayable field1 (packed decimal field) values also |
I did not understand what you mean, sorry |
What kolusu wants to understand is can there be multiple occurrences of
same combination of f1 f2 and f3 is possible?
eg
Can your input file have data like below. similarly for second file.
| Code: |
Input file 1
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-03-31
XXXXXXXX ...... ...... 2010-03-31 ..... 2010-03-31
|
|
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
Oh, ok...sorry...
no, a situation like that, it's impossible. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Quote: |
| In the second file I'll put all the records that exist in the input file 2 + all records with the date (the key field n ° 3) greater than the date defined by me. |
what is date defined by me?
Can you explain this rule clearly.
| Quote: |
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31 |
reason for this record being in op2? |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| Sambhaji wrote: |
| Quote: |
| In the second file I'll put all the records that exist in the input file 2 + all records with the date (the key field n ° 3) greater than the date defined by me. |
what is date defined by me?
Can you explain this rule clearly.
| Quote: |
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31 |
reason for this record being in op2? |
I need to "clean" a table from a certain date. This date may not always be the same, but I decide the date from which to start "cleaning".
(Warning: I do not choose the date within the record
XXXXXXXX ...... ...... 2010-01-31 ..... 2010-01-31)
but the one that should be in the icetool. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
thenone1987,
Well try this DFSORT JOB and let me know if it gives you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=&&HEADR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,BUILD=(290X),HEADER1=(3C'$')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HEADR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=Your input FB 290 byte file2,DISP=SHR
// DD DSN=&&HEADR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=Your input FB 290 byte file1,DISP=SHR
//ONLYF1 DD SYSOUT=*
//OTHER DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(291:ID=1))
SORT FIELDS=(14,08,PD,A,
38,10,CH,A,
58,10,CH,A),EQUALS
SUM FIELDS=(291,1,ZD)
OUTFIL FNAMES=ONLYF1,BUILD=(1,290),
INCLUDE=(291,1,ZD,EQ,1,AND,58,10,CH,LT,C'DATE COND')
OUTFIL FNAMES=OTHER,BUILD=(1,290),
INCLUDE=(291,1,ZD,GT,2,AND,38,10,CH,GT,C'DATE COND',AND,
001,3,CH,NE,C'$$$')
//* |
|
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| Skolusu wrote: |
thenone1987,
Well try this DFSORT JOB and let me know if it gives you the desired results
|
the code give me this error
| Code: |
INCLUDE=(291,1,ZD,GT,2,AND,38,10,CH,GT,C'2010-02-28,AND,
001,3,CH,NE,C'$$$')
$
SYNTAX ERROR
|
also can you explain me what this se for:
| Code: |
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(291:ID=1))
|
thank you.... |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| Skolusu wrote: |
thenone1987,
|
ok, I found the error.
however there are instructions that I have never used (I am not an expert, yet), so might you explain it?
eg
a)
/ / SORTOUT DD DSN = & & HEADR, DISP = (, PASS), SPACE = (TRK, (1,0), RLSE)
/ / SYSIN DD *
SORT FIELDS = COPY
OUTFILE REMOVECC, BUILD = (290X), header1 = (3C '$')
b)
Inreco ifthen = (WHEN = GROUP, BEGIN = (1,3, CH, EQ, C'$$$'), PUSH = (291: ID = 1))
c)
OUTFILE = OTHER FNAMES, BUILD = (1,290)
INCLUDE = (291.1, ZD, GT, 2, AND, 58.10, CH, GT, C'2009-12-31 ', AND,
001.3, CH, N, C'$$$')
excuse me for the ignorance.
thanks. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080 |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
the code works...
i have one more question left...
if I wanted to extract all records with a date less than the current date, how do I?
for example
Today is March 20, 2010, I want all records with date <January 31, 2010
I swear, this is my last question ... |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
| If GT is greater than, maybe something very similar would be less than. . .? |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| dick scherrer wrote: |
| If GT is greater than, maybe something very similar would be less than. . .? |
my request was not clear ...
Now I set the date by parameter. I would rather that the date would be "calculated" according to the system date. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
| dick scherrer wrote: |
Between them should be all that is needed. |
actually, It was not very useful ...
I found this topic that is similar to what I want ...
ibmmainframes.com/viewtopic.php?t=47380&highlight=date
could i write in my icetool in this way?
| Code: |
OUTFIL FNAMES=ONLYF1,BUILD=(1,290),
INCLUDE=(291,1,ZD,EQ,1,AND,58,10,CH,LT,CURRENT DATE - 2)
OUTFIL FNAMES=OTHER,BUILD=(1,290),
INCLUDE=(291,1,ZD,GT,2,AND,38,10,CH,GT,CURRENT DATE - 2,AND,
001,3,CH,NE,C'$$$')
//* |
To subtract 2 months to the current date... |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
...Sigh. . .
| Quote: |
| actually, It was not very useful ... |
Please explain. . .
Using the info from those posts you can build a SYMNAMS value you could use to compare the dates. . .
Or is there something else that is not yet clear? |
|
| Back to top |
|
 |
theone1987
New User

Joined: 14 Sep 2009 Posts: 60 Location: Milan
|
|
|
|
i wrote this statment
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD *
CURDT,S'&YR4.-&MON.-&DAY'
//SORTIN DD *
DUMMY REC
the result is
What should I do if I wanted to get
ie two months ago (the last day of the month)
thank you |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
theone1987,
You don't have to use symbols to get the desired results. You can use DATE1+n , DATE1-n (n can be any number from 1 to 9999), which would give current date + n days or current date - n days in C'yyyymmdd' format.
However there is no direct feature to get the last day of two months ago. There is a trick to get the last date of the month. Is there any other condition ? And please describe all your requirements at once.
Thanks |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|