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

Program logic help on building code/psudocode


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 08, 2011 7:02 pm
Reply with quote

what did You not understand in the pseudo code I posted ?
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Feb 08, 2011 7:35 pm
Reply with quote

Layout of both files are as follows

Code:
Accnt range file :
01  ACCT-RANG-REC.
           05  FROM-ACCT-NO.
               10  ACRG-FROM-OFFC      PIC  X(03).
               10  ACRG-FROM-ACCT      PIC  X(05).
           05  THRU-ACCT-NO.
               10  ACRG-THRU-OFFC      PIC  X(03).
               10  ACRG-THRU-ACCT      PIC  X(05).
           05  ACRG-FILLER             PIC  X(64).

Data file Key part

01  DATALINE-REC.
           05  ML-KEY.
               10  ML-CLIENT           PIC XX.
               10  ML-OFFC-ACCT.
                   15  ML-OFFICE       PIC XXX.
                   15  ML-ACCOUNT      PIC X(5).
               10  ML-CURRENCY-CODE    PIC XX.






Till now i have done as follows

Code:
Perform READ-ACCT-RANGES

READ ACNT-RANGE-FILE                         
    END                                     
        MOVE HIGH-VALUES TO FROM-ACCT-NO
     NOT END                                 
        ADD  1           TO AR-CTR           
END-READ.                                   

PERFORM I-MAIN-LOGIC      THRU PARA-EXIT
    UNTIL FROM-ACCT-NO = HIGH-VALUES.   

MOVE FROM-ACCT-NO TO ML-OFFC-ACCT.

START MONY-LINE-FILE KEY >= ML-KEY.         
EVALUATE ML-STATUS                           
    WHEN '00'                               
        PERFORM 175-READ-DATALINE-FILE     
    WHEN '23'                               
        MOVE HIGH-VALUES TO ML-OFFC-ACCT     
    WHEN OTHER                               
        DISPLAY 'ABORT NUMBER:  ' ABEND-NUM 
        DISPLAY 'FILE STATUS :  ' ML-STATUS 
        PERFORM 999-ABORT-JOB               
END-EVALUATE.                               

175-READ-DATALINE-FILE.                       
    READ DATA-LINE-FILE NEXT.                   
    EVALUATE ML-STATUS                         
        WHEN '00'                               
            ADD  1           TO ML-CTR         
        WHEN '10'                               
            MOVE HIGH-VALUES TO ML-OFFC-ACCT   
        WHEN OTHER                             
            DISPLAY 'ABORT NUMBER:  ' ABEND-NUM
            DISPLAY 'FILE STATUS :  ' ML-STATUS
            PERFORM 999-ABORT-JOB               
    END-EVALUATE.                               

PERFORM UNTIL ML-OFFC-ACCT > THRU-ACCT-NO
perform...
peform ... etc
etc..

PERFORM 175-READ-DATALINE-FILE
Perform READ-ACCT-RANGES



Could you suggest more efficient and simple way of achieving above?


Regards,
N
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Feb 08, 2011 7:43 pm
Reply with quote

yeah, use the rope that enrico mentioned earlier.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 08, 2011 7:49 pm
Reply with quote

Quote:
Could you suggest more efficient and simple way of achieving above?
It is not always possible to do this. Some problems just require a certain amount of logic (and hence code) to resolve -- and without completely changing the problem statement, you cannot get around this. Either learn to deal with the complexity, or get used to being utterly confused as an IT person, or find a career that doesn't require the complexity. Your choice.
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Tue Feb 08, 2011 7:49 pm
Reply with quote

Anyway.. can you please give me some examples of such programs so that i will take a look and try to buid it accordingly.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 08, 2011 8:14 pm
Reply with quote

I do not speak cobolese, but whatever the language chosen
I would follow strictly the pseudo code I suggested
effective, and very easy to follow

it did not take me very long to prototype the whole thing in REXX

file1 ( the range data )
Code:

3 5
10 12
14 18


file2 ( the data )
Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


the prototype to check the logic
Code:

#! /opt/oorexx/bin/rexx

/* read the first record from the range file */
file1buff = ""
file1buff = linein("file1.txt")
/* check for an empty range file */
if  file1buff = "" then do
    /* simulate end of file */
    key1 = 9999
    key2 = 9999
end
else do
    key1 = strip(word(file1buff,1))
    key2 = strip(word(file1buff,2))
end

/* read the first record from the data file */
file2buff = ""
file2buff = linein("file2.txt")
do  forever
    /* check for end-of-file on the data file */
    if  file2buff = "" then ,
        leave
    keyd = strip(file2buff)

    /* check for the data key in the current range */
    if  key1 <= keyd & keyd <= key2 then do
        file3buff = right(keyd,4) || " in range    " right(key1,4) right(key2,4)
        say file3buff
        /* read the next record from the data file */
        file2buff = ""
        file2buff = linein("file2.txt")
        iterate
    end

    /* check for the data key below the current range */
    if  keyd < key1 then do
        file3buff = right(keyd,4) || " NOT in range"
        say file3buff
        /* read the next record from the data file */
        file2buff = ""
        file2buff = linein("file2.txt")
        iterate
    end

    /* check for the data key above the current range */
    /* not needed but prevents nasty situations       */
    if  keyd > key2 then do
        /* read the next record from the range file */
        file1buff = ""
        file1buff = linein("file1.txt")
        /* check for end-of-file on the range file */
        if  file1buff = "" then do
            key1 = 9999
            key2 = 9999
        end
        else do
            key1 = strip(word(file1buff,1))
            key2 = strip(word(file1buff,2))
        end
        iterate
    end

    say "***** Logic Error, should not be here "

end

exit


the result
Code:

   1 NOT in range
   2 NOT in range
   3 in range        3    5
   4 in range        3    5
   5 in range        3    5
   6 NOT in range
   7 NOT in range
   8 NOT in range
   9 NOT in range
  10 in range       10   12
  11 in range       10   12
  12 in range       10   12
  13 NOT in range
  14 in range       14   18
  15 in range       14   18
  16 in range       14   18
  17 in range       14   18
  18 in range       14   18
  19 NOT in range
  20 NOT in range


it did not take that long - check the posts timestamps
started doing since Your last post appeared
while waiting for a loong build to complete on my mac icon_biggrin.gif
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Feb 08, 2011 8:15 pm
Reply with quote

Perhaps the code example provided in this link could get you started in the right direction.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 08, 2011 8:23 pm
Reply with quote

Hi Ronald!
getting into a self reference loop icon_biggrin.gif

if the TS had read and understood the pseudo code we would not be here!
since I was having a coffee break I prototyped the sillyness in rexx
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 -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
Search our Forums:

Back to Top