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
 

 

Easytrieve - Compare two Alphanumeric ranges

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products
View previous topic :: :: View next topic  
Author Message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Sun Jan 01, 2012 6:45 am    Post subject: Easytrieve - Compare two Alphanumeric ranges
Reply with quote

There was a topic, here, which started out with wrong results from an Easytrieve program and looked for a DFSORT solution, which was duly provided.

Here is an Easytrieve solution.

There is some confusion over exactly the sequence that is to be checked, but this is code for three-character-alphanumeric. The sequce is A-Z then 0-9 in three positions.
The "instream table" can be readily amended for numeric-only, alpha-only, groups of letters, or various mixtures, even "special characters" as long as they are in "collating" sequence - depending on the requirement,

I've typed as carefully as I can. Unfortunately I have no current access to Easytrieve, so can't test the program (it is desk-checked) or confirm that it compiles.


Code:
FILE MSSB FB (80 ,  0)           
    MS-BRCH   03 03 A                 
     MS-BRCH-CHAR-1    MS-BRCH 1 A
     MS-BRCH-CHAR-2 +1 MS-BRCH 1 A
     MS-BRCH-CHAR-3 +2 MS-BRCH 1 A

                                 
FILE REP1 FB (50 ,  0)           
    REP-START-BR   02 03 A             
    REP-END-BR     12 03 A             
*                       
FILE NXTCHAR TABLE INSTREAM
  ARG 1 1 A
  DESC 3 1 A
A B
B C
C D
D E
E F
F G
G H
H I
I J
J K
K L
L M
M N
N O
O P
P Q
Q R
R S
S T
T U
U V
V W
W X
X Y
Y Z
Z 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 A
ENDTABLE

W-FIRST-BRANCH-IN-SEQUENCE W 3 A
W-NEXT-BRANCH-VALUE W 3 A
  W-NBV-CHAR-1 W-NEXT-BRANCH-VALUE    1 A
  W-NBV-CHAR-2 W-NEXT-BRANCH-VALUE +1 1 A
  W-NBV-CHAR-3 W-NEXT-BRANCH-VALUE +2 1 A
W-LAST-BRANCH-IN-SEQUENCE W 3 A

W-OUTPUT-COUNT W 5 P

JOB INPUT MSSB +
    START 00-INITIALISATION +
    FINISH 90-LAST-RECORD-AND-COUNTS               

    IF W-FIRST-BRANCH-IN-SEQUENCE EQ "%%%"
        PERFORM 10-SET-UP-BRANCH
        PERFORM 20-WORK-OUT-NEXT-BRCH-VALUE
        GO TO JOB
    END-IF

    IF MS-BRCH EQ W-NEXT-BRANCH-VALUE
        W-LAST-BRANCH-IN-SEQUENCE = MS-BRCH
        PERFORM 20-WORK-OUT-NEXT-BRCH-VALUE
        GO TO JOB
    END-IF

    PERFORM 30-FORMAT-AND-OUTPUT-RECORD
    PERFORM 10-SET-UP-BRANCH

00-INITIALISATION. PROC                     
    W-FIRST-BRANCH-IN-SEQUENCE = "%%%"
END-PROC
10-SET-UP-BRANCH. PROC
    W-FIRST-BRANCH-IN-SEQUENCE = MS-BRCH
    W-LAST-BRANCH-IN-SEQUENCE = MS-BRCH
    W-NEXT-BRANCH-VALUE = MS-BRCH
END-PROC
20-WORK-OUT-NEXT-BRCH-VALUE. PROC                           
    SEARCH NXTCHAR WITH MS-BRCH-CHAR-3 GIVING W-NBV-CHAR-3
    IF W-NBV-CHAR-3 LT MS-BRCH-CHAR-3
        SEARCH NXTCHAR WITH MS-BRCH-CHAR-2 GIVING W-NBV-CHAR-2
        IF W-NBV-CHAR-2 LT MS-BRCH-CHAR-2
            SEARCH NXTCHAR WITH MS-BRCH-CHAR-1 GIVING W-NBV-CHAR-1
            IF W-NBV-CHAR-1 LT MS-BRCH-CHAR-1
                DISPLAY "OH, CRIPES, NOWHERE TO GO"
                RETURN-CODE = 12
                STOP EXECUTE
            END-IF
        END-IF
    END-IF
END-PROC
30-FORMAT-AND-OUTPUT-RECORD. PROC
    REP-START-BR   = W-FIRST-BRANCH-IN-SEQUENCE
    REP-END-BR     = W-LAST-BRANCH-IN-SEQUENCE
    PUT REP1
    W-OUTPUT-COUNT = W-OUTPUT-COUNT + 1
END-PROC
90-LAST-RECORD-AND-COUNTS. PROC
    PERFORM 30-FORMAT-AND-OUTPUT-RECORD
    IF W-OUTPUT-COUNT NE ( REP1 : RECORD-COUNT )
        DISPLAY "SOMETHING AMISS - OUTPUT RECORDS COUNTED WERE " W-OUTPUT-COUNT
    END-IF
END-PROC
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Jan 01, 2012 11:20 am    Post subject:
Reply with quote

Hi Bill,

New Year is quite a slow time on the forum. . . icon_smile.gif

It is several minutes before midnight here and i've put myself at the keyboard with the phone in reach. Usually, several calls come in between now and 12:15-12:30.

Happy New Year!

d
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Sun Jan 01, 2012 2:07 pm    Post subject: Reply to: Easytrieve - Compare two Alphanumeric ranges
Reply with quote

Hi Dick,

