dbTalk Databases Forums  

Ultimate plus pgmr forced to interact with mainframers

comp.databases.pick comp.databases.pick


Discuss Ultimate plus pgmr forced to interact with mainframers in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
britter440
 
Posts: n/a

Default Ultimate plus pgmr forced to interact with mainframers - 11-03-2010 , 07:50 AM






I'm working on an Ultimate Plus r83 virtual machine running on AIX.
I'm working on a project that requires me to feed a file to a
Mainframe COBOL environment. They have a predefined layout that
requires two COMP type fields and a COMP-3 field. The COBOL
definition for the COMP-3 field is S9(7) COMP-3.

I'm able to accomplish the COMP-3 packing, but I'm losing any required
zero fill at the beginning of my field. here's an example.

MYVAR = '15000'
MYOUT = ICONV(MYVAR,'MP'); *this packs the "15000" into a comp-3
field, but it doesn't know that my field def is S9(7)

So, instead of HEX data that looks like
0100
050F

I get the following:
100
50F

I tried zero padding MYVAR

MYVAR = '15000' 'R%7'
MYOUT = ICONV(MYVAR,'MP')

but it drops the leading zeroes.

If i try to append anything to the front, it just adds ASCII
characters.

Has anyone had to tackle this previously?

Reply With Quote
  #2  
Old   
x
 
Posts: n/a

Default Re: Ultimate plus pgmr forced to interact with mainframers - 11-03-2010 , 11:05 AM






Try the routine found at:
http://pata-group.com
At the bottom of the page see:
"Convert signed number to COMP-3 format".
The result is byte ordered left to right but the order might be
different on the target machine.
Test program:
DEFFUN COMP3()

A = -1500 ;* Number to convert
SIZE = 4 ;* S9(7) length in bytes

X = COMP3(A,SIZE)
PRINT OCONV(X,'MX')
STOP

Reply With Quote
  #3  
Old   
Bill Crowell
 
Posts: n/a

Default Re: Ultimate plus pgmr forced to interact with mainframers - 11-03-2010 , 11:42 AM



In your example, you're doing field formatting prior to the ICONV
function.


MYVAR = '15000' 'R%7'
MYOUT = ICONV(MYVAR,'MP')

What you say that you want is a packed field with leading zeros. The
size is 4.

MYIN = 15000 ;* FOR CLARITY
MYVAR = ICONV(MYIN,'MP) ;* PACK THE FIELD
MYOUT = MYVAR 'R%4' ;* FORMAT IT RIGHT JUSTIFIED IN 4 ZEROS

depending on your compiler you could do this

MYOUT = ICONV(15000,'MP')'R%4'

I've not worked on Ultimate since about 1985...

Always format your data AFTER you process it. Formatting is part of
the output phase.

Good Luck!

Reply With Quote
  #4  
Old   
Kevin Powick
 
Posts: n/a

Default Re: Ultimate plus pgmr forced to interact with mainframers - 11-03-2010 , 11:54 AM



On 2010-11-03 13:42:04 -0400, Bill Crowell <bcrowell (AT) pavuk (DOT) com> said:

Quote:
depending on your compiler you could do this

MYOUT = ICONV(15000,'MP')'R%4'
That's fine to get an ASCII string formatted as described, but I
believe he needs COMP-3 encoding, which Lucian seems to have provided a
link to some code that will do it.

--
Kevin Powick

Reply With Quote
  #5  
Old   
britter440
 
Posts: n/a

Default Re: Ultimate plus pgmr forced to interact with mainframers - 11-05-2010 , 07:22 AM



On Nov 3, 1:42*pm, Bill Crowell <bcrow... (AT) pavuk (DOT) com> wrote:
Quote:
In your example, you're doing field formatting prior to the ICONV
function.

MYVAR = '15000' 'R%7'
MYOUT = ICONV(MYVAR,'MP')

What you say that you want is a packed field with leading zeros. The
size is 4.

MYIN * *= 15000 * * * * * * * * * *;* FOR CLARITY
MYVAR = ICONV(MYIN,'MP) ;* PACK THE FIELD
MYOUT = MYVAR 'R%4' * * * ;* FORMAT IT RIGHT JUSTIFIED IN 4 ZEROS

depending on your compiler you could do this

MYOUT = ICONV(15000,'MP')'R%4'

I've not worked on Ultimate since about 1985...

Always format your data AFTER you process it. Formatting is part of
the output phase.

Good Luck!
Bill I tried that one. The problem that I ran into was that the
"padding" was in ascii, it wasn't packed.


I think I can make Lucian's stuff work, but this compiler is flat out
rotten and doesn't like to use DEFFUN. I can work around that
though. Thanks for all of the help guys.

I was a fairly regular contributor to this group about 10 years ago.
I thought it had died. I was extremely happy to see that people are
still out here.

Reply With Quote
  #6  
Old   
x
 
Posts: n/a

Default Re: Ultimate plus pgmr forced to interact with mainframers - 11-05-2010 , 10:52 AM



I've changed the code so now is a subroutine that works on ancient
compilers too.
http://pata-group.com

A = -123 ;* Number to convert
SIZE = 4 ;* S9(7) length in bytes
CALL COMP3(A,B,SIZE)
PRINT OCONV(B,'MX')

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.