Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move Data from x(10) to s9(06) comp-3 not working 1

Status
Not open for further replies.

Coder7

Programmer
Oct 29, 2002
224
US
Hello all. I'd appreciate your help, please.

Data:
hold-grp-id pic x(10)
hv-grp-nbr pic s9(06) comp-3

The pic for hv-pic-nbr must be as is above for data extract data from a db2 table.

Data value example for hold-grp-id = 003453 (+ 4 spaces)

Cobol pgm:
move hold-grp-id to hv-grp-nbr

Here's where I need help, please:
the resulting value in hv-grp-nbr = 530000 and it should be 003453.

Thanks again!




 
Have you tried this ?
move FUNCTION NUMVAL(hold-grp-id) to hv-grp-nbr
or this:
move hold-grp-id(1:6) to hv-grp-nbr

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Moving 1:6 got it PH...thanks so very much!!

And thanks to you, too, Tom for offering your assistance. Have a great week (what's left!) and weekend.
 
How could:

move hold-grp-id(1:6) to hv-grp-nbr

possibly work with a COMP-3 receiving field?
 
Do you know that the field will always have 6 digits followed by 4 spaces?
 
Hi.

Slade: Maybe PHV can answer you.

Webrabbit: For right now yes but in the not-too-distant future we'll have to add conditional logic because that field could contain 6-10 digits.
 
move hold-grp-id(1:6) to hv-grp-nbr

is just like moving an elementary Pic X(6) to a packed decimal field. It works. Personally, I prefer not to mix modes. As most of you know, moving a group item to packed decimal does not work properly. Moving Pic X to Pic 9 can cause problems if you don't understand all the nuances.
 
Slade,

The rules for moving an elementary alphanumeric field to a numeric are in the COBOL Standard. Essentially, the alphanumeric field is treated as if it were an integer. A reference-modified field is explicitly defined to be an elementary alphanumeric item (not a group item), and thus picks up this MOVE rule.

Tom Morrison
 
Anyway, the best approach if the field could contains 6-10 digits is something like this:
move FUNCTION NUMVAL(hold-grp-id) to hv-grp-nbr

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top