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

How to pass information in quotes thorugh COBOL statement.


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

New User


Joined: 11 May 2005
Posts: 26
Location: Hyderabad

PostPosted: Mon May 15, 2006 7:19 pm
Reply with quote

Hi,

I want to write in a report file a heading which should be in quotes. For instance i need to write 'REPORT FOR PAYROLL SYSTEM'

When i declare in thw working storage section :
I put WS-HEADER PIC X(25) VALUE 'REPORT FOR PAYROLL SYSTEM'

But the result comes as REPORT FOR PAYROLL SYSTEM without quotes. Please let me know how can i achieve the desired results.
Back to top
View user's profile Send private message
hariavinash

New User


Joined: 04 Jan 2006
Posts: 64

PostPosted: Mon May 15, 2006 8:41 pm
Reply with quote

try putting "'REPORT FOR PAYROLL SYSTEM' " i.e double quotes.
if this did not work
use this

MOVE X'7D'

with the same values u have defined to override with single quotes whereever you wanted.

cheers
Back to top
View user's profile Send private message
shrivatsa
Warnings : 1

Active User


Joined: 17 Mar 2006
Posts: 174
Location: Bangalore

PostPosted: Mon May 15, 2006 10:11 pm
Reply with quote

***************************** Top of Data ***********************
IDENTIFICATION DIVISION.
PROGRAM-ID. COB1.
ENVIRONMENT DIVISION.
*************************
* THIS PROGRAM CAN BE USED AS A TEMPLATE.
*************************
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COUNT PIC X(30) VALUE "'REPORT FOR PAYROLL SYSTEM'".
PROCEDURE DIVISION.
MAIN-PARA.
DISPLAY WS-COUNT.
STOP RUN.


Outer is the double quote and inside is the single quote

Output

'REPORT FOR PAYROLL SYSTEM'
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon May 15, 2006 10:19 pm
Reply with quote

Avinash_Gupta,

It appears as though your compiler is running with APOST option on.

Try WS-HEADER PIC X(25) VALUE '''REPORT FOR PAYROLL SYSTEM'''.

This is three single quote ( apostrophe ).

Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue May 16, 2006 5:52 am
Reply with quote

Hi Avinash,

The 2 things to keep in mind:
1) You code 2 quotes for every quote you want to see displayed.
2) The entire literal must begin with 1 quote and end with one quote.

Here's the best example:

Suppose you wanted to display ''. That is, just 2 single quotes. How would you code the literal?
Code:


05  TWO-QUOTES       PIC  X(002) VALUE ''''''.


DISPLAY TWO-QUOTES

or

DISPLAY ''''''   


Both will display ''

Of course, the 2nd DISPLAY will not require the variable TWO-QUOTES.

I haven't tested, but it should work. If anybody has the time, give it a try and let us know the resuts.
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Tue May 16, 2006 1:02 pm
Reply with quote

Hi Avinash,

If none of the above solutions work, please use this!

Declare the varible as

Code:
01 WS-HEADER.
     10  FILLER                PIC X VALUE QUOTE.
     10  WS-HEADER-VAL         PIC X(25) VALUE 'REPORT FOR PAYROLL SYSTEM'.
     10  FILLER                PIC X VALUE QUOTE.

Please let me know how it goes by.

Cheers, Twissi.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu May 18, 2006 4:33 am
Reply with quote

Playing off of Shri's suggestion, if your compiler is set to use single quotes to contain a literal, you can use double quotes to print:
Code:


"REPORT FOR PAYROLL SYSTEM"

with VALUE '"REPORT FOR PAYROLL SYSTEM"'


If it uses double quotes, do just the opposite to print:
Code:


'REPORT FOR PAYROLL SYSTEM'

with VALUE "'REPORT FOR PAYROLL SYSTEM'" 
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top