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

Pick a record from a file based on timestamp


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mani453

New User


Joined: 19 Nov 2015
Posts: 13
Location: INDIA

PostPosted: Thu Jan 07, 2016 6:18 am
Reply with quote

Hi

In my requirement I am facing one condition difficulty.

My requirement is from multiple duplicate record it should pic latest record based on timestamp.

Example
In the below input I have 5 records, three records are same but timestamp differ and two records are completely different. In that three records I need to pic a record which has latest timestamp. Observe the following output.

Can anyone suggest using Cobol or JCL.
Input
456&67 520 vshjsjw 2012-10-01.098908
456&67 520 vshjsjw 2012-10-01.102122
456&67 520 vshjsjw 2012-10-01.112321
456&43 530 vshjsjw 2013-10-01.098908
456&54 540 vshjsjw 2014-10-01.098908

Output
456&67 520 vshjsjw 2012-10-01.112321
456&43 530 vshjsjw 2013-10-01.098908
456&54 540 vshjsjw 2014-10-01.098908

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

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Jan 07, 2016 7:08 am
Reply with quote

Quote:
Can anyone suggest using Cobol or JCL.

Are you again asking the same thing icon_evil.gif : http://ibmmainframes.com/viewtopic.php?p=333018&highlight=#333018

.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Jan 07, 2016 9:21 am
Reply with quote

Quote:
Can anyone suggest using Cobol or JCL.
1. It cannot be done in JCL. JCL only allocates resources and executes programs -- so you cannot write a JCL to pick records -- PERIOD.

2. Write a COBOL program. Seriously, if you do not understand the IF statement in COBOL and how to use it to simply and easily resolve your problem, you belong on The Beginner's and Students Forum, not on this forum which is for experts and people with mainframe experience. The question you asked in your post today is a beginner's question. You most likely will not get a lot of help on this forum for your question as those people who respond understand that you don't know COBOL and hence any help provided isn't likely to do much good without a LOT of follow up.

3. Terminology is critical in IT where similar terms may mean very different things. Your topic title and post statements use the term "pic" -- which is an abbreviation in a COBOL program for PICTURE -- yet the context indicates that you meant "pick". When you cannot use proper English capitalization and cannot spell a four-letter word correctly, you DEFINITELY belong on the Beginner's Forum and should not be posting on this forum for quite a while. Using appropriate English rules and spelling indicates a respect for the time of the people who respond on this forum, since they don't have to spend the time figuring out what you meant and can directly proceed to answering your question.
Back to top
View user's profile Send private message
Mani453

New User


Joined: 19 Nov 2015
Posts: 13
Location: INDIA

PostPosted: Fri Jan 08, 2016 9:11 pm
Reply with quote

Thanks all for your suggestions.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Tue Jan 19, 2016 12:47 am
Reply with quote

You could do a SORT of the file which includes the timestamp field and then afterwards run a COBOL program to select the record with the most recent timestamp. This is the hard way.

It would be easier to use ICETOOL SELECT statement which can be invoked using JCL. Follow the links to see samples.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
Search our Forums:

Back to Top