Skip a error record and continue with the next record

55 pts.
Tags:
AS/400
MSGW
We have a MSGW job due to wrong date format (dd/mm/yyyy), need to skip the particular record and continue with next record. Can some one suggest the opt code to monitor the error and skip the record If possible a example code will be very much help full. Thanks Arun

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 11  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Please show the section of code that is failing. We need to know how the program is written before we can guess how an error should be handled. For example, a 'P'rimary input file in RPG III would be very different from a full-procedural file in RPG IV. -- Tom
    125,585 pointsBadges:
    report
  • Arun123456789

    hi thanks for the responce ....

    below is the code .. please check and suggest

        begsr                                
                                                          
    ***              dow       not %eof(RH1901P) AND      
    ***                        PONO = saveord#            
                                                          
    c                 eval      CDAC50 = cdac              
    c                 eval      CUSO52 = CUSO50            
    c                 eval      linecount = linecount + 1  
    c                 eval      POLE52 = linecount         
    c                 eval      CATN52 = ITMNO             
    c                 move      QTYRQD        ordqty       
    c                 z-add     ordqty        QTOR52       
    c                 move      REQDAT        reqdate      
    c   *dmy          move      reqdate       dateymd      
    c   *ymd          move      dateymd       yymmdd       
    c     move      cyymmdd       DTDR52         
    c     eval      UPDT52 = '1'                 
    c     eval      UNQE52 = UNQE50              
    c    eval      timnum = %dec(REQTIM:6:0)    
    c     eval      DETR52 = timnum              
    c    eval      STRC52 = whse                
    c    write     AIR52                        
                                            
    c    read      RH1901P                      
                                     
    c          enddo             
                           
    c           endsr

     

     

    55 pointsBadges:
    report
  • Arun123456789

    this is rpgIV and its moving the data in to a file called RH1901P

     

    55 pointsBadges:
    report
  • Arun123456789

    and while moving the data as below job is going to MSGW.. which need to be fixed by skipping the perticular recode with wrong date formet,  

    c   *dmy          move      reqdate       dateymd      
    c   *ymd          move      dateymd       yymmdd 

    55 pointsBadges:
    report
  • Splat
    The TEST opcode might be your best bet.

    This is from the V5R4 ILE RPG Reference Manual:

     *  %ERROR will return '1', since Num_Date is not *DMY.
     *
    C     *DMY          TEST (DE)               Num_Date
    

    7,305 pointsBadges:
    report
  • WoodEngineer
    The MONITOR op code may do what you need.  When it traps the error in question, just go to the code that reads the next record.  
    6,680 pointsBadges:
    report
  • ToddN2000

    My question is where is your bad date coming from?  Your MSGW to me sounds like it's a batch process. This means you may have more bad data out there. Looks like you need to put some validity checks into your programs that are writing this bad date in the first place. If this bad date is coming from a user interface or another file,  I'd validate the date before it gets written to any file for processing. Better to be proactive than reactive. 

    11,820 pointsBadges:
    report
  • Arun123456789

    hi all,

    thank you for the replys and suggessions,

    and yes its a batch process, and coming to the code i only need to skip the error record with wrong date and continue with the next record so that the job does not go in to MSGW...

    its also a good idea to validate the error and automate it,

    but the problem is we receive the data from a excel sheet and its updates in to file,

    so i want to make it simple by skipping the error record,

    if some one can give me a sample code with TEST  or   MONITOR based on my code above will be helpful.

    thanks a lot

     

     

     

     

    55 pointsBadges:
    report
  • philpl1jb
    the simplist might look like this, which adds three lines.
    If an error is encountered between Monitor and EndMon processing 
    advances to the ON-ERROR.  Between ON-ERROR and ENDMON you could
    put code to manage the bad record.  
     
    c                 monitor                             <--
    c                 eval      CDAC50 = cdac               
    c                 eval      CUSO52 = CUSO50             
    c                 eval      linecount = linecount + 1   
    c                 eval      POLE52 = linecount          
    c                 eval      CATN52 = ITMNO              
    c                 move      QTYRQD        ordqty        
    c                 z-add     ordqty        QTOR52        
    c                 move      REQDAT        reqdate       
    c   *dmy          move      reqdate       dateymd       
    c   *ymd          move      dateymd       yymmdd        
    c     move      cyymmdd       DTDR52          
    c     eval      UPDT52 = '1'                  
    c     eval      UNQE52 = UNQE50               
    c    eval      timnum = %dec(REQTIM:6:0)     
    c     eval      DETR52 = timnum               
    c    eval      STRC52 = whse                 
    c    write     AIR52
    
    c     on-error                                    <--
    c     endmon                                      <--
                                             
    c    read      RH1901P                   
    50,205 pointsBadges:
    report
  • TomLiotta

    One basic way to go is something like this:

         c                   monitor
         c                   move      REQDAT        reqdate
         c     *dmy          move      reqdate       dateymd
         c     *ymd          move      dateymd       yymmdd
         c                   move      cyymmdd       DTDR52
         c                   eval      UPDT52 = '1'
         c                   eval      UNQE52 = UNQE50
         c                   eval      timnum = %dec(REQTIM:6:0)
         c                   eval      DETR52 = timnum
         c                   eval      STRC52 = whse
         c                   write     AIR52
         c                   on-error  *program
         c                   dump
         c                   endmon

    Put a MONITOR black around the code that handles the dates. If an error shows up, do something in the ON-ERROR group. As soon as a program error appears for any statement in the group, control jumps to the ON-ERROR group. Note that the WRITE statement will be skipped for that record. This example does a DUMP, but you should do something like send a message to somewhere so the error can be addressed.

    Tom

    125,585 pointsBadges:
    report
  • Arun123456789

    i was planning to send a mail when a error occurs,

     

     

    55 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following