View previous topic :: View next topic
|
Author |
Message |
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
Hi Guys,
I have a set of programs (say A,B,C,D....) which call program BCE807ST
as follows:
CALL 'BCE807ST' USING
FROM-FIELD
TO-FIELD
LENGTH
var11
var22
Program BCE807ST is used to move data from the FROM-FIELD to the TO-FIELD.
Now I am facing the following problems:
1) All programs are not passing Var11 and Var22 as parameters to BCE807ST. So the programs which are not passing these parameters how do I define default values for these parameters in BCE807ST ?
(as we cannot have value clause in the linkage section)
2) The length of the variables passed from the calling program is not fixed.
For example:
FROM-FIELD can be PIC X(10) to PIC X(10000)
I dont want to use PIC X(10000) in program BCE807ST if data passed from calling program has data type PIC X(10).
can you please suggest me a way to do so using pointers wherein i dont need to haed code the length of the variables passed to the program BCE807ST? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
instead of passing 5 parms,
why not pass one parm? - a structure (copybook defining all fields necessary)
to include the fields containing the length of FROM-Field and to-field.
obviously FROM-FIELD and TO-FIELD must be defined in the structure as 10,000.
also, keep in mind that the FROM/TO-FIELDs defined in the structure,
are working storage of the CALLing programs and are linkage of the CALLed programs.
I would also suggest having some type of FUNCTION field defined in the structure.
you have asked about using pointers; this can easily be done, by someone with experience. That you have asked, shows you have little.
I am not begrudging your experience, but I feel that you are over complicating the task. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
You need to be aware that COBOL generates pseudo-assembler code based on what you indicate you are doing. Passing a 10-byte variable will require only one address register to access the data; passing a 10000-byte variable will require three address registers to access the data. Unless you follow Dick's suggestion and include lengths of fields as part of the structure you pass to BCE807ST, you have an excellent chance of getting S0C4 abends. |
|
Back to top |
|
|
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
Hi Guys,
Due to some constraints I am not allowed to make any changes to the parameters passed from the calling programs or rather i do not have the authority to make any changes to the calling programs.
So now I need to know:
Can I have default values set for variables var11 and var22 in my called program BCE807ST, as some of the calling programs do not pass these parameters to BCE807ST? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Although I haven't tested this, you SHOULD be able to use
Code: |
IF ADDRESS OF var22 = NULL
.
.
.
IF ADDRESS OF var11 = NULL |
to check for these variables not being passed and take appropriate action. |
|
Back to top |
|
|
Amb
New User
Joined: 12 Mar 2010 Posts: 64 Location: India
|
|
|
|
thanks Robert...
the above code is working... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Glad to hear that -- thanks for letting us know. |
|
Back to top |
|
|
|