Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Training on numeric fields data formats

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Thu Aug 01, 2019 8:15 pm    Post subject: Training on numeric fields data formats
Reply with quote

This topic is supposed to add some clarification to the whole mess in misunderstanding of data formats, and how to process different data correctly.
When I do not understand the stuff of any kind I usually create a tiny test for myself to understand it better, rather than screaming on forums:
"I have a requirement to convert one unknown file to another unknown file. Please, help!!!"

Here is one sample to clarify major numeric data conversions and considerations provided by both SYNCSORT, and DFSORT utilities (because both of them are based on fundamental IBM machine data formats, rather than on sophisticated/messy/boring data definitions invented in hundreds of programming languages).

Code:
//*===============================
//* CONVERSION OF NUMERIC FORMATS
//*===============================
//SORTNUMS EXEC PGM=SORT         
//*                               
//SYSOUT   DD  SYSOUT=*           
//*                               
//SORTIN   DD  *                 
 9999999                         
 8888888                         
 7777777                         
 6666666                         
 5555555                         
 4444444                         
 3333333                         
 2222222                         
 1111111                         
 0000000                         
 999999.                         
 88888.8                         
 7777.77                         
 666.666                         
 55.5555                         
 4.44444                         
 .333333                         
 2.22                             
    11.1                         
 000.000                         
-9999999                         
-8888888                         
-7777777                         
-6666666                         
-5555555                         
-4444444                         
-3333333                         
-2222222                         
-1111111                         
-0000000                         
-999999.                                                 
-88888.8                                                 
-7777.77                                                 
-666.666                                                 
-55.5555                                                 
-4.44444                                                 
-.333333                                                 
-2.22                                                     
-   11.1                                                 
-000.000                                                 
//*                                                       
//SORTOUT  DD  SYSOUT=*                                   
//HEXOUT   DD  SYSOUT=*           
//*                                                       
//SYSIN    DD  *                                         
 INREC BUILD=(1,8,                                       
            X,1,8,HEX,                                   
            X,1,8,SFF,ADD,+0,TO=ZD,LENGTH=8,             
            X,1,8,SFF,ADD,+0,TO=PD,LENGTH=5,             
            X,1,8,SFF,ADD,+0,TO=BI,LENGTH=4,             
            X,1,8,SFF,ADD,+0,TO=FI,LENGTH=4)             
*                                                         
 SORT FIELDS=COPY                                         
*                                                         
 OUTFIL FNAMES=(SORTOUT)                                 
*                                                         
 OUTFIL FNAMES=(HEXOUT),                                 
        REMOVECC,                                         
        BUILD=(1,8,                                       
             X,10,16,                                     
             X,27,8,                                     
             X,27,8,HEX,                                 
             X,36,5,HEX,                                 
             X,42,4,HEX,                                 
             X,47,4,HEX),                                 
       HEADER1=(C' CH       CH->HEX          SFF->ZD ',   
                C' ZD->HEX         ',                     
                C' SFF->PD    SFF->BI  SFF->FI',         
              /,C'-------- ---------------- -------- ',   
                C'---------------- ',                     
                C'---------- -------- --------')   
*                                                   
 END                                               
//*


I suppose the results are self-explanatory.
Code:
 CH       CH->HEX          SFF->ZD  ZD->HEX          SFF->PD    SFF->BI  SFF->FI
