Consultor Eletrônico



Kbase 16775: How to Compile / Preprocess a SmartObject to Read ADM Code
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
How to Compile / Preprocess a SmartObject to Read ADM Code

INTRODUCTION
============
This knowledgebase entry discusses how to and why you should
compile SmartObjects with the preprocess option to read and
better understand ADM code.

WHY YOU NEED TO KNOW THIS
=========================
Understanding what is in your SmartObject ADM code is important
because it is really just a 4gl extension of your application.
It would also be useful to understand what the ADM is doing in
order to modify it to meet your business needs. Refer to
knowledgebase entry 15815 Modifying ADM support code for
information about changing the ADM. You may also want to
do this if you feel you are running into an ADM bug and
would like to investigate it in the ADM code and possibly
fix it yourself (please still report any ADM bugs you find
to Technical Support so they will be fixed in a future
release).

PROCEDURAL APPROACH
===================
Suppose you have a SmartViewer that contains multiple
enabled tables and you would like to know how the records
are deleted.

Here is a look at a portion of the adm-delete-record procedure in
dlc/src/adm/method/tableio.i:

&IF NUM-ENTRIES("{&adm-first-enabled-table}":U, " ":U) = 1 &THEN

DEFINE VARIABLE delete-failed AS LOGICAL NO-UNDO INIT no.

&IF DEFINED(adm-browser) NE 0 &THEN
IF BROWSE {&BROWSE-NAME}:NUM-SELECTED-ROWS NE 1 THEN
DO:
MESSAGE "No row has been selected for deletion." VIEW-AS ALERT-BOX.
RETURN.
END.
&ENDIF

DO TRANSACTION ON STOP UNDO, LEAVE ON ERROR UNDO, LEAVE:
/* If this object has a group-assign-source for its first or only
table, then don't try to re-delete the record here. */
IF group-assign-add NE yes THEN
DO:
FIND CURRENT {&adm-first-enabled-table} EXCLUSIVE-LOCK NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
UNDO, RETURN "ADM-ERROR":U.
END.
DELETE {&adm-first-enabled-table} NO-ERROR.
END.

&IF "{&adm-second-enabled-table}":U NE "":U &THEN
FIND CURRENT {&adm-second-enabled-table} EXCLUSIVE-LOCK NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
UNDO, RETURN "ADM-ERROR":U.
END.
DELETE {&adm-second-enabled-table} NO-ERROR.
&ENDIF
&IF "{&adm-third-enabled-table}":U NE "":U &THEN
FIND CURRENT {&adm-third-enabled-table} EXCLUSIVE-LOCK NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
UNDO, RETURN "ADM-ERROR":U.
END.
DELETE {&adm-third-enabled-table} NO-ERROR.
&ENDIF

IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
delete-failed = yes.
END.

To preprocess ADM code you use the preprocess option of the compile
statement:

COMPILE v-myview.w PREPROCESS myview.txt

Here is the same portion of adm-delete-record that is shown
above after being preprocessed, this code is much easier to
read and understand:

DEFINE VARIABLE delete-failed AS LOGICAL NO-UNDO INIT no.

DO TRANSACTION ON STOP UNDO, LEAVE ON ERROR UNDO, LEAVE:

/* If this object has a group-assign-source for its first or only
table, then don't try to re-delete the record here. */
IF group-assign-add NE yes THEN
DO:
FIND CURRENT Customer EXCLUSIVE-LOCK NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
UNDO, RETURN "ADM-ERROR":U.
END.
DELETE Customer NO-ERROR.
END.

FIND CURRENT Salesrep EXCLUSIVE-LOCK NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
UNDO, RETURN "ADM-ERROR":U.
END.
DELETE Salesrep NO-ERROR.

IF ERROR-STATUS:ERROR THEN
DO:
RUN dispatch('show-errors':U).
delete-failed = yes.
END.

REFERENCES TO WRITTEN DOCUMENTATION
===================================
Progress Language Reference: Syntax A to F


Progress Software Technical Support Note # 16775