support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets

Veryant Knowledge Base
Home > All Categories > Compiler General > How can I make my Linkage parameters more flexible?
Question Title How can I make my Linkage parameters more flexible?

By using standard COBOL variables in the Linkage Section of your program to receive strings and numbers, you force the calling programs to use specific data items to pass the parameters.
For example, if you define a parameter as PIC X(100), the calling program will be able to pass that parameter using a PIC X(100) data item or a constant string, but not a PIC X ANY LENGTH data item. On the other hand, if you define a parameter as PIC X ANY LENGTH, then the calling program will be forced to use a PIC X ANY LENGTH item to pass the parameter. If you define a parameter as PIC 9(2), the calling program will be able to pass the parameter using a PIC 9(2) data item, but not computational data item or a constant number.
You can get rid of these limitations and create more dynamic routines by defining your Linkage parameters as CobolVar objects and then using the toint() and toString() methods to get the parameter value.
The following test program demonstrates the procedure:

   program-id. callee.
   configuration section.
   class cobolvar as "com.iscobol.types.CobolVar".
   |note: if you're compiling with -cp, the class name is "com.iscobol.types_n.CobolVar"
   working-storage section.
   77 string-param pic x any length.
   77 numeric-param pic s9(9).
   linkage section.
   77 param-1 object reference cobolvar.
   77 param-2 object reference cobolvar.
   procedure division using param-1, param-2.
   set string-param to param-1:>toString()
   set numeric-param to param-2:>toint()
   display "First parameter (string): " string-param.
   display "Second parameter (number): " numeric-param.

Test it with
1) constant values:

   working-storage section.
   procedure division.
   call "callee" using "xxx" 123.

2) dynamic length items

   working-storage section.
   77 dynamic-string pic x any length.
   procedure division.
   move "xxx" to dynamic-string.
   call "callee" using dynamic-string 123.

3) fixed length items and comp items

   working-storage section.
   77 fixed-string pic x(10).
   77 my-number pic 9 comp-1.
   procedure division.
   move "xxx" to fixed-string
   move 123 to my-number
   call "callee" using fixed-string my-number.
Authored by: Veryant Support This question has been viewed 4376 times so far.
Click Here to View all the questions in Compiler General category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. Why do I get the error "java.lang.NoClassDefFoundError: com/sun/tools/javac/Main" ?
  2. How do I resolve "Error writing file: too many constants" error?
  3. Is there a faster way to compile?
  4. What compiler options cannot be specified with the >> IMP OPTION compiler directive?
  5. How do I retrieve the version of the Java Compiler and the isCOBOL Compiler that produced a given class file?
  6. Using Regular Expressions to replace text in your program
  7. Is there a compiler option in isCOBOL to extend the length of AREA B in a program source code?
  8. This is a test
Article Information Additional Information
Article Number: 267
Created: 2016-04-05 8:27 AM
Rating: No Rating
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
Search Knowledge Base Search Knowledge Base


© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.