Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Mon Oct 12, 2009 1:15 pm    Post subject: sort with edit fields I have an existing sort OUTREC FIELDS=(1,19,UFF,EDIT=(TTTTTTTTTTTTTTTT.TT)) Input value would be: 234500.67 Output will be: 0000000000234500.67 but this sort is not giving expected results when the input value is entered with decimal values. For ex: i/p 234567 output is given as 0000000000002345.67 but the expected output is 0000000000234567.00 Could any one of you suggest how this can be handled in sort?

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

 Posted: Mon Oct 12, 2009 8:55 pm    Post subject: Are you saying that the input values may or may not have the decimal places? What exactly would the values with and without the decimal places look like in the field? Are they left aligned, right aligned or what? Can a value have only no decimal places, one decimal place or two decimal places or are there other variatons? Please show an example of your input records with the possible variations in the input value, and the expected output records. Give the starting position and length of all relevant fields. Give the RECFM and LRECL of the input file.
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Tue Oct 13, 2009 12:53 pm    Post subject: Reply to: sort with edit fields the length of input and output is 19bytes.. LRECL=19 the input values are left aligned. the input would have maximum of two decimals. either decimal value would be entered or it would not be entered. it can be one decimal, two decimals or no decimals. For ex: Input can be:- 1345.67 1567890 23456789.8 Output should be: 0000000000001345.67 0000000001567890.00 0000000023456789.80 I coded a sort with if then condition luking for substring search for a decimal point.here is the sort card :- INREC IFTHEN=(WHEN=(1,19,SS,NE,C'.'), OVERLAY=(1:1,16,UFF,EDIT=(TTTTTTTTTTTTTTTT),17:C'.',18:C'00')) SORT FIELDS=COPY OUTREC FIELDS=(1,19,UFF,EDIT=(TTTTTTTTTTTTTTTT.TT)) So, when there is no decimal point I'm using overlay condition, when there is decimal its handled in edit fields. Is there any other way to solve this issue.??
Anu Vijayaraghavan

New User

Joined: 13 Feb 2008
Posts: 16
Location: Chennai

Posted: Tue Oct 13, 2009 4:02 pm    Post subject:

The sort card which you have provided works fine.
Find below the sortstep and its corresponding output

 Code: //S1       EXEC  PGM=SORT                                                //SYSOUT   DD  SYSOUT=*                                                  //SORTIN   DD *                                                          1345.67                                                                  1567890                                                                  23456789.8                                                              //SORTOUT  DD SYSOUT=*                                                  //SYSIN    DD    *                                                        INREC IFTHEN=(WHEN=(1,19,SS,NE,C'.'),                                    OVERLAY=(1:1,16,UFF,EDIT=(TTTTTTTTTTTTTTTT),17:C'.',18:C'00'))          SORT FIELDS=COPY                                                        OUTREC FIELDS=(1,19,UFF,EDIT=(TTTTTTTTTTTTTTTT.TT))                    /*

output:

 Code: ********************************* TOP OF DATA ********************************** 0000000000001345.67                                                              0000000001567890.00                                                              0000000002345678.98                                                              ******************************** BOTTOM OF DATA ********************************
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Tue Oct 13, 2009 4:06 pm    Post subject: Reply to: sort with edit fields Could you please check the last record the value before decimal in input got moved to after decimal. ie., 23456789.8 is coming as 0000000002345678.98 but., i need tat value as 000000023456789.80
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Tue Oct 13, 2009 9:14 pm    Post subject:

You can use these DFSORT control statements to do what you asked for:

 Code: OPTION COPY   INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(ENDBEFR=C'.',FIXLEN=16),                %02=(FIXLEN=2)),         BUILD=(%01,UFF,TO=ZD,LENGTH=16,C'.',%02)),      IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=18,ENDPOS=19,        INOUT=(C' ',C'0')))
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Wed Oct 14, 2009 7:05 pm    Post subject: Reply to: sort with edit fields Thanks Frank.. But I have some clarification... What if the numeric value starts in 11 position .. I mean if the LRECL=40 Input is like XXXXXXXXXX945678.55 YYYYYYYYYYYY12345.5 ZZZZZZZZZZZ3456 Output should be: XXXXXXXXXX000000000945678.55 YYYYYYYYYYYY0000000000012345.50 ZZZZZZZZZZZ000000000003456.00 Could you please help me out with this?
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Wed Oct 14, 2009 7:07 pm    Post subject: Reply to: sort with edit fields sorry lrecl =30 not 40.. the numbers are left justified..
Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

Posted: Wed Oct 14, 2009 10:18 pm    Post subject:

You said the numbers were left justified and showed them starting in position 1, so silly me I assumed that's what they looked like. If they really start in position 11, why didn't you say that in the first place and save us both some time.

Before I spend more time on this, let me make sure I understand what you want. I think you're showing input numeric values like this:

 Code: XXXXXXXXXX945678.55 YYYYYYYYYYYY12345.5 ZZZZZZZZZZZ3456

which are NOT left aligned as you said they were. The first number starts in position 11, the second number starts in position 13 and the third number starts in position 12. Is that what they really look like or do they really look like this (left aligned starting in position 11)?

 Code: XXXXXXXXXX945678.55 YYYYYYYYYY12345.5 ZZZZZZZZZZ3456

Likewise, what do the expected output records really look like? Please use code tags around your examples so we can see what they really look like.
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

Posted: Wed Oct 14, 2009 10:33 pm    Post subject: Reply to: sort with edit fields

input would look like as you have given in second code.. and output would be as below:

 Code: XXXXXXXXXX0000000000945678.55 YYYYYYYYYY0000000000012345.50 ZZZZZZZZZZ0000000000003456.00

it will always start at position 11.
Skolusu

Senior Member

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

Posted: Thu Oct 15, 2009 2:26 am    Post subject: Reply to: sort with edit fields

praanu,

Use the following Control cards

 Code: //SYSIN    DD *                                                    SORT FIELDS=COPY                                                  INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(ABSPOS=11,ENDBEFR=C'.',                    FIXLEN=16),%02=(FIXLEN=2)),                            OVERLAY=(11:%01,UFF,TO=ZD,LENGTH=16,C'.',%02)),                   IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=28,ENDPOS=29,                   INOUT=(C' ',C'0')))                                      //*
Praanu

New User

Joined: 27 Mar 2009
Posts: 8
Location: chennai

 Posted: Thu Oct 15, 2009 10:29 am    Post subject: Reply to: sort with edit fields Thank you !! its working great
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am How to Generate JCL using Sort naveen katkuri DFSORT/ICETOOL 7 Tue Mar 13, 2018 3:50 pm Need better approach to create a sort... Vamshi Veludandi DFSORT/ICETOOL 8 Thu Mar 08, 2018 5:59 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us