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

Converting comp-3 format file to numeric format file records


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

New User


Joined: 13 Jul 2006
Posts: 10

PostPosted: Tue Dec 18, 2007 9:32 pm
Reply with quote

hi i am working on a file which of fully comp-3 format var a(s9(7) comp-3and needs to be converted to numeric readable var b format(-s9(7)).
but while converting i am getting values as '4040404'(->spaces in hex) whenever in the input comp-3 variable contains no data and the same value '40404' is moving into numeric var b. i dont want this to happen.
the condition is comp-3 var a may contain positive or negative value.but if the comp-3 does not contain any value it should move spaces only in the numeric var b instead of currently moving as '404044'


please suggest


thanks
rjskumar
icon_biggrin.gif
Back to top
View user's profile Send private message
rjskumar_14

New User


Joined: 13 Jul 2006
Posts: 10

PostPosted: Tue Dec 18, 2007 9:35 pm
Reply with quote

an example of my way of moving data is

01 a pic s9(7) comp-3
01 b pic s9(7).

move a to b.

if a contains value it is fine
if a contains spaces (40404) and it just moves 40404 into b instead of spaces.
further how to check whether comp-3 var A contains any valid data or not.

tnks
rjskumar
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Dec 18, 2007 9:39 pm
Reply with quote

rjskumar_14 wrote:
hi i am working on a file which of fully comp-3 format var a(s9(7) comp-3and needs to be converted to numeric readable var b format(-s9(7)).
but while converting i am getting values as '4040404'(->spaces in hex) whenever in the input comp-3 variable contains no data and the same value '40404' is moving into numeric var b. i dont want this to happen.
the condition is comp-3 var a may contain positive or negative value.but if the comp-3 does not contain any value it should move spaces only in the numeric var b instead of currently moving as '404044'


please suggest


thanks
rjskumar
icon_biggrin.gif


If "numeric var B" is really defined as numeric then you can't move spaces to it! Check the comp-3 variables before you move them to be sure they are numeric (it is always a smart move to check outside data before using it). Why do you need to convert comp-3 to numeric display?
Back to top
View user's profile Send private message
rjskumar_14

New User


Joined: 13 Jul 2006
Posts: 10

PostPosted: Wed Dec 19, 2007 1:34 pm
Reply with quote

the main reason for converting this format is part of the requirement.
please tell me how to check and validate comp-3 variable fields whether it contains any data or not.
i tried by comparing the var A with x'40' but it didnt work.

just see here my output of the file

1000849- 30- 30 - 404040- 404040
1002867- 10- 10 - 404040- 404040
1002874- 20- 20 - 404040- 404040
1002881- 20- 20 - 404040- 404040


just look at above the 404040 in last two fields
i want spaces there if there is no valid data.please see main logic of mine below
please correct me where i am wrong.
A PIC S9(7) COMP-3
B PIC X(8)
C PIC S9(7).

MOVE A TO B.
IF B > LOW-VALUES
MOVE B TO C
END-IF.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Dec 19, 2007 8:45 pm
Reply with quote

Hello,

You might redefine the comp-3 field with a pic x field and if the x-field is spaces, move zeros to the comp-3 field before doing anything else.
Back to top
View user's profile Send private message
Gijz

New User


Joined: 27 Nov 2007
Posts: 9
Location: The Netherlands

PostPosted: Thu Dec 20, 2007 8:41 pm
Reply with quote

Hi rjskumar,

Test if A is numeric like Crag suggested, as follows:

03 A PIC S9(7) COMP-3.
03 A1 REDEFINES A PIC X(4).

03 B.
05 C PIC S9(7).

IF A IS NUMERIC
MOVE A TO C
ELSE
MOVE A1 TO B
END-IF

If A is not numeric B will be filled with A (A1) padded to the right with spaces. If you always want spaces into B when A is not numeric change MOVE A1 TO B into MOVE SPACE TO B.

Hope this is what you meant.

Regards,
Gijs
Back to top
View user's profile Send private message
rjskumar_14

New User


Joined: 13 Jul 2006
Posts: 10

PostPosted: Fri Dec 21, 2007 5:05 pm
Reply with quote

Thanks gijz..your suggestion works but with a correction

\the size of A1 is pic x(8) INSTEAD OF PIC X(4) as you mentioned.
else the values are getting truncated. , I OBSERVED....
LIKE THIS BELOW...
03 A pic s9(7) comp-3
03 A1 REDEFINES A PIC X(8).
03 C PIC S9(7).

while reading from file with this new redefines layout whether values will be misplaced or it wont affect the original fields in the file...from getting wrongly populated or truncated.

FURTHER i have one more doubt
here a change in pic clause is required to edit C properly for me if it is positive or negative.
i have used the editable char - as below .please check and confirm whether it is correct
03 C PIC -------9. (COMMENT- I HAVE USED 8 HYPHENS(-) AND A NINE for s9(7)--is it correct TO GET THE +VE OR -VE VALUE)

and there is another alpha numeric field in which i am recieving invalid value (i am not sure whether this value comes truncated because of the new redefines clause introduced in file copybook as above) or is it coming as such FROM INPUT...

example.
[b]03 E PIC X(40) --VALUE i got while debugging is 21-00005

03 F pic s9(40) --
AND THE CODE FOR THIS FIELD(since it alphanumeric i just used below)
if E > spaces
move E TO F
ELSE
MOVE ZEROES TO F[/b]
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Dec 21, 2007 6:18 pm
Reply with quote

You can't say (correctly) that a field has no value. Each bit is definitely set to 0 or 1. The value may not match up with your format - in which case the above mentioned redefinition is useful.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top