Ed Danley
Ed Danley

Reputation: 63

Single source for IBM i and z/OS

I am primarily a C developer, not a regular COBOL developer. I would like my COBOL program to have the same source on IBM-i as it does on z/OS.

My COBOL program calls a subroutine. On z/OS I do the call like this:

CALL                                      
  'PBFNInit' USING                        
                    BY VALUE NULL-POINTER,

On IBM i I have to call like this:

    CALL PROCEDURE
      'PBFNInit' USING                        
                        BY VALUE NULL-POINTER,

Is there some way I can dynamically tell the COBOL compiler which format of the CALL statement to use?

I was hoping for some kind of dynamic statement like the debug statement controlled by this

SOURCE-COMPUTER. IBM-3270 WITH DEBUGGING MODE.

Upvotes: 1

Views: 206

Answers (4)

Joel Bauwens
Joel Bauwens

Reputation: 1

I don't work with these compilers and don't develop infrastructure SPLs, but if I had to, because the word PROCEDURE is the only difference for the compiler on IBM i , I'd do it like this

  • Of course as said by piet.t Apr. 1/2022

    DEFINE(IBM-I) as compile-option when compiling on IBM i and add >>DEFINE IBM-I AS PARAMETER in your COBOL source (at beginning)

  • Into your cobol source, just be sure to add the PROCEDURE word when needed

     CALL 
         >>IF IBM-I DEFINED 
              PROCEDURE
         >>END-IF
    
          'PBFNInit' USING                        
           BY VALUE NULL-POINTER, [...]
    

Upvotes: 0

Barbara Morris
Barbara Morris

Reputation: 3674

If all your calls should be procedure calls, it looks like you can set this for all calls with a parameter on the compile or a process option.

https://www.ibm.com/docs/en/i/7.4?topic=program-identifying-linkage-type-called-programs-procedures

It says

the LINKLIT parameter of the CRTCBLMOD and CRTBNDCBL commands, or the associated PROCESS statement option.

The LINKLIT parameter of the CRTCBLMOD and CRTBNDCBL commands allows you to specify, at compile time, the linkage type for all external CALL literal-1, CANCEL literal-1, or SET procedure-pointer-data-item TO ENTRY literal-1 statements in the ILE COBOL program. You do not need to specify the LINKAGE TYPE clause in the SPECIAL-NAMES paragraph or the LINKAGE TYPE phrase with the CALL, CANCEL, or SET…ENTRY statement when the linkage has been defined by the LINKLIT parameter of CRTCBLMOD or CRTBNDCBL.

Upvotes: 0

cschneid
cschneid

Reputation: 10775

If your compiler supports conditional compilation, you could define a constant with a compiler directive and then...

    >>EVALUATE TRUE
    >>WHEN DEFINED IBM-Z
        CALL 'PBFNInit' USING                        
            BY VALUE NULL-POINTER, [...]
    >>WHEN DEFINED IBM-I
        CALL PROCEDURE 'PBFNInit' USING                        
            BY VALUE NULL-POINTER, [...]
    >>WHEN OTHER
        !non-sequiter, your facts do not coordinate
    >>END-EVALUATE

UPDATE 1 per comment...

You could try combining this answer with that of @SimonSobisch, something like...

    >>IF DEFINED IBM-I
        REPLACE ==CALL== BY ==CALL PROCEDURE==.
    >>END-IF

        CALL 'PBFNInit' USING                        
            BY VALUE NULL-POINTER, [...]

There is nothing currently in the documentation to indicate the text being conditionally compiled must be valid code. Maybe the authors felt this was implicit, or maybe it's a bug.

Upvotes: 2

Simon Sobisch
Simon Sobisch

Reputation: 7297

The WITH DEBUGGING MODE would be a minor change in each file - but also overlap with an actual COBOL feature.

If "minor change" is ok for you then only code CALL PROCEDURE and use a single

REPLACE ==CALL PROCEDURE== BY ==CALL==.

in the source.

Upvotes: 0

Related Questions