Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
sort with edit fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Mon Oct 12, 2009 1:15 pm    Post subject: sort with edit fields
Reply with quote

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?
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Mon Oct 12, 2009 8:55 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Tue Oct 13, 2009 12:53 pm    Post subject: Reply to: sort with edit fields
Reply with quote

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.??
Back to top
View user's profile Send private message
Anu Vijayaraghavan

New User


Joined: 13 Feb 2008
Posts: 16
Location: Chennai

PostPosted: Tue Oct 13, 2009 4:02 pm    Post subject:
Reply with quote

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 ********************************
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Tue Oct 13, 2009 4:06 pm    Post subject: Reply to: sort with edit fields
Reply with quote

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
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Oct 13, 2009 9:14 pm    Post subject:
Reply with quote

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')))
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Wed Oct 14, 2009 7:05 pm    Post subject: Reply to: sort with edit fields
Reply with quote

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?
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Wed Oct 14, 2009 7:07 pm    Post subject: Reply to: sort with edit fields
Reply with quote

sorry lrecl =30 not 40..

the numbers are left justified..
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Oct 14, 2009 10:18 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

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

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.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

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

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')))                                     
//*
Back to top
View user's profile Send private message
Praanu

New User


Joined: 27 Mar 2009
Posts: 8
Location: chennai

PostPosted: Thu Oct 15, 2009 10:29 am    Post subject: Reply to: sort with edit fields
Reply with quote

Thank you !! its working great
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us