View previous topic :: View next topic
|
Author |
Message |
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
I tried to search for an existing topic (without luck I guess). I'm trying to emulate something that I did dozens of times in IBM HLASM by inserting the binary length into a OP Code for a CLC instruction, but in Enterprise COBOL.
Is this possible...using the methodology that I coded (see code block below)?
Thanks for your help.
Chris.
Code: |
<data - input loaded into table below>
GOL 2JGOLD VIOLIN
NON 2NNORM THOMPSON
ORC 2ZORCHARD BRANDS
ORCHARD GOLD VIOLIN 2ZORCHARD GOLD VIOLIN
ORCHARD NORM THOMPSO2ZORCHARD NORM THOMPSON
ORCHARD SAHALIE 2ZORCHARD SAHALIE
ORCHARD SOLUTIONS 2ZORCHARD SOLUTIONS
RET 2ZNORM THOMPSON RETAIL STORES
SAH 2ESAHALIE
SOL 2SSOLUTIONS
VITAMINCOMPASS 2KVITAMIN COMPASS (HEALTHY SOLUTIONS)
VITAMINSUPPLY 2VVITAMIN SUPPLY (HEALTHY SOLUTIONS)
<table definition in w/s>
01 WS-YM-DIV-TABLE.
05 YM-DIV-ENTRIES PIC 9(3) VALUE 0.
05 YM-DIV-EOF PIC X(3) VALUE 'NO '.
05 YM-DIV-ENTRY OCCURS 1 TO 100 TIMES
DEPENDING ON YM-DIV-ENTRIES
ASCENDING KEY TBL-YM-DIV
INDEXED BY HM-DIV-INX.
10 TBL-YM-DIV PIC X(20).
10 TBL-YM-DIV-LGTH PIC 99.
10 TBL-MZP-SUB-CODE PIC X(2).
10 TBL-MZP-SUB-NAME PIC X(40).
<alternate looping that provides matches>
PERFORM VARYING YM-DIV-INX FROM 1 BY 1
UNTIL YM-DIV-INX > YM-DIV-ENTRIES
IF TBL-YM-DIV (YM-DIV-INX) =
YER-GENERIC-FLD-7
(1:TBL-YM-DIV-LGTH (YM-DIV-INX))
MOVE TBL-MZP-SUB-CODE (YM-DIV-INX) TO YER-SUB-CODE
ADD +1 TO YM-DIV-MATCH
CNT-DIV-CODE-YM-XREF
ELSE
IF YM-DIV-INX = YM-DIV-ENTRIES
ADD +1 TO YM-DIV-NOMATCH
END-IF
END-IF
END-PERFORM.
<original intended SEARCH ALL w/ Reference Mod technique -- that isn't working>
SEARCH ALL YM-DIV-ENTRY
AT END
ADD +1 TO YM-DIV-NOMATCH
WHEN TBL-YM-DIV (YM-DIV-INX)
= YER-GENERIC-FLD-7
(1:TBL-YM-DIV-LGTH (YM-DIV-INX))
ADD +1 TO YM-DIV-MATCH
CNT-DIV-CODE-YM-XREF
MOVE TBL-MZP-SUB-CODE (YM-DIV-INX) TO YER-SUB-CODE.
** <load> routine to set actual string length **
9150-LOAD-YM-DIV-XREF.
MOVE NOT-EPH-YM-DIV-CODE
TO TBL-YM-DIV (YM-DIV-INX).
MOVE ZEROS TO I.
INSPECT FUNCTION REVERSE(NOT-EPH-YM-DIV-CODE)
TALLYING I FOR LEADING SPACE.
COMPUTE TBL-YM-DIV-LGTH (YM-DIV-INX) =
(LENGTH OF TBL-YM-DIV (YM-DIV-INX) - I).
MOVE NOT-EPH-MZP-DIV-CODE
TO TBL-MZP-SUB-CODE (YM-DIV-INX).
MOVE NOT-EPH-DIV-DESCRIPTION
TO TBL-MZP-SUB-NAME (YM-DIV-INX).
ADD +1 TO YM-DIV-ENTRIES. |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
When you say "isn't working" does this mean there are no matches?
You might change this:
Code: |
WHEN TBL-YM-DIV (YM-DIV-INX)
= YER-GENERIC-FLD-7
(1:TBL-YM-DIV-LGTH (YM-DIV-INX)) |
to:
Code: |
WHEN TBL-YM-DIV (1:TBL-YM-DIV-LGTH (YM-DIV-INX))
= YER-GENERIC-FLD-7
(1:TBL-YM-DIV-LGTH (YM-DIV-INX)) |
as an experiment.
I'm not sure if the currently coded compare will be of equal lengths. |
|
Back to top |
|
|
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
I had started with a variation of your suggestion, have the reference modifcation on the array-side and the compiler didn't like this. I thought that I still had the compiler error, but I don't. I will however give this method a try.
Thanks Dick. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
IMHO, the ODO (in WS) can be changed to just a plain old OCCURS 100. Also, based upon the number of entries that you're loading, you'd be much better off with either a SEARCH or an in-line PERFORM. Generally, when a table exceeds 128 entries, then a SEARCH ALL is the more efficient method for table searching, providing (of course) all the table entries are sorted.
If you intend on keeping the SEARCH ALL, before you populate the table, you need to initialize it with ALL HIGH-VALUES and then load the valid table entries. What's the value of YM-DIV-ENTRIES?
But, I'm unsure why your reference modification compare doesn't work. However, COBOL (in its infinite wisdom) will NOT expand into a CLC, but rather a CLCL. This is due to the fact that the reference modification length is OTHER THAN a LENGTH OF. I know it seems silly that COBOL would not have the smarts to use a CLC, but that's the way it is. Inasmuch as you'd like to insert the length for operand-1 into a generated CLC, you can't do that in COBOL.
FWIW, the same thing happens on a MOVE with a reference modification length which is unknown (other than a LENGTH OF), COBOL will issue an MVCL, even for ONE byte! I know, it's crazy, but that's the way it is.
I had a discussion with a COBOL compiler guy at SHARE 2008 and I asked him that very question; why the CLCL, MVCL etc? He said is was because the compiler doesn't know the length until execution time and I said "Well, PL/I does", but he never gave me a good answer and dodged me. PL/I will actually generate an EX over an MVC or CLC, using the supplied length minus 1. To make it more interesting, the PL/I complier folks are on the same floor and in the same vicinity as the COBOL compiler folks. But, I guess they don't talk to one another.
But, fellow member "Enrico" said it best "Because PL/I is a smarter compiler". However, if I had uttered this to the COBOL guy, I would have gotten a coffee shampoo!
Later....
Bill |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
That's why i always prefer to code in Assembler.
If they let me do this. :-) |
|
Back to top |
|
|
Chris Chapel
New User
Joined: 11 Sep 2007 Posts: 10 Location: Marshfield, WI
|
|
|
|
Bill, thanks for your advise on the suggested threshold to apply the binary versus serial search. I've heard many suggestions in the past 15-20 years (most of them significantly smaller than 128 entries), but have never performance tested the theory.
Regarding the initialize with ALL HIGH-VALUES, that would be required on a search with a "static" number of entries, but w/ the ODO clause, the scope of the search is limited to the value presented to the ODO clause (which in this case is: 12 - the number of records from the input-loading table which is stored in YM-DIV-ENTRIES).
As I mentioned following Dick's reply, I tried the reference modification on the array-side of the WHEN... clause and received the following compiler error.
Code: |
001621 136600 SEARCH ALL YM-DIV-ENTRY C
001622 136700 AT END C
001623 1 136800 ADD +1 TO YM-DIV-NOMATCH C
001624 136900 WHEN TBL-YM-DIV (YM-DIV-INX) C
001625 136910 (1:TBL-YM-DIV-LGTH (YM-DIV-INX)) C
001625==> IGYPS2213-S "TBL-YM-DIV" was reference modified and reference modification is not
allowed in this context. The statement was discarded.
001626 137000 = YER-GENERIC-FLD-7 C
001627 1 137200 ADD +1 TO YM-DIV-MATCH C
001628 1 137300 CNT-DIV-CODE-YM-XREF C
001629 1 137400 MOVE TBL-MZP-SUB-CODE (YM-DIV-INX) TO YER-SUB-CODE. C |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I was afraid of that. . . Bummer.
Did you try this without the ODO? Again just an experiment. |
|
Back to top |
|
|
|