IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX MACRO Error


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 12:19 pm
Reply with quote

Hi,


I have written a MACRO which will be run against the COBOL program.

I need to add a line containing the value of SEE by calling ADD subroutine.

But it is appearing as SEE.

The value NEW is not reflecting.

Is there anything wrong in the syntax as it does not appear to enter into the condition IF SYSDSN ("'"FILEIN"'") = 'OK' THEN?

Code:


/*REXX*/ 
FILEIN = G68462.BCPPOLFC                                           
"ISREDIT MACRO"                                                     
/*CHECK IF THE LIBRARY EXISTS OR NOT*/                             
/*INVOKING ISPF FILE SERVICES*/                                     
       IF SYSDSN ("'"FILEIN"'") = 'OK' THEN                         
       DO                                                           
          "ALLOC DSN(G68462.BCPPOLFC)DD(INDSET)SHR REUSE"           
           "EXECIO * DISKR INDSET(STEM REC.)"                       
           SEE = 'NEW'                                           
           J = 1                                                   
           CTR = 0                                                 
           IF REC.0 > 0 THEN                                       
           DO I = 1 TO REC.0                                       
              PARSE VAR REC.I WITH 7 COL7 +1 STRING 73             
              IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN         
                 NOP   
            ELSE                                                 
            DO                                                   
             POS_WORD = FIND(STRING,'PIC')                     
            IF POS_WORD <> 0 THEN                             
             DO                                                 
                        SAY 'EXISTS'                                   
                         FSTRING.J = WORD(STRING,POS_WORD-1)             
                        CTR = CTR +1                                   
                         DEFINED = YES                                   
                        SAY FSTRING.J */                               
                         IF FSTRING.J <> "" THEN                         
                        J = J + 1                                     
                        ELSE                                           
                        NOP                                           
          END                                               
         ELSE                                               
            NOP                                             
            SAY 'NOT EXIST' */                             
      END                                                   
   END                                                     
     SAY CTR                                               
     SAY FSTRING.1                                         
     IF DEFINED = YES THEN                                 
     DO                                                     
     CALL ADD                                               
     END           

 

/* ADD THE JCL STATEMENTS*/                       
 ADD:                                             
 ADDRESS ISREDIT "(LASTLINE) = LINENUM .ZL"       
 POINTER = LASTLINE                               
  REC.1  = "IF "||FSTRING.1||" = "||FSTRING.1||"";
  REC.2 = "END "SEE""                           
  REC.0  = 2;                                     
 DO J =1 TO REC.0                                 
   L2 = REC.J;                                     
   'ISREDIT LINE_AFTER (POINTER)= <1,(L2)>';       
 END;                                             
 ISREDIT "SAVE"                                   
  ISREDIT "SAVE"         
  EXIT
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Fri Sep 18, 2009 12:23 pm
Reply with quote

Please put your code between
Code:
[code][/code]
tags, the posting is too unreadable to do anything with it. Stripping trailing blanks from Cut&Paste'd data would also help...
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 12:30 pm
Reply with quote

I hope this works.

Code:
/*REXX*/


FILEIN = G68462.BCPPOLFC

"ISREDIT MACRO"

/*CHECK IF THE LIBRARY EXISTS OR NOT*/
/*INVOKING ISPF FILE SERVICES*/


       IF SYSDSN ("'"FILEIN"'") = 'OK' THEN
       DO

          "ALLOC DSN(G68462.BCPPOLFC)DD(INDSET)SHR REUSE"
           "EXECIO * DISKR INDSET(STEM REC.)"
           SEE = 'NEW'

           J = 1
           CTR = 0
           IF REC.0 > 0 THEN
           DO I = 1 TO REC.0
              PARSE VAR REC.I WITH 7 COL7 +1 STRING 73
              IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN
                 NOP
              ELSE
              DO
                 POS_WORD = FIND(STRING,'PIC')
                 IF POS_WORD <> 0 THEN
                 DO
                    SAY 'EXISTS'
                    FSTRING.J = WORD(STRING,POS_WORD-1)
                    CTR = CTR +1
                    DEFINED = YES
/*                  SAY FSTRING.J */
                    IF FSTRING.J <> "" THEN
                      J = J + 1
                    ELSE
                      NOP
                  END
                 ELSE
                    NOP
/*                  SAY 'NOT EXIST' */
              END
           END
             SAY CTR
             SAY FSTRING.1

             IF DEFINED = YES THEN
             DO
             CALL ADD
             END

       END

/* ADD THE JCL STATEMENTS*/
ADD:

