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

Easytrieve - Compare two Alphanumeric ranges


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jan 01, 2012 6:45 am
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

Moderator Emeritus


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

PostPosted: Sun Jan 01, 2012 11:20 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jan 01, 2012 2:07 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jan 01, 2012 3:38 pm
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: 1788
Location: Bloomington, IL

PostPosted: Sun Jan 01, 2012 9:02 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top