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
 

 

Implement the below logic with a single PERFORM statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jsnair

New User


Joined: 26 Sep 2006
Posts: 38
Location: India

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

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.
Back to top
View user's profile Send private message

Escapa

Senior Member


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

PostPosted: Mon Apr 20, 2009 5:02 pm    Post subject:
Reply with quote

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??

please clarify..
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Mon Apr 20, 2009 5:04 pm    Post subject: Reply to: PERFORM - Loop
Reply with quote

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) icon_wink.gif

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,
Back to top
View user's profile Send private message
jsnair

New User


Joined: 26 Sep 2006
Posts: 38
Location: India

PostPosted: Mon Apr 20, 2009 5:39 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon Apr 20, 2009 6:08 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Apr 20, 2009 8:55 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

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

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
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Tue Apr 21, 2009 5:49 am    Post subject: Reply to: Implement the below logic with a single PERFORM st
Reply with quote

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.... icon_wink.gif
Back to top
View user's profile Send private message
jsnair

New User


Joined: 26 Sep 2006
Posts: 38
Location: India

PostPosted: Wed Apr 29, 2009 2:17 pm    Post subject:
Reply with quote

Thanks Sambhaji, Dick, enrico and Bill for your valuable suggestions...
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts Splitting of single report to seperat... abdulrafi TSO/ISPF 7 Mon Mar 27, 2017 3:59 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


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