S
smat-consulting
Guest
Here's a sample wrapper/api system as mentioned above - no idea whether this is applicable in your case, just to give you an idea ( have the three files located in a temp directory within the main working directory). Try to compile the two .p with PREPROCESS option ( for example: COMPILE temp/octavio.p PREPROCESS temp/ocatavio.pp.p)... temp/apiOcatvio.p: /*----------------------------------------------------------------------------- File : api/apiOctavio.p Purpose : simply includes octavio.p with the API preprocessor set to TRUE to implement the actual API logic Author(s) : initialized by SMAT-tools of SMAT-Consulting Thomas Hutegger - info@smat-consulting.com Created : Notes : History : 2016-03-09 tmh created template ---------------------------------------------------------------------------*/ { temp/octavio.p &API = "TRUE" } /*---------------------------------------------------------------------------*/ temp/ocatvio.p: /*----------------------------------------------------------------------------- File : api/octavio.p Purpose : implements wrapper and actual API Preprocessors: &API "" in octavio.p "true" in apiOctavio.p Author(s) : initialized by SMAT-tools of SMAT-Consulting Thomas Hutegger - info@smat-consulting.com Created : Notes : History : 2016-03-09 tmh created template ---------------------------------------------------------------------------*/ DEFINE TEMP-TABLE ttSampleIn FIELD custNameFrom AS CHARACTER FIELD custNameTo AS CHARACTER /* only one record, so no index is needed */ . DEFINE TEMP-TABLE ttSampleOut FIELD custNum AS CHARACTER FIELD custName AS CHARACTER INDEX upi IS UNIQUE PRIMARY custName . DEFINE INPUT PARAMETER TABLE FOR ttSampleIn. DEFINE OUTPUT PARAMETER TABLE FOR ttSampleOut. DEFINE OUTPUT PARAMETER opcMessage AS CHARACTER NO-UNDO. &IF "{&API}" = "" &THEN /* wrapper */ { temp/octavioCheckDb.i } /* only if DB is connected the next statement is being executed */ RUN apiOctavio.p ( INPUT TABLE ttSampleIn , OUTPUT TABLE ttSampleOut , OUTPUT opcMessage ). &ELSE /* actual api */ RUN whateverProceduresYouWantToDoTheWork. RUN someMoreIfYoUWant. RUN untilAllIsSaidAndDone. &ENDIF temp/ocatvioCheckDb.i: /*----------------------------------------------------------------------------- File : api/checkDb.i Purpose : check fi the DB is connected and if not try to connect to it. if still not connected return error-message, otherwise let includer make one statement of their choice Author(s) : initialized by SMAT-tools of SMAT-Consulting Thomas Hutegger - info@smat-consulting.com Created : Notes : History : 2016-03-09 tmh created template ---------------------------------------------------------------------------*/ IF CONNECTED ( "db" ) THEN CONNECT db/sports -pf db/sports.as.pf. IF NOT CONNECTED ( "sports") THEN ASSIGN opcMessage = "ERROR - db not connected" . ELSE /*---------------------------------------------------------------------------*/
Continue reading...
Continue reading...