Last Fields from a VB File



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Last Fields from a VB File

Postby rajesh-amigos » Mon Jan 09, 2012 5:01 pm

Hi All,

I am sure that this question might have been asked before somewhere. I tried to search the forum but couldnt get any direct answer.
So Here I am, Posting this in a new thread.

Lets say I have a VB file as below:
Rajesh14XXXXX000001
Rajesh13XXXX000001
Rajesh11XX000002
Rajesh11XX000003
Rajesh10X000004
Rajesh11XX000005
Rajesh12XXX000006
Rajesh12XXX000007
Rajesh12XX0000008
Rajesh12XX0000009


Basically there is a fixed 6 digit key at the end of each VB record.

1) How do I write a SORTCARD which gets me only the fixed 6 digit key?
2) I know that the first 4 bytes are RDW on a VB file which have the length each record. Is it possible to use this in a Sortcard?
3) Lets say Hypothetically that in columns between 7 and 8 I have the starting column of the key; e.g 14 in the first record. Is it possible to use this in a Sortcard to get the 6 digit key?

I am sorry if this sounds stupid, But in my current organisation I dont get to work on DFSORT often and hence my prior knowledge is a little hazy.
Would appreciate pointers, even if there is no direct answer.

Thanks,
Rajesh
rajesh-amigos
 
Posts: 1
Joined: Mon Jan 09, 2012 4:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Last Fields from a VB File

Postby Frank Yaeger » Tue Jan 10, 2012 2:00 am

DFSORT does not have any built-in functions for calculating a position from a field, but you can use a series of IFTHEN clauses to do what you want like this (note that your starting column does NOT include the 4-byte RDW, so we have to add 4, e.g. 14 = 14 + 4 = 18).

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (FB/6)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=(11,2,CH,EQ,C'10'),BUILD=(1,4,14,6)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C'11'),BUILD=(1,4,15,6)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C'12'),BUILD=(1,4,16,6)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C'13'),BUILD=(1,4,17,6)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C'14'),BUILD=(1,4,18,6))
  OUTFIL VTOF,BUILD=(5,6)
/*


Alternatively, if you use the pattern of the data (nonnumeric, numeric starting in position 13) instead of the column value, you can use DFSORT's PARSE function like this:

  OPTION COPY                                                       
  INREC PARSE=(%01=(ABSPOS=13,FIXLEN=6,                             
         STARTAT=C'0',STARTAT=C'1',STARTAT=C'2',STARTAT=C'3',       
         STARTAT=C'4',STARTAT=C'5',STARTAT=C'6',STARTAT=C'7',       
         STARTAT=C'8',STARTAT=C'9')),                               
        BUILD=(1,4,%01)                                             
  OUTFIL VTOF,BUILD=(5,6)                                           
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post