【问题标题】:Single source for IBM i and z/OSSingle source for IBM i and z/OS
【发布时间】:2022-04-01 21:07:10
【问题描述】:

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.

    标签: ibm-midrange cobol zos


    【解决方案1】:

    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.

    • Thank you. I have the basic conditional statement working in the code but how do I signify the DEFINE variable? I tried passing it in on the PARM statement but it says it was invalid.
    • I found it. In the PARM, I use something like DEFINE(IBM-Z).
    • I found that this isn't working for me (z/OS COBOL V6.3). While the JCL has the DEFINE(IBM-Z), the >>IF isn't accepting that as a >>DEFINE variable. So I'm still lost how to do this. :(
    • To me the documentation reads like you must use a >>DEFINE IBM-Z AS PARAMTER in your COBOL-source for the compiler to pick up the DEFINE(IBM-Z) from the compile-option.
    • piet likely meant >>DEFINE IBM-Z AS PARAMETER (typo, missing E). To format in comment, just put backticks ` around your to-be-formatted-as-code
    【解决方案2】:

    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.

    • Actually something like what @cschneid is what I was looking for. Thanks for the suggestion however.
    • I think that works fine with Enterprise COBOL, but questioned that it does with COBOL for IBM/i
    【解决方案3】:

    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.

      猜你喜欢
      • 1970-01-01
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多