1

I need to make date calculations for ROBOT in AS400 (that the built in pgm cant do), for the reserved command variables.

Robot is calling my cl-program and the cl-program is calling my rpgle-program (because the cl program cant make the date calculations i want).

How do i get the result from the date calculation in the rpgle program back to the CL-variable? So that ROBOT can fetch it.

Can i update the variable in the cl program by calling a rpgle. But how do i do it.

As4rikru
  • 35
  • 3
  • 1
    In Addition to RockBoro's explanation, "by address" means, simply pointers in a C-sense of programming. Maybe that helps in understanding. – PoC May 31 '21 at 07:59

1 Answers1

2

parameters passed from CL to RPG are passed by address. So any value placed in the parameter by the RPG program will be returned to the CL program.

here is a CL program calling RPG:

             PGM                                                             
                                                                             
             dcl        &rtndate *char 10                                    
                                                                             
/* call RPG program.  RPG program sets &rtnDate parm to date of yesterday */ 
/* in *ISO format.                                                        */ 
             call       test0290r parm(&rtnDate)                             
                                                                             
             SNDPGMMSG  MSG('yesterday date:' *BCAT &RTNDATE)                
                                                                             
             ENDPGM  

and the called RPG program:

** test0290r: return yesterdate as iso date.                 
h option(*srcstmt:*nodebugio)                                
                                                             
** --------------------------- test0290r --------------------
** test0290r: return yesterdate as iso date.                 
dtest0290r        pr                  extpgm('TEST0290R')    
d outDate                       10a                          
                                                             
** --------------------------- test0290r --------------------
** test0290r: call open api using ifs_openNew.               
dtest0290r        pi                                         
d outDate                       10a                          
                                                             
d ch80            s             80a   varying                
d yesterday_date  s               d                          
 /free                                                       
      yesterday_date = %date(%timestamp( )) - %days(1) ;     
      outDate     = %char(yesterday_date:*iso) ;             
                                                             
      *inlr       = '1' ;                                    
      return ;                                               
 /end-free  
RockBoro
  • 2,163
  • 2
  • 18
  • 34