Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting invalid numeric packed decimal to valid numeric

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

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Thu Apr 27, 2006 2:38 am    Post subject: Converting invalid numeric packed decimal to valid numeric
Reply with quote

Hi,

Trying in DFSORT to convert invalid numeric value(low-values) in PD field to valid PD so I can use the edit mask option to convert to numeric text.

Can you suggest way. I've tried the following with no success:

INREC IFTHEN=(WHEN=(298,6,PD,EQ,X'000000000000'),
OVERLAY=(X'00000000000C'))

Any assistance would be appreciated.

Thanks
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: Thu Apr 27, 2006 2:52 am    Post subject:
Reply with quote

You're on the right track but your syntax is a little off. You can use this DFSORT INREC statement:

Code:

  INREC IFTHEN=(WHEN=(298,6,BI,EQ,+0),   
     OVERLAY=(298:+0,TO=PD,LENGTH=6))   


If you prefer hex constants, this would work too:

Code:

  INREC IFTHEN=(WHEN=(298,6,BI,EQ,X'000000000000'),
    OVERLAY=(298:X'00000000000C'))                 
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Thu Apr 27, 2006 10:34 pm    Post subject: Converting invalid numeric packed decimal to valid numeric
Reply with quote

Thanks, Frank. I got it to work with the syntax you requested.

Unfortunately, the field I am overlaying is invalid data with different hex values, not always x'000000000000'. Is there a way to replace any invalid data as you would in COBOL using not numeric check.

Also, I had to first overlay data in one sort step and then bring to another step to use the edit option298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-).
Otherwise I was getting data exception.

Any advice would be appreciated
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: Thu Apr 27, 2006 11:55 pm    Post subject:
Reply with quote

Quote:
Also, I had to first overlay data in one sort step and then bring to another step to use the edit option298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-).
Otherwise I was getting data exception.


You don't need two steps. You can do it all in one step/pass in several ways with INREC and OUTREC (or OUTREC and OUTFIL) or just with IFTHEN.

Quote:
Unfortunately, the field I am overlaying is invalid data with different hex values, not always x'000000000000'. Is there a way to replace any invalid data as you would in COBOL using not numeric check.


Well, I don't know COBOL, but you can use DFSORT's new NUM function in z/OS DFSORT V1R5 PTF PK90007 or DFSORT R14 PTF PK90006 to check for numerics or non-numerics and do the edit. You didn't say what you wanted to replace the bad values with, so I'll assume it's P'0'. You could use:

Code:

   INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),   
        BUILD=(...,
           298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),
           ...)),
      IFTHEN=(WHEN=NONE,
        BUILD=(...,
           298:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),
           ...))


If you don't have the April, 2006 DFSORT PTF, ask your System Programmer to install it.
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Fri Apr 28, 2006 2:32 am    Post subject:
Reply with quote

Hi Frank,

I tried your syntax and received following error:

Code:

0 BLOCKSET     SORT  TECHNIQUE SELECTED                                 
1 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 16:56 ON THU APR
                                                                       
    SORT FIELDS=(1,8,CH,A)                                             
    ALTSEQ CODE=(0040,4B40,0F40)                                       
    INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),                               
                                    $                                   
E COMPARISON FIELD ERROR                                               
          BUILD=(298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))               
          $                                                             
0 STATEMENT DEFINER ERROR                                               
3 END OF DFSORT                                                         


Is this becase I do not have the right DFSORT PTF?

Thanks
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: Fri Apr 28, 2006 3:54 am    Post subject:
Reply with quote

Quote:
Is this becase I do not have the right DFSORT PTF?


Yes. As I said, you need DFSORT R14 PTF PK90006 to use the new NUM function. Ask your System Programmer to install it.
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Mon May 08, 2006 9:57 pm    Post subject: Numeric validation
Reply with quote

Hi Frank,

We now have the proper PTF. I ran using above code you gave me and my results are not correct.

See code I used:

