AS/400: Find a half string in entire array

40 pts.
Tags:
AS/400
Can someone please advise how can I find half character string in Array. I have tried with %lookup but doesn't work for half string. And %scan doesn't work for entire array, it actually works index basis. I am stuck it would be great if someone can advise on this. Thank you.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try something like this

EVAL      EndPosition = %SCAN(‘scanvalue ‘ : fieldname : starting position)

If end comes back 0 then value not found.


Discuss This Question: 3  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.
  • ToddN2000
    Post the code you have tried. It might just be off just a bit and we can help straighten it out.
    82,620 pointsBadges:
    report
  • Hndasnp
    /free                                                                           
       position= %lookup(' ' : correct_code_array);                                 
       position -= 1;                                                               
       BaseCorrectionCode = correct_code_array(1);                                  
                                                                                    
       for count = 1 to position;                                                   
       lengthOfBaseOpcode = %len(%trim(BaseCorrectionCode));                        
       lengthOfBaseOpcode -= 1;                                                     
       corrCode_lop = %subst(correct_code_array(1):1:lengthOfBaseOpcode);           
       result = %lookup(corrCode_lop:correct_code_array);                           
          if result > 0;                                                            
             chain (company_number:correct_code_array(result)) SDPLOPC;             
                if %found(SDPLOPC);                                                 
                   lengthOfBaseOpcode += 2;                                         
                   CombineCorrectCode  += 1;                                        
                   CorrectionCode_sufix = %subst(correct_code_array(result)         
                                     :lengthOfBaseOpcode:1);                        
                   if CombineCorrectCode >= 1;                                      
                      CorrCode_lines += 1;                                          
    s6454                   CorrCode_lines += 1;                              
    s6454                   %occur(CorrCode_info) = CorrCode_lines;           
    s6454                   lop_code = %trim(BaseCorrectionCode) + %trim      
    s6454                        (CorrectionCode_sufix);                      
    s6454                   lop_desc = %trim(SODES1) + ' ' + %trim(SODES2)    
    s6454                      + ' ' + %trim(SODES3) + ' ' + %trim(SODES4);   
    s6454                   lop_desc = xmlEncode(lop_desc);                   
    s6454                   labor_hours = warranty_hours;                     
    s6454                   labor_amount = waranty_amount;                    
    s6454                   labor_rate  = warranty_rate;                      
    s6454                   correct_code_array(count) =  *blanks;             
    s6454                endif;    
                           endif;
                         endfor;                                           
    40 pointsBadges:
    report
  • Hndasnp
    Here I'm trying to search half string in whole array the result comes zero.
    40 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.

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

Following

Share this item with your network: