Portal | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need help in REXX code to list the affinities between exec

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

New User


Joined: 30 Jun 2010
Posts: 30
Location: hyderabad

PostPosted: Wed Apr 01, 2020 12:53 pm    Post subject: Need help in REXX code to list the affinities between exec
Reply with quote

Hi Team,

I'm working on REXX tool to get the list of affinities used in CICS program.

I'm facing the issue if we have "EXEC CICS" & "END-EXEC" are on same line.


Example 1:
Input:


Code:

AAAAAAA |           EXEC CICS RETURN END-EXEC.                 
AAAAAAA |           EXEC CICS LINK                             
AAAAAAA |                     PROGRAM  (WS-LOG-PRG)           
AAAAAAA |                     COMMAREA (WS-LNK-ERROR)         
AAAAAAA |                     LENGTH   (LENGTH OF WS-LNK-ERROR)
AAAAAAA |                     RESP     (CICS-RESP)             
AAAAAAA |           END-EXEC.



Output of Example 1 is not populating the link statement by my requirement of output should be same as Example 2.

Example 2:
Input:


Code:

AAAAAAA |           EXEC CICS RETURN
AAAAAAA |           END-EXEC.                 
AAAAAAA |           EXEC CICS LINK                             
AAAAAAA |                     PROGRAM  (WS-LOG-PRG)           
AAAAAAA |                     COMMAREA (WS-LNK-ERROR)         
AAAAAAA |                     LENGTH   (LENGTH OF WS-LNK-ERROR)
AAAAAAA |                     RESP     (CICS-RESP)             
AAAAAAA |           END-EXEC.



Output of Example 2:
PROGRAM | COMMAND TYPE
AAAAAAA | LINK PROGRAM | WS-LOG-PRG


I'm able to understand that is because, we are checking for first 8 position for END-EXEC but not able to fix it.

Code:

when left( tail, 9 ) = "EXEC CICS" then do
    exec = space( exec tail )             
end                                       
                                           
when left( tail, 8) = "END-EXEC" then do   
    exec = space( exec tail )

            select
                when wordpos( word( exec, 3),  "LINK  XCTL ") > 0 then do



For example 1 output is blank but output should similar to example 2.

Here is my code:


Code:

/* REXX */
/* TRACE ALL */
CLRSCRN
ADDRESS TSO
SAY "ENTER INPUT FILE WITH LIST OF EXEC STMTS"
PULL DSN1
PS1=STRIP(DSN1)
SAY "ENTER THE OUTPUT FILE TO WRITE THE REPORT WITH AFFNITIES"
PULL DSN2
PS2=STRIP(DSN2)
/*----------------TO LOAD ALL EXEC STMTS TO ARRAY---------------*/
"ALLOC F(INFILE) DA('"||PS1||"') SHR "
"EXECIO * DISKR INFILE (STEM DATA. FINIS"
"FREE FI(INFILE)"
/*----TO DELETE THE DATA FROM O/P FILE BEFORE WRITTING          */
"ALLOC F(OUTFILE) DA('"||PS2||"') SHR "
"EXECIO 0 DISKW OUTFILE (OPEN FINIS"
"FREE FI(OUTFILE)"
/*--------------------------------------------------------------*/

QUEUE "PROGRAM  | COMMAND TYPE "

CALL RPT_EXTRACT

CALL WRITE_OUTPUT

/*--------------------------------------------------------------*/
/* read exec statements and write the report                    */
/*--------------------------------------------------------------*/
RPT_EXTRACT:
/*--------------------------------------------------------------*/
exec = ""; iden = ""; line = ""
do i = 1 to data.0

    work = translate(data.i, " ", "'")
    work = translate(work )
    work = space(work)

    parse var work head "|" tail
    head = strip( head )
    line = head "|"

    tail = strip( tail )

    line = head "|"

    p = pos( " (", tail )
    do  while p > 0
        tail = left( tail, p-1) || substr( tail, p+1)
        p = pos( " (", tail )
    end

    select

        when left( tail, 9 ) = "EXEC CICS" then do
            exec = space( exec tail )
        end

        when left( tail, 8) = "END-EXEC" then do
            exec = space( exec tail )

            select
                when wordpos( word( exec, 3),  "LINK  XCTL ") > 0 then do
                    line = line word( exec, 3)
                    parse value(space(exec,0))  with . "PROGRAM(" iden ")" .
                        if  iden ª= "" then do
                            line = line "PROGRAM" "|"
                        end
                    if  iden ª= "" then do
                        line = line iden
                        QUEUE LINE
                    end
                end

                when wordpos( word( exec, 3),  "ASSIGN ") > 0 then do
                    line = line word( exec, 3)
                    parse value(space(exec,0))  with . "APPLID(" iden ")" .
                        if  iden ª= "" then do
                            line = line "APPLID" "|"
                            line = line iden
                            QUEUE LINE
                        end
                    parse value(space(exec,0)) with  . "SYSID(" iden ")" .
                        if  iden ª= "" then do
                            line = ""
                            line = head "|"
                            line = line word( exec, 3)
                            line = line "SYSID" "|"
                            line = line iden
                            QUEUE LINE
                        end
                end

                otherwise do
                    nop
                end
            end

            exec = ""; iden = ""; line = ""
         
        end
        otherwise do
            exec = space( exec tail )
        end

    end

end
return

/*--------------------------------------------------------------*/
/* write output at EOF                                          */
/*--------------------------------------------------------------*/
WRITE_OUTPUT:
/*--------------------------------------------------------------*/

"ALLOC FI(REPT) DA('"||PS2||"') SHR REU"

