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
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
// 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