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
 

 

Dynamic Decimal validation
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Rohit Umarjikar

Senior Member


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

PostPosted: Wed Dec 05, 2012 9:20 pm    Post subject: Dynamic Decimal validation
Reply with quote

Hello Team,


Code:
 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. PROG500A.                                           
 DATA DIVISION.                                                 
 WORKING-STORAGE SECTION.                                             
 01  O-RATE                  PIC 9(2)V9(3) usage comp-3.
 01  ws-RATE                 PIC X(10).                 
 01  WS-A                             PIC 9(3) value '2'.             
 01  WS-B                             PIC 9(3) value '3'.                   
                                                                 
 LINKAGE SECTION.                                               
                                                                 
 PROCEDURE DIVISION.                                                                 
     MOVE '$3.125%'         TO WS-INTEREST-RATE                     
     PERFORM                      05-DO-VALD-DEC   
    .                                                         
05-DO-VALD-DEC.   
                                                                                                 
    EXEC SQL                                           
  SELECT DECIMAL(CHAR(REPLACE(REPLACE(             
        REPLACE(:WS-RATE,'%',''),'$','') 
                          ,',',''),40),:WS-A,:WS-B)
   INTO :O-RATE                           
   FROM SYSIBM.SYSDUMMY1                           

END-EXEC








Can WS-A and WS-B changed dynamically?

Or is there any way to create a gereic routine which can be called for any type of decimal validation?
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Dec 05, 2012 9:34 pm    Post subject: Reply to: Dynamic Decimal validation
Reply with quote

Quote:
Or is there any way to create a gereic routine which can be called for any type of decimal validation?


it is weird that after more that 50 years of IT there is still an organization which has not implemented a general use validation <function>

putting an SQL/DB2 dependency just for decimal validation and formatting is not the smartest move

been there seen that ... people almost sacked foe pseudo smart moves icon_cool.gif
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Dec 05, 2012 9:34 pm    Post subject:
Reply with quote

You wanted to change the value of Ws-a and Ws-b?

or the host variables dynamically?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Wed Dec 05, 2012 9:54 pm    Post subject:
Reply with quote

Quote:
You wanted to change the value of Ws-a and Ws-b?


Yes WS-A and WS-B needs to changed dynamically.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Dec 05, 2012 10:29 pm    Post subject:
Reply with quote

Rohit,

Did you check Enrico's reply?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Dec 05, 2012 11:06 pm    Post subject:
Reply with quote

Hello,

Many organizations do not permit using SQL statements in code that has no need to . . . .

It is rather incomplete to issue an SQL statement and not check for successful execution.

Why is this being called "validation"?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Thu Dec 06, 2012 12:36 am    Post subject:
Reply with quote

Hello Dick,

I am agree to you and others but my shop follow some standard practices and I don't have any other option than adhering to it strictly.

Validation here it means, to get the data in ZD and convert it to PD so any invaid format of ZD comes then its the error.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Thu Dec 06, 2012 12:37 am    Post subject:
Reply with quote

But the question is can WS-A and WS-B be used as shown? or any alternative for this?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7233

PostPosted: Thu Dec 06, 2012 12:47 am    Post subject: Reply to: Dynamic Decimal validation
Reply with quote

Can you say what exactly you want to happen?

NUMVAL/NUMVALC can turn "text" into numerics.

You have a simple-looking case (I see it comes from your previous topic?).

To use NUMVALC you'd use INSPECT to get rid of the percent sign. To use NUMVAL you'd need to get rid of the dollar sign as well. Is dollar the only currency symbol invoved? Can they be two-character symbols (or longer)?

The "normal" way to do this is to have a field for currency, a field for the value, and the name of the field for the value to include the word "percent". Your data-provider continues to do you a disservice, which presumably no-one is going to bother doing anything about.

If absolutely stuck with the data like that, I'd use INSPECT and UNSTRING if the "currency" part is a simple one-character, otherwise ODO...
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Dec 06, 2012 12:50 am    Post subject:
Reply with quote

You could do the same set of operations through Inspect and reference modification in Cobol or even Sort for that matter

Probably this needs to be addressed in COBOL forum
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Dec 06, 2012 12:54 am    Post subject:
Reply with quote

Hello,

Quote:
Validation here it means, to get the data in ZD and convert it to PD so any invaid format of ZD comes then its the error
Code:
MOVE '$3.125%'         TO. . .
That literal is NOT a Zoned-DECIMAL value. How is "the error" detected?