DATALINES = QUEUED()
DO DATALINE = 1 TO DATALINES
   "EXECIO 1 DISKW REPT"
END

"EXECIO 0 DISKW REPT (FINIS"
"FREE FI(REPT)"

EXIT                                                           


Can someone help me to fix this.

Stay safe from Corona Virus.

I'm not able to move this topic to REXX. Requesting someone to move this to REXX.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2419
Location: Hampshire, UK

PostPosted: Wed Apr 01, 2020 4:03 pm    Post subject: Reply to: Need help in REXX code to list the affinities between exec
Reply with quote

Stick another WHEN clause in testing for both EXEC CICS and END-EXEC. This would have to precede both the WHEN for EXEC CICS and the WHEN for END-EXEC.
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10701
Location: italy

PostPosted: Wed Apr 01, 2020 4:55 pm    Post subject: Reply to: Need help in REXX code to list the affinities between exec
Reply with quote

since I had already fixed the thing for the ORIgiNAL REQUEST

warning ...
no attempt to resync the for missing EXEC CICS and END-exec

the TS can do it himself
even if the TS main issue is the logic , the code is just a lowly technicality
he would have asked even if he had to do it in COBOL


Code:


Trace "O"

/* do Your own reading of the input */

exec = ""; iden = ""; line = ""
do i = 1 to data.0

    work = translate( data.i, " ", "'")
    work = translate( work )
    work = space( work )

    parse var work head "|" tail
    head = strip( head )
    line = head "|"

    tail = strip( tail )
    -- say "at ".line~right(3) ">>"head"<<"
    -- say "at ".line~right(3) ">>"tail"<<"

    p = pos( " (", tail )
    do  while p > 0
        tail = left( tail, p-1) || substr( tail, p+1)
        p = pos( " (", tail )
    end

    select

        when pos( "END-EXEC", tail ) > 0 then do
            exec = space( exec tail )
            -- say "at ".line~right(3) " >>"exec"<<"
            -- say "at ".line~right(3) " >>"word( exec, 3)"<<"

            select
                when wordpos( word( exec, 3),  "LINK  XCTL" ) > 0 then do
                    line = line word( exec, 3) "|"
                    parse value(space(exec,0))  with . "PROGRAM(" iden ")" .
                    line = line iden "|" "NA" "|" "NA" "|"
                end

                when wordpos( word( exec, 3),  "WRITE READ INQUIRE STARTBR ENDBR READNEXT" ) > 0 then do
                    line = line word( exec, 3) "|"
                    parse value(space(exec,0)) with  . "FILE(" iden ")" .
                    if  iden = "" then ,
                        parse value(space(exec,0)) with  . "DATASET(" iden ")" .
                    line = line "NA" "|" iden "|" "NA" "|"
                end

                when wordpos( word( exec, 3),  "READQ WRITEQ" ) > 0 then do
                    line = line word( exec, 3)
                    line = line word( exec, 4) "|"
                    parse value(space(exec,0)) with  . "QUEUE(" iden ")" .
                    line = line "NA" "|" "NA" "|" iden "|"
                end

                otherwise do
                    line = line "NA" "|" "NA" "|" "NA" "|" "NA" "|"
                end
            end

            say line
            exec = ""; iden = ""; line = ""

        end

        when left( tail, 9 ) = "EXEC CICS" then do
            exec = space( tail )
            -- say "at ".line~right(3) " >>"exec"<<"
        end

        otherwise do
            exec = space( exec tail )
        end

    end

end



the input
Code:


 BBBBBBBB |     EXEC CICS   END-EXEC.

cccccccc |           EXEC CICS RETURN
cccccccc | END-EXEC.

AAAAAAA |           EXEC CICS LINK
AAAAAAA |                     PROGRAM  (WS-LOG-PRG)
AAAAAAA |                     COMMAREA (WS-LNK-ERROR)
AAAAAAA |                     LENGTH   (LENGTH OF WS-LNK-ERROR)
AAAAAAA |                     RESP     (CICS-RESP)
AAAAAAA |           END-EXEC.

A |           EXEC CICS LINK
A |                     PROGRAM  (WS-LOG-PRG2)
A |                     COMMAREA (WS-LNK-ERROR)
A |                     LENGTH   (LENGTH OF WS-LNK-ERROR)
A |                     RESP     (CICS-RESP) END-EXEC.
A |



the output
Code:

BBBBBBBB | NA | NA | NA | NA |
CCCCCCCC | NA | NA | NA | NA |
AAAAAAA | LINK | WS-LOG-PRG | NA | NA |
A | LINK | WS-LOG-PRG2 | NA | NA |
Back to top
View user's profile Send private message
chavinash2004

New User


Joined: 30 Jun 2010
Posts: 30
Location: hyderabad

PostPosted: Wed Apr 01, 2020 7:43 pm    Post subject: Reply to: Need help in REXX code to list the affinities between exec
Reply with quote

It worked. Thanks for your time and help on this.

Thanks once again and stay safe.
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 REXX script to beautify XML jzhardy CLIST & REXX 1 Sun Oct 11, 2020 1:23 pm
No new posts Easytrieve EZABX007 with error code 0... Carol Schablow CA Products 7 Thu Sep 24, 2020 3:30 am
No new posts List of Active Jobs in CTRL-M Vineet JCL & VSAM 1 Mon Sep 21, 2020 7:58 pm
No new posts TWS PIF (EQQYCOM) Rexx - Occurrence S... Richard Baker IBM Tools 0 Wed Sep 16, 2020 10:45 am
No new posts Call Natural program with rexx shahaf CLIST & REXX 2 Tue Sep 08, 2020 11:22 am

Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us