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

Help needed on DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Mar 20, 2009 12:04 pm
Reply with quote

Following is the DB2 QUERY:
Code:
SELECT SOURCE_CODE, DATA_SOURCE, ICN, REL_LINE_NBR,
       CONTRACT_NBR, MEMBER_NBR, ADJUST_INDIC,
       SUM (BILLED_AMT) BILL, SUM (PAYMENT_AMT) PYMT,
       SUM (WITHHOLD_AMT) WHLD, COUNT(*) CTR,
       MAX (FIN_CYCLE_DT) FIN_CYCLE_DT,'1'
FROM DSNV.DWS_CLAIMS_L_MTH
GROUP BY SOURCE_CODE, DATA_SOURCE, ICN, REL_LINE_NBR,
         CONTRACT_NBR, MEMBER_NBR, ADJUST_INDIC
ORDER BY SOURCE_CODE, DATA_SOURCE, ICN, REL_LINE_NBR,
         CONTRACT_NBR, MEMBER_NBR, ADJUST_INDIC;


My requirement is, I want to execute the same query using SORT.
I can extract data from table using select * from DSNV.DWS_CLAIMS_L_MTH, which can be input to SORT

Code:
LAYOUT OF INPUT FILE:      BYTES                                STARTING POSITION
SOURCE_CODE            - PIC X(2)                              19
DATA_SOURCE             - PIC X(2)                              106
ICN, REL_LINE_NBR       - PIC X(16)                             3
CONTRACT_NBR            - PIC X(12)                             42
MEMBER_NBR              - PIC X(2)                              54
ADJUST_INDIC            - PIC X(1)                              64
BILLED_AMT              - PIC  S9(9)V9(2) USAGE COMP-3          289
FIN_CYCLE_DT            - PIC  S9(9)V9(2) USAGE COMP-3          65
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Fri Mar 20, 2009 12:58 pm
Reply with quote

Do you want to format the output file by mapping each field to any specific bytes or can it be retained as it is in the input file.
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Fri Mar 20, 2009 1:01 pm
Reply with quote

Positions and Pic class of Payment_amt and withhold_amt
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Mar 20, 2009 1:35 pm
Reply with quote

I want to reformat the output file having only those fields which are present in selct query
Back to top
View user's profile Send private message
bnveena

New User


Joined: 29 May 2007
Posts: 50
Location: hyderabad

PostPosted: Fri Mar 20, 2009 1:39 pm
Reply with quote

Payment_amt S9(9)V9(2) USAGE COMP-3 295

withhold_amt S9(9)V9(2) USAGE COMP-3 302
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Mar 20, 2009 10:05 pm
Reply with quote

bnveena,

The following DFSORT JCL will give you the desired results.

Using an INREC we only pick the fileds we are interested. I Put all your GROUP by fields at pos 1 and we sort on the first 35 bytes which is your GROUP BY clause length and using outfil sections we feature we get the desired results.

When you have GROUP BY the ORDER BY is a mute unless your order by clause is different from the Group by.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD DSN=Your unload file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  INREC BUILD=(019,02,                 $ SOURCE CODE         
               106,02,                 $ DATA SOURCE         
               003,16,                 $ ICN,REL LINE NBR   
               042,12,                 $ CONTRACT NUMBER     
               054,02,                 $ MEMBER NUMBER       
               064,01,                 $ ADJUST INDIC       
               065,06,                 $ FIN CYCLE DT       
               289,06,                 $ BILLED AMT         
               295,06,                 $ PAYMENT AMT         
               302,06)                 $ WITHHOLD AMT       
                                                             
  SORT FIELDS=(1,35,CH,A)                                   
                                                             
  OUTFIL REMOVECC,NODETAIL,BUILD=(64X),                     
  SECTIONS=(1,35,                                           
  TRAILER3=(1,35,                                           
            TOT=(42,06,PD,PD,LENGTH=6),                     
            TOT=(48,06,PD,PD,LENGTH=6),                     
            TOT=(54,06,PD,PD,LENGTH=6),                     
            COUNT=(BI,LENGTH=4),                             
            MAX=(36,06,PD,PD,LENGTH=6),                     
            '1'))                     
/*
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts Mainframe Programmer with CICS Skill... Mainframe Jobs 0
Search our Forums:

Back to Top