Igualmente.

Todos:

Um feliz ano novo para os todos.

Cat woke me up this morning wanting food. Find something, put it in his bowl, Hope it was catfood. Back into bed.

Dang. Did I miss a line? Thinks. Yes, I did. Lesson to be re-learned, don't make the program look even prettier after desk-checking.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Sun Jan 01, 2012 3:38 pm    Post subject: Reply to: Easytrieve - Compare two Alphanumeric ranges
Reply with quote

Now even, even, prettier and desck-checked again.

The program can be easily arranged without the "GO TO JOB"s. The proc-numbering doesn't have much benefit in small programs (but nor in Cobol, either).

The program could even be adjusted for arbitrary, non-collating, sequences without enormous effort.

Code:

FILE MSSB FB (80 ,  0)           
    MS-BRCH   03 03 A                 
     MS-BRCH-CHAR-1    MS-BRCH 1 A
     MS-BRCH-CHAR-2 +1 MS-BRCH 1 A
     MS-BRCH-CHAR-3 +2 MS-BRCH 1 A

                                 
FILE REP1 FB (50 ,  0)           
    REP-START-BR   02 03 A             
    REP-END-BR     12 03 A             
*                       
FILE NXTCHAR TABLE INSTREAM
  ARG 1 1 A
  DESC 3 1 A
A B
B C
C D
D E
E F
F G
G H
H I
I J
J K
K L
L M
M N
N O
O P
P Q
Q R
R S
S T
T U
U V
V W
W X
X Y
Y Z
Z 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 A
ENDTABLE

W-FIRST-BRANCH-IN-SEQUENCE W 3 A
W-NEXT-BRANCH-VALUE W 3 A
  W-NBV-CHAR-1 W-NEXT-BRANCH-VALUE    1 A
  W-NBV-CHAR-2 W-NEXT-BRANCH-VALUE +1 1 A
  W-NBV-CHAR-3 W-NEXT-BRANCH-VALUE +2 1 A
W-LAST-BRANCH-IN-SEQUENCE W 3 A

W-OUTPUT-COUNT W 5 P

JOB INPUT MSSB +
    START 00-INITIALISATION +
    FINISH 90-LAST-RECORD-AND-COUNTS               

    IF ( MSSB : RECORD-COUNT ) EQ 1
        PERFORM 10-NEW-BRANCH
        GO TO JOB
    END-IF

    IF MS-BRCH EQ W-NEXT-BRANCH-VALUE
        W-LAST-BRANCH-IN-SEQUENCE = MS-BRCH
        PERFORM 99A-WORK-OUT-NEXT-BRANCH-VALUE
        GO TO JOB
    END-IF

    PERFORM 99D-FORMAT-AND-OUTPUT-RECORD
    PERFORM 10-NEW-BRANCH

00-INITIALISATION. PROC                     
   
END-PROC
10-NEW-BRANCH. PROC
    PERFORM 10A-SET-UP-BRANCH
    PERFORM 99A-WORK-OUT-NEXT-BRANCH-VALUE
END-PROC
10A-SET-UP-BRANCH. PROC
    W-FIRST-BRANCH-IN-SEQUENCE = MS-BRCH
    W-LAST-BRANCH-IN-SEQUENCE  = MS-BRCH
    W-NEXT-BRANCH-VALUE        = MS-BRCH
END-PROC
90-LAST-RECORD-AND-COUNTS. PROC
    PERFORM 99D-FORMAT-AND-OUTPUT-RECORD
    IF W-OUTPUT-COUNT NE ( REP1 : RECORD-COUNT )
        DISPLAY "SOMETHING AMISS - OUTPUT RECORDS COUNTED WERE " W-OUTPUT-COUNT
    END-IF
END-PROC
99A-WORK-OUT-NEXT-BRANCH-VALUE. PROC                           
    SEARCH NXTCHAR WITH MS-BRCH-CHAR-3 GIVING W-NBV-CHAR-3
    IF W-NBV-CHAR-3 LT MS-BRCH-CHAR-3
        SEARCH NXTCHAR WITH MS-BRCH-CHAR-2 GIVING W-NBV-CHAR-2
        IF W-NBV-CHAR-2 LT MS-BRCH-CHAR-2
            SEARCH NXTCHAR WITH MS-BRCH-CHAR-1 GIVING W-NBV-CHAR-1
            IF W-NBV-CHAR-1 LT MS-BRCH-CHAR-1
                DISPLAY "OH, CRIPES, NOWHERE TO GO"
                RETURN-CODE = 12
                STOP EXECUTE
            END-IF
        END-IF
    END-IF
END-PROC
99D-FORMAT-AND-OUTPUT-RECORD. PROC
    REP-START-BR   = W-FIRST-BRANCH-IN-SEQUENCE
    REP-END-BR     = W-LAST-BRANCH-IN-SEQUENCE
    PUT REP1
    W-OUTPUT-COUNT = W-OUTPUT-COUNT + 1
END-PROC
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1746
Location: Bloomington, IL

PostPosted: Sun Jan 01, 2012 9:02 pm    Post subject: Re: Reply to: Easytrieve - Compare two Alphanumeric ranges
Reply with quote

Bill Woodger wrote:
Cat woke me up this morning wanting food. Find something, put it in his bowl, Hope it was catfood. Back into bed.

Ah, yes, I know that feeling well icon_smile.gif Katie got a small can of lamb stew about 20 minutes ago.
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 -> CA Products All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts COMPARE command sivatechdrive TSO/ISPF 7 Fri Sep 16, 2016 4:31 pm
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am


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