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

How to use INITIALIZE verb to replace NUMERIC by SPACES?


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

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Thu Apr 03, 2008 12:21 pm
Reply with quote

I have following record.

01 wk-dtl-rec.
10 WK-DTL-DT-INTR-PD-THRU PIC X(10) VALUE SPACES.
10 WK-DTL-DT-CLM-DLNQ PIC X(10) VALUE SPACES.
10 WK-DTL-AMTL-DSBR PIC ZZZ,ZZZ,ZZ9.99- VALUE ZEROES.

I use the verb,

INITIALIZE WK-DTL-REC REPLACING NUMERIC DATA
BY ZEROES

But i got MAXcc 12.

Can any one suggest me how to do this?

Regards
R.karthik
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Thu Apr 03, 2008 12:24 pm
Reply with quote

sorry i use the verb,

INITIALIZE WK-DTL-LINE-1 REPLACING NUMERIC DATA
BY SPACES.

The error i got is,

"INITIALIZE" STATEMENT RECEIVER "WK-DTL-LINE-1" WAS INCOMPATIBLE WITH THE DATA CATEGORY(S) OF THE "REPLACING"
OPERAND(S). "WK-DTL-LINE-1" WAS NOT INITIALIZED.

Regards
R.Karthik
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Thu Apr 03, 2008 12:33 pm
Reply with quote

what is the picture clause of WK-DTL-LINE-1 ?
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Thu Apr 03, 2008 12:36 pm
Reply with quote

01 WK-DTL-LINE-1.
10 WK-DTL-DT-INTR-PD-THRU PIC X(10) VALUE SPACES.
10 WK-DTL-DT-CLM-DLNQ PIC X(10) VALUE SPACES.
10 WK-DTL-AMTL-DSBR PIC ZZZ,ZZZ,ZZ9.99- VALUE ZEROES.

Regards
R.Karthik
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 03, 2008 12:43 pm
Reply with quote

wk-dtl-line-1 does not contain any numeric fields.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Thu Apr 03, 2008 12:55 pm
Reply with quote

Quote:
sorry i use the verb,

INITIALIZE WK-DTL-LINE-1 REPLACING NUMERIC DATA
BY SPACES.

The error i got is,

"INITIALIZE" STATEMENT RECEIVER "WK-DTL-LINE-1" WAS INCOMPATIBLE WITH THE DATA CATEGORY(S) OF THE "REPLACING"
OPERAND(S). "WK-DTL-LINE-1" WAS NOT INITIALIZED.


you cannot initialize NUMERIC item with spaces, keep it in mind.

Quote:
INITIALIZE WK-DTL-LINE-1 REPLACING NUMERIC DATA
BY SPACES.


the above syntax must be INITIALIZE WK-DTL-LINE-1 REPLACING NUMERIC DATA BY ZEROS.

and

INITIALIZE WK-DTL-LINE-1 REPLACING ALPHANUMERIC DATA BY SPACES.you can use above commands inside PROCEDURE DIVISION.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 03, 2008 1:18 pm
Reply with quote

you guys sure waste a lot of time. full of answers without bothering to look at the problem.+

there are no numeric fields to be initialized, so why waste time trying to do so?

if you want to be silly and load a numeric field with spaces - when you have a numeric field - then move spaces to the group item.

or as in this case where there are no numeric fields to be initialized, then

INITIALIZE WK-DTL-LINE-1

will satisfy the OP's wishes without cluttering up his/her mind with facts about data types.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Apr 03, 2008 4:55 pm
Reply with quote

Why not do a plain:
Code:
    MOVE SPACES TO WK-DTL-LINE-1

Also, if you define:
Code:
10 WK-DTL-AMTL-DSBR PIC ZZZ,ZZZ,ZZ9.99- VALUE 0 BLANK WHEN ZEROES.
then the field with have spaces when you do MOVE ZERO TO WK-DTL-AMTL-DSBR
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Fri Apr 04, 2008 10:49 am
Reply with quote

Hi Marso.....

Code:
10 WK-DTL-AMTL-DSBR PIC ZZZ,ZZZ,ZZ9.99- VALUE 0 BLANK WHEN ZEROES


is the above code works with all cobol versions. Because it is an compaq COBOL.

Please let us know whether this commands work with COBOL-85 and COBOL II.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 05, 2008 12:49 am
Reply with quote

I assumed that the OP must INIT the fields repeatedly, so the value clause doesn't help, unless he constructs a model rec and moves that to his active rec in each iteration.
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 Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
Search our Forums:

Back to Top