Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
jsnair

New User

Joined: 26 Sep 2006
Posts: 38
Location: India

Posted: Mon Apr 20, 2009 4:36 pm    Post subject: Implement the below logic with a single PERFORM statement

Hi All,

I have one single dimensional array with 200 elements. The existing logic is to take first 99 elements and load in to second array which can hold upto 100 elements. Now I need to map values from 160 and 166th position from the first array To 23rd and 24th position of the second array as well. Because the values present in 160, 166 positions are required and 23,24 positions in second array are free. So we can use these.

Can anybody suggest me whether I can implement the above logic with a single PERFORM statement.

Below please find the current logic.

 Code: PERFORM VARYING CNT1 FROM 1 BY 1 UNTIL CNT1 > TOT-COUNT                                     OR CNT1 > 99             MOVE .....  MOVE ......      END-PERFORM.

Here TOT-COUNT --> Total element count in first array.

Escapa

Senior Member

Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

Posted: Mon Apr 20, 2009 5:02 pm    Post subject:

Certainly it is possible but need some clarification first...

 Quote: The existing logic is to take first 99 elements and load in to second array which can hold upto 100 elements

 Quote: 23,24 positions in second array are free

These two statements are conflicting...

by first statement 23,24th pos of of second array will be already holding value from 23,24 pos of first array...
so how you are saying 23,24 pos in second array are free??

Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

 Posted: Mon Apr 20, 2009 5:04 pm    Post subject: Reply to: PERFORM - Loop Your pseudo-code should work properly, when used together with several PERFORM's. To incorporate all that you need to do into a single PERFORM, may cause your colleagues some heartache (as well as dirty looks) There's really no reason to make this complicated or clever (with a single PERFORM) and your colleagues will appreciate the easiest method possible (for future maintenance consideration). Just my .02 cents.... Regards,
jsnair

New User

Joined: 26 Sep 2006
Posts: 38
Location: India

 Posted: Mon Apr 20, 2009 5:39 pm    Post subject: Hi Sambhaji, What I mean the values present in positions 23 and 24 are currently not using. So we can map with the new values.
Escapa

Senior Member

Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

Posted: Mon Apr 20, 2009 6:08 pm    Post subject:

Ok..
If I understand correctly you can use below..
 Code: PERFORM VARYING CNT1 FROM 1 BY 1 UNTIL CNT1 > TOT-COUNT                                     OR CNT1 > 99            IF CNT1 NOT = 23 AND CNT1 NOT = 24      MOVE FARRAY(CNT1) TO SARRAY(CNT1) ELSE IF CNT1=23       MOVE FARRAY(160) TO SARRAY(CNT1)      ELSE       MOVE FARRAY(166) TO SARRAY(CNT1)      END-IF END-IF  END-PERFORM.
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

Posted: Mon Apr 20, 2009 8:55 pm    Post subject:

the if statement is correct,
but following-up with what Bill said about changing requirements,
an EVALUATE statement would be
• easier to modify
• easier to read and understand:

 Code: PERFORM VARYING  CNT1            FROM  1              BY  1           UNTIL  CNT1 > TOT-COUNT              OR  CNT1 > 99               EVALUATE  TRUE        WHEN  CNT1=23              MOVE FARRAY(160)  TO SARRAY(CNT1)        WHEN  CNT1=24              MOVE FARRAY(166)  TO SARRAY(CNT1)        WHEN  OTHER              MOVE FARRAY(CNT1) TO SARRAY(CNT1)    END-EVALUATE END-PERFORM
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10437
Location: italy

Posted: Mon Apr 20, 2009 9:54 pm    Post subject: Reply to: Implement the below logic with a single PERFORM st

 Quote: Can anybody suggest me whether I can implement the above logic with a single PERFORM statement.

do You have a doctor' s prescription to do it inside a single perform ??

why not use a perform to fill 99 entries
at the end move the two spurious lines where they belong
simpler more clear

something like ...
 Code: PERFORM VARYING  CNT1  FROM  1  BY  1              UNTIL  CNT1 > TOT-COUNT OR  CNT1 > 99               MOVE FARRAY(CNT1) TO SARRAY(CNT1) END-PERFORM MOVE FARRAY(160)  TO SARRAY(23) MOVE FARRAY(166)  TO SARRAY(24)

also it will save all the evaluate stuff from being repeated
when You know that the result will be true only in the 2% of the iterations
Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

 Posted: Tue Apr 21, 2009 5:49 am    Post subject: Reply to: Implement the below logic with a single PERFORM st As a sidenote, make sure CNT1 and TOT-COUNT are both larger enough to hold a value greater than 99. If you define them as 9(08) COMP, COMP-4, BINARY or COMP-5, you'll never have to worry....
jsnair

New User

Joined: 26 Sep 2006
Posts: 38
Location: India

 Posted: Wed Apr 29, 2009 2:17 pm    Post subject: Thanks Sambhaji, Dick, enrico and Bill for your valuable suggestions...
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Logic to skip Maximum time-stamp and ... vickey_dw DB2 2 Thu Feb 01, 2018 11:15 pm Is CICS BMS logic on z/OS different ... Andi1982 CICS 2 Fri Dec 01, 2017 1:56 pm Formatting multiple records to a sing... Vignesh Sid SYNCSORT 3 Tue Nov 07, 2017 12:22 pm COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am More than 1 Include criteria for sing... Roy Ware SYNCSORT 6 Wed Sep 13, 2017 11:45 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us