MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Select Previous record if condition met
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Wed May 06, 2009 3:03 pm    Post subject: Select Previous record if condition met Reply with quote

Hi All,

I have a input report file LRECL=121 and RECFM=FBA.

I want to extract the records that have letters "TS" in postion 45 and the previous record as shown in the output

Input

Code:

1                                                                       Date:  2/19/2009   Time: 16.05.35    Page:      1

                                                    LOGPRINT DETAIL REPORT
 CMD   TBL DBID URI      BLOCK    L# TSN      JOB NAME R-UNIT MP USER ID AREA MONITOR INFO     INPUT RECORD FPR    RXX
       DATE       TIME     CLOCK            SEC.USER MOVE TO  LRID     PREV     LRSN     LBSN     TASK STATUS RECL DATA
 UPDAT P66  187 0293F220 0049CC01 00 AADEE441 LCC370   51,340    ZLW9125  B04                            56
       02/18/2009 22.39.29 C3C4E67EC2B11681 PRODJOBZ 00000000 06CDBD37 06CDBD36 04A1C7B7 00140A89   56 B      0141 2E26
 UPDAT P66  187 0293F221 0049CC01 00 AADEE441 LCC370   51,340    ZLW9125  B04                            57
       02/18/2009 22.39.29 C3C4E67EC2BCF580 TS123456 00000000 06CDBD38 06CDBD37 04A1C7B8 00140A89   56 B      0141 2E26
1                      (CONTINUED)                                      Date:  2/19/2009   Time: 16.05.35    Page:      2

                                                    LOGPRINT DETAIL REPORT
 CMD   TBL DBID URI      BLOCK    L# TSN      JOB NAME R-UNIT MP USER ID AREA MONITOR INFO     INPUT RECORD FPR    RXX
       DATE       TIME     CLOCK            SEC.USER MOVE TO  LRID     PREV     LRSN     LBSN     TASK STATUS RECL DATA

 UPDAT P66  187 02262001 0031DA06 00 AADEE441 LCC370   51,340    ZLW9125  B04                            59
       02/18/2009 22.39.29 C3C4E67EC3756D00 PRODJOBZ 00000000 06CDBD3A 06CDBD38 04A1C7BA 00140A89   56 B      0141 2E26
 UPDAT P66  187 02952B97 004A0506 00 AADEE441 LCC370   51,340    ZLW9125  B04                            60
       02/18/2009 22.39.29 C3C4E67EC3AD5900 TS98762  00000000 06CDBD3B 06CDBD3A 04A1C7BB 00140A89   56 B      0141 2E26
 UPDAT P66  187 0226200C 0031DA06 00 AADEE441 LCC370   51,340    ZLW9125  B04                            61
       02/18/2009 22.39.29 C3C4E67EC3B67980 PRODJOBZ 00000000 06CDBD3C 06CDBD3B 04A1C7BC 00140A89   56 B      0141 2E26




Output

Code:
 UPDAT P66  187 0293F221 0049CC01 00 AADEE441 LCC370   51,340    ZLW9125  B04                            57
       02/18/2009 22.39.29 C3C4E67EC2BCF580 TS123456 00000000 06CDBD38 06CDBD37 04A1C7B8 00140A89   56 B      0141 2E26
 UPDAT P66  187 02952B97 004A0506 00 AADEE441 LCC370   51,340    ZLW9125  B04                            60
       02/18/2009 22.39.29 C3C4E67EC3AD5900 TS98762  00000000 06CDBD3B 06CDBD3A 04A1C7BB 00140A89   56 B      0141 2E26


Thank you,
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed May 06, 2009 4:53 pm    Post subject: Reply with quote

chandra,

The following DFSORT/ICETOOL JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*     
//IN       DD DSN=your 121 byte FBA input file,
//            DISP=SHR
//OUT      DD SYSOUT=*                                   
//TOOLIN   DD *                                           
  SELECT FROM(IN) TO(OUT) ON(122,8,CH) ALLDUPS USING(CTL1)
