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

Add Comp variable to Comp3.


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

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Wed Sep 17, 2008 2:27 pm
Reply with quote

Hi,
I have the variable as below in my detail record:
Var1 PIC S9(09) COMP.
Which needs to be added for each detail records in the file and then provide the total in the trailer as
Var2 PIC S9(12) COMP-3.

Please let me know how will I do that.

Thanks,
Ritam Dutta
Back to top
View user's profile Send private message
Hritam

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Wed Sep 17, 2008 4:56 pm
Reply with quote

Although I think the requirement is clear enough, this is what I want.
Detail record of an I/P file is having a field:
VAR1 PIC S9(09) COMP.

For each detail record we need to add this field and display in the O/P file as trailer in the field:
Var2 PIC S9(12) COMP-3.

something lilke:
ADD VAR1 to VAR2.

Let me know if you have any further question.

Thanks.......
Back to top
View user's profile Send private message
Kevin Wailes

New User


Joined: 29 Aug 2008
Posts: 10
Location: UK

PostPosted: Wed Sep 17, 2008 5:10 pm
Reply with quote

Hi

I reckon you've answered your own question....

ADD VAR1 TO VAR2

shoudl work fine.
Back to top
View user's profile Send private message
Cristopher

New User


Joined: 31 Jul 2008
Posts: 53
Location: NY

PostPosted: Wed Sep 17, 2008 5:13 pm
Reply with quote

Hello,

i reckon you can use compute and move statement to get the required output. something like this :
Code:

COMPUTE VAR1-T = VAR1-T + VAR1-DTL1
Keep adding for every detail record

At the end
Move VAR1-T TO VAR2-TRAIL


Cris
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Sep 18, 2008 1:19 am
Reply with quote

Note that PIC S9(12) COMP-3 only allows 6 1/2 Bytes of the allocated 7-Bytes for the actual numeric data, so erroneously, you could get high-order truncation or an overflow.

For sign-fullwords, the maximum positive decimal value is 2147483647.

So, define the S9(12) COMP-3 field as PIC S9(13) COMP-3 and this will allow the high-order 4-Bits of the 1st-Byte to be used.

Other than PIC S9(18) COMP-3 (not ARITH=EXTEND) for whole number definitions (no implied decimal), odd-number picture clauses for COMP-3 fields are the preference. Why restrict the field capacity with an even-number in the picture when the storage requirements are the same?

Just my .02 cents....

Regards,

Bill
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top