View previous topic :: View next topic
|
Author |
Message |
krunalbafna Warnings : 1 Active User
Joined: 18 Jan 2010 Posts: 143 Location: Pune
|
|
|
|
Hi Team,
01 ws-var1 pic x(07)
I want to move following value ('00aa%') to the above variable.The variable shld have Apostophe and percent '%' in the ws-var1.
May you please provide me some hint to move above variable using MOVE statement.
Regards,
KB |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
There is a link to manuals at the top of the page, including the COBOL manuals. These manuals tell you everything you could possibly want to know about the MOVE statement -- if you read them.
Your hint is: when APOST compiler option is set, and you need an apostrophe in a literal, you must use two apostrophes and COBOL will replace them with a single apostrophe in the appropriate place. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Use HEX notation -
Code: |
MOVE X'7DF0F081816C7D' TO WS-VAR1.
|
Note: If you're using OS/VS COBOL, this won't work as HEX notation was not introduced until VS/COBOL II, the successor to OS/VS COBOL.
You should familiarize yourself with the EBCDIC collating sequence.
There is a benefit in using HEX notation in that if you open the source-member and accidentially set CAPS ON, edit a line (or several) where there are lower-case letters (such as 'aa') and then save it, the 'aa' will then become 'AA'.
This won't happen when you use HEX notation.
Bill |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi KB,
If you want to do it the old fashioned way, the rule is:
If your literal delimiter is a quote (') and you're using quotes as part of the literal, you must code each qoute in the literal as 2 quotes ('').
So, if you want to move value '00aa%' to WS-VAR1 you "wrap" it in quotes and double each quote in the literal, i.e.: '''00aa%''' and the MOVE stmt is:
MOVE '''00aa%''' TO WS-VAR1
Another example: suppose the literal was 00a'%'
You would code '00a''%''' as the sending field in the MOVE. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It is also possible to have a variable with the value of a quote:
Code: |
01 stuff.
05 my-quote pic x value quote. |
|
|
Back to top |
|
|
|