ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

RNX1221 unmonitored by ZAER002NF at statement 0000000258, instruction X'0000'.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RNX1221 unmonitored by ZAER002NF at statement 0000000258, instruction X'0000'.

    Hey Guys,

    Can anyone tell me what is wrong with this snippet of code? I know, through DBG, that this section is what is causing all my problems! (I'm very new to RPG Free so forgive me if this is elementary).

    PHP Code:
                 EMBOXN MAILBOX;
                 
    DoU %Eof(EDMAST22);
                  
    Chain(N) (EMBOXNEDMAST22;
                  IF %
    Found(EDMAST22);
                  
    EMSTSN 'R';
                  
    UPDATE R#MAST;
                  
    Iter;
                  EndIf;
                 
    EndDo;
             EndIf; 
    If y'all would like the full program, just let me know.

    Thanks a ton!!!!
    -TJ

  • #2
    PHP Code:
     *--------------------------------------------------------------------------------------------*
          *--------------------------------------------------------------------------------------------*
          *
    Files
           Dcl
    -F EDOTBX DISK(*EXTkeyed Usage(*Update);
           
    Dcl-F EDMAST22 DISK(*EXTkeyed Usage (*Update);
          *--------------------------------------------------------------------------------------------*
          *--------------------------------------------------------------------------------------------*
          *
    Standalones
           Dcl
    -S WKORD                   Char(11);       //Standalone that grabs PARM($ORDNWD)
           
    Dcl-S MAILBOX                 like(OTBOX);    //Sets Standalone to the Keyfield of EDOTBX
           
    Dcl-S EMBOXN                  like(EMBOX);    //Sets Standalone to K03-D field of EDMAST22
           
    Dcl-S EMSTSN                  like(EMSTS);    //Sets Standalone to the K01 field EMLSST
          
    *--------------------------------------------------------------------------------------------*
          *--------------------------------------------------------------------------------------------*
          *
    Plist for $ORDNWD
           Dcl
    -Pi ZAER002NF ExtPgm;                       // This is the modern way of specifying
             
    $ORDNWD           Char(7);                   // entry parameters for the program.
           
    End-Pi;
          *--------------------------------------------------------------------------------------------*
          *--------------------------------------------------------------------------------------------*

           
    //MAINLINE PROCESSING
           
    /Free
             WKORD 
    '%' $ORDNWD '%';
             
    OTBOX = *Blanks;
             
    EMBOX = *Blanks;
             
    EMSTS = *Blanks;

           
    //Find OTBOX # based off the PO number
             
    EXEC SQL
             select OTBOX into 
    :MAILBOX
                     from EDOTBX
                     where OTDTA LIKE 
    :WKORD;

             
    ExSR Error;                                  //Error-Handling SR

             
    IF (SQLSTATE = *Zeros);

              
    SetLL (MAILBOXEDOTBX;                     //Sets the first record of EDOTBX to MAILBOX
              
    Dou %Eof(EDOTBX);
              
    ReadE (MAILBOXEDOTBX;                     //Read record equal to MAILBOX in EDOTBX

                
    IF not %Eof(EDOTBX);
                  IF %
    SUBST(OTDTA:1:9) = 'BAK*06*AT';
                    %
    SUBST(OTDTA:5:5) = '44*RJ';
                    
    UPDATE R#OTBX;
                    
    Iter;
                  EndIf;

                  IF %
    SUBST(OTDTA:1:8) = 'ACK*IA*1';
                    %
    SUBST(OTDTA:5:4) = 'ID*0';
                    
    UPDATE R#OTBX;
                    
    Iter;
                  EndIf;
                EndIf;
               
    EndDo;

              
    EMBOXN MAILBOX;
                 
    DoU %Eof(EDMAST22);
                  
    Chain(N) (EMBOXNEDMAST22;
                  IF %
    Found(EDMAST22);
                  
    EMSTSN 'R';
                  
    UPDATE R#MAST;
                  
    Iter;
                  EndIf;
                 
    EndDo;
             EndIf;


           *
    InLR = *On;


           
    //Error-Handling Subroutine
             
    BegSR Error;

             
    //If no records or duplicate records found
              
    IF (SQLSTATE <> *Zeros);
                
    Dsply ('PO INVALID');
              EndIf;

             
    //If a record is found but is not valid for 855
              
    IF (SQLSTATE = *Zeros);
               
    SetLL (MailboxEDOTBX;
               
    ReadE (MailboxEDOTBX;

                  IF %
    SUBST(OTDTA:1:6) <> 'ST*855*';
                    
    Dsply ('PO provided invalid for 855 request');
                  EndIf;


              EndIf;


             
    ENDSR;

           /
    End-Free 


    Just decided to post the whole thing.
    (Again, I know it's a very simple program so apologies in advance!)

    Comment


    • #3
      The RNX1221 is because you have a (n) on your chain - which is saying to the system to not have a lock on the record. In this case, you need to remove the (n) from your chain so that you are declaring that you intend to interact with the record you are chaining to.

      Essentially, since you are going to update every record (I'd probably use a setll/reade instead of a chain in this case, but let's focus on your issue), then you do not need to do an "unlock". But if you had an if statement so you were not updating every record, you would explicitly need to write a "unlock EDMAST22;" in an else statement.

      I've included an example of what I mean below so that you get an idea of what I'm talking about.

      PHP Code:
      chain (somethingEDMAST22;
      if %
      found(EDMAST22);
        if 
      EDMAST22.'1';
          
      EDMAST22.'2';
          
      update R#OTBX;
        
      else;
          
      unlock EDMAST22;
        endif;
      endif; 
      Here is a little bit of reading on record locking https://www.ibm.com/support/knowledg...sc/rcdlock.htm

      Comment


      • Tho_Ros
        Tho_Ros commented
        Editing a comment
        Actually there is only one, uniquely identified, record that I want to update! I'm still pretty green when it comes to RPG so correct me if I'm wrong, but is Chain not used for finding unique records? Currently the snippet of code is set up like this:
        PHP Code:
        EMBOXN MAILBOX;
                     
        DoU %Eof(EDMAST22);
                      
        Chain (EMBOXNEDMAST22;
                      IF %
        Found(EDMAST22);
                       IF 
        EMSTS <> 'R';
                       
        EMSTS 'R';
                       
        UPDATE R#MAST;
                       
        Else;
                       
        Unlock R#MAST;
                       
        EndIf;
                      EndIf;
                     
        EndDo
        However when compiling I run into the RNF7260 error "The Factor 2 operand R#MAST is not valid for the specified operation" which has to do with my Unlock. Any idea why that may be?

        By the way, I really appreciate you taking the time to help a noob like me with all the simple stuff!

      • Tho_Ros
        Tho_Ros commented
        Editing a comment
        Actually there is only one, uniquely identified record that I want to update! I'm still pretty green when it comes to RPG so correct me if I'm wrong, but is Chain not used for finding unique records? Currently the snippet of code is set up like this:
        PHP Code:
        EMBOXN MAILBOX;
                     
        DoU %Eof(EDMAST22);
                      
        Chain (EMBOXNEDMAST22;
                      IF %
        Found(EDMAST22);
                       IF 
        EMSTS <> 'R';
                       
        EMSTS 'R';
                       
        UPDATE R#MAST;
                       
        Else;
                       
        Unlock R#MAST;
                       
        EndIf;
                      EndIf;
                     
        EndDo
        However when compiling I run into the RNF7260 error "The Factor 2 operand R#MAST is not valid for the specified operation" which has to do with my Unlock. Any idea why that may be?

        By the way, I really appreciate you taking the time to help a noob like me with all the simple stuff!

      • Ghost +
        Ghost + commented
        Editing a comment
        Ooops - I've given you a wrong turn! (Quarantine brain - doh!)

        When unlocking, you have to specify the name of the file, not of the record format. so you'd want unlock EDMAST22;
        Correct - chain is used for when you want to get a single specific record.

        OK, given you want a single record, I would change the code to remove your dou loop in that case - like below:
        PHP Code:
        EMBOXN MAILBOX;
                    
        Chain (EMBOXNEDMAST22;
                    IF %
        Found(EDMAST22);
                     IF 
        EMSTS <> 'R';
                       
        EMSTS 'R';
                       
        UPDATE R#MAST;
                     
        Else;
                       
        Unlock EDMAST22;
                     EndIf;
                    EndIf; 
        My apologies!!!

    • #4
      Terrific Ghost +
      Thanks a ton pal, I learned a lot from this!

      Comment


      • Ghost +
        Ghost + commented
        Editing a comment
        You're most welcome!
    Working...
    X