Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 2502
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 11 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us