Page 1 of 1

Query Related to SORT

PostPosted: Tue Aug 17, 2010 6:32 pm
by Vineet
My Requirement is I need to Reformat the File. Below I am Providing the Input Data & Desired Output Format.

Input Rec,
1         16     Hello How R U
2          8      MAINFRAME
19        2      COBOL
2          18    JCL


Expected O/P:

00000001 000000016 Hello How R U
00000002 00000008   Mainframe
00000019 00000002   COBOL
00000002 000000018  JCL

Rgds

Vineet

Re: Query Related to SORT

PostPosted: Tue Aug 17, 2010 9:40 pm
by skolusu
vineet,

What are the rules to reformat the data? What is the length of each field? are the numbers right justified? or left justified?

Re: Query Related to SORT

PostPosted: Thu Aug 19, 2010 1:37 pm
by Vineet
Hi SKOLUSU,

Below is My requirement Along with Attributes of File:

File Attribute: LRECL = 1000, Blksize = 0, RECFM = FB.

Records Appearing in INPUT File:
Input Rec:
1 16 Hello How R U ---> ( Value 1 Followed by 8 Spaces,16 Followed by 7 Spaces. Both left Justified)
2 8 MAINFRAME ---> ( Value 2 Followed by 8 Spaces,8 Followed by 8 Spaces. Both left Justified)
19 2 COBOL ---> ( Value 19 Followed by 7 Spaces,2 Followed by 8 Spaces. Both left Justified)
12 18 JCL ---> ( Value 12 Followed by 7 Spaces,18 Followed by 7 Spaces. Both left Justified)

Output Rec:
000000001 000000016 Hello How R U ( 8 Zeros Followed by 1, 7 Zeros followed by 16. Both Right Justified)
000000002 000000008 Mainframe ( 8 Zeros Followed by 2, 8 Zeros followed by 8. Both Right Justified)
000000019 000000002 COBOL ( 7 Zeros Followed by 19,8 Zeros followed by 2. Both Right Justified)
000000012 000000018 JCL ( 7 Zeros Followed by 12, 7 Zeros followed by 18. Both Right Justified)

Note: Length Of Both The Fields need To be Formatted is 9 Byte.

Thanks
Kind Rgds

Vineet Anand

Re: Query Related to SORT

PostPosted: Thu Aug 19, 2010 10:14 pm
by skolusu
Vineet,

Use the following JCL. I assumed that both numeric fields are at pos 1 and 10.


//STEP0100 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD DSN=Your input 1000 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                       
  SORT FIELDS=COPY                     
  INREC BUILD=(01,9,UFF,M11,LENGTH=9, 
               10,9,UFF,M11,LENGTH=9, 
               19,982)           
//*