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

Moving a Group variable to fixed length one.


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

New User


Joined: 01 Oct 2008
Posts: 12
Location: India

PostPosted: Tue Mar 02, 2010 1:37 am
Reply with quote

Hi
I have 2 group variables one is TEST-VAR second one RESULT-KEY

Code:
01  TEST-VAR.                                   
    05 TEST-A       PIC S9(01) COMP-3.
    05 TEST-B       PIC S9(01) COMP-3.
    05 TEST-C       PIC S9(05) COMP-3.
    05 TEST-D       PIC S9(05) COMP-3.

01  RESULT-KEY.                                     
    05 RESULT-ROG                 PIC X(4).         
    05 RESULT-FACILITY           PIC X(4).         
    05 RESULT-TESTABCD         PIC S9(12) COMP-3.


I would like to have the TEST-VAR as whole in RESULT-TESTABCD.
( concatenated TEST-A,TEST-B,TEST-C,TEST-D)

Is it possible to move the group variable to a fixed length one ?
How can we achieve this in minimum steps ?



Thanks
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Mar 02, 2010 1:46 am
Reply with quote

Yes it is possible but it will be alphanumeric to numeric move.
What result are you expecting here, can you explain with an example?
Back to top
View user's profile Send private message
Tone

New User


Joined: 01 Oct 2008
Posts: 12
Location: India

PostPosted: Tue Mar 02, 2010 1:51 am
Reply with quote

one sample value is

TEST-A is 2
TEST-B is 5
TEST-C is 74536
TEST-D is 88123

I would like to have 257453688123 in RESULT-TESTABCD.

PS: I won't be able to changes the the above mentioned variable declarations, but i can define new ones to achieve this.


Thanks
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Mar 02, 2010 2:09 am
Reply with quote

Tone wrote:
TEST-A is 2
TEST-B is 5
TEST-C is 74536
TEST-D is 88123

I would like to have 257453688123 in RESULT-TESTABCD
As I see it, what you really have in hex is:
TEST-A is 2C
TEST-B is 5C
TEST-C is 74536C
TEST-D is 88123C
And the results:
RESULT-ROG is 2C5C7453
RESULT-FACILITY is 6C88123C
RESULT-TESTABCD is 40404040404040

The sending field is eight bytes while the receiving field is fifteen bytes.
From your sample, just what do you want to see in the result fields?
Back to top
View user's profile Send private message
Tone

New User


Joined: 01 Oct 2008
Posts: 12
Location: India

PostPosted: Tue Mar 02, 2010 2:49 am
Reply with quote

For the sample mentioned,
Whether it is hex or not, I want equivalent of 257453688123 in RESULT-TESTABCD.

So that i can use in condition checks
eg: If CORRECT-KEY = RESULT-KEY ?


Thanks
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: Tue Mar 02, 2010 2:58 am
Reply with quote

Hello,

Move the 4 TEST fields to 4 fields that are defined as unsigned zoned decimal:
Code:
01  the-group.
    05 t-a pic 9.
    05 t-b pic 9
    05 t-c pic 9(5).
    05 t-d pic 9(5).
01  the-group-n redefines the-group pic 9(12).

After the move, you should have what you want.
Back to top
View user's profile Send private message
Tone

New User


Joined: 01 Oct 2008
Posts: 12
Location: India

PostPosted: Tue Mar 02, 2010 3:34 am
Reply with quote

Thank you !
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: Tue Mar 02, 2010 4:35 am
Reply with quote

You're welcome - good luck icon_smile.gif

d
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Mar 02, 2010 10:19 am
Reply with quote

Dick's solution is probably the best, but you could get what you desire into RESULT-TESTABCD by using the following untested code:
Code:

COMPUTE RESULT-TESTABCD
      = TEST-A * 100000000000
      + TEST-B *  10000000000
      + TEST-C *       100000
      + TEST-D
END-COMPUTE
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 Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top