Reputation: 251
I have written a program for matching two records. If its matching then i need to have a message "Matched" but the problem here is I don't get any idea about how to matching. Let me share my program
DEFINE VARIABLE cPos AS INTEGER NO-UNDO.
DEFINE TEMP-TABLE tt_data NO-UNDO
FIELD cPosition AS CHARACTER FORMAT "X(60)"
FIELD cEndCode AS CHARACTER
FIELD cShotCode AS CHARACTER.
CREATE tt_data.
ASSIGN
tt_data.cPosition ="S$$$^^^^^^^^^^$$$^^^MC^^^^^^^^^^^^R^^^^^^^^^^^^^^^^^^^^^^^^^"
tt_data.cEndCode = 10
tt_data.cShotCode = "S".
CASE tt_data.cEndCode:
WHEN 10 THEN DO:
cPos = 1.
END.
WHEN 20 THEN DO:
cPos = 2.
END.
.
.
.
WHEN 600 THEN DO:
cPos = 60
END.
END CASE.
FIND FIRST tt_date WHERE tt_data.cShotCode = SUBSTRING(tt_data.cPosition,cPos,1) NO-LOCK NO-ERROR.
DISPLAY tt_data.cShotCode. /* Displayed Value is S */
If you see tt_datacEndCode value is 10 which means its pointing ENTRY 1 of tt_data.cPosition (i.e. S).
When 20 then its for ENTRY 2 like wise i want to get up to 600 (i.e. tt_datacEndCode = 60).
The problem here is I cannot have WHEN statement up to 600. So Could you please help this case?
Upvotes: 0
Views: 535
Reputation: 14020
For the example that you have shown you could eliminate the CASE statement and simply replace it with:
cPos = integer( tt_data.cEndCode / 10 ).
(assuming that, as shown, cEndCode is always a multiple of 10 and the desired cPos is 1/10th of that value.)
Thus:
DEFINE VARIABLE cPos AS INTEGER NO-UNDO.
DEFINE TEMP-TABLE tt_data NO-UNDO
FIELD cPosition AS CHARACTER FORMAT "X(60)"
FIELD cEndCode AS CHARACTER
FIELD cShotCode AS CHARACTER.
CREATE tt_data.
ASSIGN
tt_data.cPosition ="S$$$^^^^^^^^^^$$$^^^MC^^^^^^^^^^^^R^^^^^^^^^^^^^^^^^^^^^^^^^"
tt_data.cEndCode = 10
tt_data.cShotCode = "S".
cPos = integer( tt_data.cEndCode / 10 ).
FIND FIRST tt_date WHERE tt_data.cShotCode = SUBSTRING(tt_data.cPosition,cPos,1) NO-LOCK NO-ERROR.
DISPLAY tt_data.cShotCode. /* Displayed Value is S */
Upvotes: 3