Trying to create a report using DFSORT but stuck on DATES

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
skotikila2
Member
Posts: 4
Joined: Thu May 01, 2014 6:31 pm

Trying to create a report using DFSORT but stuck on DATES

Post by skotikila2 » Thu May 01, 2014 6:58 pm

I have an Input file with a RUN DATE in position 116, The RUN DATE is in MM/DD/YY format. If the RUN DATE is today's date then i need to look further down in the report and extract few values.
I'm using the below SORT card in my first SORT step to select and modify the data.

Code: Select all

SORT FIELDS=COPY                                                   
INCLUDE COND=(116,8,CH,EQ,C'RUN DATE',OR,2,11,CH,EQ,C'GRAND TOTAL')
INREC  IFTHEN=(WHEN=(2,11,CH,EQ,C'GRAND TOTAL'),                   
       BUILD=(1:C'VALUE 1:',15:63,17)),                            
       IFTHEN=(WHEN=(116,8,CH,EQ,C'RUN DATE'),                     
       PARSE=(%00=(ABSPOS=126,FIXLEN=2),                           
              %01=(ABSPOS=129,FIXLEN=2),                           
              %02=(ABSPOS=132,FIXLEN=2)),                          
       BUILD=(1:C'20',3:%02,5:%00,7:%01))                          
OUTREC IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(40:1,80))                
OUTFIL STARTREC=2                                                  

This modifies my FILE with one output record which looks like this
****** ***************************** Top of Data **********
000001 VALUE 1: 10,228.32 20140501
****** **************************** Bottom of Data ********

Then i run a second SORT step to compare the modified RUN DATE with Current Date DATE1 and based on it i decide if the value needs to be kept or not. The second SORT card is

Code: Select all

   INCLUDE COND=(1,5,CH,EQ,C'VALUE')                               
   OUTREC IFTHEN=(WHEN=(40,8,CH,NE,DATE1),                         
          OVERLAY=(15:C'DATE ERROR, COLLECT THE REPORT MANUALLY')),
          IFTHEN=(WHEN=(40,8,CH,EQ,DATE1),                         
          OVERLAY=(40:C'                                      '))  
   SORT FIELDS=COPY                                                
If dates match, my Output is

****** ***************************** Top of Data ********
000001 VALUE 1: 10,228.32
****** **************************** Bottom of Data ******

If they dont match, then the output becomes

****** ***************************** Top of Data ***************
000001 VALUE 1: DATE ERROR, COLLECT THE REPORT MANUALLY
****** **************************** Bottom of Data *************

Now this whole thing works only If my input file has only one record with keyword "GRAND TOTAL" in position 2,11, If there are multiple records then my records dont have RUN DATE at the end (except for Record1). I'm sure there must be a simple way to do this. Could someone point me in the right direction please. Please let me know if you need any more information. All files used are FB with an RC of 133. Is there a better way to compare dates, then may be set an RC if the RUN DATE and Current date dont match or a way to EDIT each record to contain the RUN DATE at the end of the each resulting records of the first output file. And can this be done with one SORT step instead of 2. My apologies if I'm overstating or over-elaborating the problem. Thanks in advance.

skotikila2
Member
Posts: 4
Joined: Thu May 01, 2014 6:31 pm

Post by skotikila2 » Mon May 05, 2014 12:50 pm

Could someone please help me out with this??? I'm not sure why i'm not getting any replies... did i miss giving you some information, or did not state the problem correctly ? ... if so please let me know, I will try to give the information missing from here... Thanks in advace...

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

Post by William Collins » Mon May 05, 2014 5:59 pm

Unfortunately for you, we are either here or not, depending on circumstances. If you need more certainty than that, you have to pay for it.

You have no sample input data. You haven't used the Code tags to make your question look more "friendly".

It is not clear what you want for your correct result. Do you want only one record output, or do you want each record output to have the date at the end?

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon May 05, 2014 8:19 pm

Typically, a way to get help more quickly is to show your code/jcl (as you have done) using the Code tag, some sample input data, and the exact output you want from that sample input.

Your sort control statements have been Code'd for readability and to retain alignment.
Have a good one

skotikila2
Member
Posts: 4
Joined: Thu May 01, 2014 6:31 pm

Post by skotikila2 » Mon May 05, 2014 8:30 pm

Hi William Collins and DikDude,
Thank you very much for your replies. I never had to post any questions in this forum, because i found answers to all of my questions when i searched through the questions asked by others, so my skills of posting a questions are not too good and i do apologies for that. I will restate my questions more clearly here with the input and the desired output formats.

Input:

Code: Select all

Command ===>                                                  Scroll ==
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----
****** ***************************** Top of Data **********************
000001 +                      SUMMARY REPORT       RUN DATE : 05/04/14 
000002  ** TOTALS **                                                   
000003 0DATABASE                         AMOUNT                        
000004 +___________                      _______                       
000005 -PROCESS1                        10,228.32                      
000006 -                                                               
000007 0AREA1 TOTAL                     10,228.32                      
000008 0AREA5 TOTAL                     10,228.32                      
000009 0DIST1 TOTAL                     10,228.32                      
000010 0DIST2 TOTAL                     10,228.32                      
000011 0GRAND TOTAL                     10,228.32                      
****** **************************** Bottom of Data ********************
The RUN DATE is in MM/DD/YY format.
So If that RUN DATE equals current system date then the output should be

Code: Select all

Command ===>                                                  Scroll ===> CSR 
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
****** ***************************** Top of Data *****************************
000001 0AREA1 TOTAL                     10,228.32                             
000002 0AREA5 TOTAL                     10,228.32                             
000003 0GRAND TOTAL                     10,228.32                             
****** **************************** Bottom of Data ***************************
If the RUN DATE is not qual to Current system date then the output should be

Code: Select all

Command ===>                                                  Scroll ===> CSR
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7
****** ***************************** Top of Data ****************************
000001 0AREA1 TOTAL                    DATE MIS-MATCH COLLECT THE DATA MANUAL
000002 0AREA5 TOTAL                    DATE MIS-MATCH COLLECT THE DATA MANUAL
000003 0GRAND TOTAL                    DATE MIS-MATCH COLLECT THE DATA MANUAL
****** **************************** Bottom of Data **************************
All the files are FB, LRECL of 133.
So can this be done using DFSORT and can it be done in one SORT step? Please let me know if you need any more information. Thank you for your time.

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

Post by William Collins » Mon May 05, 2014 10:34 pm

You can identify 'RUN DATE :' with WHEN=GROUP and PUSH it on to each line. You can't PUSH a literal (only data from a record) so you can use IFTHEN=(WHEN=INIT to extend the record to include C'20'

The date elements are in fixed positions, so you don't need to use PARSE, just specify the start and length of each element, which you can do in the PUSH.

With the date on each line, it should be simple to do one thing or another with IFTHEN=(WHEN=(logical expression and IFTHEN=(WHEN=NONE.

skotikila2
Member
Posts: 4
Joined: Thu May 01, 2014 6:31 pm

Post by skotikila2 » Tue May 06, 2014 5:06 pm

Thank you William, I'm not exactly sure how to use PUSH to insert the RUN DATE to each line, but I will read through the manuals and look at the previous posts on PUSH and will let you know the outcome... Thank you for the help and guidence...

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