For: Steven Warren -- Mail Problems -- C/COBOL structures 
Author Message
 For: Steven Warren -- Mail Problems -- C/COBOL structures

Can't seem to be able to send you mail. always receiving lock errors. So I

up. Looks like you need to beat up your communications guy.

-------------------------------------------------------------------------



Certify:        Y
Subject:        re: COBOL and C integration, insight sought
Date:           Thursday, October 12, 1995 at 6:17:12 pm EDT
Attached:       None

Quote:
- - - - - - - - - - - - - - Original Message - - - - - - - - - - - - - -

Received: by gencredits.com; Thu, 12 Oct 95 17:49:10 EDT

        id AA28844; Thu, 12 Oct 1995 14:49:04 -0700
Received: from sys_sf01.wfnia.com by comm_sf_01 (4.1/SMI-4.1)
        id AA09042; Thu, 12 Oct 95 14:43:09 PDT
Received: from ats_sf0.wfnia.com by sys_sf01.wfnia.com with SMTP
        (1.38.193.5/16.2) id AA23742; Thu, 12 Oct 1995 14:43:02 -0700
Received: from localhostby ats_sf0.wfnia.com (1.38.193.5) id AA23121; Thu, 12
Oct 1995 14:43:01 -0700

Date: Thu, 12 Oct 95 14:43:01 -0700


X-Mailer: Mozilla 1.1 (X11; U; HP-UX A.09.04 9000/887)
Mime-Version: 1.0

Subject: COBOL and C integration, insight sought

Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii

Hi, I noticed in your posting you do a lot of C and COBOL.  I just finished
migrating a ~12 million line system to UNIX from a mainframe and the biggest
problem I had/have is integrating the C stuff I wrote around the core COBOL.
Do you have any insights/advice/software which deals with COBOL->C structure
conversion?  Specifically I have trouble handling data alignment and packed
decimal types...

Thanks for any input/insight you have.

--
Steven Warren

"I am Homer of Borg.  Prepare to be assim... OOH! DONUTS!"
"I am Popeye of Borg. You will be askimilgrated."
"I am Porky Pig of Borg. You will be abbadi abbadi abbadi assimilated!"
"Hi, ho! Kermit the Borg here, with an assimilation news flash!"
Borg...James Borg.
"I am Locutus, of the Hair Club for Men."

- - - - - - - - - - - - End of Original Message - - - - - - - - - - - -

Yeah, we deal with the same problems. It wasn't as bad when I wrote all of
the supporting routines in assembler, then I had complete control over the
packing. With C, if you try to pack the structures that are used internally
(direct.h, etc), you have additional problems.

Here we are on the i386 platforms, running Banyan Vines on top of Unix. Our
appliations are all written for the PC's so what we do is probably a little
different that what you are doing.

One trick I picked up along the way was in learning how to order my
structures. For example if we were going to contain the following items in a
structure (group item):

        char    UserName[9];
        char    Password[12];
        int     Age;
        long    LastLogin;
        int     NumberOfSession;

If this is what the specs called for you would probably make a structure such
as the following:

        01  XYZ.
                02  UserName    PIC X(09).
                02  Password    PIC X(12).
                02  AGE         PIC S9(4) COMP-5.
                02  LastLogin   PIC S9(8) COMP-5.
                02  NumSessions PIC S9(4) COMP-5.

typedef struct {
        char    UserName[9];
        char    Password[12];
        int     Age;
        long    LastLogin;
        int     NumberOfSession;
} XYZ;

But, when you try to access it from C, your structure will not line up
properly. But, if the COBOL structure is defined as:

        01  XYZ.
                02  LastLogin   PIC S9(8) COMP-5.
                02  AGE         PIC S9(4) COMP-5.
                02  NumSessions PIC S9(4) COMP-5.
                02  UserName    PIC X(09).
                02  Password    PIC X(12).

Then the cooresponding C structure:

typedef struct {
        long    LastLogin;
        int     Age;
        int     NumberOfSession;
        char    UserName[9];
        char    Password[12];
} XYZ;

Will align properly. This takes into consideration the fact that C compilers
will generally align LONG INT, DOUBLE, and FLOAT or a 4 Byte boundry and an
INT on a 2 byte boundry. Character arrays usually are not aligned.

You have probably already thought of this, but if you hadn't I thought I
would throw it in.

As for converting computation types, we have C routines that I have written
to do it for us automatically. They have names such as Comp3_2_Display,
Comp6_2_Display, Cobol_2_C, C_2_Cobol, etc. If you would like to see any of
the code I will be happy to forward it to you.

StorminNormin                   - Norman E. Gottschalk III
Manager of MIS


Norman E. Gottschalk III
Manager of MIS
General American Credits, Inc.



Tue, 31 Mar 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. US-NJ(Warren )-COBOL/C++, Microfocus Programmer -Recruiter [NL550 - 99]

2. conflict between CS-PICK and control structure checking

3. please unscribe dinh@cs.ucla.edu from the scheme mailing list

4. to CS: or not to CS: in F-PC assembler

5. COBOL/VSAM/Contract/CS/Tx

6. Help a Non Cobol CS Instructor with CASE...

7. * US-OH-COLUMBUS-PA-COBOL/IMS/CICS

8. some lost porters are brave and other closed onions are sticky, but will Steven taste that

9. Steven Miales extensions

10. Steven Miales extensions

11. Paging Steven B Wahl...

12. Steven Byrne, where are you ?

 

 
Powered by phpBB® Forum Software