Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Initializing comp-3 fields in an array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sampathkmn
Warnings : 1

New User


Joined: 12 Dec 2005
Posts: 31
Location: bangalore

PostPosted: Wed Mar 11, 2009 11:39 am    Post subject: Initializing comp-3 fields in an array
Reply with quote

Hi,

I want to initialize a record in a file of variable record length, & maximum record length can be 28356.

the record structure has picture clause of X as well as comp-3 for few fields. there are few array fields in the structure.
I am able to initialize the entire lenth of record using below array:
Code:
01  WS-INIT-ARRY.                             
    05  WS-INIT-REC    OCCURS 28356 TIMES.
        10  WS-INIT-FIELD       PIC 9(01).     
01  WS-COUNTER                  PIC 9(05).

ans the following code used for initialization:
Code:
PERFORM VARYING WS-COUNTER FROM 1 BY 1                   
                UNTIL WS-COUNTER > 28356                 
   MOVE ZEROS         TO WS-INIT-FIELD(WS-COUNTER) 
END-PERFORM                                             


When i open the file with initialized record (with above logic) in INSYNC tool mapped with copybook layout, all comp-3 fields show a value of X'F0F0F0' which is not a valid one.

How can i initialize the record so that i get comp-3 as 0000.
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Wed Mar 11, 2009 12:23 pm    Post subject:
Reply with quote

Hello,

Quote:
How can i initialize the record so that i get comp-3 as 0000
You cannot - 0000 is not a valid comp-3 (packed-decimal) value.

Your array shows no comp-3 fields in the definition.
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Mar 11, 2009 2:22 pm    Post subject:
Reply with quote

Yes Dick.

The last byte will be '0C' for a packed decimal.

But still 'move zeros' statement should work for a packed decimal too.

Can you please give us the exact variable definition.
Back to top
View user's profile Send private message
sampathkmn
Warnings : 1

New User


Joined: 12 Dec 2005
Posts: 31
Location: bangalore

PostPosted: Wed Mar 11, 2009 3:03 pm    Post subject:
Reply with quote

I have one the arrays like mentioned below:

10 WS-SUMM-DATA
OCCURS 0 TO 1 TIMES
DEPENDING ON WS-TEST-SUMM.


15 B PIC 9(09) COMP-3.
15 C PIC 9(03) COMP-3.

I have initialized the above group using below code:

MOVE ZEROS TO B C


I am getting value when i write above group into a file as follows:
B ---> X'000F000000' ---> is this ok?
C ---> 0
Back to top
View user's profile Send private message
sampathkmn
Warnings : 1

New User


Joined: 12 Dec 2005
Posts: 31
Location: bangalore

PostPosted: Wed Mar 11, 2009 3:04 pm    Post subject:
Reply with quote

Please ignore the array declaration above...


15 B PIC 9(09) COMP-3.
15 C PIC 9(03) COMP-3.

I have initialized the above variable using below code:

MOVE ZEROS TO B C


I am getting value when i write above group into a file as follows:
B ---> X'000F000000' ---> is this ok?
C ---> 0
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Mar 11, 2009 3:27 pm    Post subject:
Reply with quote

No.

If you move zeros to B and C,

B should be X'000000000F' and displayed as '0'.

C should be X'000F' and displayed as '0'.

i think storage overlapping occurs in your wroking storage. Please check.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Mar 11, 2009 7:16 pm    Post subject:
Reply with quote

sampathkmn wrote:
I am getting value when i write above group into a file as follows:
B ---> X'000F000000' ---> is this ok?
C ---> 0
What proof can you offer that what you say is the values in B & C are the actual values? After the MOVE, add a line of:
DISPLAY "*" b "*" c "*"
and then HEX display the output.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Mar 11, 2009 9:58 pm    Post subject:
Reply with quote

Mathiv Anan wrote:
But still 'move zeros' statement should work for a packed decimal too.
Code:
01  WS-INIT-ARRAY.
    05  WS-INIT-REC    OCCURS 28356 TIMES.
        10  WS-INIT-FIELD       PIC 9(01).
01  WS-COUNTER                  PIC 9(05).

It works, but there is no packed decimal in your receiving array.

Mathiv Anan wrote:
and the following code used for initialization:
Code:
PERFORM VARYING WS-COUNTER FROM 1 BY 1
                UNTIL WS-COUNTER > 28356
   MOVE ZEROS         TO WS-INIT-FIELD(WS-COUNTER)
END-PERFORM

you could as well have done MOVE ALL ZERO TO WS-INIT-ARRAY. It would give the same wrong result, but much faster!

Mathiv Anan wrote:
the record structure has picture clause of X as well as comp-3 for few fields. there are few array fields in the structure.

Do you really want to move zeroes into your X fields as well ?

Can you please show us the REAL array, the one with X fields and COMP-3 fields and arrays ???
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 11, 2009 11:48 pm    Post subject: Reply to: Initializing comp-3 fields in an array
Reply with quote

Once you've properly defined all the elementary items (assuming they are of mixed-data types) associated with each table-entry group-level (WS-INIT-REC) -

Code:

03  WS-MAX-SUB PIC S9(08) BINARY.
03  WS-SUB     PIC S9(08) BINARY.

DIVIDE LENGTH OF WS-INIT-ARRAY BY LENGTH OF WS-INIT-REC (1)
                               GIVING WS-MAX-SUB.

INITIALIZE WS-INIT-REC (WS-MAX-SUB).

ADD -1 TO WS-MAX-SUB GIVING WS-SUB.

PERFORM UNTIL WS-SUB < 1
    MOVE WS-INIT-REC (WS-MAX-SUB) TO WS-INIT-REC (WS-SUB)
    ADD -1 TO WS-SUB
END-PERFORM.

Because your initialization begins at the calculated last table-entry, if the OCCURS is altered, the value in WS-MAX-SUB will always be correct.

But, Marso's assessment points out a better initialization method. If the entire array is defined as display-numeric -

Code:

MOVE ZERO TO WS-INIT-ARRAY.

will initialize the entire array to all EBCDIC ZEROS (most likely via an MVCL) and will be much faster than a loop.

Regards,
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Mar 12, 2009 2:57 am    Post subject:
Reply with quote

If you show us the exact definition of the array you want initialized, we can show you at least 2 different ways of accomplishing what you want with very little coding and one of the methods doesn't even involve procedure division statements.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Subtract the ZD fields to provide neg... Balaryan DFSORT/ICETOOL 4 Wed Oct 11, 2017 10:51 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us