View previous topic :: View next topic
|
Author |
Message |
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Hi,
I'm getting incorrect data in a file due to my edited picture class logic error.
A layout of file copybook is like this.
Code: |
01 ws-record pic x(1020).
01 WS-TRLR REDEFINES WS-RECORD.
03 WS-TRL-NAME PIC X(51)
03 WS-TRL-A PIC X(969).
03 WS-TRL-B REDEFINES WS-TRL-A
05 WS-TRL-B-OC OCCURS 51 TIMES.
07 WS-TRL-B-REC PIC ++++++++++++++9.99.
07 FILLER PIC X.
|
Now my working storage variable which is used to populate ws-trl-b record is as follows.
Code: |
01 WS-TMP-TRLR.
03 WS-TMP-TRL-B.
05 WS-TMP-TRL-B-OC OCCURS 51 TIMES.
07 FILLER PIC X(9).
07 WS-TMP-TRL-B-REC PIC S9(15)V9(2) COMP-3.
07 FILLER PIC X VALUE ','.
|
Now before writing to the file i wrote the operation in COBOL as
MOVE 'DATA' TO WS-TRL-NAME
MOVE WS-TMP-TRL-B TO WS-TRL-B.
WRITE WS-RECORD.
Here, i'm not getting any compilation or run time errors. But, there is no edited picture class data in the file corresponding to WS-TRL-B-REC field. I'm having the data in COMP-3 format. I feel data in array variables is getting lost in this move operation.
Need some help in how to convert COMP-3 data in WS-TMP-TRL-B-REC which is 9 bytes to WS-TRL-B-REC edited pic which is of 18 bytes.
I'm trying to move the data for entire occurs 51 times array. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
A group level move, which is what you are doing, will NOT handle COMP, COMP-3, or edited numeric variables. The entire group of data is moved as if it were PIC X(?) -- hence the results you got. If you want your COMP-3 variable to move to the edited numeric variable, you need to move elementary variable to elementary variable. |
|
Back to top |
|
|
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
So you mean to say, i need to remove the present layout of this variables and write seperate individual variables for facilitating comp-3 to edit pic variables movement?
I've almost 51 fields to be written in output. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
No, you need merely MOVE WS-TMP-TRL-B-REC (I) TO WS-TRL-B-REC (I) in a paragraph PERFORMed VARYING I FROM 1 TO 51. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Editing only occurs when the field with the edit pattern itself is the target of something.
You also seem to want the commas. When showing us code, it is nice if it does not produce compiler diagnostics. You should always check and correct things.
You could give your FILLER a name and MOVE COMMA to it in the same loop. Or you could be slack and MOVE ALL COMMA to the group item before your loop. Or you could be adventurous and try to include the comma in your edit picture. However, with 51 fields, it would generally be expected that there would be 50 commas. Perhaps you have more data afterwards? |
|
Back to top |
|
|
dsivapradeep
New User
Joined: 06 Jul 2012 Posts: 43 Location: INDIA
|
|
|
|
Thanks Akatsukami. I couldn't think of this simple logic while coding.
Bill, Yes COMMA is important as i'm generating a CSV file. What i did was, added one extra line "MOVE ',' TO WS-COMMA(I)" inside the perform. So i'm able to generate COMMAS in sequence. |
|
Back to top |
|
|
|