IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Specail character in the variable.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krunalbafna
Warnings : 1

Active User


Joined: 18 Jan 2010
Posts: 143
Location: Pune

PostPosted: Fri Jul 30, 2010 7:22 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jul 30, 2010 7:35 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Jul 30, 2010 7:38 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Aug 01, 2010 4:24 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Aug 01, 2010 5:02 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top