-------- ---------------- -------- ---------------- ---------- -------- --------
 9999999 40F9F9F9F9F9F9F9 0999999I F0F9F9F9F9F9F9C9 009999999C 0098967F 0098967F
 8888888 40F8F8F8F8F8F8F8 0888888H F0F8F8F8F8F8F8C8 008888888C 0087A238 0087A238
 7777777 40F7F7F7F7F7F7F7 0777777G F0F7F7F7F7F7F7C7 007777777C 0076ADF1 0076ADF1
 6666666 40F6F6F6F6F6F6F6 0666666F F0F6F6F6F6F6F6C6 006666666C 0065B9AA 0065B9AA
 5555555 40F5F5F5F5F5F5F5 0555555E F0F5F5F5F5F5F5C5 005555555C 0054C563 0054C563
 4444444 40F4F4F4F4F4F4F4 0444444D F0F4F4F4F4F4F4C4 004444444C 0043D11C 0043D11C
 3333333 40F3F3F3F3F3F3F3 0333333C F0F3F3F3F3F3F3C3 003333333C 0032DCD5 0032DCD5
 2222222 40F2F2F2F2F2F2F2 0222222B F0F2F2F2F2F2F2C2 002222222C 0021E88E 0021E88E
 1111111 40F1F1F1F1F1F1F1 0111111A F0F1F1F1F1F1F1C1 001111111C 0010F447 0010F447
 0000000 40F0F0F0F0F0F0F0 0000000{ F0F0F0F0F0F0F0C0 000000000C 00000000 00000000
 999999. 40F9F9F9F9F9F94B 0099999I F0F0F9F9F9F9F9C9 000999999C 000F423F 000F423F
 88888.8 40F8F8F8F8F84BF8 0088888H F0F0F8F8F8F8F8C8 000888888C 000D9038 000D9038
 7777.77 40F7F7F7F74BF7F7 0077777G F0F0F7F7F7F7F7C7 000777777C 000BDE31 000BDE31
 666.666 40F6F6F64BF6F6F6 0066666F F0F0F6F6F6F6F6C6 000666666C 000A2C2A 000A2C2A
 55.5555 40F5F54BF5F5F5F5 0055555E F0F0F5F5F5F5F5C5 000555555C 00087A23 00087A23
 4.44444 40F44BF4F4F4F4F4 0044444D F0F0F4F4F4F4F4C4 000444444C 0006C81C 0006C81C
 .333333 404BF3F3F3F3F3F3 0033333C F0F0F3F3F3F3F3C3 000333333C 00051615 00051615
 2.22    40F24BF2F2404040 0000022B F0F0F0F0F0F2F2C2 000000222C 000000DE 000000DE
    11.1 40404040F1F14BF1 0000011A F0F0F0F0F0F1F1C1 000000111C 0000006F 0000006F
 000.000 40F0F0F04BF0F0F0 0000000{ F0F0F0F0F0F0F0C0 000000000C 00000000 00000000
-9999999 60F9F9F9F9F9F9F9 0999999R F0F9F9F9F9F9F9D9 009999999D 0098967F FF676981
-8888888 60F8F8F8F8F8F8F8 0888888Q F0F8F8F8F8F8F8D8 008888888D 0087A238 FF785DC8
-7777777 60F7F7F7F7F7F7F7 0777777P F0F7F7F7F7F7F7D7 007777777D 0076ADF1 FF89520F
-6666666 60F6F6F6F6F6F6F6 0666666O F0F6F6F6F6F6F6D6 006666666D 0065B9AA FF9A4656
-5555555 60F5F5F5F5F5F5F5 0555555N F0F5F5F5F5F5F5D5 005555555D 0054C563 FFAB3A9D
-4444444 60F4F4F4F4F4F4F4 0444444M F0F4F4F4F4F4F4D4 004444444D 0043D11C FFBC2EE4
-3333333 60F3F3F3F3F3F3F3 0333333L F0F3F3F3F3F3F3D3 003333333D 0032DCD5 FFCD232B
-2222222 60F2F2F2F2F2F2F2 0222222K F0F2F2F2F2F2F2D2 002222222D 0021E88E FFDE1772
-1111111 60F1F1F1F1F1F1F1 0111111J F0F1F1F1F1F1F1D1 001111111D 0010F447 FFEF0BB9
-0000000 60F0F0F0F0F0F0F0 0000000{ F0F0F0F0F0F0F0C0 000000000C 00000000 00000000
-999999. 60F9F9F9F9F9F94B 0099999R F0F0F9F9F9F9F9D9 000999999D 000F423F FFF0BDC1
-88888.8 60F8F8F8F8F84BF8 0088888Q F0F0F8F8F8F8F8D8 000888888D 000D9038 FFF26FC8
-7777.77 60F7F7F7F74BF7F7 0077777P F0F0F7F7F7F7F7D7 000777777D 000BDE31 FFF421CF
-666.666 60F6F6F64BF6F6F6 0066666O F0F0F6F6F6F6F6D6 000666666D 000A2C2A FFF5D3D6
-55.5555 60F5F54BF5F5F5F5 0055555N F0F0F5F5F5F5F5D5 000555555D 00087A23 FFF785DD
-4.44444 60F44BF4F4F4F4F4 0044444M F0F0F4F4F4F4F4D4 000444444D 0006C81C FFF937E4
-.333333 604BF3F3F3F3F3F3 0033333L F0F0F3F3F3F3F3D3 000333333D 00051615 FFFAE9EB
-2.22    60F24BF2F2404040 0000022K F0F0F0F0F0F2F2D2 000000222D 000000DE FFFFFF22
-   11.1 60404040F1F14BF1 0000011J F0F0F0F0F0F1F1D1 000000111D 0000006F FFFFFF91
-000.000 60F0F0F04BF0F0F0 0000000{ F0F0F0F0F0F0F0C0 000000000C 00000000 00000000
Back to top
View user's profile Send private message

sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Thu Aug 08, 2019 9:08 pm    Post subject:
Reply with quote

Training #2
How to handle flexible decimal point for numeric input data

There are many questions on the issue with SORT utilities (either DFSORT, or SYNCSORT - doesn't matter): how to re-order data including numeric fields with decimal point at different positions of this field? Take this as an example:
Code:
----+----1----+----2----+----3
+00009999999
-00009999999
+09999999.99
-09999999.99
+00999999.99
-00999999.99
+00099999.99
-00099999.99
+00009999.99
-00009999.99
+00000999.99
-00000999.99
+00000099.99
-00000099.99
+00000009.99
-00000009.99
+00000000.99
-00000000.99
+00000000.09
-00000000.09
+00000000.00
-00000000.00
+         9.
-         9.
+        9.9
-        9.9
+       9.99
-       9.99
+      9.99
-      9.99
+     9.99 
-     9.99 
+    0.99   
-    0.99   
+   0.990000
-   0.990000
+  0.9900000
-  0.9900000
+ 0.99000000
- 0.99000000
+ .99       
- .99       
+.9         
-.9

Any attempt of stupid sort using formats like CH, SFF, UFF, ZD, PD, BI, FI either produced unacceptable results, or even caused SORT utility to fail due to unacceptable data format, with either SORT error message, or System ABEND like well-known S0C7. The best of possible results may look as follows
Code:
----+----1----+----2----+----3
+         9.
+        9.9
+       9.99
+      9.99
+     9.99 
+    0.99   
+   0.990000
+  0.9900000
+ .99       
+ 0.99000000
+.9         
+00000000.00
+00000000.09
+00000000.99
+00000009.99
+00000099.99
+00000999.99
+00009999.99
+00009999999
+00099999.99
+00999999.99
+09999999.99
-         9.
-        9.9
-       9.99
-      9.99
-     9.99 
-    0.99   
-   0.990000
-  0.9900000
- .99       
- 0.99000000
-.9         
-00000000.00
-00000000.09
-00000000.99
-00000009.99
-00000099.99
-00000999.99
-00009999.99
-00009999999
-00099999.99
-00999999.99
-09999999.99


In order to produce reasonable and meaningful results all free-text numerical data which include: decimal points, and/or +/- signs, and/or spaces, need to be aligned by their decimal point position, and/or converted to one of numeric formats recognized by SORT utilities; those are - SFF, PD, ZD, FI.
If positive/negative values are not the case, then also formats UFF, BI can be used.
Some dilettant methods are often used to handle only specific cases of data; after any minor variation in data the process either fails, or quietly produces wrong results.
Below is one of much more general approach how to achieve this result in a regular professional way.
Code:
* Convert free-text numerics to aligned value columns in 4 formats     
 INREC IFTHEN=(WHEN=INIT,                    apply to any record       
               PARSE=(%1=(ABSPOS=1,          detect whole part         
                          ENDBEFR=C'.',      ending with dot           
                          FIXLEN=12),        max len of the whole part 
                      %2=(ENDBEFR=BLANKS,    detect fractional part     
*                         optional specific field separators:           
*                         ENDBEFR=C',',      | support CSV with comma   
*                         ENDBEFR=C';',      | support CSV non-USA     
*                         ENDBEFR=X'05',     | support TAB separator   
*                         ENDBEFR=X'0A',     | support LF separator     
*                         ENDBEFR=X'0D',     | support CR separator     
                          FIXLEN=2)),        max two digits, no more   
*              Place two parts of number left and right from dec point 
               OVERLAY=(14:%1,SQZ=(SHIFT=RIGHT),  place whole part     
                           C'.',                  dec '.' (view only)   
                           %2,SQZ=(SHIFT=LEFT,    place fraction part   
                                   TRAIL=C'00')), fill zeroes if none   
                HIT=NEXT),         allow second conversion pass         
*       small trick: second pass of field conversion                   
        IFTHEN=(WHEN=INIT,                   apply to any record       
                OVERLAY=(38:14,15,SFF,                                 
                            ADD,+0,         dummy arithmetic to fix dec
                            TO=PD,LENGTH=7, convert to S9(11)V99 COMP-3
                         53:14,15,SFF,                                 
                            TO=FI,LENGTH=4, convert to S9(8)V99 COMP-1 
                         62:14,15,SFF,                                 
                            ADD,+0,         dummy arithmetic to fix dec
                            TO=ZD,LENGTH=8)) convert to S9(11)V99.     
*                                                                       
* Correct sorting by any of 4 converted normalized values               
 SORT FIELDS=(14,15,SFF,A)  sort by aligned and normalized SFF format   
*SORT FIELDS=(38,08,PD,A)   sort by aligned packed decimal format       
*SORT FIELDS=(53,04,FI,A)   sort by aligned binary format               
*SORT FIELDS=(62,08,ZD,A)   sort by aligned unpacked decimal format     
*                                                                       
* Unpack internal formats to print contents                           
 OUTREC IFTHEN=(WHEN=INIT,                                             
                OVERLAY=(38:38,7,HEX,     unpack COMP-3 as hexadecimal
                         53:53,4,HEX))    unpack COMP-1 as hexadecimal
*                                                                     
 OUTFIL REMOVECC,                                                     
        HEADER1=(C'  CH/SFF     ',                                     
                 C' WHOLE PART .FRACTION   ',                         
                 C' SFF->PD       ',                                   
                 C' SFF->FI ',                                         
                 C' SFF->ZD',                                         
               /,C'--as is-----|',                                     
                 C'--as is----- ----------|',                         
                 C'--hex---------|',                                   
                 C'--hex---|',                                         
                 C'--as is-')                                         
                                                                       
 END


The produced output looks much better than any straightforward sort of such flexible format data.
Code:
  CH/SFF      WHOLE PART .FRACTION    SFF->PD        SFF->FI  SFF->ZD
--as is-----|--as is----- ----------|--hex---------|--hex---|--as is-
-09999999.99    -09999999.99         0000999999999D C4653601 9999999R
-00009999999 -00009999999.00         0000999999900D C4653664 9999990}
-00999999.99    -00999999.99         0000099999999D FA0A1F01 9999999R
-00099999.99    -00099999.99         0000009999999D FF676981 0999999R
-00009999.99    -00009999.99         0000000999999D FFF0BDC1 0099999R
-00000999.99    -00000999.99         0000000099999D FFFE7961 0009999R
-00000099.99    -00000099.99         0000000009999D FFFFD8F1 0000999R
-00000009.99    -00000009.99         0000000000999D FFFFFC19 0000099R
-       9.99           -9.99         0000000000999D FFFFFC19 0000099R
-      9.99            -9.99         0000000000999D FFFFFC19 0000099R
-     9.99             -9.99         0000000000999D FFFFFC19 0000099R
-        9.9           -9.90         0000000000990D FFFFFC22 0000099}
-         9.           -9.00         0000000000900D FFFFFC7C 0000090}
-00000000.99    -00000000.99         0000000000099D FFFFFF9D 0000009R
-    0.99              -0.99         0000000000099D FFFFFF9D 0000009R
-   0.990000           -0.99         0000000000099D FFFFFF9D 0000009R
-  0.9900000           -0.99         0000000000099D FFFFFF9D 0000009R
- 0.99000000           -0.99         0000000000099D FFFFFF9D 0000009R
- .99                   -.99         0000000000099D FFFFFF9D 0000009R
-.9                     -.90         0000000000090D FFFFFFA6 0000009}
-00000000.09    -00000000.09         0000000000009D FFFFFFF7 0000000R
+00000000.00    +00000000.00         0000000000000C 00000000 0000000{
-00000000.00    -00000000.00         0000000000000C 00000000 0000000{
+00000000.09    +00000000.09         0000000000009C 00000009 0000000I
+.9                     +.90         0000000000090C 0000005A 0000009{
+00000000.99    +00000000.99         0000000000099C 00000063 0000009I
+    0.99              +0.99         0000000000099C 00000063 0000009I
+   0.990000           +0.99         0000000000099C 00000063 0000009I
+  0.9900000           +0.99         0000000000099C 00000063 0000009I
+ 0.99000000           +0.99         0000000000099C 00000063 0000009I
+ .99                   +.99         0000000000099C 00000063 0000009I
+         9.           +9.00         0000000000900C 00000384 0000090{
+        9.9           +9.90         0000000000990C 000003DE 0000099{
+00000009.99    +00000009.99         0000000000999C 000003E7 0000099I
+       9.99           +9.99         0000000000999C 000003E7 0000099I
+      9.99            +9.99         0000000000999C 000003E7 0000099I
+     9.99             +9.99         0000000000999C 000003E7 0000099I
+00000099.99    +00000099.99         0000000009999C 0000270F 0000999I
+00000999.99    +00000999.99         0000000099999C 0001869F 0009999I
+00009999.99    +00009999.99         0000000999999C 000F423F 0099999I
+00099999.99    +00099999.99         0000009999999C 0098967F 0999999I
+00999999.99    +00999999.99         0000099999999C 05F5E0FF 9999999I
+00009999999 +00009999999.00         0000999999900C 3B9AC99C 9999990{
+09999999.99    +09999999.99         0000999999999C 3B9AC9FF 9999999I
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Fri Aug 09, 2019 12:17 am    Post subject:
Reply with quote

I found a few typos in my example - after it had been already blocked for editing.
They can be easily found by anyone when trying and learning.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2299
Location: NY,USA

PostPosted: Fri Aug 09, 2019 9:19 pm    Post subject:
Reply with quote

This should achieve the results in one pass and in simplest and better way specially for -000.00 and +000.00 values and it can be any trailing Decimal and not just 2.

Note: It looks like a bug to me in EDIT , when '- ' passed to EDIT(STTTTT) it changes the sign to + from - which it should not have (for e.g '-.9' or '- .99') . So i have to replace first byte sign from original input to avod that happening.
Code:
//SORTOUT DD SYSOUT=*                                             
//SYSIN    DD    *                                               
 SORT FIELDS=(60,16,ZD,D,40,15,ZD,D)                             
  INREC IFTHEN=(WHEN=INIT,                                       
    PARSE=(%01=(ABSPOS=1,ENDBEFR=C'.',FIXLEN=15),%02=(FIXLEN=15)),
    OVERLAY=(1:1,15,                                             
            20:%01,SFF,EDIT=(STTTTTTTTTTTTTTT),SIGNS=(+,-),       
            40:%02,ZD,EDIT=(TTTTTTTTTTTTTTT),                     
            60:1,1,21,15))                                       
 OUTFIL BUILD=(1,15) 

Output:
Code:
+09999999.99
+00999999.99
+00099999.99
+00009999.99
+00000999.99
+00000099.99
+00000009.99
+       9.99
+      9.99
+     9.99 
+        9.9
+         9.
+00000000.99
+    0.99   
+ 0.99000000
+ .99       
+   0.990000
+  0.9900000
+.9         
+00000000.09
+00000000.00
-09999999.99
-00999999.99
-00099999.99
-00009999.99
-00000999.99
-00000099.99
-00000009.99
-     9.99 
-      9.99
-       9.99
-        9.9
-         9.
-9.         
-00000000.99
-    0.99   
-  0.9900000
-   0.990000
- .99       
- 0.99000000
-.9         
-00000000.00
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Fri Aug 09, 2019 11:02 pm    Post subject:
Reply with quote

Rohit Umarjikar wrote:
This should achieve the results in one pass and in simplest and better way specially for -000.00 and +000.00 values and it can be any trailing Decimal and not just 2.

There is no difference from my explanation.

One pass is performed in both cases.

The number of desired fraction part is optional, as expected. 2 was used as example; one can change it to whatever is needed.

There is no any bug in conversion of +/- signs by SFF; no extra efforts are needed.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2299
Location: NY,USA

PostPosted: Sat Aug 10, 2019 12:48 am    Post subject:
Reply with quote

I am talking about +/- sign conversion by EDIT and not SFF. Look at offset 20 starting and for -.9 or -.99 value. For '- spaces' EDIT converted to '+ Zeroes' instead of '-Zeroes'. In your e.g. -0000 and +0000 came together where it should have been flip flopped based on the signs but that don't make much of a difference.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Sat Aug 10, 2019 12:56 am    Post subject:
Reply with quote

Rohit Umarjikar wrote:
I am talking about +/- sign conversion by EDIT and not SFF. Look at offset 20 starting and for -.9 or -.99 value. For '- spaces' EDIT converted to '+ Zeroes' instead of '-Zeroes'. In your e.g. -0000 and +0000 came together where it should have been flip flopped based on the signs but that don't make much of a difference.

+0 and -0 are considered as equal values in all IBM-based hardware/software solutions. That's why after any SORT all +0's and -0's always go together as one group, but their order within this group remain the same as in input data (when option SORT ...EQUALS is in effect). Otherwise those values may be mixed in any order within this group of "zero values".

'-0' value can be introduced only manually; after any arithmetic operation, even simple 'MINUSZERO,PD,ADD,0' the result is mandatory converted to '+0'
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2299
Location: NY,USA

PostPosted: Sat Aug 10, 2019 1:03 am    Post subject:
Reply with quote

When you treat them as ZD the results are what I got where -000 goes on the top of the list
Code:
//S1    EXEC  PGM=SORT 
//SYSOUT    DD  SYSOUT=*
//SORTLIST  DD  SYSOUT=*
//SORTIN    DD *       
+00000                 
-00000                 
-00000                 
+00000                 
-00000                 
//SORTOUT DD SYSOUT=*   
//SYSIN    DD    *     
 SORT FIELDS=(1,6,ZD,A)

When you do with SFF , it did not care and kept the sorting order as is.
Code:
//S1    EXEC  PGM=SORT 
//SYSOUT    DD  SYSOUT=*
//SORTLIST  DD  SYSOUT=*
//SORTIN    DD *       
+00000                 
-00000                 
-00000                 
+00000                 
-00000                 
//SORTOUT DD SYSOUT=*   
//SYSIN    DD    *     
 SORT FIELDS=(1,6,SFF,A)
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Sat Aug 10, 2019 1:04 am    Post subject:
Reply with quote

Since my last example seems to be too complicated (I mixed together several examples into one), here is its simplified version: SORT only, without extra conversion to other possible formats.

Code:
* Convert free-text numerics to aligned value columns in 4 formats     
 INREC IFTHEN=(WHEN=INIT,                    apply to any record       
               PARSE=(%1=(ABSPOS=1,          detect whole part         
                          ENDBEFR=C'.',      ending with dot           
                          FIXLEN=12),        max len of the whole part
                      %2=(ENDBEFR=BLANKS,    detect fractional part   
                          FIXLEN=12)),       max 12 digits, no more   
*              Place two parts of number left and right from dec point
               OVERLAY=(14:%1,SQZ=(SHIFT=RIGHT),  place whole part     
                           C'.',                  dec '.' (view only) 
                           %2,SQZ=(SHIFT=LEFT,    place fraction part 
                                   TRAIL=C'000000000000'))) fill 0's   
* Correct sorting by converted value                                   
 SORT FIELDS=(14,23,SFF,A)  sort by aligned and normalized SFF format 
*                                                                     
 OUTFIL REMOVECC,                                                     
        HEADER1=(C'  CH/SFF     ',                                     
                 C' WHOLE PART .FRACTION   ',                         
               /,C'--as is-----|',                                     
                 C'--as is----- ----------')                           
 END


Code:
  CH/SFF      WHOLE PART .FRACTION   
--as is-----|--as is----- ---------- 
-09999999.99    -09999999.990000000000
-00009999999 -00009999999.000000000000
-00999999.99    -00999999.990000000000
-00099999.99    -00099999.990000000000
-00009999.99    -00009999.990000000000
-00000999.99    -00000999.990000000000
-00000099.99    -00000099.990000000000
-00000009.99    -00000009.990000000000
-       9.99           -9.990000000000
-      9.99            -9.990000000000
-     9.99             -9.990000000000
-        9.9           -9.900000000000
-         9.           -9.000000000000
-00000000.99    -00000000.990000000000
-    0.99              -0.990000000000
-   0.990000           -0.990000000000
-  0.9900000           -0.990000000000
- 0.99000000           -0.990000000000
- .99                   -.990000000000
-.9                     -.900000000000
-00000000.09    -00000000.090000000000
+00000000.00    +00000000.000000000000
-00000000.00    -00000000.000000000000
+00000000.09    +00000000.090000000000
+.9                     +.900000000000
+00000000.99    +00000000.990000000000
+    0.99              +0.990000000000
+   0.990000           +0.990000000000
+  0.9900000           +0.990000000000
+ 0.99000000           +0.990000000000
+ .99                   +.990000000000
+         9.           +9.000000000000
+        9.9           +9.900000000000
+00000009.99    +00000009.990000000000
+       9.99           +9.990000000000
+      9.99            +9.990000000000
+     9.99             +9.990000000000
+00000099.99    +00000099.990000000000
+00000999.99    +00000999.990000000000
+00009999.99    +00009999.990000000000
+00099999.99    +00099999.990000000000
+00999999.99    +00999999.990000000000
+00009999999 +00009999999.000000000000
+09999999.99    +09999999.990000000000
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Sat Aug 10, 2019 1:08 am    Post subject:
Reply with quote

Rohit Umarjikar wrote:
When you treat them as ZD the results are what I got where -000 goes on the top of the list

-0 isn't normal data in IBM world.

It can be entered only manually; no hardware/software arithmetic operation can produce the value -0, in any numeric format.

In order to mandatory eliminate possible -0's in input data one can use any dummy arithmetic, like "MINUSZERO,PD,ADD,0"

It's a kind of nonsense to require "-0 must be sorted as less value than +0"

Same story: requirement to consider the numeric 00000 as greater than 000 icon_razz.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2299
Location: NY,USA

PostPosted: Sat Aug 10, 2019 4:44 am    Post subject:
Reply with quote

-00000 value was always there in your sample data, I guess if removed then it solves the discussion icon_smile.gif. Second SFF and ZD gave different results when -0 is not considered by IBM. Third, why in my case EDIT changed the sign form '-' to'+' remains unresolved.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Sat Aug 10, 2019 7:23 pm    Post subject:
Reply with quote

Rohit Umarjikar wrote:
-00000 value was always there in your sample data, I guess if removed then it solves the discussion icon_smile.gif. Second SFF and ZD gave different results when -0 is not considered by IBM. Third, why in my case EDIT changed the sign form '-' to'+' remains unresolved.

Off-topic
All explained above.
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 609
Location: Maryland

PostPosted: Wed Aug 21, 2019 9:51 pm    Post subject:
Reply with quote

Training #3
Undescribed problems with 64-bit binary conversion


Typical conversion from character fields (CH, ZD, SFF, UFF) to binary (FI, BI) is performed using SORT statements like
Code:
 BUILD=(p,l,ZD,TO=FI,LENGTH=n)
 BUILD=(p,l,SFF,TO=FI,LENGTH=n)


Usually parameter LENGTH=2, or 4, or 8 to generate 16-, 32, or 64-bit binary values.

Surprisingly, when using LENGTH=8, the SORT utility, before creating 64-bits binary, first of all performs intermediate conversion to the field depending on the total number of numeric characters in the input field. The test shows that when the number of input digits is less than 16, intermediate conversion to FI,LENGTH=4 is performed.

For example in case BUILD=(1,15,ZD,TO=FI,LENGTH=8) the maximal possible value of input field would be C'999999999999999' (to be converted to X'000‭38D7EA4C67FFF' in 64-bit notation).
Nevertheless actually the highest accepted value is C'000002147483647' (which is converted to X'000000007FFFFFFF' in 64-bit notation); any larger input value causes SORT utility to issue error message "OUTREC ARITHMETIC OVERFLOW", and ABEND U0016.
Code:
 ZD,15                           FI,8           
-as is---------                 -hex------------
000000000000009                 0000000000000009
000000000000090                 000000000000005A
000000000000900                 0000000000000384
000000000009000                 0000000000002328
000000000090000                 0000000000015F90
000000000900000                 00000000000DBBA0
000000009000000                 0000000000895440
000000090000000                 00000000055D4A80
000000900000000                 0000000035A4E900
000001000000000                 000000003B9ACA00
000002000000000                 0000000077359400
000002147483647                 000000007FFFFFFF
. . . . . . next values cause ABEND U0016 . . . . .


When using BUILD=(1,16,ZD,...) or longer, no overflow occurred.
Code:
 ZD,16                           FI,8           
-as is----------                -hex------------
0000000000000009                0000000000000009
0000000000000090                000000000000005A
0000000000000900                0000000000000384
0000000000009000                0000000000002328
0000000000090000                0000000000015F90
0000000000900000                00000000000DBBA0
0000000009000000                0000000000895440
0000000090000000                00000000055D4A80
0000000900000000                0000000035A4E900
0000009000000000                0000000218711A00
0000900000000000                000000D18C2E2800
0009000000000000                0000082F79CD9000
0090000000000000                000051DAC207A000
0900000000000000                0003328B944C4000
9000000000000000                001FF973CAFA8000
9999999999999999                002386F26FC0FFFF
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extract data from n DB2 Views automat... esmeraldo All Other Mainframe Topics 4 Wed Nov 13, 2019 12:32 am
No new posts adrdssu for copy all data robyjhl JCL & VSAM 5 Tue Nov 12, 2019 11:17 pm
No new posts Convert mainframe data to .csv format... karan_reddy DFSORT/ICETOOL 10 Sat Nov 02, 2019 2:09 am
No new posts How to place name of the file where t... danielgp89 SYNCSORT 18 Thu Oct 17, 2019 12:55 am
No new posts Formatting bit fields IanWorthington DFSORT/ICETOOL 9 Thu Sep 19, 2019 6:14 pm

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