modify date conditionally

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

modify date conditionally

Post by bernix » Wed Oct 24, 2012 1:44 pm

My file has a header record containing a date and data records. My task is to modify the date in the data records to current-date but only if the date is the same as in the header record. As that is a little confusing I will give an example
00 is the header record
01 are the data records
today is 20121024

input
00 20121018XYZ
01 20121018XYZ
01 20121016XYZ

output
00 20121018XYZ
01 20121024XYZ
01 20121016XYZ

header record remains unchanged
record 1: 20121018 is changed to 20121024 (current date) because it has the same date as header record
record 2: remains unchanged because the date is not equal header record

any solution for my problem

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Oct 24, 2012 2:33 pm

This pseudo code should be handy:

Code: Select all

If header-date=detail-date
   ACCEPT ws-date FROM DATE
   move ws-date to detail-date
END-IF
In above pseudo- code "DATE" is a 'conceptual data items' and has the implicit PICTURE 9(6) and the sequence of data elements (from left to right) would be: 2 digits for the year, 2 digits for the month, 2 digits for the day.

As you have a four-digit year, you can consider to use intrinsic function CURRENT-DATE. However, how do you make use of the working-storage definitions in using DATE and CURRENT-DATE, I leave it you for experiment.
Regards,
Anuj

bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

Post by bernix » Wed Oct 24, 2012 3:44 pm

thanks but i dont need a program code, i'd like to have a DFSORT solution :D

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Oct 24, 2012 3:51 pm

Please post the ICE201I message from any Sort step so we can see what level of the product you have.

It should be simple with a IFTHEN=(WHEN=GROUP on the header record, and PUSH the date from the header. Then you have functions for the current date (consult the manual) if you want all the confusion of "before midnight or after midnight" and problems with re-running/testing.

bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

Post by bernix » Wed Oct 24, 2012 5:21 pm

William Collins wrote:Please post the ICE201I message from any Sort step so we can see what level of the product you have.

It should be simple with a IFTHEN=(WHEN=GROUP on the header record, and PUSH the date from the header. Then you have functions for the current date (consult the manual) if you want all the confusion of "before midnight or after midnight" and problems with re-running/testing.
ICE201I H RECORD TYPE IS V - DATA STARTS IN POSITION 5

bernix
Member
Posts: 21
Joined: Tue Oct 28, 2008 8:32 pm
Location: Vienna, Austria

Post by bernix » Wed Oct 24, 2012 6:08 pm

thank you william, your hint (WHEN=GROUP) was sufficient to assemble the statements that performed the job. i considered the manual and BINGO!

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Oct 24, 2012 8:35 pm

Good for you. The "H" in the message says you are reasonably up-to-date, but now I don't need to know that :-)

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Fri Oct 26, 2012 2:17 pm

I'm sorry, I thought it was in COBOL Part of the Forum -- however, as they say if it ends well, all is well. :)
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others