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
 
ALPHANUMERIC to COMP-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
prgrmr

New User


Joined: 26 Jun 2010
Posts: 3
Location: swiper

PostPosted: Sat Jun 26, 2010 12:39 am    Post subject: ALPHANUMERIC to COMP-3
Reply with quote

Hi,

I need to convert alphanumeric to comp-3 as below. Can any of you help me with it, please?

Data moved from

007300 05 ALPHANUMERIC PIC X(26).

Data moved to

05 Num-key
10 Num-abc PIC 9(12) COMP-3.
10 Num-def PIC 9(14) COMP-3.


Here is what I get out of displays when I redefine X(26) to 9(12) and 9(14) and another redefine to abc - 9(12) comp-3 and def- 9(12) comp-3.

KEY 50005000000000000123001234
-----------------------------------
Output – Num-key 50005000000000000123001234
abc 5 0 0 0 5 0
def 0 0 0 0 0 0 0

I also tried redefining X(26) to 9(12) and 9(14) and moving data from numeric to comp-3. Still doesnt seem to work.

I have verified several posts in net, before sending this.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jun 26, 2010 1:10 am    Post subject:
Reply with quote

You are moving 26 bytes to 15 bytes (7 for num-abc, 8 for num-def). It is not at all clear why you are doing this. Perhaps if you explained more it would help us understand.
Back to top
View user's profile Send private message
prgrmr

New User


Joined: 26 Jun 2010
Posts: 3
Location: swiper

PostPosted: Sat Jun 26, 2010 1:20 am    Post subject:
Reply with quote

Yes. This value is the key. In one file it is in alphanumeric and in another in COMP-3.

For some calculation, I need to match the keys in the two files, to work on.

Hope that clarifies. My concern is on where the fillers will have to be inserted - providing FILLERS at the end did not work.
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: Sat Jun 26, 2010 1:38 am    Post subject:
Reply with quote

Hello,

No, it hasn't been clarified yet. . .

Is this one value or is it 2 values? Why not define the input as 9(12) and 9(14) and them move the individual fields?

Usually, comp-3 (packed-decimal) fields do not make good keys due to the signs.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 683
Location: Pennsylvania

PostPosted: Sat Jun 26, 2010 1:40 am    Post subject:
Reply with quote

This does not clarify it.

You need to show that key data in both of the files. Please use code tag since actual positions are important.

My guess is that a redifine from X(26) to a group containing
9(12) and 9(14) elementary levels is fine.

I think you need to do two individual moves from 9(12) to 9(12) comp3
and 9(14) to 9(14) comp3 to pack the data.

This is the best I can do since my crystal ball is already at happy hour.
Back to top
View user's profile Send private message
prgrmr

New User


Joined: 26 Jun 2010
Posts: 3
Location: swiper

PostPosted: Sat Jun 26, 2010 1:46 am    Post subject:
Reply with quote

Alpha is in X(26) and Numeric is 9(12) COMP-3 and 9(14) COMP-3.

That is how it is in the system - a very old but largely used system. We cannot change anything about it. Both the formats are already in use.

I would think atleast 9(12) should be convenient to move to 9(12) COMP-3 - but in actual scenario it doesnt seem to work.
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: Sat Jun 26, 2010 2:21 am    Post subject:
Reply with quote

Hello,

You are making this more difficult than necessary. . .

Quote:
We cannot change anything about it.

You can redefine data without changing anything. . .

Redefine the x(26) as 2 numeric fields 9(12) and 9(14) - or create a new working-storage field that contains these and move the entire x(26) field to this new field. Then move the 2 numeric fields to the comp-3 fields.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jun 26, 2010 3:02 am    Post subject:
Reply with quote

Quote:
I would think atleast 9(12) should be convenient to move to 9(12) COMP-3 - but in actual scenario it doesnt seem to work.
What does this mean -- the move worked but the data is not numeric? the move worked and the data is numeric but not what you expected? the move generated an abend? the move generated some kind of return code? Saying "it doesn't (sic) seem to work" is not providing any useful information.

Does the alphanumeric variable have just numbers in it -- or can it have non-numeric characters as well? You say in one file it is alphanumeric and another it is COMP-3 -- do you mean it is a single 26-byte packed decimal variable (which is allowed under the COBOL ARITH(EXTEND) option)?

Let's start at the beginning since you have so far managed to completely confuse a large number of people -- please describe the key field as defined in both programs (use the CODE button to post the actual descriptions from the programs), and describe what transformation rule(s) you are expecting to use to go between the two keys.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 683
Location: Pennsylvania

PostPosted: Mon Jun 28, 2010 5:44 pm    Post subject:
Reply with quote

prgrmr

My crystal ball tells me that if your file layout looks like:
Code:

01 FILE-1-DATA.
   05 ALPHA-FIELD     PIC X(26).
   05 KEY-FIELD REDEFINES ALPHA-FIELD.
      10 KEY-FIELD-1  PIC 9(12).
      10 KEY-FIELD-2  PIC 9(14).

01 FILE-2-DATA.
   05 KEY-FIELD-GROUP1 PIC X(15).
   05 KEY-FIELD-GROUP2 REDEFINES KEY-FIELD-GROUP1.
      10 KEY-FIELD-1  PIC 9(12) COMP-3.
      10 KEY-FIELD-2  PIC 9(14) COMP-3.


Then your data would like like this (if you were actually show it to help every one out):
Code:

FILE-1-DATA.
PIC X(26) FIELD
----+----1----+----2----+----3---
50005000000000000123001234
PIC 9(12) FIELD
500050000000
PIC 9(14) FIELD
00000123001234

FILE-2-DATA.
PIC 9(12) COMP-3 FIELD
----+----1----+----2----+----3---
0000000
505000F
PIC 9(14) COMP-3 FIELD
----+----1----+----2----+----3---
00013024
0002013F


From my experience, COMP-3 fields are generally an odd number in length. This is because the last half-byte is an F, C, or D depending on sign/unsign.

In your case as an even number, I would guess there is a leading zero in the first half byte, and a trailing F in the last half byte.

If you were to show your data (I know high expectations on my part), with HEX ON and CODE tag, my guess would be confirmed.

HELP US HELP YOU or respond: 'I no longer need your help'.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm

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