Fetch-return Statement

I have a program p1 which calls 3 other program p2,p3,p4 using fetch return.
Program p1 passes some parameters to each of these other programs.
I want these value of these parameters after execution of fetch return.
How do i get these values from the other modules.Does fetch reTurn give you the value of the parameters passed after execution?
I have used the parameters as local in p2,p3 and p4.
I want this detail because I want to make changes only to p1 such that it applies to all the fecthing modules.
If I dont get these values passed back from p2,p3 and p4 then i’ll have to repeat the changes for every module (which I dont want to do).
Can some throw light on this.

Eg:
DEFINE DATA
LOCAL
01 #UPDATE-FLAG (L) INIT
END-DEFINE
.
.
.

FETCH RETURN P2-MODULE #UPDATE-FLAG #END-TIME

IF #UPDATE-FLAG =TRUE
PERFORM USAGE
ELSE
ESCAPE BOTTOM
END-IF

FETCH RETURN P3-MODULE #UPDATE-FLAG #END-TIME

(same code here)

IN P2

DEFINE DATA
LOCAL
01 #UPDATE-FLAG (L) INIT
END-DEFINE

No, there is absolutely NO connection between the calling and the called program’s LOCAL data.

When you pass parameters on a FETCH or FETCH RETURN, these are put on the STACK and can be read by the called program via an INPUT statement.

If you absolutely insist in having the called objects being of type PROGRAM instead of making it SUBROUTINEs and just CALLNAT them, choices are:

  • - STACK the modified parameters in the called programs and read them back in with an INPUT in P1 after the FETCH RETURN.

    - Put that variables into a GLOBAL data area, which can be shared by caller and callee.

This works as follows:

P1 is:

define data local
01 p2-module (A8) const <'p2module'>
01 p3-module (A8) const <'p3module'>
01 #UPDATE-FLAG (L) INIT<FALSE>
end-define

FETCH RETURN P2-MODULE #UPDATE-FLAG
input #update-flag   /* get data from stack

IF #UPDATE-FLAG =TRUE
write 'p2-true'
ELSE
write 'p2-false'
END-IF

reset #update-flag
FETCH RETURN P3-MODULE #UPDATE-FLAG
input #update-flag

IF #UPDATE-FLAG =TRUE
write 'p3-true'
ELSE
write 'p3-false'
END-IF
end

P2MODULE is:

DEFINE DATA
LOCAL
01 #UPDATE-FLAG (L)
END-DEFINE
input #update-flag
#update-flag := TRUE
stack top data #update-flag
END

Third possibility is: Use CALLNAT and write a proper subprogram.

thanks wolf and matthias
That helped me a lot

May favorite is to use Application Independent Variables (AIV’s) in cases like this. Just another alternative.