midrange.com code scratchpad
Name:
Michael Schutte
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
07/11/2011 05:42:16 pm
IP:
Logged
Description:
Code to produce example of UDF calling external service program RPGLE that returns an indicator value.
Code:
  1. First create the module and compile as a service program, 
  2.  
  3. D IsDirectLabor   PR              N            
  4. D  JobCode                       5    Const  
  5. P IsDirectLabor   B                   EXPORT   
  6. D IsDirectLabor   PI              N            
  7. D  JobCode                       5    Const    
  8.                                                
  9. D Found           S              1             
  10.  /Free                                         
  11.    If JobCode = '71';
  12.       return *On;
  13.    Else;
  14.       Return *Off;
  15.    EndIf; 
  16.                                                
  17.  /End-Free
  18. B                      E
  19.  
  20.  
  21. Second create the UDF. 
  22.  
  23.  
  24. CREATE FUNCTION MYLIB/ISDIRECTLABOR (              
  25.  JOBCODE CHAR(5) )                                      
  26.  RETURNS CHAR(1)                                        
  27.  LANGUAGE RPGLE                                         
  28.  SPECIFIC MYLIB/CUG@JCIDR
  29.  DETERMINISTIC                                          
  30.  NO SQL                                                 
  31.  CALLED ON NULL INPUT                                   
  32.  DISALLOW PARALLEL                                      
  33.  EXTERNAL NAME 'MYLIB/CUG@JC(ISDIRECTLABOR)'       
  34.  PARAMETER STYLE GENERAL ;                              
  35.  
  36. Finally, run UDF to see the results. 
  37.  
  38. Select ISDIRECTLABOR('71   ') from sysibm/sysdummy1 
  39. union all 
  40. Select ISDIRECTLABOR('00   ') from sysibm/sysdummy1 
  41.  
  42.  
  43.  
  44.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css