SORT FIELDS=COPY
ALTSEQ CODE=(0040,4B40,0F40)
INCLUDE COND=(1,8,CH,EQ,C'FF000081')
INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
BUILD=(298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))

There are 2 records that are selected. The first record shows up fine and had correct data in position 298. The second record has low-values in position 298 and on output file the record is all spaces except for position 298 which is formated with zeroes.

Does the ifthen and build only pass that field when condition is true. If so,
I would have to include all fiedls in the inrec statement for all fields in BUILD=(...,298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS,...).

Please advise.

Thanks in advance for your help.
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 May 08, 2006 10:25 pm    Post subject:
Reply with quote

I don't understand what you're doing. This is what I gave you:

Code:

 INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),   
        BUILD=(...,
           298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),
           ...)),
      IFTHEN=(WHEN=NONE,
        BUILD=(...,
           298:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),
           ...))


The ...s are for the fields before and after the ones you're changing. You need to fill those in to use BUILD successfully (but see my discussion of using OVERLAY below).

The WHEN=(logic) condition gives you +0 in your desired format for records that do not have valid PD values. The WHEN=NONE condition gives you the PD value converted to your desired format for records that do have valid PD values.

Here's what you used:

Code:

  INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
      BUILD=(298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))


Since you haven't specified any fields before or after the 298: item, you get blanks before 298 and then the +0 in your desired format for records that do not have valid PD values. Since you don't have WHEN=NONE, you get the original record (with its original length) for records that do have valid PD values.

Quote:
would have to include all fiedls in the inrec statement for all fields in BUILD=(...,298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS,...).


Since your input field is 6 bytes and your output field is 14 bytes, you can't use OVERLAY unless you want that 14 byte field to be the last field in the record. Otherwise, you will overly the bytes after the original 6 bytes. If that converted field is, in fact, the last field you want, you can use this:
Code:

 INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),     
        OVERLAY=(298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))),
      IFTHEN=(WHEN=NONE,
        OVERLAY=(298:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))


The fields before 298 will not be changed and the 14-byte overlaid field will be the last field.
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Mon May 08, 2006 11:49 pm    Post subject: Numeric conversion
Reply with quote

Hi Frank,

I saw your response. All fields before position 298 and are character fields. I was hoping to not have to name all fields in BUILD statement. I would like to use 2 sort steps, the first it to take input file that has invalid data in position 298 and convert all invalid data to numeric using the NUM feature. This file would be used in another SORT to edit position 298 where I would list all fields for output.

Step1 SORT:
INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
BUILD=(298:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))
Step2 SORT:
OUTREC FIELDS=(C'"',1,11,TRAN=ALTSEQ,C'"',C',',
C'"',12,10,TRAN=ALTSEQ,C'"',C',',
C'"',22,13,TRAN=ALTSEQ,C'"',C',',
C'"',35,01,TRAN=ALTSEQ,C'"',C',',
C'"',36,06,TRAN=ALTSEQ,C'"',C',',
C'"',42,07,TRAN=ALTSEQ,C'"',C',',
C'"',49,08,TRAN=ALTSEQ,C'"',C',',...
298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),C',',
C'"',504,01,TRAN=ALTSEQ,C'"',C',',
504,1,TRAN=ALTSEQ)

I hope this can be done without listing all fields in BUILD. Please clarify.

Thanks Frank for your response.
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 May 09, 2006 12:29 am    Post subject:
Reply with quote

Howard,

We seem to be going around in circles.

You can't overlay a 6-byte input field with a 14-byte field output field without overwriting the 8 bytes AFTER the 6-byte field.

However, since you're doing a BUILD for all the fields anyway, you could overlay the 14-byte target output field with the converted +0 field (for non-numerics) or converted input field (for numerics). But you'd have to know where exactly you're putting the converted output field. You should be able to figure that out from your OUTREC BUILD statement.

You show:

Code:

  OUTREC FIELDS=(C'"',1,11,TRAN=ALTSEQ,C'"',C',',
    ...
    298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),C',',
    ...


