Problem with LMGET after an LMPUT & LMADD



TSO Programming, ISPF, SDF, SDSF and PDF, FTP, TCP/IP Concepts, SNA & SNA/IP etc...

Problem with LMGET after an LMPUT & LMADD

Postby don shaw » Fri Jun 10, 2011 12:50 am

My program reads a member of a PDS, and processes statements within it. If the member does not exist, then i create it with a dummy statement; but i get a RC=* when i attempt to read that member within the same program invocation. If i run the program again after the member has been created, i can read it it successfully. I think i'm missing a FREE, or specifying the wrong DATAID, or ??? Any suggestions as to what's missing in the attached code?
/* REXX */                                                           
PARSE SOURCE s1 s2 s3 s4 s5 s6 s7 s8 s9                               
 thislib = s5                                                         
 membr = "$MYDSN$"                                                   
 prefix = sysvar('SYSPREF')        /* tso profile prefix            */
 uid    = sysvar('SYSUID')         /* tso userid                    */
 If prefix = '' then prefix = uid  /* use uid if null prefix        */
 If prefix <> '' & prefix <> uid then /* different prefix than uid  */
    prefix = prefix || '.' || uid /* use  prefix.uid                */
call S100_PDS_Get_Member                                             
say " CYaBy..."                                                       
exit (0)                                                             
                                                                     
S100_PDS_Get_Member:                                                 
Address ISPEXEC                                                       
   "LMINIT DATAID(MYDSNS) DATASET('"thislib"') ENQ(SHR)"             
   "LMOPEN DATAID("mydsns") option(input)"                           
   "LMMFIND DATAID("mydsns") MEMBER("membr")"                         
   if rc = 8 then   /*  member not there, so add it... */             
    do                                                               
     Say "Member '"thislib"("membr")' is not there; creating... "     
     "LMMLIST DATAID("mydsns") OPTION(FREE)"     /* free the list */   
     "LMCLOSE DATAID("mydsns")"  /* close as input, reopen as output */
     "LMFREE DATAID("mydsns")"                                         
     "LMINIT DATAID(MYDSNS) DATASET('"thislib"') ENQ(SHRW)"           
     "LMOPEN DATAID("mydsns") option(output)"                         
     recdline = thislib                                               
     "LMPUT DATAID("mydsns") MODE(INVAR) ",                           
          " DATALOC(recdline) DATALEN(80)"                             
     "LMMADD DATAID("mydsns") MEMBER("membr") STATS(NO)"               
     "LMMLIST DATAID("mydsns") OPTION(FREE)"     /* free the list */   
     "LMCLOSE DATAID("mydsns")"  /* close as output, reopen as input*/
     "LMFREE DATAID("mydsns")"                                         
     "LMINIT DATAID(MYDSNS) DATASET('"thislib"') ENQ(SHR)"             
     "LMOPEN DATAID("mydsns") option(input)"                           
    end                                                               
   Call S200_Records_Get                                               
   "LMMLIST DATAID("mydsns") OPTION(FREE)"   /* free the list */       
   "LMCLOSE DATAID("mydsns")"                                         
   "LMFREE DATAID("mydsns")"                                           
Return                                                                 
S200_Records_Get:                                                 
   LM_GET = "LMGET DATAID("mydsns") mode(invar) dataloc(myrec) ",
      " datalen(inlen) maxlen(080)"                               
   do forever                                                     
     LM_GET                                                       
     if rc = 0 then                                               
      do                                                         
       call S300_Record_Process                                   
      end                                                         
     else                                                         
     if rc = 8 then                                               
      do                                                         
       /* say "LMGET EOF..."  */                                 
       leave                                                     
      end                                                         
     else                                                         
      do                                                         
       say "LMGET bad RC = " rc                                   
       leave                                                     
      end                                                         
     end                                                         
Return             
S300_Record_Process:
Return             
don shaw
 
Posts: 5
Joined: Fri Oct 29, 2010 7:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Problem with LMGET after an LMPUT & LMADD

Postby MrSpock » Fri Jun 10, 2011 2:41 am

There should be a "Drop mydsns" REXX instruction somewhere in there if you intend to reuse the same Dataid name again.
User avatar
MrSpock
Global moderator
 
Posts: 807
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Re: Problem with LMGET after an LMPUT & LMADD

Postby don shaw » Fri Jun 10, 2011 7:17 pm

Thank you Mr Spock!

I used a different dataid for the creation of the new member, and did an LMMFIND for it, then the process worked as desired.
Thanks for the tip!

Cheers, ...Don
don shaw
 
Posts: 5
Joined: Fri Oct 29, 2010 7:49 pm
Has thanked: 0 time
Been thanked: 0 time


Return to TSO & ISPF

 


  • Related topics
    Replies
    Views
    Last post