ILE Best method of Parameter handling using Procedures

35 pts.
Tags:
RPG
RPG ILE
RPG ILE Parameter handling
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

Answer Wiki

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

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
=========

Discuss This Question: 2  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
    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
    125,585 pointsBadges:
    report
  • Teandy
    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,860 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