940 pts.
 Data area *LIBL/INSRLIST is not allocated for output.
The following is a snippet of the code. I get an error on the OUT op code as in the title.

 * Next List Number                                   D                 DS                                  D Get_Next_List                  6S 0 DtaAra(INSRLIST)

//  Create Header record              In *Lock Get_Next_List;         //  Ge                                       DoU Done  = @True;                    Chain(E) Get_Next_List INSRL100;      If %Found;                     // Inc    Get_Next_List = Get_Next_List +1;        If Get_Next_List = 999999;               Get_Next_List =      1;            EndIf;                             Iter;                              EndIf;                                If NOT %Found;                           SHListNo      = Get_Next_List;        Get_Next_List = Get_Next_List  +1;    Out      Get_Next_List;      //  Up EndIf;                               

Thanks, Phil



Software/Hardware used:
V5R4
ASKED: February 25, 2010  9:31 PM
UPDATED: February 26, 2010  2:17 PM

Answer Wiki:
<pre> * Next List Number D DS D Get_Next_List 6S 0 DtaAra(INSRLIST) // Create Header record In *Lock Get_Next_List; // Ge DoU Done = @True; Chain(E) Get_Next_List INSRL100; If %Found; // Inc Get_Next_List = Get_Next_List +1; If Get_Next_List = 999999; Get_Next_List = 1; EndIf; Iter; EndIf; If NOT %Found; SHListNo = Get_Next_List; Get_Next_List = Get_Next_List +1; Out Get_Next_List; // Up EndIf; </pre>
Last Wiki Answer Submitted:  February 25, 2010  9:36 pm  by  MurrayInfoSys   940 pts.
All Answer Wiki Contributors:  MurrayInfoSys   940 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Phil
Nothing seems wrong in the code you’ve shown
Eventually it reaches the Enddo looping back to the do until
And if DoU Done = @True; this isn’t true it finds another number and tries to out to the dataarea. But the second time the dataarea is no longer locked — the out unlocks it and the error occurs.
The other Phil

 44,180 pts.

 

// finally a good business use for recursion — this still needs work — if all numbers
// are used it never ends

In *Lock Get_Next_List; //
if getNextVal(Get_Next_List );
SHListNo = Get_Next_List;
Get_Next_List = Get_Next_List +1;
Out Get_Next_List;
——————————————
P getNextVal B
D getNextVal PI N
D Get_Next_List like (SHListNo )
/free
Get_Next_List = Get_Next_List +1;
If Get_Next_List = 999999;
Get_Next_List = 1;
EndIf;
Chain(E) Get_Next_List INSRL100;
if found%(INSRL100);
return getNextVal(Get_Next_List );
else
return *on;
endif;
/end-free
P getNextVal B

 44,180 pts.