Quote:
But the question is can WS-A and WS-B be used as shown?
What happens when you run the posted sql?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Dec 06, 2012 1:20 am    Post subject: Reply to: Dynamic Decimal validation
Reply with quote

Quote:
... my shop follow some standard practices ...


OK...
but for what reason those standard idiots do not provide standard tested and working snippets for standard tasks icon_cool.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Mon Mar 25, 2013 10:08 pm    Post subject:
Reply with quote

Is querying on SYSIBM.SYSDUMMY1 is a performance issue? I mean if we do the same validations using COBOL fuctions as mentioned by you then would it be more efficient over SYSIBM.SYSDUMMY1?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 26, 2013 8:06 pm    Post subject:
Reply with quote

Hello,

Quote:
Is querying on SYSIBM.SYSDUMMY1 is a performance issue?

Suggest you not be concerned about the performance implications of using SYSIBM.SYSDUMMY1 . . . There are many other database interractions that will have more impact.

Quote:
I mean if we do the same validations using COBOL fuctions as mentioned by you then would it be more efficient over SYSIBM.SYSDUMMY1?
Which functions do you have in mind?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Tue Mar 26, 2013 8:26 pm    Post subject:
Reply with quote

Quote:
Which functions do you have in mind?


NUMVAL in COBOL or any MATH/DATE calculations.

Quote:
Suggest you not be concerned about the performance implications of using SYSIBM.SYSDUMMY1 . . . There are many other database
interractions that will have more impact.


Very true, but just would like to know is it a good practice to use SYSIBM.SYSDUMMY1 over COBOL fuctions or which one is more faster in terms of executions.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Mar 26, 2013 8:36 pm    Post subject: Reply to: Dynamic Decimal validation
Reply with quote

Quote:
Very true, but just would like to know is it a good practice to use SYSIBM.SYSDUMMY1 over COBOL fuctions or which one is more faster in terms of executions.


what is that is not clear when we tell that it is a BAD PRACTICE to have a DB2 dependency just to check for numerics ???

is this the first time in Your organization somebody has to check for a valid numerics ???

the fastest/most effective way would be to have a standard function callable in ONE simple statement to do it

pseudocode
Code:
if checknumber(number) != 0 then do
  process the format error
end


the write once use always subroutine/function could be expanded to provide more advanced application dependent facilities
BTDTGTTS

anyway from a pure performance point of view the COBOL should beat DB2 hands down
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Tue Mar 26, 2013 8:48 pm    Post subject:
Reply with quote

Quote:
anyway from a pure performance point of view the COBOL should beat DB2 hands down


Yes, Just would like to know this.

Quote:
what is that is not clear when we tell that it is a BAD PRACTICE to have a DB2 dependency just to check for numerics ???


Already it is a COBOL-DB2 program and the questions was which choice to be taken for decimal validations, by COBOL or SYSIBM.SYSDUMM1.

Quote:
is this the first time in Your organization somebody has to check for a valid numerics ???


It is already in place thru some COBOL logics lots of unstring,INSPECT...

Quote:
the write once use always subroutine/function could be expanded to provide more advanced application dependent facilities


Agree.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Mar 26, 2013 9:16 pm    Post subject:
Reply with quote

Things may have changed but...
DB2 is not the fastest thing in the world - although much faster than it used to be - so the less work you give it the faster it is for everyone else who is using it and you probably wouldn't notice any performance degradation of your COBOL program. In fact, it may well improve!
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 26, 2013 9:44 pm    Post subject:
Reply with quote

Hello,

How might you use SYSDUMMY1 to accomplish the functionality of NUMVAL?

How would you use this in place of COMPUTE or ADD or ?

If your intent is to improve performance, i believe this is Not the place to concentrate.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


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

PostPosted: Wed Mar 27, 2013 12:41 am    Post subject:
Reply with quote

Quote:
How might you use SYSDUMMY1 to accomplish the functkinoality of NUMVAL?


We can use cast,decimal,char,replace fuctions over sysdummy1 and formats the data
Quote:

How would you use this in place of COMPUTE or ADD or ?


Not for this operations.

Quote:
If your intent is to improve performance, i believe this is Not the place to concentrate.


true,

My question was just to confirm any harm using sysdummy1 over COBOL functions for decimal data validations.
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 -> DB2 All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

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 Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Rexx Panel Validation ajithajt CLIST & REXX 6 Sun Jul 17, 2016 10:50 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm


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