ADDRESS ISREDIT "(LASTLINE) = LINENUM .ZL"
POINTER = LASTLINE

 REC.1  = "IF "||FSTRING.1||" = "||FSTRING.1||"";
 REC.2 = "END "SEE""
 REC.0  = 2;

DO J =1 TO REC.0
  L2 = REC.J;
  'ISREDIT LINE_AFTER (POINTER)= <1,(L2)>';
END;

ISREDIT "SAVE"
ISREDIT "SAVE"
 EXIT


Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Fri Sep 18, 2009 1:25 pm
Reply with quote

Still cannot be bothered to use
Code:
[code][/code]
tags?

Add 'trace ?r' after /* REXX */ and try finding out the problem yourself.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 1:36 pm
Reply with quote

Have you ran the REXX using TRACE I or TRACE R
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 1:49 pm
Reply with quote

Code:
7 *-* "ISREDIT MACRO"                         
   >>>   "ISREDIT MACRO"                       
   +++ RC(20) +++                               
                                               
 9 *-* /*CHECK IF THE LIBRARY EXISTS OR NOT*/   
10 *-* /*INVOKING ISPF FILE SERVICES*/         
13 *-* IF SYSDSN ("'"FILEIN"'") = "OK"         
   >>>   "0"                                   
                                               
57 *-*  /* ADD THE JCL STATEMENTS*/             
58 *-*  ADD:

Above is the result of running TRACE.

Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 1:54 pm
Reply with quote

How do you invoke the macro

MACRONAME
0r
TSO MACRONAME
or
TSO EXEC 'pds name(MACRONAME)'
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 1:58 pm
Reply with quote

Invoke the MACRO by MACRONAME.

If i try giving the statement SEE ='NEW' outside the IF condition it works.
The value 'NEW' reflects.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 2:23 pm
Reply with quote

Ok, I have spent a while tidying up your original post, and as Prino has said - use the code tags. Look at the difference between the tidied version and the raw version.

learn the tags, and use them !!!

It is obvious that the result from your SYSDSN is not "OK" as you want it to be.

I would use TRACE I - a bit cumbersome but more informative - to see what the return is and possibly why.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 2:36 pm
Reply with quote

Having done a test or two, I suggest that you look at the syntax for SYSDSN and the examples shown in the manual, then you might get somewhere.
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 2:36 pm
Reply with quote

Ok,

I have solved the error.

Now i need to pass the array FSTRING into the subroutine ADD.

I used the statement CALL ADD(FSTRING).

How do you pass the same?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Fri Sep 18, 2009 2:58 pm
Reply with quote

Hello MARINA,

Are the messages from Robert (priso) not visible at your end? I've edited the "code" and "error" messages you post. Please use BBcode tags going forward.
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 3:02 pm
Reply with quote

Going forward yes , i will use the tags.

But in my last post i did not post any code, just asked how to pass an array to a subroutine within a MACRO.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 3:31 pm
Reply with quote

What have you tried, and what was the result
Back to top
View user's profile Send private message
MARINA JOSEPH

New User


Joined: 11 Jun 2009
Posts: 61
Location: chennai

PostPosted: Fri Sep 18, 2009 3:45 pm
Reply with quote

I am not sure about the syntax to pass an array to an internal subroutine within a MACRO.

So if somebody could help me with the syntax...

I tried

CALL ADD(FSTRING.) within the calling routine.


ADD:

ARG FSTRING.

It throws error in the way i have used the CALL statement.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Sep 18, 2009 4:23 pm
Reply with quote

Why do you think that you need to pass the array to an internal subroutine.

Have you tried to simply use the array in the subroutine exactly as it is

How long would it have taken you to test this yourself icon_evil.gif
Code:

/* REXX *** POSSIBLE TO PASS AN ARRAY TO AN INTERNAL ROUTINE         */
A.1 = 'A'
A.2 = 'B'
A.3 = 'C'
A.4 = 'D'
A.5 = 'E'
A.0 = 5

SAY "START - - - MAIN ROUTINE"
DO AA = 1 TO A.0
  SAY A.AA
END
SAY "END - - - - MAIN ROUTINE"

CALL SUBROUT

EXIT
/*-------------------------------------------------------------------*/
SUBROUT:
SAY "START - - - SUB ROUTINE"
DO AA = A.0 TO 1 BY -1
  SAY A.AA
END
SAY "END - - - - SUB ROUTINE"
RETURN
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1314
Location: Vilnius, Lithuania

PostPosted: Fri Sep 18, 2009 4:32 pm
Reply with quote

You cannot pass stems to subroutines.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts Help on IMS -API URL migrating from P... IMS DB/DC 1
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts Help needed in automation cics transa... CLIST & REXX 1
Search our Forums:

Back to Top