35 pts.
 ILE Best method of Parameter handling using Procedures
Using prototypes and Procedure interfaces I understand that no parameter may be returned if a procedure is called directly via CALLP. And only one parameter may be returned if procedure is called via EVAL with return.

What is the best way to return multiple parameters from a procedure (assuming I don't want to use PLIST/PARM's).

For example a date routine (now created as procedure) passes back a date formatted in two different ways. Am I now supposed to format both dates into one field and return merged field/use the LDA? Or is there a better method?



Software/Hardware used:
AS400
ASKED: October 15, 2009  11:09 AM
UPDATED: October 19, 2009  1:18 PM

Answer Wiki:
You've got it a little wrong All parameters passed are returned and can be changed by the procedure unless the prototype declares them as constant they cannot be changed. Here is a procedure interface. To use this procedure you pass it 4 fields, it returns a value and the final values in the four fields but Fld4 cannot be changed in the called procedure. D procedure1 pr 1A D Fld1 2s 0 D Fld2 3a D Fld3 6a D Fld4 11a Const C Eval myChar1 = Procedure1(Fld2s0 : Fld3a : Fld6a : Fld11a) Phil Thanks Phil, Iwas getting confused i#O -------------- Hope we helped. Phil Sorry about the garble, I'm finally getting round to learning ILE and read somewhere about the use of eval to call a procedure/module with the the ability to pass back a parameter but if using callp no parameter would be returned and assumed from that statement FLD1-3 (in your example) could not be returned. When in fact they were referring to additional 1A field defined in your PR example. Tested it out an works great thanks. Thanks again. Barry ========== Yes, now you've got it. Phil =========
Last Wiki Answer Submitted:  October 19, 2009  1:18 pm  by  Barryo   35 pts.
All Answer Wiki Contributors:  Barryo   35 pts. , philpl1jb   44,070 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Where did you learn that parameter values for a procedure, external or internal, can’t be returned? That source of info needs to be corrected. You wouldn’t happen to be working out how to call a ‘stored procedure’, are you? That can take some extra effort.

Tom

 107,735 pts.

 

If you want to return more than one value, you can return a data structure. Your prototype will look something like this:

 ********************************************************************** 
 * PROTOTYPE FOR PROCEDURE TO RETURN COST SHEET INFORMATION.            
 ********************************************************************** 
D  RTVCSTSHTR     PR                  LIKEDS(COST_RETURNED_INFO)        
D  PRODUCT#                     15                                      
 *********************************************************************  
 * DATA STRUCTURE FOR RETURNED COST SHEET INFORMATION.                  
 *********************************************************************  
D  COST_RETURNED_INFO...                                                
D                 DS                  INZ                               
D    RETURNED_MATERIAL_COST...                                          
D                         1     10  4                                   
D    RETURNED_LABOR_COST...                                             
D                        11     20  4                                   
D    RETURNED_VARIABLE_OVER_HEAD_COST...                                
D                        21     30  4                                   
  D    RETURNED_FIXED_OVER_HEAD_COST...    
D                        31     40  4    
D    RETURNED_VARIABLE_BELOW_LINE_COST...
D                        41     50  4    
D    RETURNED_TOTAL_COST...              
D                        51     60  4    
D    RETURNED_CURRENT_SELLING_PRICE...   
D                        61     70  4    
D    RETURNED_SURCHARGE_AMOUNT...        
D                        71     79  4    
 5,830 pts.