Date format in Trailer

2019-08-02 20:01发布

问题:

OPTION COPY                                                 
  OUTFIL  REMOVECC,                                          
      TRAILER1=('FT',DATE,55X,COUNT=(EDIT=(IIITT)),   
     299X,TOTAL=(370,13,SFF,EDIT=(STTTTTTTTT.TT),       
                        SIGNS=(+,-),                    
                        LENGTH=13))                     

I have a Trailer record with the above options. In this scenario, the date is displayed in the format but I want the date to be displayed in the format 2014-10-21 only. My trailer record will look like below.

FT10/21/14       04    +000000192.21

It should be like below. FT2014-10-21 04 +000000192.21

Also, in this one I have found the Count of all the records and the total of all records. My input file has A or L in column 2 and corresponding amounts in coloumn 370. I also want find the count of the records that have A or L in column 2 and also the total of those records. I have to display this count and sum in the trailer record too. Experts help needed urgently.

Note : In my trailer, I need to display the current date in the format yyyy-mm-dd and I am already displaying the count and total of all the input records, I also want to display the count and total of the records with A or L in column 2 and the total of the corresponding amounts in column 370.

Based on the answer provided by Bill, this is what I have.

//SORTA    EXEC PGM=SORT                                                
//SORTIN   DD  DSN=TESTIBN.MYFILE.CHGHIS.SAMP,                    
//             DISP=SHR                                                 
//SORTOUT  DD  DSN=TESTIBN.MYFILE.CHGHIS.NEW,                     
//             DISP=(NEW,CATLG,DELETE),                                 
//             UNIT=SYSDA,                                              
//             RECFM=FB                                                 
//SORTWK01 DD  SPACE=(CYL,(364)),                                       
//             UNIT=SYSDA                                               
//SORTWK02 DD  SPACE=(CYL,(364)),                                       
//             UNIT=SYSDA                                               
//SORTWK03 DD  SPACE=(CYL,(364)),                                       
//             UNIT=SYSDA                                               
//SORTWK04 DD  SPACE=(CYL,(364)),                                       
//             UNIT=SYSDA                                               
//SORTWK05 DD  SPACE=(CYL,(364)),                                       
//             UNIT=SYSDA                                               
//SYSPRINT DD  SYSOUT=*                                                 
//SYSOUT   DD  SYSOUT=*                                                 
//SYSIN    DD  *                                                        
  OPTION COPY                                                           
   OUTFIL  REMOVECC,                                                    
            TRAILER1=('FT',DATE=(4MD-),55X,COUNT=(EDIT=(IIITT)),        
           299X,TOTAL=(370,13,SFF,EDIT=(STTTTTTTTT.TT),                 
                              SIGNS=(+,-),                              
                              LENGTH=13)) 

Yes, the record length is 500. The input file has A or L in position 2 only for few records. These are adjustment records. They may have C in position 2 for charge records. I have already put the totals of all the records (charge+adjustments) in the trailer, now I have to put the count and total of the adjustment records as well. Kindly help me with the actual code.

回答1:

From the DFSORT Application Programming Guide

DATE=(abcd)

specifies that the current date is to appear in the report record in the form 'adbdc', where a, b, and c indicate the order in which the month, day, and year are to appear and whether the year is to appear as two or four digits, and d is the character to be used to separate the month, day and year. For a, b, and c, use M to represent the month (01-12), D to represent the day (01-31), Y to represent the last two digits of the year (for example, 05), or 4 to represent the four digits of the year (for example, 2005). M, D, and Y or 4 can each be specified only once. Examples: DATE=(DMY.) would produce a date of the form 'dd.mm.yy', which on March 29, 2005, would appear as '29.03.05'. DATE=(4MD−) would produce a date of the form 'yyyy-mm-dd', which on March 29, 2005,would appear as '2005-03-29'.

The very last line of the description gives you exactly what you want, which is to replace your simple DATE by DATE=(4MD-).

To get the counts and total amounts of A and L records:

Use

 INREC IFTHEN=(WHEN=INIT,OVERLAY=(position-after-end-of-record:Z,13Z,Z,13Z),

Assuming your records are 500 bytes and fixed in length that would be (501:Z,13Z,Z,13Z),

This will temporarily (because we'll chop them back later) extend the records.

Then use two IFTHEN=(WHEN=(logical-expression) to test for your A and L. If A, use OVERLAY to put a C'1' in position 501 and the amount starting at 502. If L, use OVERLAY to put a C'1' in position 515 and the amount starting at 516.

Amend your TRAILER1 to do TOT/TOTAL of all those four fields. That will give you the count of As and total amount of As, count of Ls and total amount of Ls. Add BUILD=(1,500) to your OUTFIL to return your records to the original size.

Note, I'm using 500 as an example. Use the actual LRECL of your records.

If you have variable-length records, it needs a slight change.

 OPTION COPY

 INREC IFTHEN=(WHEN=INIT,
                OVERLAY=(501:Z,13Z,Z,13Z)),
       IFTHEN=(WHEN=(2,1,CH,EQ,C'A'),
                OVERLAY=(501:C'1',370,13)),
       IFTHEN=(WHEN=(2,1,CH,EQ,C'A'),
                OVERLAY=(515:C'1',370,13))

 OUTFIL  REMOVECC,                                          
         TRAILER1=('FT',DATE,55X,COUNT=(EDIT=(IIITT)),
                   TOTAL=(501,1,ZD,EDIT=(IIITT)),   
                   TOTAL=(502,13,ZD,EDIT=(STTTTTTTTT.TT),       
                                               SIGNS=(+,-),
                   TOTAL=(515,1,ZD,EDIT=(IIITT)),   
                   TOTAL=(516,13,ZD,EDIT=(STTTTTTTTT.TT),       
                                               SIGNS=(+,-),
                   263X,TOTAL=(370,13,SFF,EDIT=(STTTTTTTTT.TT),       
                                               SIGNS=(+,-),                    
                                               LENGTH=13))  

I've not even tossed this into the machine, but it should be close.

I can't tell where you want the new figures, so I've just put them into the first available area of the 299 blanks.

You are using OPTION COPY, you do not need SORTWK files at all. You are getting hold of 1,500+ cylinders of space that you don't need, but will hold to the end of the step.

I'd suggest your site investigates using dynamic allocation of workspace. It will greatly reduce space contention judging by the JCL you have shown.

You also shouldn't specify any DCB information for the output file (SORTOUT), as DFSORT will provide all that, and best it is done in one place only for clarity and to avoid confusion/error on maintenance.