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

COBOL query: move space to 9(2)


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Mar 15, 2008 7:55 am
Reply with quote

Initialize uses the first definition of an item if the the item is redefined.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Sun Mar 16, 2008 3:54 am
Reply with quote

Craq,

Interesting, Will have to check whether my group variable is redefined and whether the first defnition is alphanumeric.

Anuj,

The definition in my first post is just an example and not actually how my copybook looks.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sun Mar 16, 2008 4:46 am
Reply with quote

Hi,

Yes
Quote:
Initialize uses the first definition of an item if the the item is redefined.
once a memory is "masked" with some definition, we can 'resue' it with that definition only. You re-define the variables not the memory.
Back to top
View user's profile Send private message
dr_te_z

New User


Joined: 08 Jun 2007
Posts: 71
Location: Zoetermeer, the Netherlands

PostPosted: Mon Mar 17, 2008 7:03 pm
Reply with quote

INITIALIZE ignores FILLER's. So to be sure I code both:
Code:

MOVE SPACE TO FOO-GR                               
INITIALIZE    FOO-GR  REPLACING NUMERIC DATA BY ZERO
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Tue Mar 18, 2008 6:11 pm
Reply with quote

Aaru wrote:
Hi,

Quote:
Hi, can anyone tell what should be the supposed result if you move spaces into a numeric field.

I tried that and got zeroes in the numeric field.


Techies,

I have a doubt here. As per all your explanations we would have zeroes if we move SPACES to numeric field. But consider this scenario,

01 Group Variable
05 Elementary item 1 PIC 9(1)
05 Elementary item 2 PIC 9(1)
05 Elementary item 3 PIC 9(1)

As far as i know, group variables are always alphanumeric and hence if you initialize this Group variable we would have spaces in the 3 elementary items and not zeroes.

So is there any way to move zeroes to these elementary items other than moving zeroes to this gp variable?


Code:


Aaru i tried this and i think it may help u.

01 WS-VARIABLE.
   05 WS-ITEM1 PIC 9(1).
   05 WS-ITEM2 PIC 9(1).
   05 WS-ITEM3 PIC 9(1).

INITIALIZE WS-VARIABLE.
   DISPLAY 'WS-VARIABLE :' WS-VARIABLE.
   DISPLAY 'WS-ITEM1    :' WS-ITEM1.
   DISPLAY 'WS-ITEM2    :' WS-ITEM2.
   DISPLAY 'WS-ITEM3    :' WS-ITEM3.

Here is the SYSOUT i got.

WS-VARIABLE :000
WS-ITEM1    :0
WS-ITEM2    :0
WS-ITEM3    :0


Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. 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