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

Edited picture class for COMP-3 logic error


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

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Tue Oct 15, 2013 2:26 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Oct 15, 2013 3:11 pm
Reply with quote

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
View user's profile Send private message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Tue Oct 15, 2013 3:28 pm
Reply with quote

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. icon_sad.gif
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Oct 15, 2013 3:35 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Oct 15, 2013 4:40 pm
Reply with quote

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
View user's profile Send private message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Tue Oct 15, 2013 5:51 pm
Reply with quote

Thanks Akatsukami. icon_smile.gif 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
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 Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts building java class with zip4j.jar on... Java & MQSeries 0
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top