View previous topic :: View next topic
|
Author |
Message |
sampathkmn Warnings : 1 New User
Joined: 12 Dec 2005 Posts: 31 Location: bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
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 |
|
|
sampathkmn Warnings : 1 New User
Joined: 12 Dec 2005 Posts: 31 Location: bangalore
|
|
|
|
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 |
|
|
sampathkmn Warnings : 1 New User
Joined: 12 Dec 2005 Posts: 31 Location: bangalore
|
|
|
|
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 |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
|