//CTL1CNTL DD *                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(122:SEQNUM,8,ZD)),     
  IFTHEN=(WHEN=(45,2,CH,EQ,C'TS'),                       
  OVERLAY=(122:122,8,ZD,SUB,+1,M11,LENGTH=8))             
  OUTFIL FNAMES=OUT,BUILD=(1,121)                         
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Wed May 06, 2009 8:46 pm    Post subject: Reply with quote

Thank you very much Kolusu...

You have solution for every problem !!!!...

It is working perfectly !!

Thanks once again
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Wed May 13, 2009 8:46 am    Post subject: Reply with quote

Sorry Kolusu,

I was not able to understand how the previous records were selected through the sort control card.

Can you please explain it..........
(Hope I am not wasting your time with this)

Thanks in Advance,
Manoj
Back to top
View user's profile Send private message
chandra
Beginner


Joined: 26 Sep 2003
Posts: 130
Topics: 36

PostPosted: Wed May 13, 2009 9:59 am    Post subject: Reply with quote

Hi Manoj,

The sequence number will be generated for every record and when the Letters "TS" found at 45 postion we are subtracting one from the sequence number so that both the sequence number will be same.

In the select statement we are selecting only duplicate sequece number.

Let me know if you have any questions...

Thanks
_________________
Regards,
Chandra
Back to top
View user's profile Send private message
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Thu May 14, 2009 3:48 am    Post subject: Reply with quote

Hi Chandra,

Such a simple logic and I was braking my head.........actually I was not aware that in the control card we were negating one to get the duplicate value in the sequence number generation......

Now I got it....Thanks once again.
Back to top
View user's profile Send private message
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Aug 20, 2009 10:58 am    Post subject: I tried but getting previous one record only Reply with quote

Hi, Kolusu.

I have tried this solution but getting previous one record only !

Code:

//STEP0100 EXEC PGM=ICETOOL                                             
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                         
 UPDAT P66  187 0293F220 0049CC01 00 AADEE441 LCC370   51,340    ZLW9125
B04                            56                                       
       02/18/2009 22.39.29 C3C4E67EC2B11681 PRODJOBZ 00000000 06CDBD37 
06CDBD36 04A1C7B7 00140A89   56 B      0141 2E26                       
 UPDAT P66  187 0293F221 0049CC01 00 AADEE441 LCC370   51,340    ZLW9125
B04                            57                                       
       02/18/2009 22.39.29 C3C4E67EC2BCF580 TS123456 00000000 06CDBD38 
06CDBD37 04A1C7B8 00140A89   56 B      0141 2E26                       
 UPDAT P66  187 02262001 0031DA06 00 AADEE441 LCC370   51,340    ZLW9125
B04                            59                                       
       02/18/2009 22.39.29 C3C4E67EC3756D00 PRODJOBZ 00000000 06CDBD3A 
06CDBD38 04A1C7BA 00140A89   56 B      0141 2E26                       
 UPDAT P66  187 02952B97 004A0506 00 AADEE441 LCC370   51,340    ZLW9125
B04                            60                                       
       02/18/2009 22.39.29 C3C4E67EC3AD5900 TS98762  00000000 06CDBD3B 
06CDBD3A 04A1C7BB 00140A89   56 B      0141 2E26                       
 UPDAT P66  187 0226200C 0031DA06 00 AADEE441 LCC370   51,340    ZLW9125
B04                            61                                       
       02/18/2009 22.39.29 C3C4E67EC3B67980 PRODJOBZ 00000000 06CDBD3C 
06CDBD3B 04A1C7BC 00140A89   56 B      0141 2E26                       
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                         
  SELECT FROM(IN) TO(OUT) ON(122,8,CH) ALLDUPS USING(CTL1)             
//CTL1CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(122:SEQNUM,8,ZD)),                   
  IFTHEN=(WHEN=(45,2,CH,EQ,C'TS'),                                     
  OVERLAY=(122:122,8,ZD,SUB,+1,M11,LENGTH=8))                           
  OUTFIL FNAMES=OUT,BUILD=(1,121)                                       
