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
 
Add Comp variable to Comp3.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Add Comp variable to Comp3.
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    Post subject:
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    Post subject: Reply to: Add Comp variable to Comp3.
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    Post subject: Reply to: Add Comp variable to Comp3.
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: 2504
Location: Atlanta, Georgia, USA

PostPosted: Thu Sep 18, 2008 1:19 am    Post subject: Re: Add Comp variable to Comp3.
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    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 Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

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