So you're converting the 6-byte input PD value to a 14-byte output value at some position in the output record. Let's call that output position c. Once you know what that output position is, you can use these control statements to do what you want in one pass:

Code:

* Convert non-numerics to 14-byte edited +0 value starting in
* output position c.
  INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
          OVERLAY=(c:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))),
* Convert numerics to 14-byte edited value starting in
* output position c.
        IFTHEN=(WHEN=NONE,
          OVERLAY=(c:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))
* Insert converted 14-byte edited value directly into output record
* at position c:.
  OUTREC FIELDS=(C'"',1,11,TRAN=ALTSEQ,C'"',C',',
     ...
     c,14,C',',
     ...
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Tue May 09, 2006 2:25 am    Post subject: Numeric check
Reply with quote

Frank,

My mistake. I meant to send you this:

Step1 SORT:
INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
BUILD=(298:+0)

Step2 SORT:
OUTREC FIELDS=(C'"',1,11,TRAN=ALTSEQ,C'"',C',',
C'"',12,10,TRAN=ALTSEQ,C'"',C',',
C'"',22,13,TRAN=ALTSEQ,C'"',C',',
C'"',35,01,TRAN=ALTSEQ,C'"',C',',
C'"',36,06,TRAN=ALTSEQ,C'"',C',',
C'"',42,07,TRAN=ALTSEQ,C'"',C',',
C'"',49,08,TRAN=ALTSEQ,C'"',C',',...
298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-),C',',
C'"',504,01,TRAN=ALTSEQ,C'"',C',',
504,1,TRAN=ALTSEQ)

I just wanted to convert data to valid numeric in first sort and then edit in next sort. Will try your advice you just gave.

Thanks
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Thu May 11, 2006 2:25 am    Post subject: Numeric validation
Reply with quote

Hi Frank,

I tried following and receiving error:
Code:

SORT FIELDS=COPY                                             
INCLUDE COND=(1,8,CH,EQ,C'FF000081')                         
INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),                         
       OVERLAY=(C:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))),     
      IFTHEN=(WHEN=NONE,                                     
       OVERLAY=(C:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))
OUTREC FIELDS=(C'"',1,08,TRAN=ALTSEQ,C'"',C',',               
               C,14,C',',)                                   


error with C:

Code:

    SORT FIELDS=COPY                                             
    INCLUDE COND=(1,8,CH,EQ,C'FF000081')                         
    INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),                       
           OVERLAY=(C:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))),     
                              $                                           
1 SYNTAX ERROR                                                   
          IFTHEN=(WHEN=NONE,                                     
          $                                                     
0 STATEMENT DEFINER ERROR                                       
           OVERLAY=(C:298,6,PD,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-)))
           $                                                     
0 STATEMENT DEFINER ERROR                                       
    OUTREC FIELDS=(C'"',1,08,TRAN=ALTSEQ,C'"',C',',             
                   C,14,C',',)                                   
                    $                                           


Please advise.

Thanks
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: Thu May 11, 2006 3:10 am    Post subject:
Reply with quote

You got:

Code:

                   OVERLAY=(C:+0,EDIT=(STTTTTTTTT.TTT),SIGNS=(,-))),
                             $                                       
ICE007A 1 SYNTAX ERROR                                               


Note that the $ is pointing to the : after C. C is invalid. You need to replace C with the correct output position as I explained in my earlier post.

Your last line is also invalid:

Code:

               C,14,C',',) 


Again, you need to replace C with the correct output position.
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Thu May 11, 2006 7:43 pm    Post subject: Numeric validation
Reply with quote

Hi Frank,

It works. Here is my code:

Code:

  SORT FIELDS=COPY                                                 
  INCLUDE COND=(1,8,CH,EQ,C'FF000081')                             
  INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),                           
         OVERLAY=(298:+0,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))),       
        IFTHEN=(WHEN=NONE,                                         
         OVERLAY=(298:298,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))) 
  OUTREC FIELDS=(C'"',1,08,TRAN=ALTSEQ,C'"',C',',                 
                 298,14,C',')                 


