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
 
how to insert decimal values into the ims database

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> IMS DB/DC
View previous topic :: :: View next topic  
Author Message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Wed Nov 28, 2007 12:22 pm    Post subject: how to insert decimal values into the ims database
Reply with quote

hi everyone,

i need to know how i can insert decimal values into the ims database..
i have given the datatype of the field that needs to accept decimal values as packed decimal..but it does not take in decimal values...
plzz help..

thanx in advance..

regards
alamelu
Back to top
View user's profile Send private message

Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Wed Nov 28, 2007 4:23 pm    Post subject:
Reply with quote

The same way you would do it with any file type. Maybe I am not understanding your question?
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Wed Nov 28, 2007 4:34 pm    Post subject:
Reply with quote

hi sandy,

i have a segment in the database named "product" and that segment has a field called "unit price"..this unit price needs to accept decimal values...
now,in the database i have defined this unit price field with the type=P, and in my cobol pgm declared the unit price as s9(5)v99 comp-3..but inspite of this i am not able to insert decimal values into the unit price field of the ims database...

and also
2) Can the user key in something like 12345.66 directly on the ims dc screen or will he just have to key in 1234566 and later expect the decimal point to be placed in the database..??
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Wed Nov 28, 2007 6:12 pm    Post subject:
Reply with quote

You need to talk with your users and determine what they want to enter on the screen. You can let them enter a decimal or you can define the field to accept only numerics. How is the MFS field defined? How is the field defined in the IMS message. If they want to enter the decimal point, you will need to interpret that field before moving it into your packed decimal field in the database. Your database field is correctly defined.

You will just need to make sure the field is numeric before moving it into the database field or you will get a SOC7.
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Nov 28, 2007 10:04 pm    Post subject:
Reply with quote

Quote:
in my cobol pgm declared the unit price as s9(5)v99 comp-3..but inspite of this i am not able to insert decimal values into the unit price field of the ims database...

The s9(5)v99 -> the decimal is virtual and you cannot insert into this a decimal point.

Quote:
Can the user key in something like 12345.66 directly on the ims dc screen
This is possible, refer to MFS and IMS DC manuals
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Thu Nov 29, 2007 10:07 am    Post subject:
Reply with quote

Thank you sandy and devzee for your inputs...

The requirement is that the users would like to key in the decimal value directly on the screen ( eg: 12345.77) and expect it to get inserted into the database...

The mfs field for the unit price is defined this way:

UNITPRI DFLD POS=(13,42),LTH=7,
ATTR=(NOPROT,NUM,HI,MOD)

And the input-message-area is defined this way :

01 INPUT-MESSAGE-AREA.
05 IPI-LL PIC S9(3) COMP.
05 IPI-ZZ PIC S9(3) COMP VALUE 0.
05 IP-TRANSID PIC X(9).
05 IPI-DATA.
10 IP-OPT PIC 9(1).
10 IP-PROD-PID PIC X(5).
10 IP-PROD-PNAME PIC X(25).
10 IP-PROD-SUP-ID PIC X(5).
10 IP-PROD-CAT-ID PIC X(5).
10 IP-PROD-CAT-NAME PIC X(25).
10 IP-PROD-UNIT-PRICE PIC s9(5)V99 comp-3.
10 IP-PROD-UNIT-STOCK PIC X(5).
10 IP-PROD-UNITS-IN-ORDER PIC X(5).
10 IP-CHOICE PIC X(1).
05 IPD-YN PIC X VALUE 'N'.


now condidering the above stated requirement,how would i go ahead and insert decimal values into my database...?? plz guide me..

thanx in advance

regards
alamelu
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Nov 29, 2007 5:06 pm    Post subject:
Reply with quote

UNITPRI DFLD POS=(13,42),LTH=7,
ATTR=(NOPROT,NUM,HI,MOD)

Well, first of all - how can they enter 8 positions in a field defined as 7 positions. It is also defined as numeric.

10 IP-PROD-UNIT-PRICE PIC s9(5)V99 comp-3

You could not directly move your screen field into your message area if y ou change it to MOD,ALPHA. You would also need to change the length of the field. You would then need to go thru a routine to check each position of this field for values. If you do change it to allow alpha, they could then enter 1234.5677.

The way you have it defined now would work if they keyed in 1234577 which would be interpreted as 12345v77. Can you explain to your users the the last 2 positions are considered cents?

The last 2 bytes are implied decimal positions.
10 IP-PROD-UNIT-PRICE PIC s9(5)V99 comp-3.
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Thu Nov 29, 2007 6:36 pm    Post subject:
Reply with quote

hi sandy,

yes,true like u said it wud work if the user keyed in1234567..but here i need to accept a value like 12345.67 directly from the user..

so now even if i do change the data type of the field to alpha and do accept a value like 12345.67 into my database...the problem i am facing is: when i retreive the same value from the database and try to use this value in a calculation ,then i get a soc7 abend....plz guide..

thanx in advance..

regards
alamelu
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Thu Nov 29, 2007 6:56 pm    Post subject:
Reply with quote

You need to set up an array ocurring 8 times. Move the field from your screen to the array. You will then go thru each checking for values. You will also need to set up an array that you will initialize to zeroes and then move the values from the screen into them as you validate. The resulting arrary will be 7 occurences.

You could code it as a loop or just look at each occurrence. Don't forget that you will be checking for numerics and making sure that only position 6 contains the period.

For instance......

ws-position (1) - if not numeric, move zeroes
ws-position (2) - if not numeric, move zeroes
ws-position (3) - if not numeric, move zeroes
ws-position (4) - if not numeric, move zeroes
ws-position (5) - if not numeric, move zeroes
ws-position (6) - must always be period - this will not get move anywhere
ws-position (7) - if not numeric, move zeroes
ws-position (8) - if not numeric, moves zeroes
Back to top
View user's profile Send private message
Sandy Zimmer

Active Member


Joined: 13 Jun 2007
Posts: 826
Location: Wilmington, DE

PostPosted: Fri Nov 30, 2007 6:45 pm    Post subject:
Reply with quote

Another idea to save you from going thru all of this alpha, mod stuff....which is really-really a very bad idea.

Why not keep it the way it is on the screen and once they enter a value and press a key to update, show them a message with the resulting value and ask them if this is the correct value.

For instance, let them enter 6766 - the show them the resulting field in a message - like "you have entered 67.66 - is this correct?" - you could then ask them to enter "Y" or "N" - if "Y". then do your update - if "N", then position the cursor back to that field and let them enter it again.
Back to top
View user's profile Send private message
alamelu1984

New User


Joined: 20 Apr 2007
Posts: 40
Location: bangalore

PostPosted: Mon Dec 03, 2007 11:22 am    Post subject:
Reply with quote

hi sandy,

thank you so much for ur inputs..i think this idea is much easier.... icon_smile.gif
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 -> IMS DB/DC All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Moving UDB database to Db2 on z/OS Keith Hooley DB2 4 Wed Sep 27, 2017 12:38 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am

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