/*                                                                     


Output:
Code:

B04                            57                                     
       02/18/2009 22.39.29 C3C4E67EC2BCF580 TS123456 00000000 06CDBD38
B04                            60                                     
       02/18/2009 22.39.29 C3C4E67EC3AD5900 TS98762  00000000 06CDBD3B


Note: I did not consider the full date but limited it to 80 bytes only.

Please help.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Aug 20, 2009 11:52 am    Post subject: Reply with quote

mf_user,

huh? bonk Your output shows you got 4 records which is correct , what exactly do you find wrong in that?

The requirement is to find a string 'TS' at pos 45 and if found copy the previous 1 record to that which is what you got

You need to better explain as to why you think the output is wrong
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Aug 20, 2009 10:55 pm    Post subject: Reply with quote

Kolusu, as per Chandra's request in writing, the ouput is correct. But, I was looking for the output that was shown in picture in the top of this post. It shows three lines and 6 lines in total. Let me know if it is achievable too...

Am I wrong somewhere?

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Aug 21, 2009 11:05 am    Post subject: Reply with quote

mf_user,

I have no clue as to what you are talking.The last post from you shows only 4 lines of data(when viewed even in 1024 X 768 resolution) which is the correct output according to chandra's request.

If your requirement is different then show us a sample input and desired output.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Wed Aug 26, 2009 9:53 am    Post subject: This is what I want to copy.... Reply with quote

Kolusu, the below is my input (LRECL=80, RECFM=FB)...
Code:

XXX1     OVERSTAT9000000001
43625ABCDEF8X4HC5EM A1     
40535ABCDEF8X4HC5EM A2     
XXX2     OVERSTAT9000000002
43625BCDEFG9G4HC5EM A1     
40535BCDEFG9G4HC5EM A3     
XXX3     OVERSTAT9000000008
43625CDEFGH2G4HC5EM A3     
40535CDEFGH2G4HC5EM A4     



Whenever a third record has 'A3' in 21st column, I want to copy the previous two records to outut file.

Output needed:
Code:

XXX2     OVERSTAT9000000002
43625BCDEFG9G4HC5EM A1     
40535BCDEFG9G4HC5EM A3     


Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 26, 2009 10:31 am    Post subject: Reply with quote

mf_user,

Your input and output doesn't match. There are 2 A3 records and your output shows only the first A3 record pair , what happened to the next A3? Why is it dropped?

What happens if an A3 record found and the previous 2 records overlaps with another A3?

in your example you had

Code:

XXX2     OVERSTAT9000000002
43625BCDEFG9G4HC5EM A1     
40535BCDEFG9G4HC5EM A3     
XXX3     OVERSTAT9000000008
43625CDEFGH2G4HC5EM A3     


Now the last A3 and the previous 2 records would overlap the previous A3 record. How do you handle that?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Wed Aug 26, 2009 11:26 am    Post subject: Reply with quote

Kolusu, my actual output needs to be as I shown above.

Whenever a third record has 'A3' in 21st column, I want to copy the previous two records to outut file. In the above test input, only the 2nd set of records has the "A3" in the third record.

Thanks.
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 26, 2009 12:05 pm    Post subject: Reply with quote

mf_user,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
XXX1     OVERSTAT9000000001                                         
43625ABCDEF8X4HC5EM A1                                               
40535ABCDEF8X4HC5EM A2                                               
XXX2     OVERSTAT9000000002                                         
43625BCDEFG9G4HC5EM A1                                               
40535BCDEFG9G4HC5EM A3                                               
XXX3     OVERSTAT9000000008                                         
43625CDEFGH2G4HC5EM A3                                               
40535CDEFGH2G4HC5EM A4                                               
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'XXX'),                 
  PUSH=(81:ID=8,SEQ=8)),                                             
  IFTHEN=(WHEN=GROUP,BEGIN=(89,8,ZD,EQ,1),PUSH=(97:1,80),RECORDS=3),
  IFTHEN=(WHEN=GROUP,BEGIN=(89,8,ZD,EQ,2),PUSH=(177:1,80),RECORDS=2)
  OUTFIL INCLUDE=(21,2,CH,EQ,C'A3',AND,89,8,ZD,EQ,3),               
  BUILD=(97,80,/,177,80,/,1,80)                                     
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mf_user
Intermediate


Joined: 01 Jun 2003
Posts: 372
Topics: 105

PostPosted: Thu Aug 27, 2009 10:33 am    Post subject: Reply with quote

Thanks Kolusu. I will try it and come back....
_________________
MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group