Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Passing data between programs

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
valyk

Active User


Joined: 16 Apr 2008
Posts: 104
Location: South Carolina

PostPosted: Wed Dec 22, 2010 10:09 pm    Post subject: Passing data between programs
Reply with quote

I know there have been several post about this issue, and Rexx does not offer a easy way of doing it. I was curious about what the forum thought of my process.

First I have a dataset that contains the global variables that will be passed between program.

Code:
RPT.               /* REPEATING BLOCK ARRAY                          */

MAX_ROW            /* DEFAULT SIZE DEPTH                             */
MAX_COL            /* DEFAULT SIZE WIDTH                             */
INIT_CSR           /* DEFAULT CURSOR POSITION                        */

PNL_PREF           /* DEFAULT PANEL NAME PREFIX                      */
PNL_SUFF           /* DEFAULT PANEL NAME SUFFIX                      */


Whenever a program is about to call another program, it will open the global variables dataset and it will create a single string with each parameter appended. Then, it will call the program, passing the parameter string.

Code:
DRAW_PARMS:
  PARMS = ''

  ADDRESS TSO
  "ALLOC DATASET('"DATASET"("GLOBALS")') FILE(PARM) SHR"
  'EXECIO * DISKR PARM (FINIS STEM PARMS.'
  'FREE FILE(PARM)'

  DO I = 1 TO PARMS.0
    PARM = SPACE(SUBSTR(PARMS.I,1,12))

    IF PARM > '' THEN DO
      IF POS('.',PARM) = LENGTH(PARM) THEN DO
        INTERPRET "MAX = "PARM'0'
        CALL CHANGE_STR PARM,'.',''
        PARM = STRING

        DO J = 0 TO MAX
          INTERPRET "PARMS = PARMS PARM'.'J'='"PARM'.'J
        END
      END
      ELSE
        INTERPRET "PARMS = PARMS PARM'='"PARM
    END
  END
RETURN


So in this example, the parameter string will look something like this:

Code:
RPT.0=3 RPT.1=A RPT.2=B RPT.3=C MAX_ROW=24 MAX_COL=80 INIT_CSR=5 PNL_PREF=SCRN PNL_SUFF=MOD2


Then the calling program will parse the parameter string:

Code:
PARSE_PARMS:
  PARMS = ARG(1)

  DO FOREVER
    IF PARMS > '' THEN DO
      PARSE VAR PARMS PARM PARMS
      PARSE VAR PARM PARM_NAME '=' PARM_VAL .

      IF POS('~',PARM_VAL) > 0 THEN
        PARM_VAL = TRANSLATE(PARM_VAL,' ','~'

      IF LENGTH(PARM_VAL) > 0 THEN DO
        IF POS("'",PARM_VAL) > 0 THEN DO
          PARM_VAL = '"'PARM_VAL'"'

          INTERPRET PARM_NAME "="PARM_VAL
        END
        ELSE
          INTERPRET PARM_NAME "='"PARM_VAL"'"
      END
      ELSE
        INTERPRET PARM_NAME "='"PARM_VAL"'"
    END
    ELSE
      LEAVE
  END
RETURN
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Dec 22, 2010 10:50 pm    Post subject: Reply to: Passing data between programs
Reply with quote

Yep, I've done that myself.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2025
Location: Silicon Valley

PostPosted: Fri Dec 24, 2010 11:44 am    Post subject: Reply to: Passing data between programs
Reply with quote

Code:
PARSE VAR PARMS PARM PARMS
This restricts you to numeric values or single word text values. I suggest you use a delimiter other than blank. I have seen '05'x used for that a few times.

Code:

Do while (parms ^= '')
  PARSE VAR PARMS PARM '05'x PARMS
  INTERPRET parm
End
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Fri Dec 24, 2010 11:47 am    Post subject: Reply to: Passing data between programs
Reply with quote

Code:
RPT.0=3 RPT.1=A RPT.2=B RPT.3=C MAX_ROW=24 MAX_COL=80 INIT_CSR=5 PNL_PREF=SCRN PNL_SUFF=MOD2

why not separate the assignments wit a ";" and interpret in one shot the whole string??
no parsing needed!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us