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
 
Converting comp-3 format file to numeric format file records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Converting comp-3 format file to numeric format file records
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    Post subject: Converting comp-3 format file to numeric format file records
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    Post subject: Re: Converting comp-3 format file to numeric format file rec
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    Post subject: Converting comp-3 format file to numeric format file records
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

Site Director


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

PostPosted: Wed Dec 19, 2007 8:45 pm    Post subject:
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    Post subject:
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    Post subject: Converting comp-3 format file to numeric format file records
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

Active Member


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

PostPosted: Fri Dec 21, 2007 6:18 pm    Post subject:
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    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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

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