Midrange News for the IBM i Community


Posted by: John Dowling
Array Processing
has no ratings.
Published: 01 Mar 2013
Revised: 05 Mar 2013 - 1662 days ago
Last viewed on: 21 Sep 2017 (2955 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Array Processing Published by: John Dowling on 01 Mar 2013 view comments(4)

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Array Processing
Posted: 4 years 6 months 20 days 11 hours 14 minutes ago

X + 2 = 31, your field is "only" 30.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Array Processing
Posted: 4 years 6 months 20 days 11 hours 5 minutes ago
Edited: Mon, 04 Mar, 2013 at 19:22:32 (1663 days ago)

 Here's a routine I wrote for you that should work fine. NOTE: The JOBLOG function from COZTOOLS is not necessary to make it work--its just there to allow you to see the results in the JOBLOG.

     H BNDDIR('COZTOOLS/RPGFREE') DFTACTGRP(*NO)             
      /include cozTools/qcpysrc,joblog                       
     D addr            s             30A   Inz('Chicago, IL')
     D state           s             30A                     
     D len             s             10I 0                   
     D x               s             10I 0                   
     C                   move      *ON           *INLR       
      /free                                                  
           len = %len(%trimR(addr));                         
           for x = len DOWNTO 1;                             
              if %subst(addr:x:1) = ' ' or                   
                 %subst(addr:x:1) = ',';                     
                 state = %trim(%subst(addr:x) : ', ');       
                 leave;                                      
              endif;                                         
           endfor;                                           
           if (state = '');  // Didn't find the state!       
              joblog('Sorry, no State in %s': addr);         
           else;
              joblog('STATE=%s': state);
           endif;                       
      /end-free                         

 

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Array Processing
Posted: 4 years 6 months 19 days 22 hours 48 minutes ago

Isn't the simplest solution something along the lines of:

EVALR State = %trimr(CityState);

Assuming that the CityState field ALWAYS contains the state as last two characters. Obviously this approach isn't foolproof, if the CityState content cannot be guaranteed.

Posted by: johnd01
Premium member *
Comment on: Array Processing
Posted: 4 years 6 months 19 days 20 hours 49 minutes ago

Thanks Bob that worked just great, Neil .... we just don't have states, there are countries, proviences ect

   thank guys