Thank you very much for all your assistance.
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: Thu May 11, 2006 8:59 pm    Post subject:
Reply with quote

Good. Glad I could help.
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Tue May 16, 2006 2:46 am    Post subject: Numeric data
Reply with quote

Hi Frank,

I am trying the above with multiple fields (pos 298 & 304); getting error:

Code:

 SORT FIELDS=COPY                                                   
 INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),                             
            OVERLAY=(298:+0,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))),       
           IFTHEN=(WHEN=NONE,                                         
           OVERLAY=(298:298,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))), 
           IFTHEN=(WHEN=(304,6,PD,NE,NUM),                             
                                $                                             
PLICATE, CONFLICTING, OR MISSING INREC OR OUTREC STATEMENT OPERANDS
        OVERLAY=(304:+0,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))),       
        $                                                         
ATEMENT DEFINER ERROR                                             
       IFTHEN=(WHEN=NONE,                                         
       $                                                           
ATEMENT DEFINER ERROR                                             
        OVERLAY=(304:304,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-)))   
        $                                                         
ATEMENT DEFINER ERROR                                             


I want to do same numeric overlay on all numeric fields. Is there a way?

Thanks in advance
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 May 16, 2006 4:05 am    Post subject:
Reply with quote

Yes, you can do it, but you have to get the syntax right and you can't overlay 298 with 14 bytes and then expect to put the next field at 304 since that is only 6 bytes away.

Here's an example of the type of DFSORT syntax you need to use:

Code:

  OPTION COPY
* If 298,6 is not valid PD numerics, set it to +0.
  INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
           OVERLAY=(298:+0,TO=PD,LENGTH=6),
             HIT=NEXT),
* If 304,6 is not valid PD numerics, set it to +0.
        IFTHEN=(WHEN=(304,6,PD,NE,NUM),
           OVERLAY=(304:+0,TO=PD,LENGTH=6))
* Convert 298 and 304 to displayable format.
  OUTREC BUILD=(1,297,
                298,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-),
                304,6,PD,EDIT=(STTTTTTTTTT.TT),SIGNS=(,-))
Back to top
View user's profile Send private message
howard

New User


Joined: 27 Apr 2006
Posts: 10

PostPosted: Wed May 17, 2006 12:59 am    Post subject: Numeric validation
Reply with quote

Thanks Frank. It works great.

What does HIT=NEXT do? Is it like an 'OR' operand for multiple IFTHEN's?
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 May 17, 2006 2:43 am    Post subject:
Reply with quote

Code:

 INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
           OVERLAY=(298:+0,TO=PD,LENGTH=6)),
        IFTHEN=(WHEN=(304,6,PD,NE,NUM),
           OVERLAY=(304:+0,TO=PD,LENGTH=6))


For the IFTHEN clauses above, HIT=NEXT is not specified for the first IFTHEN clause, so we do not continue to the second IFTHEN clause if the first IFTHEN clause is satisfied.

Code:

 INREC IFTHEN=(WHEN=(298,6,PD,NE,NUM),
           OVERLAY=(298:+0,TO=PD,LENGTH=6),
           HIT=NEXT),
        IFTHEN=(WHEN=(304,6,PD,NE,NUM),
           OVERLAY=(304:+0,TO=PD,LENGTH=6))


For the IFTHEN clauses above, HIT=NEXT is specified for the first IFTHEN clause, so we continue to the second IFTHEN clause even if the first IFTHEN clause is satisfied.

For complete details on DFSORT's IFTHEN processing, see:

http://www.ibm.com/servers/storage/support/software/sort/mvs/pdug/index.html
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 Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts IEF645I INVALID REFERBACK IN THE RC ... abdulrafi JCL & VSAM 2 Mon Aug 29, 2016 10:57 am
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us