Page 1 of 1

Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 10:35 am
by rtammire
Hi All,

I want to extract numeric data from a record.

Input Record format is as follows
--------------------------------------
Loaded 138 rows into database
Loaded 12345 rows into database
Loaded 1 row into database
Loaded 1234567 rows into database

i want to extract only counts from these records

Expected Output
-------------------
00000138
00012345
00000001
01234567

Can any one please let me know how to get this by using sort card.. Thanks in advance

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 11:12 am
by bodatrinadh
Tammire,

You can try this code

SORT FIELDS=COPY                                 
 INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),     
              %01=(ENDBEFR=C'ROW',FIXLEN=08)),   
       BUILD=(%01,JFY=(SHIFT=RIGHT))             
 OUTREC BUILD=(1,08,ZD,EDIT=(TTTTTTTT),LENGTH=08)


Note:- Tested on Synsort 1.4.0.1R.

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 12:52 pm
by rtammire
Hi Trinadh,

I have tried with the sort card which you have provided. But the thing is counts are not populating correctly in output file.

Please find below the input,output and sort card details

Input:
------
Loaded 13 rows into the database
Loaded 98 rows into the database
Loaded 3 rows into the database
Loaded 94 rows into the database
Loaded 1 rows into the database
Loaded 7 rows into the database
Loaded 51 rows into the database
Loaded 1 rows into the database
Loaded 8 rows into the database

Output:
--------
01309662
09809662
30966209
09409662
10966209
70966209
05109662
10966209
80966209

Sort Card
------------
SORT FIELDS=COPY                                   
 INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),       
              %01=(ENDBEFR=C'ROW',FIXLEN=08)),     
       BUILD=(%01,JFY=(SHIFT=RIGHT))               
 OUTREC BUILD=(1,08,ZD,EDIT=(TTTTTTTT),LENGTH=08) 


Please let me know where am doing wrong. Thank You

Code'd.

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 1:07 pm
by Pandora-Box
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTIN DD *
LOADED 13 ROWS INTO THE DATABASE
LOADED 98 ROWS INTO THE DATABASE
LOADED 3 ROWS INTO THE DATABASE
LOADED 94 ROWS INTO THE DATABASE
LOADED 1 ROWS INTO THE DATABASE
LOADED 7 ROWS INTO THE DATABASE
LOADED 51 ROWS INTO THE DATABASE
LOADED 1 ROWS INTO THE DATABASE
LOADED 8 ROWS INTO THE DATABASE
//SORTOUT DD SYSOUT=*
//SYSOUT  DD SYSOUT=*
//SYSIN   DD *
  SORT FIELDS=COPY
   INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),
                %01=(ENDBEFR=C'ROW',FIXLEN=08)),
         BUILD=(%01,JFY=(SHIFT=RIGHT))
   OUTREC BUILD=(1,08,ZD,EDIT=(TTTTTTTT),LENGTH=08)


Output

00000013
00000098
00000003
00000094
00000001
00000007
00000051
00000001
00000008


Can you show us your input and output with codetags on before complaining?

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 1:20 pm
by BillyBoyo
"Rows" is in mixed-case, "ROW" on your Sort control card is in upper-case.

When you see unexpected results, try to understand then in the context of what is known. Look at those repeating values. Ask yourself where they come from. What has the same value and follows your numbers, in the data? What are the hex values of whatever follows it, and the values you'd get if you treat them as numbers?

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 2:08 pm
by rtammire
Thanks for providing the solution.. Problem is with UPPER CASE.. now its working fine.. Thanks you

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 3:30 pm
by BillyBoyo
You can also try with this:

  SORT FIELDS=COPY
  INREC BUILD=(8,8,UFF,TO=ZD,LENGTH=8)


Have a look at the documentation for UFF and see why it works.

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 3:44 pm
by BillyBoyo
This is overly complex:

 SORT FIELDS=COPY                                   
 INREC PARSE=(%00=(ENDBEFR=C' ',FIXLEN=10),       
              %01=(ENDBEFR=C'ROW',FIXLEN=08)),     
       BUILD=(%01,JFY=(SHIFT=RIGHT))               
 OUTREC BUILD=(1,08,ZD,EDIT=(TTTTTTTT),LENGTH=08)


Here is a simpler version:

 SORT FIELDS=COPY                                   
 INREC PARSE=(%01=(STARTAFT=BLANKS,
                   ENDBEFR=BLANKS,
                   FIXLEN=08)),
      OVERLAY=(1:%01,JFY=(SHIFT=RIGHT),72X,
               1:1,08,ZD,EDIT=(TTTTTTTT))


Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 9:10 pm
by rtammire
Thanks Billyboyo.. Both the sort cards you have provided are working...But need one more help..:)

My input is like this

Input:

    (DD:INPUT-DODN1.FFB.DCR1.STMT35.LOADSTM)<
Loaded 3 rows into the database             
    (DD:INPUT-DODN1.FFB.DCR1.STMT36.LOADSTM)<
Loaded 94 rows into the database             
(DD:INPUT-DODN1.FFB.DCR1.STMT45.LOADSTM)<   
Loaded 1 rows into the database             
    (DD:INPUT-DODN1.FFB.DCR1.STMT51.LOADSTM)<
Loaded 7 rows into the database             


Expected Output: Need output in below format

STMT35  00000003
STMT36  00000094
STMT45  00000001
STMT51  00000007


Can anyone please help me on this.. it would be very helpfull if we can get output by using sort card.. Thank You

Code'd

Re: Sort Card to Extract numeric data

PostPosted: Tue Nov 27, 2012 9:42 pm
by BillyBoyo
Have a look at PARSE in you manual. Have a look at WHEN=GROUP. With PARSE you can isolate the 2nd-to-last element of that first line, and with WHEN=GROUP you can PUSH that element so that it is available when processing the next line, from where you then get the number and output the two together. You'll need OUTFIL with OMIT/INCLUDE to get rid of any excess lines (you have two input, for each one output).