Example 2:

This REXX exec invokes the LMINIT service in preparation for the EDIT service call. Then, it invokes the EDREC service to create an edit recovery table if one does not exist. The exec then uses the QUERY parameter of the EDREC service to see if edit recovery is pending. If it is, then it displays the edit recovery panel, ISREDM02, and process the response. If recovery is requested from ISREDM02, the EDREC service is called with the PROCESS parameter; otherwise, the EDREC service is called with the DEFER parameter. The EDREC QUERY is invoked from within a loop so that all pending edit recovery sessions can be processed. After edit recovery processing is complete, the EDIT service is called, followed by an LMFREE to free the data ID set by the LMINIT service.

/* REXX exec to use edit recovery prior to edit */
address ispexec
'lminit dataid(data1) dataset(private.source)'
if rc = 0 then
  do
    'edrec init'                            /* create recovery table */
    do until edrc/=4 | edcon = 0
      'edrec query'                         /* check for recovery ds */
       edrc = rc
       if edrc=4 then
         do
           z1=zedtdsn                      /* set up panel variable  */
                                             /* and show recovery panel*
           'display panel(isredm02) cursor(zcmd)'
           if rc = 0 & substr(zedcmd,1,1)=' ' then
             do
               'edrec process'             /* process recovery       */
               edcon = 0                   /* and end loop           */
             end
           else if rc = 0 & substr(zedcmd,1,1)='c' then
             'edrec cancel'
           else
             'edrec defer'
         end
    end
    'edit dataid('data1') member(sample)'
    'lmfree dataid('data1')'
  end