We help IT Professionals succeed at work.

CL - Can I use a Decimal Variable as a String?

header
header asked
on
3,292 Views
Last Modified: 2020-04-13
I have a decimal variable declared that I would like to write to the LDA.  I am getting an error stating that the Variable is not of the correct type for the CHGDTAARA command.  Is there some way to convert the Decimal variable to a usable string so that I can write it to the LDA?

Here are the relevant lines in my program:
DCL        VAR(&COPIES)  TYPE(*DEC)  LEN(3 0)
...
CHGDTAARA  DTAARA(*LDA (302 03)) VALUE(&COPIES)
Comment
Watch Question

Commented:
*LDA is a character data area, you cannot write Decimal data in there !!

Maybe you could declare you variable *CHAR.
It might Fix everything !!

Author

Commented:
It is being assigned a value from a display file that is defined as numeric.  I get some very odd output when I change it to *CHAR.  I would much rather keep the display file numeric in the hope that there is some way for me to convert between numeric and *CHAR in the CL.

I know that worst-case scenario I can have a COBOL program do the conversion for me, I'm just hoping that there is an easier way to do this in the CL.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
dd - I hope you know how dumb I feel right now.  I swear I've tried that before and it didn't work.  I must have been doing something wrong because it works now.  Thanks!

P.S.  I presume I can use the same method to convert from a *CHAR to a *DEC.  Please let me know if this is not the case.
:) that feeling is familiar to me...

yes, you can use same way to convert *char to *dec. I don't really remember, since which OS version it was transparent. i remember that it's not that simple in old version like V3R4M0

Author

Commented:
>> yes, you can use same way to convert *char to *dec
Good to hear!

Thanks again for all of your help!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.