Start of change

Dynamic call between AMODE 31 and AMODE 64 programs

Calls between AMODE 64 programs and AMODE 31 programs (when a subprogram has a different AMODE from the caller) can only be done via dynamic CALL. The caller can be AMODE 31 or 64. No indication in the CALL statement is needed. The dynamic call handler in the COBOL runtime determines the AMODE of the subprogram and processes accordingly.

The programs must be compiled by COBOL 6.3 or above. If the RETURNING phrase in the CALL statement is not used, the AMODE 31 program can be compiled with COBOL 5.1 and later releases. Start of changeNon-COBOL programs are not supported by mixed AMODE 31/64 COBOL dynamic call.End of change

The user program needs to make sure data items passed in parameters, directly or indirectly, are accessible by the subprogram. The DATA directive can be used to specify the storage location as required.

Parameter Passing

Both CALL ... USING BY REFERENCE and CALL ... USING BY CONTENT are supported.

CALL ... USING BY VALUE parameter is not supported.

If the CALL ... RETURNING phrase is used, the returning data item must not be larger then 24 bytes.

The RETURNING phrase supports for the following data items:
  • alphanumeric
  • zoned decimal
  • COMP-3 (packed-decimal)
  • COMP-4
  • COMP-5
  • COMP (BINARY)
Note: There is an extra copying required to return a data item across two AMODE settings. You can avoid the requirement by passing the data item with CALL ... USING BY REFERENCE. This method has better performance, especially for large data items.

Subprogram in dynamic call

When compiling the caller program, the DLL option is not needed. This is to facilitate mixed AMODE usage when the subprogram of an existing pure AMODE 31 application is recompiled with LP(64) while the caller program can remain in AMODE 31. The subprogram can be called by the caller program without recompiling the caller program with the DLL compiler option.

The subprogram must be a DLL.

To build DLL subprograms:
  • When building a DLL, specify the compiler options EXPORTALL and DLL, and the binder options RENT and DYNAM=DLL.
  • The program-id in the DLL program must be the same as the DLL module name. Otherwise the DLL cannot be called using dynamic call.
Note: As an effort to simplify DLL usage with LP(64), the DLL compiler option is not needed when building AMODE 64 programs. You can still specify it, there is no need to remove it in existing LP(64) compilations. The compiler would accept and ignore it. The EXPORTALL compiler option is still needed. The Binder option settings for DLL remain unchanged.

External file

The same external file can not be accessed by programs with different AMODE settings.

Related tasks    
Making dynamic calls

Related references    
DATA (Enterprise COBOL for z/OS® Language Reference)  
CALL statement (Enterprise COBOL for z/OS Language Reference)  

End of change