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

Moving a big alphanumeric field into a small char field.


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

New User


Joined: 15 Nov 2007
Posts: 36
Location: India

PostPosted: Thu Apr 17, 2008 5:53 pm
Reply with quote

Hi,
I have a code which reads the input file and inserts the record into a table.
Now, I have a field called SCHEME in the file which is of length 20 defined as ALPHANUMERIC.
Now, I need to move this field into the table field which is of length 3 defined as CHAR.
The field SCHEME from the file may contain one word, two words and so on.
Now, the problem is how to move this 20 byte field to a 3 byte field?
We are thinking of moving the first three bytes of the file field but we are getting duplicates which the table will not accept, the table field being a part of the index.

We are also thinking to use the first three bytes if it has one word and use the first byte of each word if the field has more than one word.
But still we are getting duplicate values for the field in this case also.
All this should be done in the code it self.
Please let me know what other ways we can think of.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Thu Apr 17, 2008 6:17 pm
Reply with quote

Poor design/implementation...
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Apr 17, 2008 6:29 pm
Reply with quote

Quote:
Now, the problem is how to move this 20 byte field to a 3 byte field?


if it were possible it would be the nightmare of storage marketing people
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Apr 17, 2008 6:43 pm
Reply with quote

Please clarify Your needs...

there is no way to squeeze into three bytes the info contained in twenty bytes
( unless Shannon had it completely wrong...
if You are interested search for "shannon entropy" )
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu Apr 17, 2008 8:13 pm
Reply with quote

Hello,

Quote:
Now, the problem is how to move this 20 byte field to a 3 byte field?
Sorry, but that is not just a problem - it is not do-able. . .

One alternative is to re-define the table to accomodate the full width of the data.

As was requested before, please clarify excatly what you need to do. Your post does not explain the requirement, but rather a "solution" that does not work.
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: Thu Apr 17, 2008 8:28 pm
Reply with quote

Well if there was only 999 posible combinations, a table lookup/translate might work....
Or 99999 iif packed decimal....
Or 16777215 if binary.......
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Apr 17, 2008 8:31 pm
Reply with quote

With a 3 byte alphanumeric code you could handle a lot of combinations, it just depends on how may variations there are in that 20 byte field. Sounds like a slight design problem.
Back to top
View user's profile Send private message
kovur

New User


Joined: 15 Nov 2007
Posts: 36
Location: India

PostPosted: Fri Apr 18, 2008 10:22 am
Reply with quote

Hi friends,
Thanks for your response.
I did not expect that the following line can make people confused.
kovur wrote:
Now, the problem is how to move this 20 byte field to a 3 byte field?


In fact, the problem is we have to take 3 bytes from the 20 byte field and move it to the table field which is char(3)
Which 3 bytes to take is the problem.
One more issue is there is a possibility that we may get a new SCHEME name in future. Then, 3 bytes should be taken from that filed and moved to the table.
Please let me know if everything is clear by now or any thing else is needed.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Fri Apr 18, 2008 12:45 pm
Reply with quote

the real question ( not answered yet )
what is the projected usage of these three bytes
given that the mapping of 20 to 3 will never be unique
( unless, as many posters do, You are hiding/not-telling something )
Back to top
View user's profile Send private message
kovur

New User


Joined: 15 Nov 2007
Posts: 36
Location: India

PostPosted: Fri Apr 18, 2008 2:16 pm
Reply with quote

Hi Enrico,
This three byte field will be moved to the table DCLGEN and this along with other fields is used to Update or insert the record in to the table.

Hope I gave the correct answer.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Fri Apr 18, 2008 2:19 pm
Reply with quote

You just told that You are shuffling things around
but not the logic why the application wants to squeeze 20 bytes in 3 bytes
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Apr 18, 2008 7:34 pm
Reply with quote

Hello,

If you explain the business requirement or rule you need to implement (rather than talking about 20 or 3 bytes), we may be able to offer better suggestions.

So far, most of us do not understand what you need to do.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Apr 21, 2008 7:56 am
Reply with quote

Hi Kovur,

You might try something like this to get your problem across:


Quote:
I have a 20 byte field that looks like this:

(Show the field here)

The 3 bytes I want to move are:

(Show the 3 bytes here)

The position of the 3 bytes will vary from rec to rec; the position in the 20 byte variable might change too, etc., etc.


I'm only guessing at what you may include, but you get the idea.
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 Help required to reset decimal points... DFSORT/ICETOOL 8
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top