MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Edit Macro to list all unused working storage variables

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
srinivasbathimmi
Beginner


Joined: 23 Aug 2006
Posts: 2
Topics: 2

PostPosted: Wed Jul 15, 2009 6:26 am    Post subject: Edit Macro to list all unused working storage variables Reply with quote

Hi,

I am beginner to edit macros and thought of wirting an edit macro to list out all the unused working storage variables in a cobol program.

High level view of below peice of code is
Find line number where working storage begins (n1)
Find line number where procedure division begins (n2)
Start processing from n1 to n2
If you find any 'PIC' string then get the variable name and give a find in procedure division till .zl (last line). If it encounters leave it else display as unused vairable.

My program is working fine incase Varaibles order in working storage section is same in procedure division.

Example :
Code:

WORKING STORAGE SECTION.
01 X.
    05 A  PIC X(9).
    05 B  PIC X(2).
    05 C  PIC 9(2).

PROCEDURE DIVISION.
PARA1.
     display A.
     display B.
     display C.


If not I am facing problem because I am doing a FIND command and not able to get the cursor back to PROCEDURE DIVISION for every field.
Is there any to solve this situation.



Could you please any one help me out

Code:

ISREDIT MACRO                                               
ADDRESS ISPEXEC "CONTROL ERRORS RETURN "                   
ADDRESS ISREDIT "(USTAT) = USER_STATE"                     
ADDRESS ISREDIT "(FLINE) = LINENUM .ZF"                     
ADDRESS ISREDIT "(LLINE) = LINENUM .ZL"                     
IF RC = 0   THEN                                           
  DO                                                       
    ADDRESS ISREDIT "FIND 'WORKING-STORAGE SECTION'"       
    ADDRESS ISREDIT "(N1) = LINENUM .ZCSR"                 
    ADDRESS ISREDIT "FIND 'PROCEDURE DIVISION'"             
    ADDRESS ISREDIT "(N2) = LINENUM .ZCSR"                 
    DO I = N1 TO N2                                         
       ADDRESS ISREDIT "(VLINE) = LINE &I"                 
       PARSE VAR VLINE WITH 7 COL7 +1 STRING 73             
       IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN         
          NOP                                               
       ELSE                                                 
       DO                                                   
          NO_WORD = FIND(STRING,'PIC')                               
          IF NO_WORD <> 0 THEN                                       
             DO                                                       
               FSTRING = WORD(STRING,NO_WORD-1)                       
               IF FSTRING <> "" THEN                                 
                  DO                                                 
                    ADDRESS ISREDIT "FIND "FSTRING""                 
                    IF RC = 0 THEN                                   
                      DO                                             
                        SAY 'VAR : ' FSTRING                         
                        ADDRESS ISREDIT "(PLINE) = LINE .ZCSR"       
                        PARSE VAR PLINE WITH 7 COL7 +1 STRING 73     
                        IF COL7 = '*' | COL7 = '-' | COL7 = '/' THEN 
                           SAY 'NOT FOUND1: ' FSTRING                 
                      END                                             
                    ELSE                                             
                        SAY 'NOT FOUND:' FSTRING                     
                  END                                                 
               ELSE                 
               ELSE     
                  NOP   
             END         
       END               
    END                 
EXIT.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jul 15, 2009 6:48 am    Post subject: Reply with quote

look at the CROSS-REFERENCE OF DATA NAMES portion of the compiler output and
only delete those which have no reference within the structure.

Problem with writting a macro for a COBOL source program, you are not able to take into account copybooks in working-storage, includes in working-storage, and most importantly, procedureal copybooks.

once you have found procedure division and working-storage, label them. then to reposition the cursor, you only have to use a locate. but, since you have the lineno of procedure division, you can always include that in your FIND command as range parms: l-no-procdiv .zlst.

learn to use BBcode when you post your code; it is easier to read.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jul 15, 2009 10:37 am    Post subject: Reply with quote

srinivasbathimmi,

You are trying to re-invent the wheel. As DBZ mentioned you can use the cross reference listing .

Also read this topic which would further help you

http://www.mvsforums.com/helpboards/viewtopic.php?t=197&highlight=overhead
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group