├── ExampleOutput.png ├── ConfigScreenshot.png ├── 4GlCode ├── Examples │ ├── CustUpdDs.r │ ├── CustUpdTt.r │ ├── FatalRecurse.r │ ├── OrderHandler.r │ ├── CustomerHandler.r │ ├── invoiceHandler.r │ ├── CustUpdDs-SchemaProvider.r │ ├── CustUpdTt-SchemaProvider.r │ ├── invoice-note.df │ ├── CustUpdTt.i │ ├── CustUpdDs.i │ ├── CustUpdDs-SchemaProvider.p │ ├── CustUpdTt-SchemaProvider.p │ ├── FatalRecurse.p │ ├── invoiceHandler.p │ ├── OrderHandler.p │ ├── CustomerHandler.p │ ├── CustUpdTt.p │ ├── CustUpdDs.p │ └── invoice-note.d └── BaseCode │ ├── NodeJsDispatch.r │ ├── nodeJsMetaSchema.r │ ├── NodeJsDynCallDispatch.r │ ├── NodeJsDispatch.p │ └── nodeJsMetaSchema.p ├── winstone ├── winstone-0.9.10.jar └── webapps │ └── Node4ProgressServlet.war ├── Examples ├── configTest.js ├── stopWinstone.js ├── hello-world-server.js ├── package.json ├── testDynCall.js ├── testRecurse.js ├── testDatasetInvoice.js ├── testDatasetCustomer.js ├── testCallHandler.js ├── testDatasetOrder.js ├── custAddTt.js ├── custAddDs.js ├── custDeleteTt.js ├── custDeleteDs.js ├── custUpdTt.js └── custUpdDs.js ├── config └── config.json ├── package.json ├── buffer.js ├── .gitignore ├── dataset.js ├── temptable.js ├── bufferfield.js ├── index.js └── README.md /ExampleOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/ExampleOutput.png -------------------------------------------------------------------------------- /ConfigScreenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/ConfigScreenshot.png -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdDs.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/CustUpdDs.r -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdTt.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/CustUpdTt.r -------------------------------------------------------------------------------- /winstone/winstone-0.9.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/winstone/winstone-0.9.10.jar -------------------------------------------------------------------------------- /4GlCode/Examples/FatalRecurse.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/FatalRecurse.r -------------------------------------------------------------------------------- /4GlCode/Examples/OrderHandler.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/OrderHandler.r -------------------------------------------------------------------------------- /4GlCode/BaseCode/NodeJsDispatch.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/BaseCode/NodeJsDispatch.r -------------------------------------------------------------------------------- /4GlCode/BaseCode/nodeJsMetaSchema.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/BaseCode/nodeJsMetaSchema.r -------------------------------------------------------------------------------- /4GlCode/Examples/CustomerHandler.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/CustomerHandler.r -------------------------------------------------------------------------------- /4GlCode/Examples/invoiceHandler.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/invoiceHandler.r -------------------------------------------------------------------------------- /4GlCode/BaseCode/NodeJsDynCallDispatch.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/BaseCode/NodeJsDynCallDispatch.r -------------------------------------------------------------------------------- /winstone/webapps/Node4ProgressServlet.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/winstone/webapps/Node4ProgressServlet.war -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdDs-SchemaProvider.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/CustUpdDs-SchemaProvider.r -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdTt-SchemaProvider.r: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FrankHilhorst/node4progress/HEAD/4GlCode/Examples/CustUpdTt-SchemaProvider.r -------------------------------------------------------------------------------- /Examples/configTest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * New node file 3 | */ 4 | var conf = require(__dirname + "/config/config.json"); 5 | var node4progress = require("node4progress")(conf); -------------------------------------------------------------------------------- /Examples/stopWinstone.js: -------------------------------------------------------------------------------- 1 | /** 2 | * New node file 3 | */ 4 | var node4progress = require("node4progressHttp")(null); 5 | node4progress.stopWinstone(function(result){ 6 | console.log(result); 7 | }); -------------------------------------------------------------------------------- /Examples/hello-world-server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | http.createServer(function (req, res) { 3 | res.writeHead(200, {'Content-Type': 'text/plain'}); 4 | res.end('Hello World\n'); 5 | }).listen(1337, '127.0.0.1'); 6 | console.log('Server running at http://127.0.0.1:1337/'); 7 | -------------------------------------------------------------------------------- /config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "AppserverUrl" : "APPSERVERDC://192.168.56.101:4090", 3 | "AppserverUserName" : "", 4 | "AppserverUserPassword" : "", 5 | "AppserverSessionModel" : "State-less", 6 | "WinstoneSvrPort" : 8087, 7 | "DateFormat" : "dd/mm" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Node4ProgressHttpTest", 3 | "version": "0.1.0", 4 | "description": "Node4ProgressHttpTest", 5 | "main": "hello-world-server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified! Configure in package.json\" && exit 1" 8 | }, 9 | "repository": "", 10 | "keywords": [ 11 | "Node.js", 12 | "Eclipse", 13 | "Nodeclipse" 14 | ], 15 | "author": "", 16 | "license": "BSD", 17 | "readmeFilename": "README.md" 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node4progress", 3 | "version": "0.1.8", 4 | "description": "Connector to Progress Appserver", 5 | "author": "Frank Hilhorst - Progressive Consulting Inc.", 6 | "main": "index.js", 7 | "scripts": {}, 8 | "private": false, 9 | "dependencies": { 10 | "numeral": "1.5.x", 11 | "debug": "2.x.x", 12 | "moment": ">=2.8.3", 13 | "http": "*" 14 | }, 15 | "engines": { 16 | "node": ">=0.10.x" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/FrankHilhorst/node4progress.git" 21 | }, 22 | "keywords": [ 23 | "Progress", 24 | "Openedge", 25 | "node", 26 | "4GL" 27 | ], 28 | "license": "BSD", 29 | "bugs": { 30 | "url": "https://github.com/FrankHilhorst/node4progress/issues" 31 | }, 32 | "homepage": "https://github.com/FrankHilhorst/node4progress" 33 | } 34 | -------------------------------------------------------------------------------- /4GlCode/Examples/invoice-note.df: -------------------------------------------------------------------------------- 1 | ADD TABLE "Invoice-Note" 2 | AREA "Info Area" 3 | LABEL "Invoice event" 4 | DUMP-NAME "invent-event" 5 | 6 | ADD FIELD "Invoice-Num" OF "Invoice-Note" AS integer 7 | FORMAT ">>>>>9" 8 | INITIAL "0" 9 | POSITION 2 10 | MAX-WIDTH 4 11 | VALEXP "invoice-num > 0" 12 | VALMSG "Invoice number cannot be zero" 13 | ORDER 10 14 | 15 | ADD FIELD "EventDtTm" OF "Invoice-Note" AS datetime 16 | FORMAT "99-99-99 HH:MM:SS.SSS" 17 | INITIAL ? 18 | LABEL "Event Data/Time" 19 | POSITION 3 20 | MAX-WIDTH 8 21 | ORDER 20 22 | 23 | ADD FIELD "EventDtTm-TZ" OF "Invoice-Note" AS datetime-tz 24 | FORMAT "99/99/99 HH:MM:SS.SSS+HH:MM" 25 | INITIAL ? 26 | LABEL "Date/Time TZ" 27 | POSITION 4 28 | MAX-WIDTH 12 29 | ORDER 30 30 | 31 | ADD FIELD "Note" OF "Invoice-Note" AS character 32 | FORMAT "x(60)" 33 | INITIAL "" 34 | LABEL "Note" 35 | POSITION 5 36 | MAX-WIDTH 120 37 | ORDER 40 38 | 39 | ADD FIELD "SeqNr" OF "Invoice-Note" AS integer 40 | FORMAT "->,>>>,>>9" 41 | INITIAL "0" 42 | LABEL "Seq #" 43 | POSITION 6 44 | MAX-WIDTH 4 45 | ORDER 50 46 | 47 | ADD INDEX "pr_u" ON "Invoice-Note" 48 | AREA "Info Area" 49 | PRIMARY 50 | INDEX-FIELD "Invoice-Num" ASCENDING 51 | INDEX-FIELD "SeqNr" ASCENDING 52 | 53 | . 54 | PSC 55 | cpstream=ISO8859-1 56 | . 57 | 0000001092 58 | -------------------------------------------------------------------------------- /Examples/testDynCall.js: -------------------------------------------------------------------------------- 1 | /** 2 | * New node file 3 | */ 4 | var conf = require("./config/config.json"); 5 | var node4progress = require("node4progress")(conf); 6 | 7 | node4progress.setAppsvrProc("Examples/CustomerHandler.p","",false,true); 8 | node4progress.setParameter("InputPars","longchar","input","NumCustomersToPull=5&batchNum=2",""); 9 | node4progress.setParameter("OutputPars","character","output","",""); 10 | node4progress.setParameter("dsCustomer","dataset-handle","output","",""); 11 | node4progress.setParameter("ErrMsg","character","output","",""); 12 | console.log("invoking Appserver Procedure"); 13 | node4progress.appProc().execute(function(err,result){ 14 | console.log("CUSTOMERS RESULT"); 15 | if(err){ 16 | console.log("ERROR->"+err); 17 | }else{ 18 | console.log(result); 19 | result=JSON.parse(result); 20 | console.log("parsed results~n"+result); 21 | } 22 | }); 23 | 24 | node4progress.setAppsvrProc("Examples/OrderHandler.p","",false,true); 25 | node4progress.setParameter("InputPars","longchar","input","NumOrdersToPull=2",""); 26 | node4progress.setParameter("OutputPars","character","output","",""); 27 | node4progress.setParameter("dsOrder","dataset-handle","output","",""); 28 | node4progress.setParameter("ErrMsg","character","output","",""); 29 | console.log("invoking Appserver Procedure"); 30 | node4progress.appProc().execute(function(err,result){ 31 | console.log("ORDERS RESULT"); 32 | if(err){ 33 | console.log("ERROR->"+err); 34 | }else{ 35 | result = result.toString(); 36 | console.log(result); 37 | result=JSON.parse(result); 38 | console.log("parsed results~n"+result); 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /buffer.js: -------------------------------------------------------------------------------- 1 | var BufferField = require('./bufferfield.js'), 2 | debug = require('debug'), 3 | log = debug('n4p:buffer'); 4 | 5 | function Buffer(iTempTable,iMetaSchema,iDateFormat){ 6 | log( "Buffer create", iTempTable ); 7 | this.currentRecord = null; 8 | this.tempTable = iTempTable; 9 | this.metaSchema = iMetaSchema; 10 | this.dateFormat = iDateFormat; 11 | this.bufferField = new BufferField(this.dateFormat); 12 | return this; 13 | } 14 | 15 | Buffer.prototype.setCurrentRecord = function(iCurrentRecord){ 16 | log( "Buffer:setCurrentRecord" ); 17 | 18 | this.currentRecord=iCurrentRecord; 19 | }; 20 | 21 | Buffer.prototype.$ = function(fieldNm){ 22 | log( "Buffer:$", fieldNm ); 23 | 24 | var value = ""; 25 | var fieldMetaSchema = null; 26 | for(var prop in this.currentRecord){ 27 | if(prop.toLowerCase() == fieldNm.toLowerCase()){ 28 | value=this.currentRecord[prop]; 29 | fieldMetaSchema=this.metaSchema[prop]; 30 | this.bufferField.setCurrenBufferField(prop,this.currentRecord,fieldMetaSchema); 31 | break; 32 | } 33 | } 34 | return this.bufferField; 35 | }; 36 | 37 | Buffer.prototype.display = function(iFieldToDisplay){ 38 | log( "Buffer:display", iFieldToDisplay ); 39 | var fields = iFieldToDisplay.split(" "); 40 | var fieldStr = ""; 41 | for(var i=0;i0){fieldStr+=" ";} 43 | fieldStr+=this.$(fields[i]).$("screenValue"); 44 | } 45 | return fieldStr; 46 | }; 47 | Buffer.prototype.writeJson = function(){ 48 | var jsonStr=""; 49 | if(this.currentRecord){ 50 | jsonStr=JSON.stringify(this.currentRecord); 51 | } 52 | return jsonStr; 53 | }; 54 | 55 | module.exports = function(iTempTable,iMetaSchema,iDateFormat) { 56 | return new Buffer(iTempTable,iMetaSchema,iDateFormat); 57 | }; -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdTt.i: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Include 4 | /*------------------------------------------------------------------------ 5 | File : Examples/CustUpd.i 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE Customer. 22 | 23 | /* _UIB-CODE-BLOCK-END */ 24 | &ANALYZE-RESUME 25 | 26 | 27 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 28 | 29 | /* ******************** Preprocessor Definitions ******************** */ 30 | 31 | 32 | 33 | /* _UIB-PREPROCESSOR-BLOCK-END */ 34 | &ANALYZE-RESUME 35 | 36 | 37 | 38 | /* *********************** Procedure Settings ************************ */ 39 | 40 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 41 | /* Settings for THIS-PROCEDURE 42 | Type: Include 43 | Allow: 44 | Frames: 0 45 | Add Fields to: Neither 46 | Other Settings: INCLUDE-ONLY 47 | */ 48 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 49 | 50 | /* ************************* Create Window ************************** */ 51 | 52 | &ANALYZE-SUSPEND _CREATE-WINDOW 53 | /* DESIGN Window definition (used by the UIB) 54 | CREATE WINDOW Include ASSIGN 55 | HEIGHT = 15 56 | WIDTH = 60. 57 | /* END WINDOW DEFINITION */ 58 | */ 59 | &ANALYZE-RESUME 60 | 61 | 62 | 63 | 64 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Include 65 | 66 | 67 | /* *************************** Main Block *************************** */ 68 | 69 | /* _UIB-CODE-BLOCK-END */ 70 | &ANALYZE-RESUME 71 | 72 | 73 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdDs.i: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Include 4 | /*------------------------------------------------------------------------ 5 | File : Examples/CustUpd.i 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE Customer. 22 | DEFINE DATASET dsCustomer FOR ttCustomer. 23 | 24 | /* _UIB-CODE-BLOCK-END */ 25 | &ANALYZE-RESUME 26 | 27 | 28 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 29 | 30 | /* ******************** Preprocessor Definitions ******************** */ 31 | 32 | 33 | 34 | /* _UIB-PREPROCESSOR-BLOCK-END */ 35 | &ANALYZE-RESUME 36 | 37 | 38 | 39 | /* *********************** Procedure Settings ************************ */ 40 | 41 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 42 | /* Settings for THIS-PROCEDURE 43 | Type: Include 44 | Allow: 45 | Frames: 0 46 | Add Fields to: Neither 47 | Other Settings: INCLUDE-ONLY 48 | */ 49 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 50 | 51 | /* ************************* Create Window ************************** */ 52 | 53 | &ANALYZE-SUSPEND _CREATE-WINDOW 54 | /* DESIGN Window definition (used by the UIB) 55 | CREATE WINDOW Include ASSIGN 56 | HEIGHT = 15 57 | WIDTH = 60. 58 | /* END WINDOW DEFINITION */ 59 | */ 60 | &ANALYZE-RESUME 61 | 62 | 63 | 64 | 65 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Include 66 | 67 | 68 | /* *************************** Main Block *************************** */ 69 | 70 | /* _UIB-CODE-BLOCK-END */ 71 | &ANALYZE-RESUME 72 | 73 | 74 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdDs-SchemaProvider.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : examples/CustUpd-TemplateHandler.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | {Examples/CustUpdDs.i} 21 | 22 | DEFINE OUTPUT PARAMETER DATASET FOR dsCustomer. 23 | 24 | /* _UIB-CODE-BLOCK-END */ 25 | &ANALYZE-RESUME 26 | 27 | 28 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 29 | 30 | /* ******************** Preprocessor Definitions ******************** */ 31 | 32 | &Scoped-define PROCEDURE-TYPE Procedure 33 | &Scoped-define DB-AWARE no 34 | 35 | 36 | 37 | /* _UIB-PREPROCESSOR-BLOCK-END */ 38 | &ANALYZE-RESUME 39 | 40 | 41 | 42 | /* *********************** Procedure Settings ************************ */ 43 | 44 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 45 | /* Settings for THIS-PROCEDURE 46 | Type: Procedure 47 | Allow: 48 | Frames: 0 49 | Add Fields to: Neither 50 | Other Settings: CODE-ONLY COMPILE 51 | */ 52 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 53 | 54 | /* ************************* Create Window ************************** */ 55 | 56 | &ANALYZE-SUSPEND _CREATE-WINDOW 57 | /* DESIGN Window definition (used by the UIB) 58 | CREATE WINDOW Procedure ASSIGN 59 | HEIGHT = 15 60 | WIDTH = 60. 61 | /* END WINDOW DEFINITION */ 62 | */ 63 | &ANALYZE-RESUME 64 | 65 | 66 | 67 | 68 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 69 | 70 | 71 | /* *************************** Main Block *************************** */ 72 | 73 | /* _UIB-CODE-BLOCK-END */ 74 | &ANALYZE-RESUME 75 | 76 | 77 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdTt-SchemaProvider.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : examples/CustUpd-SchemaProvider.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | {Examples/CustUpdTt.i} 21 | 22 | DEFINE OUTPUT PARAMETER TABLE FOR ttCustomer. 23 | 24 | /* _UIB-CODE-BLOCK-END */ 25 | &ANALYZE-RESUME 26 | 27 | 28 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 29 | 30 | /* ******************** Preprocessor Definitions ******************** */ 31 | 32 | &Scoped-define PROCEDURE-TYPE Procedure 33 | &Scoped-define DB-AWARE no 34 | 35 | 36 | 37 | /* _UIB-PREPROCESSOR-BLOCK-END */ 38 | &ANALYZE-RESUME 39 | 40 | 41 | 42 | /* *********************** Procedure Settings ************************ */ 43 | 44 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 45 | /* Settings for THIS-PROCEDURE 46 | Type: Procedure 47 | Allow: 48 | Frames: 0 49 | Add Fields to: Neither 50 | Other Settings: CODE-ONLY COMPILE 51 | */ 52 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 53 | 54 | /* ************************* Create Window ************************** */ 55 | 56 | &ANALYZE-SUSPEND _CREATE-WINDOW 57 | /* DESIGN Window definition (used by the UIB) 58 | CREATE WINDOW Procedure ASSIGN 59 | HEIGHT = 15 60 | WIDTH = 60. 61 | /* END WINDOW DEFINITION */ 62 | */ 63 | &ANALYZE-RESUME 64 | 65 | 66 | 67 | 68 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 69 | 70 | 71 | /* *************************** Main Block *************************** */ 72 | 73 | /* _UIB-CODE-BLOCK-END */ 74 | &ANALYZE-RESUME 75 | 76 | 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .c9revisions/ 2 | .c9/ 3 | node_modules/ 4 | build/ 5 | development/ 6 | config.json 7 | 8 | ################# 9 | ## Eclipse 10 | ################# 11 | *.pydevproject 12 | .project 13 | .metadata 14 | bin/ 15 | tmp/ 16 | *.tmp 17 | *.bak 18 | *.swp 19 | *~.nib 20 | local.properties 21 | .classpath 22 | .settings/ 23 | .loadpath 24 | 25 | # External tool builders 26 | .externalToolBuilders/ 27 | 28 | # Locally stored "Eclipse launch configurations" 29 | *.launch 30 | 31 | # CDT-specific 32 | .cproject 33 | 34 | # PDT-specific 35 | .buildpath 36 | 37 | 38 | ################# 39 | ## Visual Studio 40 | ################# 41 | 42 | ## Ignore Visual Studio temporary files, build results, and 43 | ## files generated by popular Visual Studio add-ons. 44 | 45 | # User-specific files 46 | *.suo 47 | *.user 48 | *.sln.docstates 49 | 50 | Build results 51 | [Dd]ebug/ 52 | [Rr]elease/ 53 | *_i.c 54 | *_p.c 55 | *.ilk 56 | *.meta 57 | *.obj 58 | *.pch 59 | *.pdb 60 | *.pgc 61 | *.pgd 62 | *.rsp 63 | *.sbr 64 | *.tlb 65 | *.tli 66 | *.tlh 67 | *.tmp 68 | *.vspscc 69 | .builds 70 | *.dotCover 71 | 72 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 73 | #packages/ 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opensdf 80 | *.sdf 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | 86 | # ReSharper is a .NET coding add-in 87 | _ReSharper* 88 | 89 | # Installshield output folder 90 | [Ee]xpress 91 | 92 | # DocProject is a documentation generator add-in 93 | DocProject/buildhelp/ 94 | DocProject/Help/*.HxT 95 | DocProject/Help/*.HxC 96 | DocProject/Help/*.hhc 97 | DocProject/Help/*.hhk 98 | DocProject/Help/*.hhp 99 | DocProject/Help/Html2 100 | DocProject/Help/html 101 | 102 | # Click-Once directory 103 | publish 104 | 105 | # Others 106 | [Bb]in 107 | [Oo]bj 108 | sql 109 | TestResults 110 | *.Cache 111 | ClientBin 112 | stylecop.* 113 | ~$* 114 | *.dbmdl 115 | Generated_Code #added for RIA/Silverlight projects 116 | 117 | # Backup & report files from converting an old project file to a newer 118 | # Visual Studio version. Backup files are not needed, because we have git ;-) 119 | _UpgradeReport_Files/ 120 | Backup*/ 121 | UpgradeLog*.XML 122 | 123 | 124 | 125 | ############ 126 | ## Windows 127 | ############ 128 | 129 | # Windows image file caches 130 | Thumbs.db 131 | 132 | # Folder config file 133 | Desktop.ini 134 | 135 | 136 | ############# 137 | ## Python 138 | ############# 139 | 140 | *.py[co] 141 | 142 | # Packages 143 | *.egg 144 | *.egg-info 145 | dist 146 | build 147 | eggs 148 | parts 149 | bin 150 | var 151 | sdist 152 | develop-eggs 153 | .installed.cfg 154 | 155 | # Installer logs 156 | pip-log.txt 157 | 158 | # Unit test / coverage reports 159 | .coverage 160 | .tox 161 | 162 | #Translations 163 | *.mo 164 | 165 | #Mr Developer 166 | .mr.developer.cfg 167 | 168 | # Mac crap 169 | .DS_Store 170 | 171 | -------------------------------------------------------------------------------- /Examples/testRecurse.js: -------------------------------------------------------------------------------- 1 | /** 2 | * New node file 3 | */ 4 | /** 5 | * New node file 6 | */ 7 | var conf = require("./config/config.json"); 8 | var sleep = require('sleep'); 9 | var node4progress = require("node4progress")(conf); 10 | 11 | node4progress.setAppsvrProc("Examples/FatalRecurse.p","",false,true); 12 | node4progress.setParameter("InputPars","integer","output","",""); 13 | console.log("invoking Appserver Procedure"); 14 | node4progress.appProc().execute(function(err,result){ 15 | console.log("FatalRecurse RESULT"); 16 | if(err){ 17 | console.log("ERROR->"+err); 18 | }else{ 19 | console.log(result); 20 | } 21 | sleep.sleep(10); 22 | node4progress.setAppsvrProc("handlers/OrderHandler.p","",false,true); 23 | node4progress.setParameter("InputPars","longchar","input","NumOrdersToPull=2",""); 24 | node4progress.setParameter("OutputPars","character","output","",""); 25 | node4progress.setParameter("dsOrder","dataset-handle","output","",""); 26 | node4progress.setParameter("ErrMsg","character","output","",""); 27 | console.log("invoking Appserver Procedure"); 28 | node4progress.appProc().execute(function(err,result){ 29 | console.log("ORDERS RESULT"); 30 | if(err){ 31 | console.log("ERROR->"+err); 32 | }else{ 33 | try{ 34 | result = result.toString(); 35 | console.log("result->ORDERS->"+result); 36 | //result=JSON.parse(result); 37 | //console.log("parsed results~n"+result); 38 | }catch(err){ 39 | 40 | } 41 | } 42 | sleep.sleep(10); 43 | node4progress.setAppsvrProc("handlers/CustomerHandler.p","",false,true); 44 | node4progress.setParameter("InputPars","longchar","input","NumCustomersToPull=5&batchNum=2",""); 45 | node4progress.setParameter("OutputPars","character","output","",""); 46 | node4progress.setParameter("dsCustomer","dataset-handle","output","",""); 47 | node4progress.setParameter("ErrMsg","character","output","",""); 48 | console.log("invoking Appserver Procedure"); 49 | node4progress.appProc().execute(function(err,result){ 50 | console.log("CUSTOMERS RESULT"); 51 | if(err){ 52 | console.log("ERROR->"+err); 53 | }else{ 54 | try{ 55 | console.log("CUSTOMERS->"+result); 56 | result=JSON.parse(result); 57 | console.log("parsed results~n"+result); 58 | sleep.sleep(10); 59 | }catch(err){ 60 | 61 | } 62 | node4progress.setAppsvrProc("handlers/OrderHandler.p","",false,true); 63 | node4progress.setParameter("InputPars","longchar","input","NumOrdersToPull=2",""); 64 | node4progress.setParameter("OutputPars","character","output","",""); 65 | node4progress.setParameter("dsOrder","dataset-handle","output","",""); 66 | node4progress.setParameter("ErrMsg","character","output","",""); 67 | console.log("invoking Appserver Procedure"); 68 | node4progress.appProc().execute(function(err,result){ 69 | result = result.toString(); 70 | console.log("result->ORDERS->"+result); 71 | }); 72 | 73 | } 74 | }); 75 | 76 | }); 77 | 78 | }); 79 | 80 | 81 | -------------------------------------------------------------------------------- /Examples/testDatasetInvoice.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : testDatasetInvoice.js 3 | * Description : Get dataset with a dynamic call, loop through the data 4 | * fields 5 | * Methods used : 6 | * node4progress.setAppsvrProc -> Define appserver procedure to call 7 | * node4progress.setParameter -> Define parameter for appserver procedure to call 8 | * node4progress.invoke -> invoke appserver procedure to call 9 | * node4progress.getDataset -> Get dataset object from the appserver output, make changes to the data 10 | * and display the data 11 | * TempTable.forEach -> Loop through records in a temp-table 12 | * buffer.display(...) -> Return a string with fields formatted in accordance with bufferfield.format 13 | */ 14 | 15 | // Load configuration file 16 | var conf = require("./config/config.json"); 17 | // Instantiate node4progress 18 | var node4progress = require("node4progress")(conf); 19 | // Define appserver procedure to call 20 | node4progress.setAppsvrProc("Examples/invoiceHandler.p","",false,true); 21 | // Define parameters 22 | node4progress.setParameter("InputPars","longchar","input","NumInvoicesToPull=5",""); 23 | node4progress.setParameter("OutputPars","character","output","",""); 24 | node4progress.setParameter("dsInvoice","dataset-handle","output","",""); 25 | node4progress.setParameter("ErrMsg","character","output","",""); 26 | console.log("invoking Appserver Procedure"); 27 | // Invoke appserver procedures 28 | node4progress.invoke(function(err,result){ 29 | var dataset = null; 30 | var line = ""; 31 | if(err){ 32 | console.log("ERROR->"+err); 33 | }else{ 34 | //console.log(result); 35 | var jsonObj=JSON.parse(result); 36 | try{ 37 | dataset = node4progress.getDataset("dsInvoice",jsonObj); 38 | }catch(err){ 39 | console.log(err); 40 | } 41 | var ttInvoice = dataset.$("ttInvoice"); 42 | var ttInvoiceNote = dataset.$("ttInvoice-Note"); 43 | // 1 1 53 08/02/93 27/09/14 12:26:34.894 pm 27/09/2014 12:26:34.894 pm -07:00 Invoive created 44 | var hdr = "Inv # Ord # Cust# Inv Dt Event date/time Event date/time TZ Note\n" + 45 | "===== ===== ===== ========= ======================== ================================= ================"; 46 | console.log(hdr); 47 | //Loop throiugh the data 48 | ttInvoice.forEach(function(invBuf){ 49 | ttInvoiceNote.forEach(function(invNoteBuf){ 50 | invNoteBuf.$("Note").setAttr("format","x(20)"); 51 | invNoteBuf.$("EventDtTm").setAttr("format","99/99/99 HH:MM:SS.SSS AM"); 52 | invNoteBuf.$("EventDtTm-TZ").setAttr("format","99/99/9999 HH:MM:SS.SSS AM +HH:MM"); 53 | if(invNoteBuf.$("Invoice-num").$('value')===invBuf.$("Invoice-num").$("value")){ 54 | line=invBuf.display("Invoice-num Order-num cust-num Invoice-date"); 55 | line+=" "+invNoteBuf.display("EventDtTm EventDtTm-TZ Note"); 56 | console.log(line); 57 | } 58 | }); 59 | }); 60 | } 61 | }); 62 | -------------------------------------------------------------------------------- /4GlCode/Examples/FatalRecurse.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : FatalRecurse.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE OUTPUT PARAMETER oRecurseTotal AS INTEGER NO-UNDO. 22 | 23 | /* _UIB-CODE-BLOCK-END */ 24 | &ANALYZE-RESUME 25 | 26 | 27 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 28 | 29 | /* ******************** Preprocessor Definitions ******************** */ 30 | 31 | &Scoped-define PROCEDURE-TYPE Procedure 32 | &Scoped-define DB-AWARE no 33 | 34 | 35 | 36 | /* _UIB-PREPROCESSOR-BLOCK-END */ 37 | &ANALYZE-RESUME 38 | 39 | 40 | 41 | /* *********************** Procedure Settings ************************ */ 42 | 43 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 44 | /* Settings for THIS-PROCEDURE 45 | Type: Procedure 46 | Allow: 47 | Frames: 0 48 | Add Fields to: Neither 49 | Other Settings: CODE-ONLY COMPILE 50 | */ 51 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 52 | 53 | /* ************************* Create Window ************************** */ 54 | 55 | &ANALYZE-SUSPEND _CREATE-WINDOW 56 | /* DESIGN Window definition (used by the UIB) 57 | CREATE WINDOW Procedure ASSIGN 58 | HEIGHT = 15 59 | WIDTH = 60. 60 | /* END WINDOW DEFINITION */ 61 | */ 62 | &ANALYZE-RESUME 63 | 64 | 65 | 66 | 67 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 68 | 69 | 70 | /* *************************** Main Block *************************** */ 71 | 72 | ASSIGN oRecurseTotal = 1. 73 | RUN Recurse (INPUT-OUTPUT oRecurseTotal). 74 | 75 | /* _UIB-CODE-BLOCK-END */ 76 | &ANALYZE-RESUME 77 | 78 | 79 | /* ********************** Internal Procedures *********************** */ 80 | 81 | &IF DEFINED(EXCLUDE-Recurse) = 0 &THEN 82 | 83 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE Recurse Procedure 84 | PROCEDURE Recurse : 85 | /*------------------------------------------------------------------------------ 86 | Purpose: 87 | Parameters: 88 | Notes: 89 | ------------------------------------------------------------------------------*/ 90 | DEFINE INPUT-OUTPUT PARAMETER oRecurseTotal AS INTEGER NO-UNDO. 91 | RUN Recurse (INPUT-OUTPUT oRecurseTotal). 92 | END PROCEDURE. 93 | 94 | /* _UIB-CODE-BLOCK-END */ 95 | &ANALYZE-RESUME 96 | 97 | &ENDIF 98 | 99 | -------------------------------------------------------------------------------- /Examples/testDatasetCustomer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : testDatasetCustomer.js 3 | * Description : Get dataset with a dynamic call, loop through the data 4 | * fields 5 | * Methods used : 6 | * node4progress.callHandler -> Execute handler procedure 7 | * node4progress.getDataset -> Get dataset object from the appserver output, make changes to the data 8 | * and display the data 9 | * TempTable.forEach -> Loop through records in a temp-table 10 | * buffer.display(...) -> Return a string with fields formatted in accordance with bufferfield.format 11 | * bufferField.setAttr -> Set format field of a bufferField 12 | * 13 | */ 14 | 15 | //Load the configuration file 16 | var conf = require("./config/config.json"); 17 | //Instantiate node4progress 18 | var node4progress = require("node4progress")(conf); 19 | //Define appserver procedure to call 20 | node4progress.setAppsvrProc("Examples/CustomerHandler.p","",false,true); 21 | //Define the appserver parameters 22 | node4progress.setParameter("InputPars","longchar","input","NumCustomersToPull=10&batchNum=1",""); 23 | node4progress.setParameter("OutputPars","character","output","",""); 24 | node4progress.setParameter("dsCustomer","dataset-handle","output","",""); 25 | node4progress.setParameter("ErrMsg","character","output","",""); 26 | //Invoke the appserver procedure with the callback procedure 27 | console.log("invoking Appserver Procedure"); 28 | node4progress.invoke(function(err,result){ 29 | var dataset = null; 30 | var modName = ""; 31 | if(err){ 32 | console.log("ERROR->"+err); 33 | }else{ 34 | //console.log(result); 35 | var jsonObj=JSON.parse(result); 36 | try{ 37 | //get the dataset object from the appserver output 38 | dataset = node4progress.getDataset("dsCustomer",jsonObj); 39 | }catch(err){ 40 | console.log(err); 41 | } 42 | var ttCustomer = dataset.$("ttCustomer"); 43 | //Uopdate the ttCutsomer.name value by appending "->modified to it 44 | ttCustomer.forEach(function(buffer){ 45 | var line = buffer.$("cust-num").$("label") + ":" + buffer.$("cust-num").$("value") + "\n" + buffer.$("name").$("label") + ":" + buffer.$("name").$("value"); 46 | buffer.$("name").bufferValue(buffer.$("name").$("value") + "->Modified"); 47 | }); 48 | 49 | //000001 Lift Line Skiing 3->Modified Boston MA 42,568.01 50 | var header="Cust# Name City ST Balance\n"+ 51 | "====== ======================================== ============ ============ ===================== "; 52 | console.log(header); 53 | //Display the modified values 54 | ttCustomer.forEach(function(buffer){ 55 | //Set the format of the name field to 40 characters "x(40)" 56 | buffer.$("name").setAttr("format","x(40)"); 57 | buffer.$("cust-num").setAttr("format","999999"); 58 | var line=buffer.display("cust-num name city state balance"); 59 | console.log(line); 60 | }); 61 | } 62 | }); 63 | -------------------------------------------------------------------------------- /Examples/testCallHandler.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : testCallHandler.js 3 | * Description : Call 2 handler procedures on the appserver, loop through the temp-tables returned and display some 4 | * fields 5 | * Methods used : 6 | * node4progress.callHandler -> Execute handler procedure 7 | * node4progress.getDataset -> Get dataset object from the appserver output 8 | * TempTable.forEach -> Loop through records in a temp-table 9 | * buffer.display(...) -> Return a string with fields formatted in accordance with bufferfield.format 10 | * 11 | */ 12 | //Load the configuration file 13 | var conf = require("./config/config.json"); 14 | // Instantiate node4progress 15 | var node4progress = require("node4progress")(conf); 16 | //Define handler to call 17 | var handler="Examples/CustomerHandler.p"; 18 | // Define Input parameters for handler 19 | var inputPars = 'NumCustomersToPull=5'; 20 | //Invoke the handler 21 | node4progress.callHandler(handler,inputPars,true,function(err,result){ 22 | console.log("CUSTOMER HANDLER RESULT"); 23 | // Get dataset from appserver output 24 | var dataset = node4progress.getDataset("dsCustomer",result); 25 | var ttCustomer = dataset.$("ttCustomer"); 26 | var header = "Cust # Customer name City ST Credit Limit\n"+ 27 | "====== ======================================== ============ == ============="; 28 | //" 1 Lift Line Skiing 3 Boston MA 42,568.01" 29 | console.log(header); 30 | //Loop through customer records and display some fields 31 | ttCustomer.forEach(function(buffer){ 32 | buffer.$("name").setAttr("format","x(40)"); 33 | var line=buffer.display("cust-num name city state balance"); 34 | console.log(line); 35 | }); 36 | console.log("\n\n"); 37 | }); 38 | 39 | //Second handler to call Examples/OrderHandler.p 40 | handler="Examples/OrderHandler.p"; 41 | //Define input parameters for the 2nd handler 42 | inputPars = 'NumOrdersToPull=5'; 43 | 44 | node4progress.callHandler(handler,inputPars,true,function(err,result){ 45 | var dataset; 46 | try{ 47 | //Get dataset from appserver output 48 | dataset = node4progress.getDataset("dsOrder",result); 49 | }catch(err){ 50 | console.log(err); 51 | } 52 | 53 | // Get ttOrder and ttOrderLine handle 54 | var ttOrder = dataset.$("ttOrder"); 55 | var ttOrderline = dataset.$("ttOrderLine"); 56 | var header = "Cust# Order Order Dt Prom Dt Line Item# Amount\n" + 57 | "===== ===== ======== ======= ==== ===== =========="; 58 | console.log(header); 59 | // Loop though ttOrder records and link to ttOrderLine records 60 | ttOrder.forEach(function(buffer){ 61 | var orderNum=buffer.$("order-num").$("value"); 62 | var line=buffer.display("cust-num order-num order-date promise-date"); 63 | var line2=""; 64 | ttOrderline.forEach(function(buffer){ 65 | if(buffer.$("order-num").$("value")==orderNum){ 66 | line2=buffer.display("line-num item-num Extended-Price"); 67 | console.log(line + line2); 68 | } 69 | 70 | }); 71 | }); 72 | 73 | }); 74 | -------------------------------------------------------------------------------- /dataset.js: -------------------------------------------------------------------------------- 1 | var TempTable = require('./temptable.js'), 2 | debug = require('debug'), 3 | log = debug('n4p:dataset'); 4 | 5 | 6 | function Dataset(iDatasetNm,iJsonObj,iDateFormat) { 7 | //log( "ds create" ); 8 | this.dateFormat = iDateFormat; 9 | this.dataset = null; 10 | this.metaSchema = null; 11 | this.name = ""; 12 | this.rootName = ""; 13 | this.tempTables = {}; 14 | this.getDataset(iDatasetNm,iJsonObj); 15 | if( this.name === "" ){ 16 | throw new Error( "Dataset " + iDatasetNm + " not found" ); 17 | } 18 | } 19 | 20 | Dataset.prototype.$ = function(ttName){ 21 | log( "ds:$", ttName ); 22 | var targetTable = null; 23 | //var datasetContents = this.dataset[this.name]; 24 | var datasetContents=null; 25 | for(var prop in this.dataset){ 26 | datasetContents=this.dataset[prop]; 27 | break; 28 | } 29 | var ttNm = ""; 30 | for(var tt in datasetContents){ 31 | if(tt.toString().toLowerCase() == ttName.toLowerCase()){ 32 | targetTable = datasetContents[tt]; 33 | ttNm=tt; 34 | break; 35 | } 36 | } 37 | if(! this.tempTables[ttNm]){ 38 | this.tempTables[ttNm]=new TempTable(this,ttNm,targetTable,this.metaSchema[ttNm],this.dateFormat); 39 | } 40 | return this.tempTables[ttNm]; 41 | }; 42 | 43 | Dataset.prototype.copyDataset = function(empty){ 44 | log( "ds:copyDataset" ); 45 | 46 | var copyDatasetJsonObj = {}, 47 | copyDataset; 48 | 49 | copyDatasetJsonObj[ this.rootName ] = JSON.parse( this.writeJson() ); 50 | copyDatasetJsonObj[ this.rootName ][ this.name + "MetaSchema" ] = JSON.parse( JSON.stringify( this.metaSchema ) ); 51 | 52 | copyDataset = new Dataset( this.name, copyDatasetJsonObj,this.dateFormat ); 53 | 54 | if(empty){ 55 | copyDataset.emptyDataset(); 56 | } 57 | 58 | return copyDataset; 59 | }; 60 | 61 | Dataset.prototype.emptyDataset = function(){ 62 | log( "ds:emptyDataset" ); 63 | for(var prop in this.dataset[this.rootName]){ 64 | this.$(prop).emptyTempTable(); 65 | } 66 | 67 | /* 68 | this.dataset[this.rootName].forEach( function( item, prop ) { 69 | this.$( prop ).emptyTemptable(); 70 | }, this ); 71 | */ 72 | }; 73 | 74 | Dataset.prototype.getDataset = function(iDatasetNm,iJsonObj){ 75 | log( "ds:getDataset", iDatasetNm ); 76 | 77 | var prop, 78 | prop2; 79 | 80 | for(prop in iJsonObj){ 81 | 82 | if( iJsonObj[ prop ][ iDatasetNm ] && iJsonObj[ prop ][ iDatasetNm + "MetaSchema" ] ) { 83 | this.dataset = iJsonObj[ prop ]; 84 | this.metaSchema = iJsonObj[ prop ][ iDatasetNm + "MetaSchema" ]; 85 | this.name = prop.toString(); 86 | for(prop2 in this.dataset){ 87 | this.rootName = prop2; 88 | break; 89 | } 90 | break; 91 | } 92 | 93 | if( typeof iJsonObj[ prop ] == "object" ){ 94 | this.getDataset( iDatasetNm, iJsonObj[ prop ] ); 95 | } 96 | } 97 | }; 98 | 99 | Dataset.prototype.writeJson = function(){ 100 | log( "ds:writeJson" ); 101 | 102 | var writeJson = "", 103 | jsonObj = {}; 104 | 105 | if( this.dataset ){ 106 | jsonObj[ this.rootName ] = this.dataset[ this.rootName ]; 107 | writeJson = JSON.stringify( jsonObj ); 108 | } 109 | return writeJson; 110 | }; 111 | 112 | module.exports = function( name, obj,dateFormat ) { 113 | return new Dataset( name, obj, dateFormat ); 114 | }; -------------------------------------------------------------------------------- /Examples/testDatasetOrder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : testDatasetOrder.js 3 | * Description : Get Order/Orderline dataset with a dynamic call, loop through the data 4 | * fields 5 | * Methods used : 6 | * node4progress.setAppsvrProc -> Define appserver procedure to call 7 | * node4progress.setParameter -> Define parameter for appserver procedure to call 8 | * node4progress.invoke -> invoke appserver procedure to call 9 | * node4progress.getDataset -> Get dataset object from the appserver output, make changes to the data 10 | * and display the data 11 | * TempTable.forEach -> Loop through records in a temp-table 12 | * buffer.display(...) -> Return a string with fields formatted in accordance with bufferfield.format 13 | * bufferField.setAttr -> Set format field of a bufferField 14 | * 15 | */ 16 | 17 | //Load the configuration file 18 | var conf = require("./config/config.json"); 19 | //Instantiate node4progress 20 | var node4progress = require("node4progress")(conf); 21 | //Define appserver procedure to call 22 | node4progress.setAppsvrProc("Examples/OrderHandler.p","",false,true); 23 | //Define parameters for appserver procedure to call 24 | node4progress.setParameter("InputPars","longchar","input","NumOrdersToPull=20",""); 25 | node4progress.setParameter("OutputPars","character","output","",""); 26 | node4progress.setParameter("dsOrder","dataset-handle","output","",""); 27 | node4progress.setParameter("ErrMsg","character","output","",""); 28 | console.log("invoking Appserver Procedure"); 29 | //Invoke the appserver procedure with callback procedure 30 | node4progress.invoke(function(err,result){ 31 | var dataset = null; 32 | var cnt=1; 33 | var mnth=1; 34 | //console.log("result->"+result); 35 | if(err){ 36 | console.log("ERROR->"+err); 37 | }else{ 38 | try{ 39 | //Extract dataset object from the appserver output 40 | dataset = node4progress.getDataset("dsOrder",result); 41 | }catch(err){ 42 | console.log(err); 43 | } 44 | //get ttOrder temp-table from dataset 45 | var ttOrder = dataset.$("ttOrder"); 46 | //get ttOrderline from dataset 47 | var ttOrderline = dataset.$("ttOrderLine"); 48 | //Update the ttOrder.order-date field 49 | ttOrder.forEach(function(buffer){ 50 | var dt = buffer.$("order-date").$("buffer-value"); 51 | var line = "Cust-num->"+buffer.$("Cust-num").$("value") + "->"+buffer.$("Order-num").$("value")+"->"+ 52 | buffer.$("Order-date").$("value"); 53 | ++cnt; 54 | ++mnth; 55 | var dt=new Date(2014,mnth,cnt); 56 | buffer.$("Order-date").bufferValue(dt); 57 | //console.log(line); 58 | }); 59 | // 53 1 02/03/14 03/02/93 1 1 00054 131.22 60 | var hdr = "Cust# Ord# Order Dt Prom. Dt Ord# Ln# item# Amount\n"+ 61 | "===== ===== ======== ======== ==== === ======= ========"; 62 | console.log(hdr); 63 | //Show the data in the ttOrder and the ttOrderLine table joining them 64 | ttOrder.forEach(function(buffer){ 65 | var orderNum=buffer.$("order-num").$("value"); 66 | var line=buffer.display("cust-num order-num order-date promise-date"); 67 | var line2=""; 68 | //Find the ttOrderLine records for the ttOrder table 69 | ttOrderline.forEach(function(buffer){ 70 | if(buffer.$("order-num").$("value")==orderNum){ 71 | line2=buffer.display("order-num line-num item-num Extended-Price"); 72 | console.log(line + line2); 73 | } 74 | 75 | }); 76 | }); 77 | } 78 | }); 79 | 80 | -------------------------------------------------------------------------------- /Examples/custAddTt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custAddTt.js 3 | * Purpose : Show how to use the temp-table object to add new records to the customer table in the sports database 4 | * Methods used : 5 | * node4progress.getEmptyTempTable(..) -> fetches an empty dataset from the appserver 6 | * tempTable.bufferCreate() -> creates new record in the temp-table 7 | * buffer.$("..") -> Passes a reference to a buffer field 8 | * bufferField.bufferValue(....) -> Set the bufferValue of a buffer-field 9 | * node4progress.setAppsvrProc -> define appserver procdure to execute 10 | * node4progress.setParameter -> define parameter for appserver procedure to execute 11 | * node4progress.invoke -> invoke the appserver procedure 12 | */ 13 | var conf = require("./config/config.json"); 14 | var node4progress = require("node4progress")(conf); 15 | 16 | node4progress.getEmptyTempTable("ttCustomer","Examples/CustUpdTt-SchemaProvider.p",function(err,ttCustomer){ 17 | var ttCustBuf=null; 18 | if(err){ 19 | console.log("ERROR->"+err); 20 | }else{ 21 | //Define the parameters for the new customer 22 | var custName = "Fred Node4Progres"; 23 | var custAddr = "757 Node4progress drive"; 24 | var custCity = "Miami"; 25 | var custState = "FL"; 26 | var postalCode = "33102"; 27 | var custPhone = "777-777-7777"; 28 | var creditLimit = 11000; 29 | //Create new record in temp-table ttCustomer 30 | ttCustBuf=ttCustomer.bufferCreate(); 31 | //Assign buffer values 32 | ttCustBuf.$("cust-num").bufferValue(-1); 33 | ttCustBuf.$("name").bufferValue(custName); 34 | ttCustBuf.$("Address").bufferValue(custAddr); 35 | ttCustBuf.$("City").bufferValue(custCity); 36 | ttCustBuf.$("State").bufferValue(custState); 37 | ttCustBuf.$("Postal-Code").bufferValue(postalCode); 38 | ttCustBuf.$("Phone").bufferValue(custPhone); 39 | ttCustBuf.$("Credit-Limit").bufferValue(creditLimit); 40 | //Define appserver procedure to call 41 | node4progress.setAppsvrProc("Examples/CustUpdTt.p","",false,true); 42 | //Define parameters for appserver procedure to call 43 | node4progress.setParameter("Imode","character","input","ADD",""); 44 | node4progress.setParameter("iInputParameters","character","input","",""); 45 | node4progress.setParameter("ttCustomer","table-handle","input-output",ttCustomer.writeJson(),"Examples/CustUpdTt-SchemaProvider.p"); 46 | node4progress.setParameter("oOutputPars","character","output","",""); 47 | node4progress.setParameter("ErrMsg","character","output","",""); 48 | 49 | console.log("invoking Appserver Procedure"); 50 | //Invoke appsrever procedure with call back procedure 51 | node4progress.invoke(function(err,result){ 52 | //console.log("result->"+result); 53 | jsonObj=JSON.parse(result); 54 | console.log("Customer Add Result->"+ 55 | "\n ->oOutputPars->"+jsonObj.output.oOutputPars+ 56 | "\n ->ErrMsg->"+jsonObj.output.ErrMsg); 57 | var ttCustomer = node4progress.getTempTable("ttCustomer",result); 58 | var ttCustBuf = ttCustomer.findFirst(); 59 | var displayMsg = ""; 60 | 61 | displayMsg = "New customer added\n" + 62 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 63 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 64 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 65 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 66 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 67 | console.log(displayMsg); 68 | 69 | }); 70 | } 71 | }); 72 | -------------------------------------------------------------------------------- /Examples/custAddDs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custAddDs.js 3 | * Purpose : Show how to use the dataset object to add new records to the customer table in the sports database 4 | * Methods used : 5 | * node4progress.getEmptyDataset(..) -> fetches an empty dataset from the appserver 6 | * dataset.$("..") -> passes handle to a temp-table 7 | * tempTable.bufferCreate() -> creates new record in the temp-table 8 | * buffer.$("..") -> Passes a reference to a buffer field 9 | * bufferField.bufferValue(....) -> Set the bufferValue of a buffer-field 10 | * node4progress.setAppsvrProc -> define appserver procdure to execute 11 | * node4progress.setParameter -> define parameter for appserver procedure to execute 12 | * node4progress.invoke -> invoke the appserver procedure 13 | */ 14 | 15 | var conf = require("./config/config.json"); 16 | var node4progress = require("node4progress")(conf); 17 | 18 | node4progress.getEmptyDataset("dsCustomer","Examples/CustUpdDs-SchemaProvider.p",function(err,dsCustomer){ 19 | var ttCustomer=null; 20 | var ttCustBuf=null; 21 | if(err){ 22 | console.log("ERROR->"+err); 23 | }else{ 24 | //Define the parameters for the new customer 25 | var custName = "John Doe"; 26 | var custAddr = "757 Kendall drive"; 27 | var custCity = "Miami"; 28 | var custState = "FL"; 29 | var postalCode = "33102"; 30 | var custPhone = "777-777-7777"; 31 | var creditLimit = 10000; 32 | //Get a instance of customer Temp-tabke object 33 | ttCustomer=dsCustomer.$("ttCustomer"); 34 | //Create new record in the ttCustomer temp-table and get a instance of the customer buffer object 35 | ttCustBuf=ttCustomer.bufferCreate(); 36 | //Populate the newly created record 37 | ttCustBuf.$("cust-num").bufferValue(-1); 38 | ttCustBuf.$("name").bufferValue(custName); 39 | ttCustBuf.$("Address").bufferValue(custAddr); 40 | ttCustBuf.$("City").bufferValue(custCity); 41 | ttCustBuf.$("State").bufferValue(custState); 42 | ttCustBuf.$("Postal-Code").bufferValue(postalCode); 43 | ttCustBuf.$("Phone").bufferValue(custPhone); 44 | ttCustBuf.$("Credit-Limit").bufferValue(creditLimit); 45 | //Define appserver procedure to call 46 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 47 | //Define parameters for appserver procedure 48 | node4progress.setParameter("Imode","character","input","ADD",""); 49 | node4progress.setParameter("iInputParameters","character","input","",""); 50 | node4progress.setParameter("dsOrder","dataset-handle","input-output",dsCustomer.writeJson(),"Examples/CustUpdDs-SchemaProvider.p"); 51 | node4progress.setParameter("oOutputPars","character","output","",""); 52 | node4progress.setParameter("ErrMsg","character","output","",""); 53 | //Invoke appserver procedure 54 | console.log("invoking Appserver Procedure CustUpdDs.p"); 55 | node4progress.invoke(function(err,result){ 56 | jsonObj=JSON.parse(result); 57 | console.log("Customer Add Result->"+ 58 | "\n ->oOutputPars->"+jsonObj.output.oOutputPars+ 59 | "\n ->ErrMsg->"+jsonObj.output.ErrMsg); 60 | var dsCust = node4progress.getDataset("dsCustomer",result); 61 | var ttCustomer = dsCust.$("ttCustomer"); 62 | var ttCustBuf = ttCustomer.findFirst(); 63 | var displayMsg = ""; 64 | 65 | displayMsg = "New customer added\n" + 66 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 67 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 68 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 69 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 70 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 71 | console.log(displayMsg); 72 | }); 73 | } 74 | }); 75 | -------------------------------------------------------------------------------- /4GlCode/BaseCode/NodeJsDispatch.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : NodeJsDispatch.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : Frank Hilhorst 13 | Created : 10/9/2013 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE INPUT PARAMETER iHandler AS CHARACTER NO-UNDO. 22 | DEFINE INPUT PARAMETER iInputPars AS LONGCHAR NO-UNDO. 23 | DEFINE INPUT PARAMETER iIncludeMetaSchema AS LOGICAL NO-UNDO. 24 | DEFINE OUTPUT PARAMETER oOutputPars AS LONGCHAR NO-UNDO. 25 | DEFINE OUTPUT PARAMETER oDatasetJson AS LONGCHAR NO-UNDO. 26 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 27 | 28 | DEFINE VARIABLE vInputPars AS CHARACTER NO-UNDO. 29 | DEFINE VARIABLE vDatasetHandle AS HANDLE NO-UNDO. 30 | DEFINE VARIABLE vhnodeJsMetaSchema AS HANDLE NO-UNDO. 31 | 32 | /* _UIB-CODE-BLOCK-END */ 33 | &ANALYZE-RESUME 34 | 35 | 36 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 37 | 38 | /* ******************** Preprocessor Definitions ******************** */ 39 | 40 | &Scoped-define PROCEDURE-TYPE Procedure 41 | &Scoped-define DB-AWARE no 42 | 43 | 44 | 45 | /* _UIB-PREPROCESSOR-BLOCK-END */ 46 | &ANALYZE-RESUME 47 | 48 | 49 | 50 | /* *********************** Procedure Settings ************************ */ 51 | 52 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 53 | /* Settings for THIS-PROCEDURE 54 | Type: Procedure 55 | Allow: 56 | Frames: 0 57 | Add Fields to: Neither 58 | Other Settings: CODE-ONLY COMPILE 59 | */ 60 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 61 | 62 | /* ************************* Create Window ************************** */ 63 | 64 | &ANALYZE-SUSPEND _CREATE-WINDOW 65 | /* DESIGN Window definition (used by the UIB) 66 | CREATE WINDOW Procedure ASSIGN 67 | HEIGHT = 15 68 | WIDTH = 60. 69 | /* END WINDOW DEFINITION */ 70 | */ 71 | &ANALYZE-RESUME 72 | 73 | 74 | 75 | 76 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 77 | 78 | 79 | /* *************************** Main Block *************************** */ 80 | 81 | DO ON ERROR UNDO, LEAVE: 82 | RUN nodeJsMetaSchema.p PERSISTENT SET vhNodeJsMetaSchema. 83 | 84 | RUN VALUE(iHandler) ( 85 | INPUT iInputPars, 86 | OUTPUT oOutputPars, 87 | OUTPUT DATASET-HANDLE vDatasetHandle, 88 | OUTPUT oErrMsg). 89 | IF VALID-HANDLE(vDatasetHandle) THEN 90 | DO: 91 | /* MESSAGE " iIncludeMetaSchema" iIncludeMetaSchema SKIP */ 92 | /* VIEW-AS ALERT-BOX INFO BUTTONS OK. */ 93 | /*vDatasetHandle:WRITE-JSON("LONGCHAR",oDatasetJson,TRUE).*/ 94 | ASSIGN oDatasetJson = DYNAMIC-FUNCTION("getDatasetOutputJson" IN vhNodeJsMetaSchema , 95 | vDatasetHandle:NAME, 96 | vDatasetHandle, 97 | iIncludeMetaSchema). 98 | END. 99 | CATCH oneError AS Progress.Lang.SysError: 100 | ASSIGN oErrMsg = oneError:GetMessage(1). 101 | END CATCH. 102 | FINALLY: 103 | END FINALLY. 104 | END. 105 | 106 | /* _UIB-CODE-BLOCK-END */ 107 | &ANALYZE-RESUME 108 | 109 | 110 | -------------------------------------------------------------------------------- /Examples/custDeleteTt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custDeleteTt.js 3 | * Description : Fetch a number of records from the customer table in the sports, find the last record in the set, 4 | * copy it over into an empty dataset, send dataset with that customer record back to appserver to be 5 | * deleted 6 | * Methods used : 7 | * node4progress.setAppsvrProc -> define appserver procdure to execute 8 | * node4progress.setParameter -> define parameter for appserver procedure to execute 9 | * node4progress.invoke -> invoke the appserver procedure 10 | * node4progress.getTempTable -> get a temp-table from the appserver output pulled from the appserver 11 | * TempTable.copyTempTabl -> create copy of a temp-table (optionnally an empty copy) 12 | * TempTable.findLast -> Find last record in temp-table 13 | * -> return reference to buffer for that record 14 | * TempTable.findFirst -> Find first record in temp-table 15 | * -> return reference to buffer for that record 16 | * tempTable.bufferCreate() -> creates new record in the temp-table 17 | * tempTable.bufferCopy() -> Copies values from a json document into a temp-table 18 | * tempTable.bufferDelete() -> Deletes record from a temp-table 19 | */ 20 | // Load configuration file 21 | var conf = require("./config/config.json"); 22 | // Instantiate node4progress 23 | var node4progress = require("node4progress")(conf); 24 | // Define appserver procedure to call 25 | node4progress.setAppsvrProc("Examples/CustUpdTt.p","",false,true); 26 | // Define parameters for appserver procedure to call 27 | node4progress.setParameter("Imode","character","input","GetCustomer",""); 28 | node4progress.setParameter("iInputParameters","character","input","mode=FromTo|cust-num-from=1000|cust-num-to=9999",""); 29 | node4progress.setParameter("ttCustomer","table-handle","input-output","","Examples/CustUpdTt-SchemaProvider.p"); 30 | node4progress.setParameter("oOutputPars","character","output","",""); 31 | node4progress.setParameter("ErrMsg","character","output","",""); 32 | // Invoke Appserver procedure 33 | node4progress.invoke(function(err,result){ 34 | // Extract temp-table from appserver output 35 | var ttCustomer = node4progress.getTempTable("ttCustomer",result); 36 | 37 | //Create empty copy of the temp-table 38 | var ttCustomerCopy=ttCustomer.copyTempTable(true); //If passed true then temp-table will be empty, otherwise data is copied as well 39 | 40 | // find last record in temp-table 41 | var buffer = ttCustomer.findLast(); 42 | 43 | // Delete record from source temp-table 44 | var deletedRecord=ttCustomer.bufferDelete(); 45 | 46 | //copy record to destination temp-table 47 | ttCustomerCopy.bufferCreate(); 48 | ttCustomerCopy.bufferCopy(deletedRecord); 49 | //console.log("ttCustomerCopy.writeJson()->"+ttCustomerCopy.writeJson()); 50 | // Define appserver procedure to call 51 | node4progress.setAppsvrProc("Examples/CustUpdTt.p","",false,true); 52 | // Define parameters for appserver procedure 53 | node4progress.setParameter("Imode","character","input","Delete",""); 54 | node4progress.setParameter("iInputParameters","character","input","",""); 55 | node4progress.setParameter("ttCustomer","table-handle","input-output",ttCustomerCopy.writeJson(),"Examples/CustUpdTt-SchemaProvider.p"); 56 | node4progress.setParameter("oOutputPars","character","output","",""); 57 | node4progress.setParameter("ErrMsg","character","output","",""); 58 | // Invoke appserver procedure 59 | node4progress.invoke(function(err,result){ 60 | jsonObj=JSON.parse(result); 61 | console.log("Customer Delete Result->"+ 62 | "\n ->oOutputPars->"+jsonObj.output.oOutputPars+ 63 | "\n ->ErrMsg->"+jsonObj.output.ErrMsg); 64 | if(!err){ 65 | var buffer=ttCustomerCopy.findLast(); 66 | displayMsg = "Customer deleted\n" + 67 | "Cust-num : " + buffer.$("cust-num").$("screenValue") + "\n" + 68 | "Name : " + buffer.$("name").$("screenValue") + "\n" + 69 | "Address : " + buffer.$("Address").$("screenValue") + "\n" + 70 | "City : " + buffer.$("City").$("screenValue") + "\n" + 71 | "Country : " + buffer.$("Country").$("screenValue") + "\n"; 72 | console.log(displayMsg); 73 | } 74 | }); 75 | 76 | 77 | }); 78 | -------------------------------------------------------------------------------- /Examples/custDeleteDs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custDeleteDs.js 3 | * Description : Fetch a number of records from the customer table in the sports, find the last record in the set, 4 | * copy it over into an empty dataset, send dataset with that customer record back to appserver to be 5 | * deleted 6 | * Methods used : 7 | * node4progress.setAppsvrProc -> define appserver procdure to execute 8 | * node4progress.setParameter -> define parameter for appserver procedure to execute 9 | * node4progress.invoke -> invoke the appserver procedure 10 | * node4progress.getDataset -> get a dataset from the appserver output pulled from the appserver 11 | * dataset.copyDataset -> create copy of a dataset (optionnally an empty copy) 12 | * TempTable.findLast -> Find last record in temp-table 13 | * -> return reference to buffer for that record 14 | * TempTable.findFirst -> Find first record in temp-table 15 | * -> return reference to buffer for that record 16 | * tempTable.bufferCreate() -> creates new record in the temp-table 17 | * tempTable.bufferCopy() -> Copies values from a json document into a temp-table 18 | * tempTable.bufferDelete() -> Deletes record from a temp-table 19 | */ 20 | 21 | // Load configuration values 22 | var conf = require("./config/config.json"); 23 | // Instantiate node4progress 24 | var node4progress = require("node4progress")(conf); 25 | // Define appserver procedure to call 26 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 27 | // Define parameters for appserver procedure to call 28 | node4progress.setParameter("Imode","character","input","GetCustomer",""); 29 | node4progress.setParameter("iInputParameters","character","input","mode=FromTo|cust-num-from=1000|cust-num-to=9999",""); 30 | node4progress.setParameter("dsCustomer","dataset-handle","input-output","","Examples/CustUpdDs-SchemaProvider.p"); 31 | node4progress.setParameter("oOutputPars","character","output","",""); 32 | node4progress.setParameter("ErrMsg","character","output","",""); 33 | //Invoke the appserver procedure 34 | node4progress.invoke(function(err,result){ 35 | 36 | //Extract dataset from appserver output 37 | var dsCustomer = node4progress.getDataset("dsCustomer",result); 38 | // Get an empty copy of the dataset 39 | var dsCustomerCopy=dsCustomer.copyDataset(true); //true parameter indicates to create an empty dataset 40 | 41 | //Find last record in the customer temp-table 42 | var buffer=dsCustomer.$("ttCustomer").findLast(); 43 | 44 | //Delete record from temp-table 45 | var deletedRecord=dsCustomer.$("ttCustomer").bufferDelete(); 46 | 47 | //Copy record over to the new dataset 48 | dsCustomerCopy.$("ttCustomer").bufferCreate(); 49 | dsCustomerCopy.$("ttCustomer").bufferCopy(deletedRecord); 50 | 51 | //Define appserver procedure to call 52 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 53 | //Define appserver parameters 54 | node4progress.setParameter("Imode","character","input","Delete",""); 55 | node4progress.setParameter("iInputParameters","character","input","",""); 56 | node4progress.setParameter("dsCustomer","dataset-handle","input-output",dsCustomerCopy.writeJson(),"Examples/CustUpdDs-SchemaProvider.p"); 57 | node4progress.setParameter("oOutputPars","character","output","",""); 58 | node4progress.setParameter("ErrMsg","character","output","",""); 59 | //Invoke appserver procedure with the callback procedure 60 | node4progress.invoke(function(err,result){ 61 | //console.log(result); 62 | jsonObj=JSON.parse(result); 63 | console.log("Customer Add Result->"+ 64 | "\n oOutputPars : "+jsonObj.output.oOutputPars+ 65 | "\n ErrMsg : "+jsonObj.output.ErrMsg); 66 | var ttCustBuf = dsCustomerCopy.$("ttCustomer").findFirst(); 67 | displayMsg = "Customer deleted\n" + 68 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 69 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 70 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 71 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 72 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 73 | console.log(displayMsg); 74 | }); 75 | 76 | 77 | }); 78 | -------------------------------------------------------------------------------- /Examples/custUpdTt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custUpdTt.js 3 | * Description : Fetch a number of records from the customer table in the sports, find the last record in the set, 4 | * Update this record, copy it over into an empty temp-table, sent copytemp-table to appserver to 5 | * update the customer 6 | * Methods used : 7 | * node4progress.setAppsvrProc -> define appserver procdure to execute 8 | * node4progress.setParameter -> define parameter for appserver procedure to execute 9 | * node4progress.invoke -> invoke the appserver procedure 10 | * node4progress.getTempTable -> get a dataset from the appserver output pulled from the appserver 11 | * TempTable.findLast -> Find last record in temp-table 12 | * -> return reference to buffer for that record 13 | * dataset.copyDataset(..) -> Create a copy of a dataset 14 | * Temp-table.bufferCreate() -> create record in temp-table 15 | * Temp-table.bufferCopy() -> create record in temp-table 16 | */ 17 | var conf = require("./config/config.json"); 18 | // Instantiate node4progress 19 | var node4progress = require("node4progress")(conf); 20 | // Define appserver procedure to call 21 | node4progress.setAppsvrProc("Examples/CustUpdTt.p","",false,true); 22 | // Define appserver procedure parameters 23 | node4progress.setParameter("Imode","character","input","GetCustomer",""); 24 | node4progress.setParameter("iInputParameters","character","input","mode=FromTo|cust-num-from=1000|cust-num-to=9999",""); 25 | node4progress.setParameter("dsCustomer","table-handle","input-output","","Examples/CustUpdTt-SchemaProvider.p"); 26 | node4progress.setParameter("oOutputPars","character","output","",""); 27 | node4progress.setParameter("ErrMsg","character","output","",""); 28 | // Invoke appserver procedure 29 | node4progress.invoke(function(err,result){ 30 | var newName = "John Doe the 3rd"; 31 | var newAddress = "1567 Leisure Lane"; 32 | var newCity = "Port Saint Lucie"; 33 | var newState = "FL"; 34 | var newCountry = "USA"; 35 | // Get temp-table from appserver output 36 | var ttCustomer = node4progress.getTempTable("ttCustomer",result); 37 | // Get last record in temp-table 38 | var ttCustBuf = ttCustomer.findLast(); 39 | 40 | var displayMsg = ""; 41 | displayMsg = "Pre-update values\n" + 42 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 43 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 44 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 45 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 46 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 47 | 48 | console.log(displayMsg); 49 | // Populate buffer with new values 50 | ttCustBuf.$("name").bufferValue(newName); 51 | ttCustBuf.$("Address").bufferValue(newAddress); 52 | ttCustBuf.$("City").bufferValue(newCity); 53 | ttCustBuf.$("Country").bufferValue(newCountry); 54 | ttCustBuf.$("State").bufferValue(newState); 55 | 56 | displayMsg = "Post-uodate values\n" + 57 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 58 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 59 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 60 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 61 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 62 | 63 | console.log(displayMsg); 64 | // Create empty copy of temp-table 65 | var ttCustomerCopy=ttCustomer.copyTempTable(true); 66 | //Copy updated values into copy of temp-table 67 | ttCustomerCopy.bufferCreate(); 68 | ttCustomerCopy.bufferCopy(ttCustBuf.writeJson()); 69 | // Define appserver procedure to call 70 | node4progress.setAppsvrProc("Examples/CustUpdTt.p","",false,true); 71 | // Define appserver procedure parameters 72 | node4progress.setParameter("Imode","character","input","UPDATE",""); 73 | node4progress.setParameter("iInputParameters","character","input","",""); 74 | node4progress.setParameter("dsCustomer","table-handle","input-output",ttCustomerCopy.writeJson(),"Examples/CustUpdTt-SchemaProvider.p"); 75 | node4progress.setParameter("oOutputPars","character","output","",""); 76 | node4progress.setParameter("ErrMsg","character","output","",""); 77 | // Invoke the appserver procedure 78 | node4progress.invoke(function(err,result){ 79 | jsonObj=JSON.parse(result); 80 | console.log("Customer update Result->"+ 81 | "\n ->oOutputPars->"+jsonObj.output.oOutputPars+ 82 | "\n ->ErrMsg->"+jsonObj.output.ErrMsg); 83 | }); 84 | }); 85 | 86 | -------------------------------------------------------------------------------- /Examples/custUpdDs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * File-name : custUpdDs.js 3 | * Description : Fetch a number of records from the customer table in the sports, find the last record in the set, 4 | * Update this record, copy it over into an empty dataset, sent copy dataset to appserver to 5 | * update the customer 6 | * Methods used : 7 | * node4progress.setAppsvrProc -> define appserver procdure to execute 8 | * node4progress.setParameter -> define parameter for appserver procedure to execute 9 | * node4progress.invoke -> invoke the appserver procedure 10 | * node4progress.geDataset -> get a dataset from the appserver output pulled from the appserver 11 | * TempTable.findLast -> Find last record in temp-table 12 | * -> return reference to buffer for that record 13 | * dataset.copyDataset(..) -> Create a copy of a dataset 14 | * Temp-table.bufferCreate() -> create record in temp-table 15 | * Temp-table.bufferCopy() -> create record in temp-table 16 | */ 17 | var conf = require("./config/config.json"); 18 | // instantiate node4progress 19 | var node4progress = require("node4progress")(conf); 20 | // Define appserver procedure to call 21 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 22 | // Define appserver parameters 23 | node4progress.setParameter("Imode","character","input","GetCustomer",""); 24 | node4progress.setParameter("iInputParameters","character","input","mode=FromTo|cust-num-from=1000|cust-num-to=9999",""); 25 | node4progress.setParameter("dsCustomer","dataset-handle","input-output","","Examples/CustUpdDs-SchemaProvider.p"); 26 | node4progress.setParameter("oOutputPars","character","output","",""); 27 | node4progress.setParameter("ErrMsg","character","output","",""); 28 | // Invoke appserver procedure 29 | node4progress.invoke(function(err,result){ 30 | var newName = "John Doe the 2nd"; 31 | var newAddress = "1567 Leisure Lane"; 32 | var newCity = "Port Saint Lucie"; 33 | var newState = "FL"; 34 | var newCountry = "USA"; 35 | 36 | // Get dataset from appserver output 37 | var dsCust = node4progress.getDataset("dsCustomer",result); 38 | var ttCustomer = dsCust.$("ttCustomer"); 39 | // Get last record in customer temp-table 40 | var ttCustBuf = ttCustomer.findLast(); 41 | var displayMsg = ""; 42 | 43 | displayMsg = "Pre-uodate values\n" + 44 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 45 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 46 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 47 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 48 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 49 | 50 | console.log(displayMsg); 51 | 52 | // update buffer values 53 | ttCustBuf.$("name").bufferValue(newName); 54 | ttCustBuf.$("Address").bufferValue(newAddress); 55 | ttCustBuf.$("City").bufferValue(newCity); 56 | ttCustBuf.$("Country").bufferValue(newCountry); 57 | ttCustBuf.$("State").bufferValue(newState); 58 | 59 | displayMsg = "Post-uodate values\n" + 60 | "Cust-num : " + ttCustBuf.$("cust-num").$("screenValue") + "\n" + 61 | "Name : " + ttCustBuf.$("name").$("screenValue") + "\n" + 62 | "Address : " + ttCustBuf.$("Address").$("screenValue") + "\n" + 63 | "City : " + ttCustBuf.$("City").$("screenValue") + "\n" + 64 | "Country : " + ttCustBuf.$("Country").$("screenValue") + "\n"; 65 | 66 | console.log(displayMsg); 67 | //Create an empty copy of the dataset 68 | var dsCustomerCopy=dsCust.copyDataset(true); //true creates an empty copy, false creates a populated copy 69 | //Copy updated values into copy dataset 70 | dsCustomerCopy.$("ttCustomer").bufferCreate(); 71 | dsCustomerCopy.$("ttCustomer").bufferCopy(ttCustBuf.writeJson()); 72 | // Define appserver procedure to call 73 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 74 | // Define appserver procedure to call 75 | node4progress.setParameter("Imode","character","input","UPDATE",""); 76 | // Define appserver parameters 77 | node4progress.setParameter("iInputParameters","character","input","",""); 78 | node4progress.setParameter("dsCustomer","dataset-handle","input-output",dsCustomerCopy.writeJson(),"Examples/CustUpdDs-SchemaProvider.p"); 79 | node4progress.setParameter("oOutputPars","character","output","",""); 80 | node4progress.setParameter("ErrMsg","character","output","",""); 81 | // Invoke the appserver procedure 82 | node4progress.invoke(function(err,result){ 83 | if(err){ 84 | console.log(err); 85 | }else{ 86 | jsonObj=JSON.parse(result); 87 | console.log("Customer Update Result->"+ 88 | "\n ->oOutputPars->"+jsonObj.output.oOutputPars+ 89 | "\n ->ErrMsg->"+jsonObj.output.ErrMsg); 90 | } 91 | }); 92 | }); 93 | 94 | -------------------------------------------------------------------------------- /temptable.js: -------------------------------------------------------------------------------- 1 | 2 | var Buffer = require('./buffer.js'), 3 | debug = require('debug'), 4 | log = debug('n4p:temptable'); 5 | 6 | function TempTable( iDataset, iName, ttRecordArray, iMetaSchema,iDateFormat ){ 7 | log( "tt create", iName ); 8 | this.dateFormat=iDateFormat; 9 | this.dataset=null; 10 | if(iDataset){ 11 | this.dataset=iDataset.dataset; 12 | } 13 | this.records=ttRecordArray; 14 | this.name=iName; 15 | this.metaSchema=iMetaSchema; 16 | 17 | this.currentRecord={}; 18 | this.currentRecordIndex=-1; 19 | this.buffer = new Buffer( this, this.metaSchema,this.dateFormat); 20 | return this; 21 | } 22 | 23 | TempTable.prototype.available = function() { 24 | log( "tt:available" ); 25 | return (this.currentRecordIndex>=0); 26 | }; 27 | 28 | TempTable.prototype.bufferCreate = function(){ 29 | log( "tt:bufferCreate" ); 30 | 31 | var newRecord = {}, 32 | fieldDefs = null, 33 | value = ""; 34 | 35 | for(var prop in this.metaSchema){ 36 | fieldDefs=this.metaSchema[prop]; 37 | value=this.initial(fieldDefs.dataType,fieldDefs.initial); 38 | newRecord[prop]=value; 39 | } 40 | 41 | this.records.push(newRecord); 42 | this.currentRecordIndex=this.records.length-1; 43 | this.buffer.setCurrentRecord(this.records[this.records.length-1]); 44 | return this.buffer; 45 | }; 46 | 47 | TempTable.prototype.bufferCopy = function(iRecordJson){ 48 | log( "tt:bufferCopy" ); 49 | 50 | if(this.currentRecordIndex >=0){ 51 | if(typeof iRecordJson === "string"){ 52 | iRecordJson=JSON.parse(iRecordJson); 53 | } 54 | if(iRecordJson instanceof Buffer){ 55 | var jsonObj=iRecordJson.writeJson(); 56 | jsonObj=JSON.parse(jsonObj); 57 | this.bufferCopy(jsonObj); 58 | }else if(typeof iRecordJson === "object"){ 59 | for(var prop in iRecordJson){ 60 | if(this.buffer.$(prop)){ 61 | this.buffer.$(prop).bufferValue(iRecordJson[prop]); 62 | } 63 | } 64 | } 65 | }else{ 66 | throw new Error("No record selected to bufferCopy to"); 67 | } 68 | }; 69 | 70 | TempTable.prototype.bufferDelete = function(){ 71 | log( "tt:bufferDelete" ); 72 | 73 | var deletedRecordJson=null; 74 | if(this.currentRecordIndex>=0){ 75 | deletedRecordJson=this.records.splice(this.currentRecordIndex); 76 | } 77 | if(this.records.length === 0){ 78 | this.currentRecordIndex=-1; 79 | }else if(this.currentRecordIndex> this.records.length-1){ 80 | this.records.length=this.records.length-1; 81 | } 82 | if(deletedRecordJson[0]){ 83 | return deletedRecordJson[0]; 84 | }else{ 85 | return null; 86 | } 87 | }; 88 | 89 | TempTable.prototype.copyTempTable = function(empty){ 90 | log( "tt:copyTempTable" ); 91 | 92 | var copyTempTableJsonObj = {}; 93 | copyTempTableJsonObj[this.name] = this.records; 94 | copyTempTableJsonObj.metaSchema = this.metaSchema; 95 | var copyTempTableStr = JSON.stringify(copyTempTableJsonObj); 96 | copyTempTableJsonObj = JSON.parse(copyTempTableStr); 97 | var copyTempTable = new TempTable(null,this.name,copyTempTableJsonObj[this.name],copyTempTableJsonObj.metaSchema,this.dateFormat); 98 | if(empty === true){ 99 | copyTempTable.emptyTempTable(); 100 | } 101 | return copyTempTable; 102 | }; 103 | 104 | TempTable.prototype.emptyTempTable = function(){ 105 | log( "tt:emptyTempTable" ); 106 | if(this.records){ 107 | while(this.records.length>0){ 108 | this.records.splice(0); 109 | } 110 | } 111 | this.currentRecordIndex=-1; 112 | /* 113 | this.records = []; 114 | */ 115 | }; 116 | 117 | TempTable.prototype.forEach = function(callback){ 118 | log( "tt:forEach" ); 119 | 120 | this.records.forEach( function(item, i ) { 121 | this.currentRecordIndex = i; 122 | this.buffer.setCurrentRecord( item ); 123 | callback( this.buffer ); 124 | }, this ); 125 | }; 126 | 127 | TempTable.prototype.findFirst = function(){ 128 | log( "tt:findFirst" ); 129 | 130 | if(this.records.length>0){ 131 | this.currentRecordIndex=0; 132 | this.buffer.setCurrentRecord(this.records[0]); 133 | }else{ 134 | this.currentRecordIndex=-1; 135 | } 136 | return this.buffer; 137 | }; 138 | 139 | TempTable.prototype.findLast = function(){ 140 | log( "tt:findLast" ); 141 | 142 | if(this.records.length>0){ 143 | this.currentRecordIndex=this.records.length-1; 144 | this.buffer.setCurrentRecord(this.records[this.records.length-1]); 145 | }else { 146 | this.currentRecordIndex=-1; 147 | } 148 | return this.buffer; 149 | }; 150 | 151 | TempTable.prototype.initial = function(iDataType,iValue){ 152 | log( "tt:initial" ); 153 | 154 | var value=null; 155 | if(iDataType.toLowerCase()==="integer"||iDataType.toLowerCase()==="decimal"){ 156 | value=Number(iValue.replace(",","")); 157 | }else if(iDataType.toLowerCase()==="date"){ 158 | if(iValue==="today"){ 159 | value = moment().format( "YYYY-MM-DD" ); 160 | }else{ 161 | value = moment( iValue ).format( "YYYY-MM-DD" ); 162 | } 163 | }else{ 164 | value=iValue.toString(); 165 | } 166 | return value; 167 | }; 168 | 169 | TempTable.prototype.writeJson = function(){ 170 | log( "tt:writeJson" ); 171 | 172 | var obj = {}; 173 | 174 | obj[ this.name ] = this.records; 175 | 176 | return JSON.stringify( obj ); 177 | }; 178 | 179 | TempTable.prototype.jsonObjectEmpty = function(jsonObj){ 180 | log( "tt:jsonObjectEmpty" ); 181 | 182 | var i = 0; 183 | jsonObjectEmpty=true; 184 | if(jsonObj !== null){ 185 | for(var prop in jsonObj) 186 | ++i; 187 | if(i > 0) 188 | jsonObjectEmpty=false; 189 | } 190 | return jsonObjectEmpty; 191 | }; 192 | 193 | module.exports = function( iDataset,iName,ttRecordArray,iMetaSchema,iDateFormat ) { 194 | return new TempTable( iDataset,iName,ttRecordArray,iMetaSchema,iDateFormat ); 195 | } -------------------------------------------------------------------------------- /4GlCode/Examples/invoiceHandler.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : InvoiceHandler.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE TEMP-TABLE ttInvoice NO-UNDO LIKE Invoice. 22 | DEFINE TEMP-TABLE ttInvoice-Note NO-UNDO LIKE Invoice-Note. 23 | 24 | DEFINE DATASET dsInvoice FOR ttInvoice, ttInvoice-Note 25 | DATA-RELATION drInvoice FOR ttInvoice, ttInvoice-Note NESTED 26 | RELATION-FIELDS(Invoice-num,Invoice-num). 27 | 28 | DEFINE INPUT PARAMETER iInputPars AS LONGCHAR NO-UNDO. 29 | DEFINE OUTPUT PARAMETER oOutputPars AS LONGCHAR NO-UNDO. 30 | DEFINE OUTPUT PARAMETER DATASET FOR dsInvoice. 31 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 32 | 33 | /* _UIB-CODE-BLOCK-END */ 34 | &ANALYZE-RESUME 35 | 36 | 37 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 38 | 39 | /* ******************** Preprocessor Definitions ******************** */ 40 | 41 | &Scoped-define PROCEDURE-TYPE Procedure 42 | &Scoped-define DB-AWARE no 43 | 44 | 45 | 46 | /* _UIB-PREPROCESSOR-BLOCK-END */ 47 | &ANALYZE-RESUME 48 | 49 | 50 | /* ************************ Function Prototypes ********************** */ 51 | 52 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 53 | 54 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD GetParVal Procedure 55 | FUNCTION GetParVal RETURNS CHARACTER 56 | ( /* parameter-definitions */ 57 | iParName AS CHAR, 58 | iNameValuePairStr AS LONGCHAR ) FORWARD. 59 | 60 | /* _UIB-CODE-BLOCK-END */ 61 | &ANALYZE-RESUME 62 | 63 | &ENDIF 64 | 65 | 66 | /* *********************** Procedure Settings ************************ */ 67 | 68 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 69 | /* Settings for THIS-PROCEDURE 70 | Type: Procedure 71 | Allow: 72 | Frames: 0 73 | Add Fields to: Neither 74 | Other Settings: CODE-ONLY COMPILE 75 | */ 76 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 77 | 78 | /* ************************* Create Window ************************** */ 79 | 80 | &ANALYZE-SUSPEND _CREATE-WINDOW 81 | /* DESIGN Window definition (used by the UIB) 82 | CREATE WINDOW Procedure ASSIGN 83 | HEIGHT = 15 84 | WIDTH = 60. 85 | /* END WINDOW DEFINITION */ 86 | */ 87 | &ANALYZE-RESUME 88 | 89 | 90 | 91 | 92 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 93 | 94 | 95 | /* *************************** Main Block *************************** */ 96 | 97 | RUN processRequest. 98 | 99 | /* _UIB-CODE-BLOCK-END */ 100 | &ANALYZE-RESUME 101 | 102 | 103 | /* ********************** Internal Procedures *********************** */ 104 | 105 | &IF DEFINED(EXCLUDE-processRequest) = 0 &THEN 106 | 107 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE processRequest Procedure 108 | PROCEDURE processRequest : 109 | /*------------------------------------------------------------------------------ 110 | Purpose: 111 | Parameters: 112 | Notes: 113 | ------------------------------------------------------------------------------*/ 114 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 115 | DEFINE VARIABLE vNumInvoicesToPull AS INTEGER NO-UNDO. 116 | 117 | ASSIGN vNumInvoicesToPull = INT(GetParVal("NumInvoicesToPull",iInputPars)) NO-ERROR. 118 | 119 | FOR EACH Invoice NO-LOCK 120 | BY Invoice.Invoice-num 121 | i = 1 TO vNumInvoicesToPull: 122 | CREATE ttInvoice. 123 | BUFFER-COPY Invoice TO ttInvoice. 124 | FOR EACH Invoice-Note OF Invoice NO-LOCK: 125 | CREATE ttInvoice-Note. 126 | BUFFER-COPY Invoice-Note TO ttInvoice-Note. 127 | END. 128 | END. 129 | 130 | END PROCEDURE. 131 | 132 | /* _UIB-CODE-BLOCK-END */ 133 | &ANALYZE-RESUME 134 | 135 | &ENDIF 136 | 137 | /* ************************ Function Implementations ***************** */ 138 | 139 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 140 | 141 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION GetParVal Procedure 142 | FUNCTION GetParVal RETURNS CHARACTER 143 | ( /* parameter-definitions */ 144 | iParName AS CHAR, 145 | iNameValuePairStr AS LONGCHAR ) : 146 | /*------------------------------------------------------------------------------ 147 | Purpose: 148 | Notes: 149 | ------------------------------------------------------------------------------*/ 150 | DEFINE VARIABLE vParVal AS CHARACTER NO-UNDO. 151 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 152 | DEFINE VARIABLE j AS INTEGER NO-UNDO. 153 | DEFINE VARIABLE vEntry AS CHARACTER NO-UNDO. 154 | DO i = 1 TO NUM-ENTRIES(iParName): 155 | ASSIGN vEntry = ENTRY(i,iNameValuePairStr ) 156 | j = INDEX(vEntry,"="). 157 | IF j > 0 AND TRIM(SUBSTR(vEntry,1,j - 1)) EQ iParName THEN 158 | DO: 159 | ASSIGN vParVal = TRIM(SUBSTR(vEntry,j + 1)). 160 | LEAVE. 161 | END. 162 | 163 | END. 164 | RETURN vParVal. /* Function return value. */ 165 | 166 | END FUNCTION. 167 | 168 | /* _UIB-CODE-BLOCK-END */ 169 | &ANALYZE-RESUME 170 | 171 | &ENDIF 172 | 173 | -------------------------------------------------------------------------------- /4GlCode/Examples/OrderHandler.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : handlers/CustomerHandler.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : Frank Hilhorst 13 | Created : 10/9/2013 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE TEMP-TABLE ttOrder NO-UNDO LIKE Order. 22 | DEFINE TEMP-TABLE ttOrderLine NO-UNDO LIKE Order-line. 23 | 24 | DEFINE DATASET dsOrder FOR ttOrder, ttOrderLine 25 | DATA-RELATION drOrderLine FOR ttOrder, ttOrderLine NESTED 26 | RELATION-FIELDS(order-num,order-num). 27 | 28 | DEFINE INPUT PARAMETER iInputPars AS LONGCHAR NO-UNDO. 29 | DEFINE OUTPUT PARAMETER oOutputPars AS LONGCHAR NO-UNDO. 30 | DEFINE OUTPUT PARAMETER DATASET FOR dsOrder. 31 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 32 | 33 | /* _UIB-CODE-BLOCK-END */ 34 | &ANALYZE-RESUME 35 | 36 | 37 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 38 | 39 | /* ******************** Preprocessor Definitions ******************** */ 40 | 41 | &Scoped-define PROCEDURE-TYPE Procedure 42 | &Scoped-define DB-AWARE no 43 | 44 | 45 | 46 | /* _UIB-PREPROCESSOR-BLOCK-END */ 47 | &ANALYZE-RESUME 48 | 49 | 50 | /* ************************ Function Prototypes ********************** */ 51 | 52 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 53 | 54 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD GetParVal Procedure 55 | FUNCTION GetParVal RETURNS CHARACTER 56 | ( /* parameter-definitions */ 57 | iParName AS CHAR, 58 | iNameValuePairStr AS LONGCHAR ) FORWARD. 59 | 60 | /* _UIB-CODE-BLOCK-END */ 61 | &ANALYZE-RESUME 62 | 63 | &ENDIF 64 | 65 | 66 | /* *********************** Procedure Settings ************************ */ 67 | 68 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 69 | /* Settings for THIS-PROCEDURE 70 | Type: Procedure 71 | Allow: 72 | Frames: 0 73 | Add Fields to: Neither 74 | Other Settings: CODE-ONLY COMPILE 75 | */ 76 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 77 | 78 | /* ************************* Create Window ************************** */ 79 | 80 | &ANALYZE-SUSPEND _CREATE-WINDOW 81 | /* DESIGN Window definition (used by the UIB) 82 | CREATE WINDOW Procedure ASSIGN 83 | HEIGHT = 15 84 | WIDTH = 60. 85 | /* END WINDOW DEFINITION */ 86 | */ 87 | &ANALYZE-RESUME 88 | 89 | 90 | 91 | 92 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 93 | 94 | 95 | /* *************************** Main Block *************************** */ 96 | 97 | RUN processRequest. 98 | 99 | /* _UIB-CODE-BLOCK-END */ 100 | &ANALYZE-RESUME 101 | 102 | 103 | /* ********************** Internal Procedures *********************** */ 104 | 105 | &IF DEFINED(EXCLUDE-processRequest) = 0 &THEN 106 | 107 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE processRequest Procedure 108 | PROCEDURE processRequest : 109 | /*------------------------------------------------------------------------------ 110 | Purpose: 111 | Parameters: 112 | Notes: 113 | ------------------------------------------------------------------------------*/ 114 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 115 | DEFINE VARIABLE vNumOrdersToPull AS INTEGER NO-UNDO. 116 | 117 | ASSIGN vNumOrdersToPull = INT(GetParVal("NumOrdersToPull",iInputPars)) NO-ERROR. 118 | FOR EACH Order NO-LOCK i = 1 TO vNumOrdersToPull: 119 | CREATE ttOrder. 120 | BUFFER-COPY Order TO ttOrder. 121 | FOR EACH Order-line OF Order NO-LOCK: 122 | CREATE ttOrderLine. 123 | BUFFER-COPY Order-line TO ttOrderLine. 124 | END. 125 | END. 126 | ASSIGN oOutputPars = "This is the order/order-line dataset" 127 | oErrMsg = "This is a sample error message" 128 | . 129 | END PROCEDURE. 130 | 131 | /* _UIB-CODE-BLOCK-END */ 132 | &ANALYZE-RESUME 133 | 134 | &ENDIF 135 | 136 | /* ************************ Function Implementations ***************** */ 137 | 138 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 139 | 140 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION GetParVal Procedure 141 | FUNCTION GetParVal RETURNS CHARACTER 142 | ( /* parameter-definitions */ 143 | iParName AS CHAR, 144 | iNameValuePairStr AS LONGCHAR ) : 145 | /*------------------------------------------------------------------------------ 146 | Purpose: 147 | Notes: 148 | ------------------------------------------------------------------------------*/ 149 | DEFINE VARIABLE vParVal AS CHARACTER NO-UNDO. 150 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 151 | DEFINE VARIABLE j AS INTEGER NO-UNDO. 152 | DEFINE VARIABLE vEntry AS CHARACTER NO-UNDO. 153 | DO i = 1 TO NUM-ENTRIES(iParName): 154 | ASSIGN vEntry = ENTRY(i,iNameValuePairStr ) 155 | j = INDEX(vEntry,"="). 156 | IF j > 0 AND TRIM(SUBSTR(vEntry,1,j - 1)) EQ iParName THEN 157 | DO: 158 | ASSIGN vParVal = TRIM(SUBSTR(vEntry,j + 1)). 159 | LEAVE. 160 | END. 161 | 162 | END. 163 | RETURN vParVal. /* Function return value. */ 164 | 165 | END FUNCTION. 166 | 167 | /* _UIB-CODE-BLOCK-END */ 168 | &ANALYZE-RESUME 169 | 170 | &ENDIF 171 | 172 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustomerHandler.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : handlers/CustomerHandler.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : Frank Hilhorst 13 | Created : 10/9/2013 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | DEFINE TEMP-TABLE ttCustomer NO-UNDO LIKE Customer 22 | FIELD record_id AS RECID. 23 | DEFINE DATASET dsCustomer FOR ttCustomer. 24 | 25 | DEFINE INPUT PARAMETER iInputPars AS LONGCHAR NO-UNDO. 26 | DEFINE OUTPUT PARAMETER oOutputPars AS LONGCHAR NO-UNDO. 27 | DEFINE OUTPUT PARAMETER DATASET FOR dsCustomer. 28 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 29 | 30 | /* _UIB-CODE-BLOCK-END */ 31 | &ANALYZE-RESUME 32 | 33 | 34 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 35 | 36 | /* ******************** Preprocessor Definitions ******************** */ 37 | 38 | &Scoped-define PROCEDURE-TYPE Procedure 39 | &Scoped-define DB-AWARE no 40 | 41 | 42 | 43 | /* _UIB-PREPROCESSOR-BLOCK-END */ 44 | &ANALYZE-RESUME 45 | 46 | 47 | /* ************************ Function Prototypes ********************** */ 48 | 49 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 50 | 51 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD GetParVal Procedure 52 | FUNCTION GetParVal RETURNS CHARACTER 53 | ( /* parameter-definitions */ 54 | iParName AS CHAR, 55 | iNameValuePairStr AS LONGCHAR, 56 | iDelimiter AS CHAR ) FORWARD. 57 | 58 | /* _UIB-CODE-BLOCK-END */ 59 | &ANALYZE-RESUME 60 | 61 | &ENDIF 62 | 63 | 64 | /* *********************** Procedure Settings ************************ */ 65 | 66 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 67 | /* Settings for THIS-PROCEDURE 68 | Type: Procedure 69 | Allow: 70 | Frames: 0 71 | Add Fields to: Neither 72 | Other Settings: CODE-ONLY COMPILE 73 | */ 74 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 75 | 76 | /* ************************* Create Window ************************** */ 77 | 78 | &ANALYZE-SUSPEND _CREATE-WINDOW 79 | /* DESIGN Window definition (used by the UIB) 80 | CREATE WINDOW Procedure ASSIGN 81 | HEIGHT = 15 82 | WIDTH = 60. 83 | /* END WINDOW DEFINITION */ 84 | */ 85 | &ANALYZE-RESUME 86 | 87 | 88 | 89 | 90 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 91 | 92 | 93 | /* *************************** Main Block *************************** */ 94 | 95 | RUN processRequest. 96 | 97 | DATASET dsCustomer:WRITE-XML("file","C:/temp/dsCustomer.xml",true). 98 | 99 | ASSIGN oOutputPars = "Message from Frank". 100 | 101 | /* _UIB-CODE-BLOCK-END */ 102 | &ANALYZE-RESUME 103 | 104 | 105 | /* ********************** Internal Procedures *********************** */ 106 | 107 | &IF DEFINED(EXCLUDE-processRequest) = 0 &THEN 108 | 109 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE processRequest Procedure 110 | PROCEDURE processRequest : 111 | /*------------------------------------------------------------------------------ 112 | Purpose: 113 | Parameters: 114 | Notes: 115 | ------------------------------------------------------------------------------*/ 116 | DEFINE VARIABLE vNumCustomersToPull AS INTEGER NO-UNDO. 117 | DEFINE VARIABLE vBatchNum AS INTEGER NO-UNDO. 118 | DEFINE VARIABLE vCnt1 AS INTEGER NO-UNDO. 119 | DEFINE VARIABLE vCnt2 AS INTEGER NO-UNDO. 120 | DEFINE VARIABLE vStartRec AS INTEGER NO-UNDO. 121 | DEFINE VARIABLE vInputPars AS CHARACTER NO-UNDO. 122 | DEFINE VARIABLE vQueryOffEnd AS LOGICAL NO-UNDO. 123 | 124 | MESSAGE "iInputPars" STRING(iInputPars) SKIP 125 | "NumCustomersToPull" GetParVal("NumCustomersToPull",vInputPars,"&") SKIP 126 | VIEW-AS ALERT-BOX INFO BUTTONS OK. 127 | /* ASSIGN vInputPars = STRING(iInputPars) /*SUBSTR(iInputPars,2)*/ */ 128 | /* vNumCustomersToPull = INT(GetParVal("NumCustomersToPull",vInputPars,"&")) */ 129 | /* vBatchNum = INT(GetParVal("batchNum",vInputPars,"&")) */ 130 | /* vStartRec = MAX((vBatchNum - 1) * vNumCustomersToPull + 1,1) */ 131 | /* NO-ERROR. */ 132 | 133 | ASSIGN vNumCustomersToPull = INT(GetParVal("NumCustomersToPull",iInputPars,"&")) 134 | vBatchNum = INT(GetParVal("batchNum",vInputPars,"&")) 135 | vStartRec = MAX((vBatchNum - 1) * vNumCustomersToPull + 1,1) 136 | NO-ERROR. 137 | FOR EACH Customer NO-LOCK BREAK BY Customer.Cust-num: 138 | ASSIGN vCnt1 = vCnt1 + 1. 139 | IF vCnt1 < vStartRec THEN NEXT. 140 | CREATE ttCustomer. 141 | BUFFER-COPY Customer TO ttCustomer 142 | ASSIGN ttCustomer.record_id = RECID(Customer). 143 | ASSIGN vCnt2 = vCnt2 + 1. 144 | IF LAST(Customer.Cust-num) THEN vQueryOffEnd = TRUE. 145 | IF vNumCustomersToPull > 0 AND vCnt2 >= vNumCustomersToPull 146 | THEN LEAVE. 147 | END. 148 | END PROCEDURE. 149 | 150 | /* _UIB-CODE-BLOCK-END */ 151 | &ANALYZE-RESUME 152 | 153 | &ENDIF 154 | 155 | /* ************************ Function Implementations ***************** */ 156 | 157 | &IF DEFINED(EXCLUDE-GetParVal) = 0 &THEN 158 | 159 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION GetParVal Procedure 160 | FUNCTION GetParVal RETURNS CHARACTER 161 | ( /* parameter-definitions */ 162 | iParName AS CHAR, 163 | iNameValuePairStr AS LONGCHAR, 164 | iDelimiter AS CHAR ) : 165 | /*------------------------------------------------------------------------------ 166 | Purpose: 167 | Notes: 168 | ------------------------------------------------------------------------------*/ 169 | DEFINE VARIABLE vParVal AS CHARACTER NO-UNDO. 170 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 171 | DEFINE VARIABLE j AS INTEGER NO-UNDO. 172 | DEFINE VARIABLE vEntry AS CHARACTER NO-UNDO. 173 | DO i = 1 TO NUM-ENTRIES(iNameValuePairStr,iDelimiter): 174 | ASSIGN vEntry = ENTRY(i,iNameValuePairStr,iDelimiter ) 175 | j = INDEX(vEntry,"="). 176 | IF j > 0 AND TRIM(SUBSTR(vEntry,1,j - 1)) EQ iParName THEN 177 | DO: 178 | ASSIGN vParVal = TRIM(SUBSTR(vEntry,j + 1)). 179 | LEAVE. 180 | END. 181 | 182 | END. 183 | RETURN vParVal. /* Function return value. */ 184 | 185 | END FUNCTION. 186 | 187 | /* _UIB-CODE-BLOCK-END */ 188 | &ANALYZE-RESUME 189 | 190 | &ENDIF 191 | 192 | -------------------------------------------------------------------------------- /bufferfield.js: -------------------------------------------------------------------------------- 1 | var moment = require('moment'), 2 | debug = require('debug'), 3 | numeral = require('numeral') 4 | log = debug('n4p:bufferfield'); 5 | 6 | function BufferField(iDateFormat){ 7 | log( "BF create" ); 8 | this.dateFormat = ""; 9 | if(iDateFormat.toLowerCase() === 'dd/mm'){ 10 | this.dateFormat="DD/MM"; 11 | }else{ 12 | this.dateFormat="MM/DD"; 13 | } 14 | this.currentRecord = null; 15 | this.name = ""; 16 | this.value = ""; 17 | this.dataType = ""; 18 | this.initial = ""; 19 | this.format = ""; 20 | this.label = ""; 21 | this.metaSchema = null; 22 | } 23 | 24 | BufferField.prototype.setCurrenBufferField = function( iName, iCurrentRecord, iFieldMetaSchema ){ 25 | log( "BF:setCurrentBufferField", iName ); 26 | 27 | this.name = iName; 28 | this.currentRecord = iCurrentRecord; 29 | this.metaSchema = iFieldMetaSchema; 30 | this.value = this.currentRecord[ this.name ]; 31 | this.dataType = iFieldMetaSchema["dataType"]; 32 | this.format = iFieldMetaSchema["format"]; 33 | this.initial = iFieldMetaSchema["initial"]; 34 | this.label = iFieldMetaSchema["label"]; 35 | }; 36 | 37 | BufferField.prototype.$ = function(iAttribute){ 38 | log( "BF:$", iAttribute ); 39 | 40 | var attrVal = ""; 41 | 42 | switch ( iAttribute.toLowerCase() ) { 43 | case "buffervalue": 44 | case "buffer-value": 45 | if(this.dataType.toLowerCase() === "date"){ 46 | attrVal = moment( this.value ).toDate(); 47 | } 48 | break; 49 | 50 | case "value": 51 | if(this.dataType.toLowerCase()=="date"){ 52 | attrVal=this.formattedValueDate(); 53 | }else{ 54 | attrVal=this.value; 55 | } 56 | break; 57 | 58 | case "format": 59 | attrVal = this.format; 60 | break; 61 | 62 | case "initial": 63 | attrVal = this.initial; 64 | break; 65 | 66 | case "label": 67 | attrVal = this.label; 68 | break; 69 | 70 | case "datatype": 71 | case "data-type": 72 | attrVal = this.dataType; 73 | break; 74 | 75 | case "screenvalue": 76 | attrVal = this.formattedValue(); 77 | break; 78 | 79 | default: 80 | throw new Error("Invalid buffer field attribute of '"+iAttribute+"' requested"); 81 | } 82 | 83 | return attrVal; 84 | }; 85 | 86 | BufferField.prototype.bufferValue = function( iValue ) { 87 | log( "BF:bufferValue", this.name, iValue ); 88 | var dateStr = ""; 89 | var yr=""; 90 | var month=""; 91 | var day=""; 92 | if( this.dataType.toLowerCase() === "date" ){ 93 | if(iValue instanceof Date){ 94 | yr=iValue.getFullYear(); 95 | month=iValue.getMonth()+1; 96 | month=month.toString(); 97 | if(month.length<=1){month="0"+month;} 98 | day=iValue.getDate(); 99 | day=day.toString(); 100 | if(day.length<=1){day="0"+day;} 101 | dateStr=yr+"-"+month+"-"+day; 102 | }else{ 103 | dateStr=iValue; 104 | } 105 | this.currentRecord[this.name] = moment(dateStr).format( "YYYY-MM-DD" ); 106 | }else{ 107 | this.currentRecord[this.name] = iValue; 108 | } 109 | }; 110 | 111 | BufferField.prototype.setAttr = function( iAttrNm, iValue ) { 112 | log( "BF:setAttr", iAttrNm, iValue ); 113 | 114 | if(iAttrNm.toLowerCase() === "format"){ 115 | this.metaSchema["format"] = iValue; 116 | } else { 117 | throw new Error( 'Attribute "' + iAttrNm + '" cannot be set' ); 118 | } 119 | }; 120 | 121 | BufferField.prototype.formattedValue = function() { 122 | log( "BF:formattedValue" ); 123 | 124 | var formattedValue = "", 125 | length = 0, 126 | i = 0; 127 | //formattedValue=""; 128 | switch ( this.dataType.toLocaleLowerCase() ) { 129 | case "character": 130 | if(this.format.substring(1,2)=="("){ 131 | length=this.format.substring(2,this.format.length-1); 132 | } else{ 133 | length=this.format.length; 134 | } 135 | if(length= 0 ){ 176 | decimalPrecision = this.format.length - this.format.toString().indexOf( '.' , 0 ) - 1; 177 | } 178 | 179 | if( decimalPrecision>0 ){ 180 | numeralFormat="0."; 181 | for(i=0;i=0){ 188 | numeralFormat="0,"+numeralFormat; 189 | } 190 | formattedValue=numeral(this.value).format(numeralFormat); 191 | j=this.format.length-formattedValue.length; 192 | for(i=0;i0){dateStr=formatStr.substring(0,i);} 216 | timeStr=formatStr.substring(i+1,formatStr.length); 217 | if(timeStr.substring(timeStr.length-6,timeStr.length)==="+hh:mm"){ 218 | timeZoneStr=" Z"; 219 | timeStr=timeStr.substring(0,timeStr.length-6); 220 | timeStr=timeStr.trim(); 221 | }; 222 | if(timeStr.substring(timeStr.length-3,timeStr.length)===" am"){ 223 | amPmStr=" a"; 224 | timeStr=timeStr.substring(0,timeStr.length-3); 225 | }else{ 226 | timeStr="HH:"+timeStr.substring(3,timeStr.length); 227 | }; 228 | if(timeStr.substring(timeStr.length-4,timeStr.length)===".sss"){ 229 | timeStr=timeStr.substring(0,timeStr.length-4)+".SSS"; 230 | } 231 | switch(dateStr){ 232 | case "99/99/9999": 233 | dateStr=this.dateFormat+"/YYYY"; 234 | break; 235 | case "99/99/99": 236 | dateStr=this.dateFormat+"/YY"; 237 | break; 238 | case "99-99-9999": 239 | dateStr=this.dateFormat.replace("/","-")+"-YYYY"; 240 | break; 241 | case "99-99-99": 242 | dateStr=this.dateFormat.replace("/","-")+"-YY"; 243 | break; 244 | } 245 | formatStr=dateStr; 246 | if(timeStr!==""){ 247 | formatStr+=" "; 248 | } 249 | formatStr+=timeStr+amPmStr+timeZoneStr; 250 | //console.log("formatStr->"+formatStr); 251 | if(timeZoneStr!=""){ 252 | formattedValue=moment(this.value).zone(this.value).format(formatStr); 253 | }else{ 254 | formattedValue=moment(this.value).format(formatStr); 255 | } 256 | return formattedValue; 257 | }; 258 | 259 | BufferField.prototype.formattedValueDate = function(){ 260 | log( "BF:formattedValueDate" ); 261 | var dateStr=this.format; 262 | switch(dateStr){ 263 | case "99/99/9999": 264 | dateStr=this.dateFormat+"/YYYY"; 265 | break; 266 | case "99/99/99": 267 | dateStr=this.dateFormat+"/YY"; 268 | break; 269 | case "99-99-9999": 270 | dateStr=this.dateFormat.replace("/","-")+"-YYYY"; 271 | break; 272 | case "99-99-99": 273 | dateStr=this.dateFormat.replace("/","-")+"-YY"; 274 | break; 275 | } 276 | return moment( this.value ).format(dateStr); 277 | //return moment( this.value ).format( (this.format == "99/99/99") ? this.dateFormat+"/YY" : this.dateFormat+"/YYYY" ); 278 | }; 279 | 280 | module.exports = function(iDateFormat) { 281 | return new BufferField(iDateFormat); 282 | }; -------------------------------------------------------------------------------- /4GlCode/BaseCode/nodeJsMetaSchema.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : nodeJsMetaSchema.p 6 | Purpose : Add metsschema definitions for dataset. 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | 21 | /* _UIB-CODE-BLOCK-END */ 22 | &ANALYZE-RESUME 23 | 24 | 25 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 26 | 27 | /* ******************** Preprocessor Definitions ******************** */ 28 | 29 | &Scoped-define PROCEDURE-TYPE Procedure 30 | &Scoped-define DB-AWARE no 31 | 32 | 33 | 34 | /* _UIB-PREPROCESSOR-BLOCK-END */ 35 | &ANALYZE-RESUME 36 | 37 | 38 | /* ************************ Function Prototypes ********************** */ 39 | 40 | &IF DEFINED(EXCLUDE-getDatasetOutputJson) = 0 &THEN 41 | 42 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getDatasetOutputJson Procedure 43 | FUNCTION getDatasetOutputJson RETURNS LONGCHAR 44 | ( /* parameter-definitions */ 45 | iParName AS CHAR, 46 | iDatasetHandle AS HANDLE, 47 | iIncludeMetaSchema AS LOGICAL) FORWARD. 48 | 49 | /* _UIB-CODE-BLOCK-END */ 50 | &ANALYZE-RESUME 51 | 52 | &ENDIF 53 | 54 | &IF DEFINED(EXCLUDE-getMetaSchemaBufferField) = 0 &THEN 55 | 56 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getMetaSchemaBufferField Procedure 57 | FUNCTION getMetaSchemaBufferField RETURNS CHARACTER 58 | ( /* parameter-definitions */ 59 | ihBufField AS HANDLE) FORWARD. 60 | 61 | /* _UIB-CODE-BLOCK-END */ 62 | &ANALYZE-RESUME 63 | 64 | &ENDIF 65 | 66 | &IF DEFINED(EXCLUDE-getMetaSchemaDataset) = 0 &THEN 67 | 68 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getMetaSchemaDataset Procedure 69 | FUNCTION getMetaSchemaDataset RETURNS LONGCHAR 70 | ( /* parameter-definitions */ 71 | ihDataset AS HANDLE) FORWARD. 72 | 73 | /* _UIB-CODE-BLOCK-END */ 74 | &ANALYZE-RESUME 75 | 76 | &ENDIF 77 | 78 | &IF DEFINED(EXCLUDE-getMetaSchemaTable) = 0 &THEN 79 | 80 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD getMetaSchemaTable Procedure 81 | FUNCTION getMetaSchemaTable RETURNS LONGCHAR 82 | ( /* parameter-definitions */ 83 | ihTable AS HANDLE ) FORWARD. 84 | 85 | /* _UIB-CODE-BLOCK-END */ 86 | &ANALYZE-RESUME 87 | 88 | &ENDIF 89 | 90 | 91 | /* *********************** Procedure Settings ************************ */ 92 | 93 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 94 | /* Settings for THIS-PROCEDURE 95 | Type: Procedure 96 | Allow: 97 | Frames: 0 98 | Add Fields to: Neither 99 | Other Settings: CODE-ONLY COMPILE 100 | */ 101 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 102 | 103 | /* ************************* Create Window ************************** */ 104 | 105 | &ANALYZE-SUSPEND _CREATE-WINDOW 106 | /* DESIGN Window definition (used by the UIB) 107 | CREATE WINDOW Procedure ASSIGN 108 | HEIGHT = 15 109 | WIDTH = 60. 110 | /* END WINDOW DEFINITION */ 111 | */ 112 | &ANALYZE-RESUME 113 | 114 | 115 | 116 | 117 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 118 | 119 | 120 | /* *************************** Main Block *************************** */ 121 | 122 | /* _UIB-CODE-BLOCK-END */ 123 | &ANALYZE-RESUME 124 | 125 | 126 | /* ************************ Function Implementations ***************** */ 127 | 128 | &IF DEFINED(EXCLUDE-getDatasetOutputJson) = 0 &THEN 129 | 130 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getDatasetOutputJson Procedure 131 | FUNCTION getDatasetOutputJson RETURNS LONGCHAR 132 | ( /* parameter-definitions */ 133 | iParName AS CHAR, 134 | iDatasetHandle AS HANDLE, 135 | iIncludeMetaSchema AS LOGICAL) : 136 | /*------------------------------------------------------------------------------ 137 | Purpose: 138 | Notes: 139 | ------------------------------------------------------------------------------*/ 140 | DEFINE VARIABLE vDatasetJsonOutputJson AS LONGCHAR NO-UNDO. 141 | DEFINE VARIABLE vTtJson AS LONGCHAR NO-UNDO. 142 | DEFINE VARIABLE vI AS INTEGER NO-UNDO. 143 | DEFINE VARIABLE vJ AS INTEGER NO-UNDO. 144 | 145 | ASSIGN vDatasetJsonOutputJson = SUBST('~n "&1" : ~{~n "&2":', 146 | iParName, 147 | iDatasetHandle:NAME). 148 | DO vI = 1 TO iDatasetHandle:NUM-BUFFERS: 149 | iDatasetHandle:GET-BUFFER-HANDLE(vI):TABLE-HANDLE:WRITE-JSON("LONGCHAR",vTtJson,FALSE). 150 | IF vI > 1 AND vTtJson BEGINS "~{" 151 | THEN vTtJson = SUBSTR(vTtJson,2). 152 | IF vI < iDatasetHandle:NUM-BUFFERS THEN 153 | DO: 154 | ASSIGN vJ = LENGTH(vTtJson). 155 | IF SUBSTR(vTtJson,vJ,1) EQ "}" 156 | THEN vTtJson = SUBSTR(vTtJson,1,vJ - 1). 157 | END. 158 | ASSIGN vDatasetJsonOutputJson = vDatasetJsonOutputJson + vTtJson. 159 | IF vI < iDatasetHandle:NUM-BUFFERS 160 | THEN ASSIGN vDatasetJsonOutputJson = vDatasetJsonOutputJson + ",~n". 161 | END. 162 | IF iIncludeMetaSchema THEN 163 | ASSIGN vDatasetJsonOutputJson = vDatasetJsonOutputJson + ",~n" + getMetaSchemaDataset(iDatasetHandle). 164 | ASSIGN vDatasetJsonOutputJson = vDatasetJsonOutputJson + "~n}". 165 | RETURN vDatasetJsonOutputJson. /* Function return value. */ 166 | 167 | END FUNCTION. 168 | 169 | /* _UIB-CODE-BLOCK-END */ 170 | &ANALYZE-RESUME 171 | 172 | &ENDIF 173 | 174 | &IF DEFINED(EXCLUDE-getMetaSchemaBufferField) = 0 &THEN 175 | 176 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getMetaSchemaBufferField Procedure 177 | FUNCTION getMetaSchemaBufferField RETURNS CHARACTER 178 | ( /* parameter-definitions */ 179 | ihBufField AS HANDLE) : 180 | /*------------------------------------------------------------------------------ 181 | Purpose: 182 | Notes: 183 | ------------------------------------------------------------------------------*/ 184 | DEFINE VARIABLE vMetaSchemaBufferField AS CHARACTER NO-UNDO. 185 | DEFINE VARIABLE vInitial AS CHARACTER NO-UNDO. 186 | DEFINE VARIABLE vDefaultValue AS CHARACTER NO-UNDO. 187 | ASSIGN vDefaultValue = ihBufField:DEFAULT-VALUE. 188 | IF ihBufField:DATA-TYPE EQ "LOGICAL" THEN 189 | DO: 190 | IF vDefaultValue EQ "no" THEN vDefaultValue = "false". 191 | IF vDefaultValue EQ "yes" THEN vDefaultValue = "true". 192 | 193 | END. 194 | ASSIGN vInitial = IF LOOKUP(ihBufField:DATA-TYPE,"CHARACTER,DATE,INTEGER,DECIMAL") > 0 THEN '"' + vDefaultValue + '"' ELSE vDefaultValue. 195 | IF vInitial EQ ? THEN vInitial = '""'. 196 | ASSIGN vMetaSchemaBufferField = SUBST('"&1":~{',ihBufField:NAME) + 197 | SUBST('"&1":"&2",',"dataType",ihBufField:DATA-TYPE) + 198 | SUBST('"&1":&2,',"initial", vInitial) + 199 | SUBST('"&1":"&2",',"format",ihBufField:FORMAT) + 200 | SUBST('"&1":"&2"',"label",ihBufField:LABEL) + 201 | "}". 202 | RETURN vMetaSchemaBufferField. /* Function return value. */ 203 | 204 | END FUNCTION. 205 | 206 | /* _UIB-CODE-BLOCK-END */ 207 | &ANALYZE-RESUME 208 | 209 | &ENDIF 210 | 211 | &IF DEFINED(EXCLUDE-getMetaSchemaDataset) = 0 &THEN 212 | 213 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getMetaSchemaDataset Procedure 214 | FUNCTION getMetaSchemaDataset RETURNS LONGCHAR 215 | ( /* parameter-definitions */ 216 | ihDataset AS HANDLE) : 217 | /*------------------------------------------------------------------------------ 218 | Purpose: 219 | Notes: 220 | ------------------------------------------------------------------------------*/ 221 | DEFINE VARIABLE vMetascemaStr AS LONGCHAR NO-UNDO. 222 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 223 | ASSIGN vMetascemaStr = SUBST('"&1MetaSchema":~{',ihDataset:NAME). 224 | DO i = 1 TO ihDataset:NUM-BUFFERS: 225 | ASSIGN vMetascemaStr = vMetascemaStr + getMetaSchemaTable(ihDataset:GET-BUFFER-HANDLE(i)) 226 | + (IF i < ihDataset:NUM-BUFFERS THEN "," ELSE ""). 227 | END. 228 | ASSIGN vMetascemaStr = vMetascemaStr + "}~n". 229 | RETURN vMetascemaStr. /* Function return value. */ 230 | 231 | END FUNCTION. 232 | 233 | /* _UIB-CODE-BLOCK-END */ 234 | &ANALYZE-RESUME 235 | 236 | &ENDIF 237 | 238 | &IF DEFINED(EXCLUDE-getMetaSchemaTable) = 0 &THEN 239 | 240 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION getMetaSchemaTable Procedure 241 | FUNCTION getMetaSchemaTable RETURNS LONGCHAR 242 | ( /* parameter-definitions */ 243 | ihTable AS HANDLE ) : 244 | /*------------------------------------------------------------------------------ 245 | Purpose: 246 | Notes: 247 | ------------------------------------------------------------------------------*/ 248 | DEFINE VARIABLE vTableMetaSchema AS LONGCHAR NO-UNDO. 249 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 250 | DEFINE VARIABLE vPostfix AS CHARACTER NO-UNDO. 251 | IF NOT PROGRAM-NAME(2) MATCHES "*getMetaSchemaDataset*" 252 | THEN vPostfix = "MetaSchema". 253 | ASSIGN vTableMetaSchema = SUBST('~n "&1":~{',ihTable:NAME + vPostfix). 254 | DO i = 1 TO ihTable:NUM-FIELDS: 255 | ASSIGN vTableMetaSchema = vTableMetaSchema + getMetaSchemaBufferField(ihTable:BUFFER-FIELD(i)) + 256 | IF i < ihTable:NUM-FIELDS THEN ",~n" ELSE "~n". 257 | 258 | END. 259 | ASSIGN vTableMetaSchema = vTableMetaSchema + "}~n". 260 | RETURN vTableMetaSchema. /* Function return value. */ 261 | 262 | END FUNCTION. 263 | 264 | /* _UIB-CODE-BLOCK-END */ 265 | &ANALYZE-RESUME 266 | 267 | &ENDIF 268 | 269 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdTt.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : CustUpdTt.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | {Examples/CustUpdDs.i} 21 | 22 | DEFINE INPUT PARAMETER iMode AS CHARACTER NO-UNDO. 23 | DEFINE INPUT PARAMETER iInputParameters AS CHARACTER NO-UNDO. 24 | DEFINE INPUT-OUTPUT PARAMETER TABLE FOR ttCustomer. 25 | DEFINE OUTPUT PARAMETER oOutputPars AS CHARACTER NO-UNDO. 26 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 27 | 28 | /* _UIB-CODE-BLOCK-END */ 29 | &ANALYZE-RESUME 30 | 31 | 32 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 33 | 34 | /* ******************** Preprocessor Definitions ******************** */ 35 | 36 | &Scoped-define PROCEDURE-TYPE Procedure 37 | &Scoped-define DB-AWARE no 38 | 39 | 40 | 41 | /* _UIB-PREPROCESSOR-BLOCK-END */ 42 | &ANALYZE-RESUME 43 | 44 | 45 | /* ************************ Function Prototypes ********************** */ 46 | 47 | &IF DEFINED(EXCLUDE-GetParameter) = 0 &THEN 48 | 49 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD GetParameter Procedure 50 | FUNCTION GetParameter RETURNS CHARACTER 51 | ( /* parameter-definitions */ 52 | iParName AS CHAR, 53 | iNamaValuePair AS CHAR, 54 | iDelimter AS CHAR) FORWARD. 55 | 56 | /* _UIB-CODE-BLOCK-END */ 57 | &ANALYZE-RESUME 58 | 59 | &ENDIF 60 | 61 | &IF DEFINED(EXCLUDE-NextCustNum) = 0 &THEN 62 | 63 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD NextCustNum Procedure 64 | FUNCTION NextCustNum RETURNS INTEGER 65 | ( /* parameter-definitions */ ) FORWARD. 66 | 67 | /* _UIB-CODE-BLOCK-END */ 68 | &ANALYZE-RESUME 69 | 70 | &ENDIF 71 | 72 | 73 | /* *********************** Procedure Settings ************************ */ 74 | 75 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 76 | /* Settings for THIS-PROCEDURE 77 | Type: Procedure 78 | Allow: 79 | Frames: 0 80 | Add Fields to: Neither 81 | Other Settings: CODE-ONLY COMPILE 82 | */ 83 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 84 | 85 | /* ************************* Create Window ************************** */ 86 | 87 | &ANALYZE-SUSPEND _CREATE-WINDOW 88 | /* DESIGN Window definition (used by the UIB) 89 | CREATE WINDOW Procedure ASSIGN 90 | HEIGHT = 15 91 | WIDTH = 60. 92 | /* END WINDOW DEFINITION */ 93 | */ 94 | &ANALYZE-RESUME 95 | 96 | 97 | 98 | 99 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 100 | 101 | 102 | /* *************************** Main Block *************************** */ 103 | 104 | CASE iMode: 105 | WHEN "ADD" THEN RUN CustAdd. 106 | WHEN "UPDATE" THEN RUN CustUpdate. 107 | WHEN "DELETE" THEN RUN CustDelete. 108 | WHEN "GetCustomer" THEN RUN CustGet. 109 | WHEN "GetNextCustNum" THEN RUN GetNextCustNum. 110 | END CASE. 111 | 112 | /* _UIB-CODE-BLOCK-END */ 113 | &ANALYZE-RESUME 114 | 115 | 116 | /* ********************** Internal Procedures *********************** */ 117 | 118 | &IF DEFINED(EXCLUDE-CustAdd) = 0 &THEN 119 | 120 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustAdd Procedure 121 | PROCEDURE CustAdd : 122 | /*------------------------------------------------------------------------------ 123 | Purpose: 124 | Parameters: 125 | Notes: 126 | ------------------------------------------------------------------------------*/ 127 | FIND FIRST ttCustomer NO-ERROR. 128 | IF AVAIL ttCustomer THEN 129 | DO: 130 | COMMIT: 131 | DO TRANSACTION ON ERROR UNDO, LEAVE: 132 | ASSIGN ttCustomer.cust-num = NEXT-VALUE(next-cust-num). 133 | CREATE Customer. 134 | BUFFER-COPY ttCustomer TO Customer. 135 | ASSIGN oOutputPars = "Customer added". 136 | CATCH ErrObj AS PROGRESS.lang.ProError: 137 | ASSIGN oErrMsg = SUBST("(&1)->&2",ErrObj:getMessageNum(1),ErrObj:getMessage(1)). 138 | END. 139 | END. 140 | END. 141 | ELSE ASSIGN oErrMsg = "No customer data submitted for add". 142 | END PROCEDURE. 143 | 144 | /* _UIB-CODE-BLOCK-END */ 145 | &ANALYZE-RESUME 146 | 147 | &ENDIF 148 | 149 | &IF DEFINED(EXCLUDE-CustDelete) = 0 &THEN 150 | 151 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustDelete Procedure 152 | PROCEDURE CustDelete : 153 | /*------------------------------------------------------------------------------ 154 | Purpose: 155 | Parameters: 156 | Notes: 157 | ------------------------------------------------------------------------------*/ 158 | DEFINE VARIABLE vI AS INTEGER NO-UNDO. 159 | DEFINE VARIABLE vCustometerDeleted AS CHARACTER NO-UNDO. 160 | COMMIT: 161 | DO TRANSACTION: 162 | FOR EACH ttCustomer: 163 | FIND Customer OF ttCustomer NO-LOCK NO-ERROR. 164 | IF AVAIL Customer THEN 165 | DO: 166 | FIND CURRENT Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR. 167 | IF NOT LOCKED Customer THEN 168 | DO: 169 | IF vCustometerDeleted NE "" THEN vCustometerDeleted = vCustometerDeleted + ",". 170 | vCustometerDeleted = vCustometerDeleted + STRING(customer.cust-num). 171 | DELETE Customer. 172 | vI = vI + 1. 173 | END. 174 | ELSE DO: 175 | oErrMsg = "Delete not executed because of a record lock on the customer table". 176 | UNDO COMMIT, LEAVE COMMIT. 177 | END. 178 | END. 179 | END. 180 | END. 181 | ASSIGN oOutputPars = SUBST("&1 customers deleted: &2",vI,vCustometerDeleted). 182 | 183 | 184 | END PROCEDURE. 185 | 186 | /* _UIB-CODE-BLOCK-END */ 187 | &ANALYZE-RESUME 188 | 189 | &ENDIF 190 | 191 | &IF DEFINED(EXCLUDE-CustGet) = 0 &THEN 192 | 193 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustGet Procedure 194 | PROCEDURE CustGet : 195 | /*------------------------------------------------------------------------------ 196 | Purpose: 197 | Parameters: 198 | Notes: 199 | ------------------------------------------------------------------------------*/ 200 | DEFINE VARIABLE vCustNum AS INTEGER NO-UNDO. 201 | DEFINE VARIABLE vCustNumFrom AS INTEGER NO-UNDO. 202 | DEFINE VARIABLE vCustNumTo AS INTEGER NO-UNDO. 203 | 204 | IF GetParameter("Mode", iInputParameters,"|") EQ "FromTo" THEN 205 | DO: 206 | ASSIGN vCustNumFrom = INT(GetParameter("Cust-num-from", iInputParameters,"|")) 207 | vCustNumTo = INT(GetParameter("Cust-num-to", iInputParameters,"|")). 208 | FOR EACH Customer NO-LOCK 209 | WHERE Customer.cust-num >= vCustNumFrom 210 | AND Customer.cust-num <= vCustNumTo: 211 | CREATE ttCustomer. 212 | BUFFER-COPY Customer TO ttCustomer. 213 | END. 214 | END. 215 | ELSE DO: 216 | ASSIGN vCustNum = INT(GetParameter("Cust-num", iInputParameters,"|")). 217 | FIND Customer WHERE Customer.Cust-num EQ vCustNum NO-LOCK NO-ERROR. 218 | IF AVAIL Customer THEN 219 | DO: 220 | CREATE ttCustomer. 221 | BUFFER-COPY Customer TO ttCustomer. 222 | END. 223 | END. 224 | END PROCEDURE. 225 | 226 | /* _UIB-CODE-BLOCK-END */ 227 | &ANALYZE-RESUME 228 | 229 | &ENDIF 230 | 231 | &IF DEFINED(EXCLUDE-CustUpdate) = 0 &THEN 232 | 233 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustUpdate Procedure 234 | PROCEDURE CustUpdate : 235 | /*------------------------------------------------------------------------------ 236 | Purpose: 237 | Parameters: 238 | Notes: 239 | ------------------------------------------------------------------------------*/ 240 | DEFINE VARIABLE vCustNum AS INTEGER NO-UNDO. 241 | FIND FIRST ttCustomer NO-ERROR. 242 | 243 | IF AVAIL ttCustomer THEN 244 | DO: 245 | FIND Customer OF ttCustomer NO-LOCK NO-ERROR. 246 | IF AVAIL Customer THEN 247 | DO: 248 | COMMIT: 249 | DO TRANSACTION ON ERROR UNDO, LEAVE: 250 | FIND CURRENT Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR. 251 | IF NOT LOCKED Customer THEN 252 | DO: 253 | ASSIGN vCustNum = ttCustomer.cust-num. 254 | BUFFER-COPY ttCustomer TO Customer. 255 | END. 256 | ELSE oErrMsg = "Customer record locked". 257 | CATCH ErrObj AS PROGRESS.lang.ProError: 258 | ASSIGN oErrMsg = SUBST("(&1)->&2",ErrObj:getMessageNum(1),ErrObj:getMessage(1)). 259 | END. 260 | FINALLY: 261 | IF oErrMsg EQ "" THEN ASSIGN oOutputPars = SUBST("Customer &1 updated",vCustNum). 262 | END. 263 | END. 264 | 265 | END. 266 | END. 267 | ELSE ASSIGN oErrMsg = "No customer data submitted for add". 268 | 269 | END PROCEDURE. 270 | 271 | /* _UIB-CODE-BLOCK-END */ 272 | &ANALYZE-RESUME 273 | 274 | &ENDIF 275 | 276 | &IF DEFINED(EXCLUDE-GetNextCustNum) = 0 &THEN 277 | 278 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE GetNextCustNum Procedure 279 | PROCEDURE GetNextCustNum : 280 | /*------------------------------------------------------------------------------ 281 | Purpose: 282 | Parameters: 283 | Notes: 284 | ------------------------------------------------------------------------------*/ 285 | ASSIGN oOutputPars = SUBST("NextCustNum=&1",NextCustNum()). 286 | END PROCEDURE. 287 | 288 | /* _UIB-CODE-BLOCK-END */ 289 | &ANALYZE-RESUME 290 | 291 | &ENDIF 292 | 293 | /* ************************ Function Implementations ***************** */ 294 | 295 | &IF DEFINED(EXCLUDE-GetParameter) = 0 &THEN 296 | 297 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION GetParameter Procedure 298 | FUNCTION GetParameter RETURNS CHARACTER 299 | ( /* parameter-definitions */ 300 | iParName AS CHAR, 301 | iNamaValuePair AS CHAR, 302 | iDelimter AS CHAR) : 303 | /*------------------------------------------------------------------------------ 304 | Purpose: 305 | Notes: 306 | ------------------------------------------------------------------------------*/ 307 | DEFINE VARIABLE vParValue AS CHARACTER NO-UNDO. 308 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 309 | DEFINE VARIABLE j AS INTEGER NO-UNDO. 310 | DEFINE VARIABLE vEntry AS CHARACTER NO-UNDO. 311 | DO i = 1 TO NUM-ENTRIES(iNamaValuePair,iDelimter): 312 | ASSIGN vEntry = ENTRY(i,iNamaValuePair,iDelimter) 313 | j = INDEX(vEntry,"="). 314 | IF j > 0 315 | AND TRIM(SUBSTR(vEntry,1,j - 1)) EQ iParName 316 | THEN DO: 317 | ASSIGN vParValue = TRIM(SUBSTR(vEntry,j + 1)). 318 | LEAVE. 319 | END. 320 | END. 321 | RETURN vParValue. /* Function return value. */ 322 | 323 | END FUNCTION. 324 | 325 | /* _UIB-CODE-BLOCK-END */ 326 | &ANALYZE-RESUME 327 | 328 | &ENDIF 329 | 330 | &IF DEFINED(EXCLUDE-NextCustNum) = 0 &THEN 331 | 332 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION NextCustNum Procedure 333 | FUNCTION NextCustNum RETURNS INTEGER 334 | ( /* parameter-definitions */ ) : 335 | /*------------------------------------------------------------------------------ 336 | Purpose: 337 | Notes: 338 | ------------------------------------------------------------------------------*/ 339 | 340 | RETURN NEXT-VALUE(Next-Cust-Num). /* Function return value. */ 341 | 342 | END FUNCTION. 343 | 344 | /* _UIB-CODE-BLOCK-END */ 345 | &ANALYZE-RESUME 346 | 347 | &ENDIF 348 | 349 | -------------------------------------------------------------------------------- /4GlCode/Examples/CustUpdDs.p: -------------------------------------------------------------------------------- 1 | &ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 2 | &ANALYZE-RESUME 3 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 4 | /*------------------------------------------------------------------------ 5 | File : CustUpd.p 6 | Purpose : 7 | 8 | Syntax : 9 | 10 | Description : 11 | 12 | Author(s) : 13 | Created : 14 | Notes : 15 | ----------------------------------------------------------------------*/ 16 | /* This .W file was created with the Progress AppBuilder. */ 17 | /*----------------------------------------------------------------------*/ 18 | 19 | /* *************************** Definitions ************************** */ 20 | {Examples/CustUpdDs.i} 21 | 22 | DEFINE INPUT PARAMETER iMode AS CHARACTER NO-UNDO. 23 | DEFINE INPUT PARAMETER iInputParameters AS CHARACTER NO-UNDO. 24 | DEFINE INPUT-OUTPUT PARAMETER DATASET FOR dsCustomer. 25 | DEFINE OUTPUT PARAMETER oOutputPars AS CHARACTER NO-UNDO. 26 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 27 | 28 | /* _UIB-CODE-BLOCK-END */ 29 | &ANALYZE-RESUME 30 | 31 | 32 | &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 33 | 34 | /* ******************** Preprocessor Definitions ******************** */ 35 | 36 | &Scoped-define PROCEDURE-TYPE Procedure 37 | &Scoped-define DB-AWARE no 38 | 39 | 40 | 41 | /* _UIB-PREPROCESSOR-BLOCK-END */ 42 | &ANALYZE-RESUME 43 | 44 | 45 | /* ************************ Function Prototypes ********************** */ 46 | 47 | &IF DEFINED(EXCLUDE-GetParameter) = 0 &THEN 48 | 49 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD GetParameter Procedure 50 | FUNCTION GetParameter RETURNS CHARACTER 51 | ( /* parameter-definitions */ 52 | iParName AS CHAR, 53 | iNamaValuePair AS CHAR, 54 | iDelimter AS CHAR) FORWARD. 55 | 56 | /* _UIB-CODE-BLOCK-END */ 57 | &ANALYZE-RESUME 58 | 59 | &ENDIF 60 | 61 | &IF DEFINED(EXCLUDE-NextCustNum) = 0 &THEN 62 | 63 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD NextCustNum Procedure 64 | FUNCTION NextCustNum RETURNS INTEGER 65 | ( /* parameter-definitions */ ) FORWARD. 66 | 67 | /* _UIB-CODE-BLOCK-END */ 68 | &ANALYZE-RESUME 69 | 70 | &ENDIF 71 | 72 | 73 | /* *********************** Procedure Settings ************************ */ 74 | 75 | &ANALYZE-SUSPEND _PROCEDURE-SETTINGS 76 | /* Settings for THIS-PROCEDURE 77 | Type: Procedure 78 | Allow: 79 | Frames: 0 80 | Add Fields to: Neither 81 | Other Settings: CODE-ONLY COMPILE 82 | */ 83 | &ANALYZE-RESUME _END-PROCEDURE-SETTINGS 84 | 85 | /* ************************* Create Window ************************** */ 86 | 87 | &ANALYZE-SUSPEND _CREATE-WINDOW 88 | /* DESIGN Window definition (used by the UIB) 89 | CREATE WINDOW Procedure ASSIGN 90 | HEIGHT = 15 91 | WIDTH = 60. 92 | /* END WINDOW DEFINITION */ 93 | */ 94 | &ANALYZE-RESUME 95 | 96 | 97 | 98 | 99 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 100 | 101 | 102 | /* *************************** Main Block *************************** */ 103 | 104 | CASE iMode: 105 | WHEN "ADD" THEN RUN CustAdd. 106 | WHEN "UPDATE" THEN RUN CustUpdate. 107 | WHEN "DELETE" THEN RUN CustDelete. 108 | WHEN "GetCustomer" THEN RUN CustGet. 109 | WHEN "GetNextCustNum" THEN RUN GetNextCustNum. 110 | END CASE. 111 | 112 | /* _UIB-CODE-BLOCK-END */ 113 | &ANALYZE-RESUME 114 | 115 | 116 | /* ********************** Internal Procedures *********************** */ 117 | 118 | &IF DEFINED(EXCLUDE-CustAdd) = 0 &THEN 119 | 120 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustAdd Procedure 121 | PROCEDURE CustAdd : 122 | /*------------------------------------------------------------------------------ 123 | Purpose: 124 | Parameters: 125 | Notes: 126 | ------------------------------------------------------------------------------*/ 127 | FIND FIRST ttCustomer NO-ERROR. 128 | IF AVAIL ttCustomer THEN 129 | DO: 130 | COMMIT: 131 | DO TRANSACTION ON ERROR UNDO, LEAVE: 132 | ASSIGN ttCustomer.cust-num = NEXT-VALUE(next-cust-num). 133 | CREATE Customer. 134 | BUFFER-COPY ttCustomer TO Customer. 135 | ASSIGN oOutputPars = "Customer added". 136 | CATCH ErrObj AS PROGRESS.lang.ProError: 137 | ASSIGN oErrMsg = SUBST("(&1)->&2",ErrObj:getMessageNum(1),ErrObj:getMessage(1)). 138 | END. 139 | END. 140 | END. 141 | ELSE ASSIGN oErrMsg = "No customer data submitted for add". 142 | END PROCEDURE. 143 | 144 | /* _UIB-CODE-BLOCK-END */ 145 | &ANALYZE-RESUME 146 | 147 | &ENDIF 148 | 149 | &IF DEFINED(EXCLUDE-CustDelete) = 0 &THEN 150 | 151 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustDelete Procedure 152 | PROCEDURE CustDelete : 153 | /*------------------------------------------------------------------------------ 154 | Purpose: 155 | Parameters: 156 | Notes: 157 | ------------------------------------------------------------------------------*/ 158 | DEFINE VARIABLE vI AS INTEGER NO-UNDO. 159 | DEFINE VARIABLE vcCustomersDeleted AS CHARACTER NO-UNDO. 160 | COMMIT: 161 | DO TRANSACTION: 162 | FOR EACH ttCustomer: 163 | FIND Customer OF ttCustomer NO-LOCK NO-ERROR. 164 | IF AVAIL Customer THEN 165 | DO: 166 | FIND CURRENT Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR. 167 | IF NOT LOCKED Customer THEN 168 | DO: 169 | IF vcCustomersDeleted NE "" THEN vcCustomersDeleted = vcCustomersDeleted + ",". 170 | vcCustomersDeleted = vcCustomersDeleted + STRING(Customer.Cust-num). 171 | DELETE Customer. 172 | vI = vI + 1. 173 | END. 174 | ELSE DO: 175 | oErrMsg = "Delete not executed because of a record lock on the customer table". 176 | UNDO COMMIT, LEAVE COMMIT. 177 | END. 178 | END. 179 | END. 180 | END. 181 | ASSIGN oOutputPars = SUBST("&1 customers deleted: &2",vI,vcCustomersDeleted). 182 | 183 | 184 | END PROCEDURE. 185 | 186 | /* _UIB-CODE-BLOCK-END */ 187 | &ANALYZE-RESUME 188 | 189 | &ENDIF 190 | 191 | &IF DEFINED(EXCLUDE-CustGet) = 0 &THEN 192 | 193 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustGet Procedure 194 | PROCEDURE CustGet : 195 | /*------------------------------------------------------------------------------ 196 | Purpose: 197 | Parameters: 198 | Notes: 199 | ------------------------------------------------------------------------------*/ 200 | DEFINE VARIABLE vCustNum AS INTEGER NO-UNDO. 201 | DEFINE VARIABLE vCustNumFrom AS INTEGER NO-UNDO. 202 | DEFINE VARIABLE vCustNumTo AS INTEGER NO-UNDO. 203 | 204 | MESSAGE 'GetParameter("Mode", iInputParameters,"|")' GetParameter("Mode", iInputParameters,"|") SKIP 205 | VIEW-AS ALERT-BOX INFO BUTTONS OK. 206 | IF GetParameter("Mode", iInputParameters,"|") EQ "FromTo" THEN 207 | DO: 208 | ASSIGN vCustNumFrom = INT(GetParameter("Cust-num-from", iInputParameters,"|")) 209 | vCustNumTo = INT(GetParameter("Cust-num-to", iInputParameters,"|")). 210 | MESSAGE "vCustNumFrom" vCustNumFrom SKIP 211 | " vCustNumTo" vCustNumTo SKIP 212 | VIEW-AS ALERT-BOX INFO BUTTONS OK. 213 | FOR EACH Customer NO-LOCK 214 | WHERE Customer.cust-num >= vCustNumFrom 215 | AND Customer.cust-num <= vCustNumTo: 216 | CREATE ttCustomer. 217 | BUFFER-COPY Customer TO ttCustomer. 218 | END. 219 | END. 220 | ELSE DO: 221 | ASSIGN vCustNum = INT(GetParameter("Cust-num", iInputParameters,"|")). 222 | FIND Customer WHERE Customer.Cust-num EQ vCustNum NO-LOCK NO-ERROR. 223 | IF AVAIL Customer THEN 224 | DO: 225 | CREATE ttCustomer. 226 | BUFFER-COPY Customer TO ttCustomer. 227 | END. 228 | END. 229 | END PROCEDURE. 230 | 231 | /* _UIB-CODE-BLOCK-END */ 232 | &ANALYZE-RESUME 233 | 234 | &ENDIF 235 | 236 | &IF DEFINED(EXCLUDE-CustUpdate) = 0 &THEN 237 | 238 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE CustUpdate Procedure 239 | PROCEDURE CustUpdate : 240 | /*------------------------------------------------------------------------------ 241 | Purpose: 242 | Parameters: 243 | Notes: 244 | ------------------------------------------------------------------------------*/ 245 | FIND FIRST ttCustomer NO-ERROR. 246 | 247 | IF AVAIL ttCustomer THEN 248 | DO: 249 | FIND Customer OF ttCustomer NO-LOCK NO-ERROR. 250 | IF AVAIL Customer THEN 251 | DO: 252 | COMMIT: 253 | DO TRANSACTION ON ERROR UNDO, LEAVE: 254 | FIND CURRENT Customer EXCLUSIVE-LOCK NO-WAIT NO-ERROR. 255 | IF NOT LOCKED Customer THEN 256 | DO: 257 | BUFFER-COPY ttCustomer TO Customer. 258 | END. 259 | ELSE oErrMsg = "Customer record locked". 260 | CATCH ErrObj AS PROGRESS.lang.ProError: 261 | ASSIGN oErrMsg = SUBST("(&1)->&2",ErrObj:getMessageNum(1),ErrObj:getMessage(1)). 262 | END. 263 | FINALLY: 264 | IF oErrMsg EQ "" THEN ASSIGN oOutputPars = SUBST("Customer with cust-num &1 updated",customer.cust-num). 265 | END. 266 | END. 267 | 268 | END. 269 | END. 270 | ELSE ASSIGN oErrMsg = "No customer data submitted for add". 271 | 272 | END PROCEDURE. 273 | 274 | /* _UIB-CODE-BLOCK-END */ 275 | &ANALYZE-RESUME 276 | 277 | &ENDIF 278 | 279 | &IF DEFINED(EXCLUDE-GetNextCustNum) = 0 &THEN 280 | 281 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE GetNextCustNum Procedure 282 | PROCEDURE GetNextCustNum : 283 | /*------------------------------------------------------------------------------ 284 | Purpose: 285 | Parameters: 286 | Notes: 287 | ------------------------------------------------------------------------------*/ 288 | ASSIGN oOutputPars = SUBST("NextCustNum=&1",NextCustNum()). 289 | END PROCEDURE. 290 | 291 | /* _UIB-CODE-BLOCK-END */ 292 | &ANALYZE-RESUME 293 | 294 | &ENDIF 295 | 296 | /* ************************ Function Implementations ***************** */ 297 | 298 | &IF DEFINED(EXCLUDE-GetParameter) = 0 &THEN 299 | 300 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION GetParameter Procedure 301 | FUNCTION GetParameter RETURNS CHARACTER 302 | ( /* parameter-definitions */ 303 | iParName AS CHAR, 304 | iNamaValuePair AS CHAR, 305 | iDelimter AS CHAR) : 306 | /*------------------------------------------------------------------------------ 307 | Purpose: 308 | Notes: 309 | ------------------------------------------------------------------------------*/ 310 | DEFINE VARIABLE vParValue AS CHARACTER NO-UNDO. 311 | DEFINE VARIABLE i AS INTEGER NO-UNDO. 312 | DEFINE VARIABLE j AS INTEGER NO-UNDO. 313 | DEFINE VARIABLE vEntry AS CHARACTER NO-UNDO. 314 | DO i = 1 TO NUM-ENTRIES(iNamaValuePair,iDelimter): 315 | ASSIGN vEntry = ENTRY(i,iNamaValuePair,iDelimter) 316 | j = INDEX(vEntry,"="). 317 | IF j > 0 318 | AND TRIM(SUBSTR(vEntry,1,j - 1)) EQ iParName 319 | THEN DO: 320 | ASSIGN vParValue = TRIM(SUBSTR(vEntry,j + 1)). 321 | LEAVE. 322 | END. 323 | END. 324 | RETURN vParValue. /* Function return value. */ 325 | 326 | END FUNCTION. 327 | 328 | /* _UIB-CODE-BLOCK-END */ 329 | &ANALYZE-RESUME 330 | 331 | &ENDIF 332 | 333 | &IF DEFINED(EXCLUDE-NextCustNum) = 0 &THEN 334 | 335 | &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION NextCustNum Procedure 336 | FUNCTION NextCustNum RETURNS INTEGER 337 | ( /* parameter-definitions */ ) : 338 | /*------------------------------------------------------------------------------ 339 | Purpose: 340 | Notes: 341 | ------------------------------------------------------------------------------*/ 342 | 343 | RETURN NEXT-VALUE(Next-Cust-Num). /* Function return value. */ 344 | 345 | END FUNCTION. 346 | 347 | /* _UIB-CODE-BLOCK-END */ 348 | &ANALYZE-RESUME 349 | 350 | &ENDIF 351 | 352 | -------------------------------------------------------------------------------- /4GlCode/Examples/invoice-note.d: -------------------------------------------------------------------------------- 1 | 0 ? ? "" 0 2 | 0 ? ? "" 0 3 | 0 ? ? "" 0 4 | 0 ? ? "" 0 5 | 0 ? ? "" 0 6 | 0 ? ? "" 0 7 | 0 ? ? "" 0 8 | 0 ? ? "" 0 9 | 0 ? ? "" 0 10 | 0 ? ? "" 0 11 | 0 ? ? "" 0 12 | 0 ? ? "" 0 13 | 0 ? ? "" 0 14 | 0 ? ? "" 0 15 | 0 ? ? "" 0 16 | 0 ? ? "" 0 17 | 0 ? ? "" 0 18 | 0 ? ? "" 0 19 | 0 ? ? "" 0 20 | 0 ? ? "" 0 21 | 0 ? ? "" 0 22 | 0 ? ? "" 0 23 | 0 ? ? "" 0 24 | 0 ? ? "" 0 25 | 0 ? ? "" 0 26 | 0 ? ? "" 0 27 | 0 ? ? "" 0 28 | 0 ? ? "" 0 29 | 0 ? ? "" 0 30 | 0 ? ? "" 0 31 | 0 ? ? "" 0 32 | 0 ? ? "" 0 33 | 0 ? ? "" 0 34 | 0 ? ? "" 0 35 | 0 ? ? "" 0 36 | 0 ? ? "" 0 37 | 0 ? ? "" 0 38 | 0 ? ? "" 0 39 | 0 ? ? "" 0 40 | 0 ? ? "" 0 41 | 0 ? ? "" 0 42 | 0 ? ? "" 0 43 | 0 ? ? "" 0 44 | 0 ? ? "" 0 45 | 0 ? ? "" 0 46 | 0 ? ? "" 0 47 | 0 ? ? "" 0 48 | 0 ? ? "" 0 49 | 0 ? ? "" 0 50 | 0 ? ? "" 0 51 | 0 ? ? "" 0 52 | 0 ? ? "" 0 53 | 0 ? ? "" 0 54 | 0 ? ? "" 0 55 | 0 ? ? "" 0 56 | 0 ? ? "" 0 57 | 0 ? ? "" 0 58 | 0 ? ? "" 0 59 | 0 ? ? "" 0 60 | 0 ? ? "" 0 61 | 0 ? ? "" 0 62 | 0 ? ? "" 0 63 | 0 ? ? "" 0 64 | 0 ? ? "" 0 65 | 0 ? ? "" 0 66 | 0 ? ? "" 0 67 | 0 ? ? "" 0 68 | 0 ? ? "" 0 69 | 0 ? ? "" 0 70 | 0 ? ? "" 0 71 | 0 ? ? "" 0 72 | 0 ? ? "" 0 73 | 0 ? ? "" 0 74 | 0 ? ? "" 0 75 | 0 ? ? "" 0 76 | 0 ? ? "" 0 77 | 0 ? ? "" 0 78 | 0 ? ? "" 0 79 | 0 ? ? "" 0 80 | 0 ? ? "" 0 81 | 0 ? ? "" 0 82 | 0 ? ? "" 0 83 | 0 ? ? "" 0 84 | 0 ? ? "" 0 85 | 0 ? ? "" 0 86 | 0 ? ? "" 0 87 | 0 ? ? "" 0 88 | 0 ? ? "" 0 89 | 0 ? ? "" 0 90 | 0 ? ? "" 0 91 | 0 ? ? "" 0 92 | 0 ? ? "" 0 93 | 0 ? ? "" 0 94 | 0 ? ? "" 0 95 | 0 ? ? "" 0 96 | 0 ? ? "" 0 97 | 0 ? ? "" 0 98 | 0 ? ? "" 0 99 | 0 ? ? "" 0 100 | 0 ? ? "" 0 101 | 0 ? ? "" 0 102 | 0 ? ? "" 0 103 | 0 ? ? "" 0 104 | 0 ? ? "" 0 105 | 0 ? ? "" 0 106 | 0 ? ? "" 0 107 | 0 ? ? "" 0 108 | 0 ? ? "" 0 109 | 0 ? ? "" 0 110 | 0 ? ? "" 0 111 | 0 ? ? "" 0 112 | 0 ? ? "" 0 113 | 0 ? ? "" 0 114 | 0 ? ? "" 0 115 | 0 ? ? "" 0 116 | 0 ? ? "" 0 117 | 0 ? ? "" 0 118 | 0 ? ? "" 0 119 | 0 ? ? "" 0 120 | 0 ? ? "" 0 121 | 0 ? ? "" 0 122 | 0 ? ? "" 0 123 | 0 ? ? "" 0 124 | 0 ? ? "" 0 125 | 0 ? ? "" 0 126 | 0 ? ? "" 0 127 | 0 ? ? "" 0 128 | 0 ? ? "" 0 129 | 0 ? ? "" 0 130 | 0 ? ? "" 0 131 | 0 ? ? "" 0 132 | 0 ? ? "" 0 133 | 0 ? ? "" 0 134 | 0 ? ? "" 0 135 | 0 ? ? "" 0 136 | 0 ? ? "" 0 137 | 0 ? ? "" 0 138 | 0 ? ? "" 0 139 | 0 ? ? "" 0 140 | 0 ? ? "" 0 141 | 0 ? ? "" 0 142 | 0 ? ? "" 0 143 | 0 ? ? "" 0 144 | 0 ? ? "" 0 145 | 0 ? ? "" 0 146 | 0 ? ? "" 0 147 | 0 ? ? "" 0 148 | 1 2014-09-27T12:26:34.894 2014-09-27T12:26:34.894-07:00 "Invoive created" 1 149 | 2 2014-09-27T12:26:34.896 2014-09-27T12:26:34.896-07:00 "Invoive created" 1 150 | 3 2014-09-27T12:26:34.897 2014-09-27T12:26:34.897-07:00 "Invoive created" 1 151 | 4 2014-09-27T12:26:34.897 2014-09-27T12:26:34.897-07:00 "Invoive created" 1 152 | 5 2014-09-27T12:26:34.898 2014-09-27T12:26:34.898-07:00 "Invoive created" 1 153 | 6 2014-09-27T12:26:34.899 2014-09-27T12:26:34.899-07:00 "Invoive created" 1 154 | 7 2014-09-27T12:26:34.900 2014-09-27T12:26:34.900-07:00 "Invoive created" 1 155 | 8 2014-09-27T12:26:34.901 2014-09-27T12:26:34.901-07:00 "Invoive created" 1 156 | 9 2014-09-27T12:26:34.902 2014-09-27T12:26:34.902-07:00 "Invoive created" 1 157 | 10 2014-09-27T12:26:34.903 2014-09-27T12:26:34.903-07:00 "Invoive created" 1 158 | 11 2014-09-27T12:26:34.904 2014-09-27T12:26:34.904-07:00 "Invoive created" 1 159 | 12 2014-09-27T12:26:34.904 2014-09-27T12:26:34.904-07:00 "Invoive created" 1 160 | 13 2014-09-27T12:26:34.905 2014-09-27T12:26:34.905-07:00 "Invoive created" 1 161 | 14 2014-09-27T12:26:34.906 2014-09-27T12:26:34.906-07:00 "Invoive created" 1 162 | 15 2014-09-27T12:26:34.907 2014-09-27T12:26:34.907-07:00 "Invoive created" 1 163 | 16 2014-09-27T12:26:34.908 2014-09-27T12:26:34.908-07:00 "Invoive created" 1 164 | 17 2014-09-27T12:26:34.909 2014-09-27T12:26:34.909-07:00 "Invoive created" 1 165 | 18 2014-09-27T12:26:34.910 2014-09-27T12:26:34.910-07:00 "Invoive created" 1 166 | 19 2014-09-27T12:26:34.911 2014-09-27T12:26:34.911-07:00 "Invoive created" 1 167 | 20 2014-09-27T12:26:34.912 2014-09-27T12:26:34.912-07:00 "Invoive created" 1 168 | 21 2014-09-27T12:26:34.912 2014-09-27T12:26:34.912-07:00 "Invoive created" 1 169 | 22 2014-09-27T12:26:34.913 2014-09-27T12:26:34.913-07:00 "Invoive created" 1 170 | 23 2014-09-27T12:26:34.914 2014-09-27T12:26:34.914-07:00 "Invoive created" 1 171 | 24 2014-09-27T12:26:34.915 2014-09-27T12:26:34.915-07:00 "Invoive created" 1 172 | 25 2014-09-27T12:26:34.916 2014-09-27T12:26:34.916-07:00 "Invoive created" 1 173 | 26 2014-09-27T12:26:34.917 2014-09-27T12:26:34.917-07:00 "Invoive created" 1 174 | 27 2014-09-27T12:26:34.920 2014-09-27T12:26:34.920-07:00 "Invoive created" 1 175 | 28 2014-09-27T12:26:34.939 2014-09-27T12:26:34.939-07:00 "Invoive created" 1 176 | 29 2014-09-27T12:26:34.940 2014-09-27T12:26:34.940-07:00 "Invoive created" 1 177 | 30 2014-09-27T12:26:34.941 2014-09-27T12:26:34.941-07:00 "Invoive created" 1 178 | 31 2014-09-27T12:26:34.942 2014-09-27T12:26:34.942-07:00 "Invoive created" 1 179 | 32 2014-09-27T12:26:34.943 2014-09-27T12:26:34.943-07:00 "Invoive created" 1 180 | 33 2014-09-27T12:26:34.944 2014-09-27T12:26:34.944-07:00 "Invoive created" 1 181 | 34 2014-09-27T12:26:34.945 2014-09-27T12:26:34.945-07:00 "Invoive created" 1 182 | 35 2014-09-27T12:26:34.953 2014-09-27T12:26:34.953-07:00 "Invoive created" 1 183 | 36 2014-09-27T12:26:34.954 2014-09-27T12:26:34.954-07:00 "Invoive created" 1 184 | 37 2014-09-27T12:26:34.955 2014-09-27T12:26:34.955-07:00 "Invoive created" 1 185 | 38 2014-09-27T12:26:34.956 2014-09-27T12:26:34.956-07:00 "Invoive created" 1 186 | 39 2014-09-27T12:26:34.957 2014-09-27T12:26:34.957-07:00 "Invoive created" 1 187 | 40 2014-09-27T12:26:34.958 2014-09-27T12:26:34.958-07:00 "Invoive created" 1 188 | 41 2014-09-27T12:26:34.959 2014-09-27T12:26:34.959-07:00 "Invoive created" 1 189 | 42 2014-09-27T12:26:34.960 2014-09-27T12:26:34.960-07:00 "Invoive created" 1 190 | 43 2014-09-27T12:26:34.961 2014-09-27T12:26:34.961-07:00 "Invoive created" 1 191 | 44 2014-09-27T12:26:34.962 2014-09-27T12:26:34.962-07:00 "Invoive created" 1 192 | 45 2014-09-27T12:26:34.963 2014-09-27T12:26:34.963-07:00 "Invoive created" 1 193 | 46 2014-09-27T12:26:34.964 2014-09-27T12:26:34.964-07:00 "Invoive created" 1 194 | 47 2014-09-27T12:26:34.965 2014-09-27T12:26:34.965-07:00 "Invoive created" 1 195 | 48 2014-09-27T12:26:34.965 2014-09-27T12:26:34.965-07:00 "Invoive created" 1 196 | 49 2014-09-27T12:26:34.966 2014-09-27T12:26:34.966-07:00 "Invoive created" 1 197 | 50 2014-09-27T12:26:34.967 2014-09-27T12:26:34.967-07:00 "Invoive created" 1 198 | 51 2014-09-27T12:26:34.968 2014-09-27T12:26:34.968-07:00 "Invoive created" 1 199 | 52 2014-09-27T12:26:34.969 2014-09-27T12:26:34.969-07:00 "Invoive created" 1 200 | 53 2014-09-27T12:26:34.970 2014-09-27T12:26:34.970-07:00 "Invoive created" 1 201 | 54 2014-09-27T12:26:34.971 2014-09-27T12:26:34.971-07:00 "Invoive created" 1 202 | 55 2014-09-27T12:26:34.971 2014-09-27T12:26:34.971-07:00 "Invoive created" 1 203 | 56 2014-09-27T12:26:34.972 2014-09-27T12:26:34.972-07:00 "Invoive created" 1 204 | 57 2014-09-27T12:26:34.974 2014-09-27T12:26:34.974-07:00 "Invoive created" 1 205 | 58 2014-09-27T12:26:34.975 2014-09-27T12:26:34.975-07:00 "Invoive created" 1 206 | 59 2014-09-27T12:26:34.976 2014-09-27T12:26:34.976-07:00 "Invoive created" 1 207 | 60 2014-09-27T12:26:34.977 2014-09-27T12:26:34.977-07:00 "Invoive created" 1 208 | 61 2014-09-27T12:26:34.979 2014-09-27T12:26:34.979-07:00 "Invoive created" 1 209 | 62 2014-09-27T12:26:34.980 2014-09-27T12:26:34.980-07:00 "Invoive created" 1 210 | 63 2014-09-27T12:26:34.981 2014-09-27T12:26:34.981-07:00 "Invoive created" 1 211 | 64 2014-09-27T12:26:34.982 2014-09-27T12:26:34.982-07:00 "Invoive created" 1 212 | 65 2014-09-27T12:26:34.983 2014-09-27T12:26:34.983-07:00 "Invoive created" 1 213 | 66 2014-09-27T12:26:34.984 2014-09-27T12:26:34.984-07:00 "Invoive created" 1 214 | 67 2014-09-27T12:26:34.985 2014-09-27T12:26:34.985-07:00 "Invoive created" 1 215 | 68 2014-09-27T12:26:34.986 2014-09-27T12:26:34.986-07:00 "Invoive created" 1 216 | 69 2014-09-27T12:26:34.987 2014-09-27T12:26:34.987-07:00 "Invoive created" 1 217 | 70 2014-09-27T12:26:34.989 2014-09-27T12:26:34.989-07:00 "Invoive created" 1 218 | 71 2014-09-27T12:26:34.990 2014-09-27T12:26:34.990-07:00 "Invoive created" 1 219 | 72 2014-09-27T12:26:34.991 2014-09-27T12:26:34.991-07:00 "Invoive created" 1 220 | 73 2014-09-27T12:26:34.992 2014-09-27T12:26:34.992-07:00 "Invoive created" 1 221 | 74 2014-09-27T12:26:34.993 2014-09-27T12:26:34.993-07:00 "Invoive created" 1 222 | 75 2014-09-27T12:26:34.994 2014-09-27T12:26:34.994-07:00 "Invoive created" 1 223 | 76 2014-09-27T12:26:34.995 2014-09-27T12:26:34.995-07:00 "Invoive created" 1 224 | 77 2014-09-27T12:26:34.995 2014-09-27T12:26:34.995-07:00 "Invoive created" 1 225 | 78 2014-09-27T12:26:34.995 2014-09-27T12:26:34.995-07:00 "Invoive created" 1 226 | 79 2014-09-27T12:26:34.996 2014-09-27T12:26:34.996-07:00 "Invoive created" 1 227 | 80 2014-09-27T12:26:35.005 2014-09-27T12:26:35.005-07:00 "Invoive created" 1 228 | 81 2014-09-27T12:26:35.007 2014-09-27T12:26:35.007-07:00 "Invoive created" 1 229 | 82 2014-09-27T12:26:35.008 2014-09-27T12:26:35.008-07:00 "Invoive created" 1 230 | 83 2014-09-27T12:26:35.014 2014-09-27T12:26:35.014-07:00 "Invoive created" 1 231 | 84 2014-09-27T12:26:35.015 2014-09-27T12:26:35.015-07:00 "Invoive created" 1 232 | 85 2014-09-27T12:26:35.016 2014-09-27T12:26:35.016-07:00 "Invoive created" 1 233 | 86 2014-09-27T12:26:35.017 2014-09-27T12:26:35.017-07:00 "Invoive created" 1 234 | 87 2014-09-27T12:26:35.018 2014-09-27T12:26:35.018-07:00 "Invoive created" 1 235 | 88 2014-09-27T12:26:35.019 2014-09-27T12:26:35.019-07:00 "Invoive created" 1 236 | 89 2014-09-27T12:26:35.020 2014-09-27T12:26:35.020-07:00 "Invoive created" 1 237 | 90 2014-09-27T12:26:35.021 2014-09-27T12:26:35.021-07:00 "Invoive created" 1 238 | 91 2014-09-27T12:26:35.024 2014-09-27T12:26:35.024-07:00 "Invoive created" 1 239 | 92 2014-09-27T12:26:35.025 2014-09-27T12:26:35.025-07:00 "Invoive created" 1 240 | 93 2014-09-27T12:26:35.025 2014-09-27T12:26:35.025-07:00 "Invoive created" 1 241 | 94 2014-09-27T12:26:35.026 2014-09-27T12:26:35.026-07:00 "Invoive created" 1 242 | 95 2014-09-27T12:26:35.028 2014-09-27T12:26:35.028-07:00 "Invoive created" 1 243 | 96 2014-09-27T12:26:35.029 2014-09-27T12:26:35.029-07:00 "Invoive created" 1 244 | 97 2014-09-27T12:26:35.030 2014-09-27T12:26:35.030-07:00 "Invoive created" 1 245 | 98 2014-09-27T12:26:35.039 2014-09-27T12:26:35.039-07:00 "Invoive created" 1 246 | 99 2014-09-27T12:26:35.040 2014-09-27T12:26:35.040-07:00 "Invoive created" 1 247 | 100 2014-09-27T12:26:35.040 2014-09-27T12:26:35.040-07:00 "Invoive created" 1 248 | 101 2014-09-27T12:26:35.041 2014-09-27T12:26:35.041-07:00 "Invoive created" 1 249 | 102 2014-09-27T12:26:35.042 2014-09-27T12:26:35.042-07:00 "Invoive created" 1 250 | 103 2014-09-27T12:26:35.043 2014-09-27T12:26:35.043-07:00 "Invoive created" 1 251 | 104 2014-09-27T12:26:35.044 2014-09-27T12:26:35.044-07:00 "Invoive created" 1 252 | 105 2014-09-27T12:26:35.045 2014-09-27T12:26:35.045-07:00 "Invoive created" 1 253 | 106 2014-09-27T12:26:35.046 2014-09-27T12:26:35.046-07:00 "Invoive created" 1 254 | 107 2014-09-27T12:26:35.047 2014-09-27T12:26:35.047-07:00 "Invoive created" 1 255 | 108 2014-09-27T12:26:35.047 2014-09-27T12:26:35.047-07:00 "Invoive created" 1 256 | 109 2014-09-27T12:26:35.048 2014-09-27T12:26:35.048-07:00 "Invoive created" 1 257 | 110 2014-09-27T12:26:35.049 2014-09-27T12:26:35.049-07:00 "Invoive created" 1 258 | 111 2014-09-27T12:26:35.050 2014-09-27T12:26:35.050-07:00 "Invoive created" 1 259 | 112 2014-09-27T12:26:35.051 2014-09-27T12:26:35.051-07:00 "Invoive created" 1 260 | 113 2014-09-27T12:26:35.052 2014-09-27T12:26:35.052-07:00 "Invoive created" 1 261 | 114 2014-09-27T12:26:35.053 2014-09-27T12:26:35.053-07:00 "Invoive created" 1 262 | 115 2014-09-27T12:26:35.063 2014-09-27T12:26:35.063-07:00 "Invoive created" 1 263 | 116 2014-09-27T12:26:35.065 2014-09-27T12:26:35.065-07:00 "Invoive created" 1 264 | 117 2014-09-27T12:26:35.066 2014-09-27T12:26:35.066-07:00 "Invoive created" 1 265 | 118 2014-09-27T12:26:35.067 2014-09-27T12:26:35.067-07:00 "Invoive created" 1 266 | 119 2014-09-27T12:26:35.068 2014-09-27T12:26:35.068-07:00 "Invoive created" 1 267 | 120 2014-09-27T12:26:35.069 2014-09-27T12:26:35.069-07:00 "Invoive created" 1 268 | 121 2014-09-27T12:26:35.070 2014-09-27T12:26:35.070-07:00 "Invoive created" 1 269 | 122 2014-09-27T12:26:35.071 2014-09-27T12:26:35.071-07:00 "Invoive created" 1 270 | 123 2014-09-27T12:26:35.073 2014-09-27T12:26:35.073-07:00 "Invoive created" 1 271 | 124 2014-09-27T12:26:35.074 2014-09-27T12:26:35.074-07:00 "Invoive created" 1 272 | 125 2014-09-27T12:26:35.076 2014-09-27T12:26:35.076-07:00 "Invoive created" 1 273 | 126 2014-09-27T12:26:35.078 2014-09-27T12:26:35.078-07:00 "Invoive created" 1 274 | 127 2014-09-27T12:26:35.079 2014-09-27T12:26:35.079-07:00 "Invoive created" 1 275 | 128 2014-09-27T12:26:35.080 2014-09-27T12:26:35.080-07:00 "Invoive created" 1 276 | 129 2014-09-27T12:26:35.081 2014-09-27T12:26:35.081-07:00 "Invoive created" 1 277 | 130 2014-09-27T12:26:35.082 2014-09-27T12:26:35.082-07:00 "Invoive created" 1 278 | 131 2014-09-27T12:26:35.082 2014-09-27T12:26:35.082-07:00 "Invoive created" 1 279 | 132 2014-09-27T12:26:35.083 2014-09-27T12:26:35.083-07:00 "Invoive created" 1 280 | 133 2014-09-27T12:26:35.084 2014-09-27T12:26:35.084-07:00 "Invoive created" 1 281 | 134 2014-09-27T12:26:35.085 2014-09-27T12:26:35.085-07:00 "Invoive created" 1 282 | 135 2014-09-27T12:26:35.086 2014-09-27T12:26:35.086-07:00 "Invoive created" 1 283 | 136 2014-09-27T12:26:35.087 2014-09-27T12:26:35.087-07:00 "Invoive created" 1 284 | 137 2014-09-27T12:26:35.088 2014-09-27T12:26:35.088-07:00 "Invoive created" 1 285 | 138 2014-09-27T12:26:35.089 2014-09-27T12:26:35.089-07:00 "Invoive created" 1 286 | 139 2014-09-27T12:26:35.090 2014-09-27T12:26:35.090-07:00 "Invoive created" 1 287 | 140 2014-09-27T12:26:35.091 2014-09-27T12:26:35.091-07:00 "Invoive created" 1 288 | 141 2014-09-27T12:26:35.092 2014-09-27T12:26:35.092-07:00 "Invoive created" 1 289 | 142 2014-09-27T12:26:35.094 2014-09-27T12:26:35.094-07:00 "Invoive created" 1 290 | 143 2014-09-27T12:26:35.095 2014-09-27T12:26:35.095-07:00 "Invoive created" 1 291 | 144 2014-09-27T12:26:35.096 2014-09-27T12:26:35.096-07:00 "Invoive created" 1 292 | 145 2014-09-27T12:26:35.097 2014-09-27T12:26:35.097-07:00 "Invoive created" 1 293 | 146 2014-09-27T12:26:35.098 2014-09-27T12:26:35.098-07:00 "Invoive created" 1 294 | 147 2014-09-27T12:26:35.105 2014-09-27T12:26:35.105-07:00 "Invoive created" 1 295 | . 296 | PSC 297 | filename=Invoice-Note 298 | records=0000000000294 299 | ldbname=Sports 300 | timestamp=2014/10/03-03:02:45 301 | numformat=44,46 302 | dateformat=mdy-1950 303 | map=NO-MAP 304 | cpstream=ISO8859-1 305 | . 306 | 0000013272 307 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var http = require("http"), 2 | moment = require("moment"), 3 | numeral = require('numeral'), 4 | Dataset = require('./dataset.js'), 5 | TempTable = require('./temptable.js'), 6 | debug = require('debug'), 7 | log = debug("n4p:index"); 8 | 9 | debug.enable("n4p:*"); 10 | 11 | /*****************************************************************************************************/ 12 | //dynCallPromise -> promise object for dynamic call requests 13 | function dynCallPromise(iNode4Progress,iDyncallJsonStr){ 14 | log( "dCP create" ); 15 | 16 | this.node4progress = iNode4Progress; 17 | this.dynCallJsonStr = iDyncallJsonStr; 18 | this.callback = null; 19 | } 20 | 21 | dynCallPromise.prototype.execute = function(iCallback){ 22 | log( "dCP:execute" ); 23 | 24 | if(iCallback){ 25 | this.callback = iCallback; 26 | } 27 | if(this.node4progress.winstoneStarted === true){ 28 | this.executeAppCall(); 29 | } else { 30 | this.node4progress.dynCallPromises.push( this ); 31 | } 32 | }; 33 | 34 | dynCallPromise.prototype.executeAppCall = function(){ 35 | log( "dCP:executeAppCall" ); 36 | 37 | var that = this; 38 | 39 | this.node4progress.prepareAppsvrCall( this.dynCallJsonStr, function( err, dynCallStr ){ 40 | if(err & err!==null){ 41 | that.callback( err, null ); 42 | }else{ 43 | //that.node4progress.httpPost( dynCallStr, that.callback ); 44 | that.node4progress.httpPost(dynCallStr, "application/json","callAppsvrProc", that.callback); 45 | } 46 | }); 47 | }; 48 | 49 | /*****************************************************************************************************/ 50 | //datasetPromise -> promise object for getDatasetScheme requests 51 | function datasetPromise( iNode4Progress, iDyncallJsonStr, iCallback ){ 52 | log( "dsP create" ); 53 | 54 | this.node4progress = iNode4Progress; 55 | this.dynCallJsonStr = iDyncallJsonStr; 56 | this.callback = iCallback; 57 | } 58 | 59 | datasetPromise.prototype.execute = function(){ 60 | log( "dsP:execute" ); 61 | 62 | if(this.node4progress.winstoneStarted === true){ 63 | this.executeRequest(); 64 | } else { 65 | this.node4progress.datasetPromises.push( this ); 66 | } 67 | }; 68 | datasetPromise.prototype.executeRequest = function(){ 69 | log( "dsP:executeRequest" ); 70 | 71 | var that = this; 72 | this.node4progress.prepareAppsvrCall( this.dynCallJsonStr, function( err, dynCallStr ){ 73 | if( err & err!==null){ 74 | that.callback( err,null ); 75 | }else{ 76 | //that.node4progress.httpPost( dynCallStr, that.callback ); 77 | that.node4progress.httpPost(dynCallStr, "application/json","callAppsvrProc", that.callback); 78 | } 79 | }); 80 | }; 81 | 82 | /*****************************************************************************************************/ 83 | //tamptablePromise -> promise object for getDatasetScheme requests 84 | function tempTablePromise( iNode4Progress, iDyncallJsonStr,iCallback){ 85 | log( "ttP create" ); 86 | 87 | this.node4progress = iNode4Progress; 88 | this.dynCallJsonStr = iDyncallJsonStr; 89 | this.callback = iCallback; 90 | } 91 | 92 | tempTablePromise.prototype.execute = function(){ 93 | log( "ttP:execute" ); 94 | 95 | if(this.node4progress.winstoneStarted === true){ 96 | this.executeRequest(); 97 | } else { 98 | this.node4progress.tempTablePromises.push(this); 99 | } 100 | }; 101 | 102 | tempTablePromise.prototype.executeRequest = function(){ 103 | log( "ttP:executeRequest" ); 104 | 105 | var that = this; 106 | this.node4progress.prepareAppsvrCall(this.dynCallJsonStr,function(err,dynCallStr){ 107 | if(err & err!==null){ 108 | that.callback(err,null); 109 | }else{ 110 | //that.node4progress.httpPost( dynCallStr, that.callback ); 111 | that.node4progress.httpPost(dynCallStr, "application/json","callAppsvrProc", that.callback); 112 | } 113 | }); 114 | }; 115 | 116 | 117 | /*****************************************************************************************************/ 118 | // handlerCallPromise -> promise object for getDatasetScheme requests 119 | function handlerCallPromise(iNode4Progress){ 120 | log( "hcP create" ); 121 | 122 | this.node4progress = iNode4Progress; 123 | this.handler = null; 124 | this.inputPars = null; 125 | this.callback = null; 126 | } 127 | 128 | handlerCallPromise.prototype.execute = function(iInputPars,iCallBack){ 129 | log( "hcP:execute", iInputPars ); 130 | 131 | if(iInputPars){ 132 | this.inputPars=iInputPars; 133 | } 134 | if(iCallBack){ 135 | this.callback=iCallBack; 136 | } 137 | if(this.node4progress.winstoneStarted === true){ 138 | this.executeHandler(); 139 | } else { 140 | this.node4progress.handlerPromises.push(this); 141 | } 142 | }; 143 | 144 | handlerCallPromise.prototype.executeHandler = function(){ 145 | log( "hcP:executeHandler" ); 146 | //var callBackNow = this.callback; 147 | //this.node4progress.callHandler( this.handler, this.inputPars, this.callback ); 148 | //this.node4progress.httpPost(this.inputPars,this.callback); 149 | this.node4progress.httpPost(this.inputPars, "text/plain", "CallHandler", this.callback); 150 | }; 151 | 152 | function node4progress(conf) { 153 | log( "n4p create" ); 154 | var that = this; 155 | if(conf !== null){ 156 | this.conf = conf; 157 | } else { 158 | this.conf = require(__dirname + "/config/config.json"); 159 | } 160 | //this.conf = require(__dirname + "/config/config.json"); 161 | this.dynCall = {}; 162 | this.dynCallPromises = []; 163 | this.handlerPromises = []; 164 | this.datasetPromises = []; 165 | this.tempTablePromises = []; 166 | this.spawn = require('child_process').spawn; 167 | //this.spawn = require('child_process').exec; 168 | this.winstoneStarted =false; 169 | this.appserverUrl = this.conf.AppserverUrl; 170 | this.appserverUserName = this.conf.AppserverUserName; 171 | this.appserverUserPassword = this.conf.AppserverPassword; 172 | this.appserverSessionModel = this.conf.AppserverSessionModel; 173 | this.winstoneSvrPort = this.conf.WinstoneSvrPort; 174 | this.dateFormat = this.conf.DateFormat; 175 | this.winstone = null; 176 | this.env = process.env; 177 | this.startWinstone(); 178 | 179 | } 180 | 181 | node4progress.prototype.startWinstone = function(){ 182 | log( "startWinstone" ); 183 | 184 | var that = this; 185 | this.env.appserverUrl = this.appserverUrl; 186 | this.env.appserverUserName = that.appserverUserName; 187 | this.env.appserverUserPassword = that.appserverUserPassword; 188 | this.env.appserverSessionModel = that.appserverSessionModel; 189 | this.env.winstoneSvrPort = that.winstoneSvrPort; 190 | 191 | var args = ['-jar', __dirname + '/winstone/winstone-0.9.10.jar','--warfile',"./webapps/Node4ProgressServlet.war",'--httpPort='+this.winstoneSvrPort]; 192 | var options = { 193 | cwd: __dirname + "/winstone", 194 | env: this.env, 195 | detached: false, 196 | setsid: false 197 | }; 198 | 199 | this.winstone = this.spawn('java', args, options); 200 | 201 | this.winstone.stdout.on('data', function (data) { 202 | console.log(""+data); 203 | //if(data.toString().indexOf("Listener started:") > 0){ 204 | if(data.toString().indexOf("running:") > 0){ 205 | that.winstoneStarted=true; 206 | for(var i=0;i"+result); 238 | }); 239 | }); 240 | 241 | }; 242 | 243 | node4progress.prototype.handler = function(){ 244 | log( "handler" ); 245 | return new handlerCallPromise(this); 246 | }; 247 | 248 | node4progress.prototype.callHandler = function( iHandler, iInputParameters,iIncludeMetaSchema, callback ){ 249 | log( "callHandler", iHandler ); 250 | 251 | var post_data = iHandler + "|" + iIncludeMetaSchema + "|" + iInputParameters; 252 | var handler = new handlerCallPromise(this); 253 | handler.execute(post_data,callback); 254 | }; 255 | 256 | node4progress.prototype.httpPost = function(post_data,content_type,callMethod,callback) { 257 | // An object of options to indicate where to post to 258 | var post_options = { 259 | host: 'localhost', 260 | port: this.winstoneSvrPort, 261 | path: '/TurboNode?' + callMethod, 262 | method: 'POST', 263 | headers: { 264 | 'Content-Type': content_type, 265 | 'Content-Length': post_data.length 266 | } 267 | }; 268 | // Set up the request 269 | var post_req = http.request(post_options, function(res) { 270 | var resultStr = ""; 271 | res.setEncoding('utf8'); 272 | res.on('data', function (chunk) { 273 | resultStr+=chunk; 274 | }); 275 | res.on('end',function(){ 276 | callback(null,resultStr); 277 | }); 278 | }); 279 | 280 | // post the data 281 | post_req.write(post_data); 282 | post_req.end(); 283 | }; 284 | 285 | node4progress.prototype.stopWinstone = function(callback){ 286 | log( "stopWinstone" ); 287 | 288 | this.httpPost("","text/plain","stop",callback); 289 | }; 290 | 291 | node4progress.prototype.setAppsvrProc = function(iProcName,iInternalProcName,iIsPersistent,iIncludeMetaSchemna){ 292 | log( "setAppSvrProc", iProcName ); 293 | 294 | this.dynCall = { 295 | dsCallStack: { 296 | ttCallProgram: [], 297 | ttCallParameter: [] 298 | } 299 | }; 300 | this.dynCall.dsCallStack.ttCallProgram.push( 301 | { 302 | ProcName: iProcName, 303 | internalProcName: iInternalProcName, 304 | IsPersistent: iIsPersistent, 305 | includeMetaSchema: iIncludeMetaSchemna 306 | } 307 | ); 308 | }; 309 | 310 | node4progress.prototype.setParameter = function(parName,parDataType,parIoMode,parValue,SchemaProvider){ 311 | log( "setParameter", parName ); 312 | 313 | this.dynCall.dsCallStack.ttCallParameter.push( { 314 | parIndex: this.dynCall.dsCallStack.ttCallParameter.length + 1, 315 | parDataType: parDataType, 316 | parIoMode: parIoMode, 317 | parName: parName, 318 | parValue: parValue, 319 | SchemaProvider: SchemaProvider 320 | }); 321 | }; 322 | 323 | node4progress.prototype.setPar = function( elm ) { 324 | log( "setPar", elm.parName ); 325 | 326 | elm.parIndex = this.dynCall.dsCallStack.ttCallParameter.length + 1; 327 | this.dynCall.dsCallStack.ttCallParameter.push( elm ); 328 | }; 329 | node4progress.prototype.appProc = function(){ 330 | log( "appProc" ); 331 | 332 | var dynCallStr = JSON.stringify(this.dynCall); 333 | return new dynCallPromise(this,dynCallStr); 334 | }; 335 | 336 | node4progress.prototype.invoke = function(callback){ 337 | log( "invoke" ); 338 | 339 | var dynCallStr = JSON.stringify(this.dynCall); 340 | var appCall = new dynCallPromise(this,dynCallStr); 341 | appCall.execute(callback); 342 | }; 343 | 344 | node4progress.prototype.getEmptyDataset = function(iDatasetNm,iDatasetProvider,callback){ 345 | log( "getEmptyDataset", iDatasetNm ); 346 | 347 | var that=this; 348 | var dataset=null; 349 | this.setAppsvrProc("getSchema","",false,true); 350 | this.setParameter(iDatasetNm,"dataset-handle","output","",iDatasetProvider); 351 | var dsPromise = new datasetPromise(this,JSON.stringify(this.dynCall),function(err,iJsonDatasetStr){ 352 | var jsonObj=null; 353 | try{ 354 | jsonObj=JSON.parse(iJsonDatasetStr); 355 | dataset=that.getDataset(iDatasetNm,iJsonDatasetStr); 356 | }catch(e){ 357 | if(jsonObj && jsonObj["error"]!==""){ 358 | err=jsonObj["error"] + "\n"; 359 | } 360 | err+=e; 361 | } 362 | callback(err,dataset); 363 | }); 364 | dsPromise.execute(); 365 | }; 366 | 367 | node4progress.prototype.getEmptyTempTable = function(iTtNm,iTtProvider,callback){ 368 | log( "getEmptyTempTable", iTtNm ); 369 | 370 | var that=this; 371 | var tt=null; 372 | this.setAppsvrProc("getSchema","",false,true); 373 | this.setParameter(iTtNm,"table-handle","output","",iTtProvider); 374 | var ttPromise = new tempTablePromise(this,JSON.stringify(this.dynCall),function(err,iJsonDatasetStr){ 375 | var jsonObj=null; 376 | try{ 377 | jsonObj=JSON.parse(iJsonDatasetStr); 378 | tt=that.getTempTable(iTtNm,iJsonDatasetStr); 379 | }catch(e){ 380 | if(jsonObj && jsonObj["error"]!==""){ 381 | err=jsonObj["error"] + "\n"; 382 | } 383 | err+=e; 384 | } 385 | callback(err,tt); 386 | }); 387 | ttPromise.execute(); 388 | }; 389 | 390 | node4progress.prototype.prepareAppsvrCall = function(dsCallStack,callback){ 391 | log( "prepareAppsvrCall" ); 392 | 393 | var j=0; 394 | var k=0; 395 | var ttLongcharChunk = null; 396 | var ttLongcharChunkRow; 397 | var errObj=null; 398 | var chunkCharSize=15000; 399 | 400 | try{ 401 | if(typeof dsCallStack == "string"){ 402 | dsCallStack = JSON.parse(dsCallStack); 403 | } 404 | 405 | dsCallStack.dsCallStack.ttCallParameter.forEach( function(callParameter) { 406 | if(callParameter.parDataType.toLowerCase()=="dataset-handle" || 407 | callParameter.parDataType.toLowerCase()=="table-handle" || 408 | callParameter.parDataType.toLowerCase()=="longchar"){ 409 | if(callParameter.parIoMode.toLowerCase()=="input"|| 410 | callParameter.parIoMode.toLowerCase()=="input-output"){ 411 | if(typeof callParameter.parValue == "object"){ 412 | callParameter.parValue = JSON.stringify(callParameter.parValue); 413 | } 414 | k=0; 415 | for(j=0;j 187 | 188 | { 189 | "AppserverUrl":"APPSERVERDC://204.236.218.31:3190", 190 | "AppserverUserName": "", 191 | "AppserverUserPassword": "", 192 | "AppserverSessionModel": "State-less", 193 | "WinstoneSvrPort": 8087, 194 | "DateFormat":"mm/dd" 195 | } 196 | 197 | - Configure the Appserver url, user name, password and session 198 | model to the correct parameters for you appserver 199 | 200 | - The appserver url must be in the following format 201 | 202 | - For an appserver connection routed through the name 203 | server 204 | 205 | - Appserver://[Host-name/Ip-address]:[NS-Port\#]/AppserverNm 206 | 207 | - e.g. Appserver://localhost:5162/Sports 208 | 209 | - For a direct appserver connection 210 | 211 | - APPSERVERDC://[Host-name/Ip-address]:[Port-number] 212 | 213 | - e.g. APPSERVERDC://localhost:4090" 214 | 215 | - The WinstoneSrverPort needs to an available port on your local 216 | machine 217 | 218 | - Most likely you can leave this parameter alone 219 | 220 | - The DateFormat parameter controls how dates are going to be 221 | formatted 222 | 223 | - Use "mm/dd" for the American format 224 | 225 | - use "dd/mm" for the European format 226 | 227 | ### Testing the configuration: 228 | 229 | From the command line in the node4progressTest directory type in the 230 | following command: 231 | 232 | - node configTest.js 233 | 234 | Open up a browser and point to the following url: 235 | 236 | - 237 | 238 | If this results in a web page that looks like this then yoiur 239 | configuration is correct: 240 | 241 | ![][1] 242 | 243 | # 4. Usage 244 | 245 | The node4progress module provides the following 2 ways calling business 246 | logic on the appserver: 247 | 248 | 1. Handler call 249 | 250 | - A handler is an appserver procedure that adheres to a specific 251 | input/output paremeter signature 252 | 253 | 2. Dynamic appsrever call 254 | 255 | - Using the dynamic appserver call approach you any appserver 256 | procedure with any input/output signature can be called 257 | 258 | ## *4.1 Using the handler approach* 259 | 260 | A handler is an appserver procedure with an input/output signature that 261 | looks as follows: 262 | 263 | {dsOrder.i} 264 | 265 | DEFINE INPUT PARAMETER iInputPars AS LONGCHAR NO-UNDO. 266 | DEFINE OUTPUT PARAMETER oOutputPars AS LONGCHAR NO-UNDO. 267 | DEFINE OUTPUT PARAMETER DATASET FOR dsOrder. 268 | DEFINE OUTPUT PARAMETER oErrMsg AS CHARACTER NO-UNDO. 269 | 270 | - The suggested use for the 1st parameter (iInputPars) is to pass a 271 | set of input parameters as name value pairs 272 | 273 | - The suggested use for the 2nd parameter is to pass a set of output 274 | parameters as name/value pairs 275 | 276 | - The 3rd dataset parameter can be any valid dataset. 277 | 278 | - The suggested use of the 4th parameter is pass an error message if 279 | the handler logic failed 280 | 281 | The output parameters of the handler procedure are translated into a 282 | JSON structure passed as a string: 283 | 284 | { 285 | "OutputPars": "...", 286 | "ErrMsg": "...", 287 | "[DatasetNm]" : {...} 288 | } 289 | 290 | In node the code for invoking a handler looks like this: 291 | 292 | var conf = require("./config/config.json"); 293 | var node4progress = require("node4progressHttp")(conf); 294 | var handler="handlers/CustomerHandler.p"; 295 | var inputPars = 'NumCustomersToPull=2'; 296 | node4progress.callHandler(handler,inputPars,true,function(err,result){ 297 | console.log("CUSTOMER HANDLER RESULT"); 298 | console.log(result); 299 | jsonObj=JSON.parse(result); 300 | }); 301 | 302 | ## *4.2 Using the dynamic call approach:* 303 | 304 | Invoking any appserver call with any parameter structure is a 3 step 305 | process: 306 | 307 | 1. Defining the appsever procedure to call using the setAppsvrProc 308 | method which takes the following input parameters 309 | 310 | 1. ProcName 311 | 312 | - Program name of the appserver procedure) 313 | 314 | 2. InternalProcName 315 | 316 | - Internal procedure name to call for a persistent appserver 317 | procedure 318 | 319 | 3. IsPersistent 320 | 321 | - True when calling a persistent appserver procedure, 322 | otherwise false 323 | 324 | 4. IncludeMetaSchema 325 | 326 | - If you want to use the node4progress dataset functionality 327 | pass true otherwise false 328 | 329 | 2. Defining each parameter using the setParameter method which takes 330 | the following input parameters 331 | 332 | 1. ParName 333 | 334 | - Parameter name (controls how this parameter will be 335 | represented in the Json output) 336 | 337 | 2. ParDataType 338 | 339 | - Datatype of parameter (character, integer, decimal, date, 340 | datatime, datetime-tz, dataset-handle, table-handle, 341 | longchar) 342 | 343 | 3. ParIoMode 344 | 345 | - Input, output, input-output 346 | 347 | 4. ParValue 348 | 349 | - For an input or input-output parameter you can pass the 350 | input value here. For a dataset-handle or a table-handle the 351 | input must be provided in write-json format 352 | 353 | 5. SchemaProvider 354 | 355 | - When passing a dataset-handle or table-handle as input or 356 | input-output you must provide the name of a schema provider 357 | program. What a schema provider is will be explained below 358 | in a separate section 359 | 360 | 3. Executing the appserver procedure using the invoke method 361 | 362 | 1. The only input parameter that the invoke method takes is the 363 | callback procedure which should have the following input 364 | parameters 365 | 366 | 1. Error 367 | 368 | - If the appserver fails to execute, for instance because 369 | of a connection problem, then an error message 370 | explaining the problem will be passed in this parameter 371 | 372 | 2. Result 373 | 374 | - The out parameters of the appserver procedure translated 375 | into a JSON string will be returned in this parameter 376 | 377 | - What this JSON structure looks like is explained 378 | below 379 | 380 | ### *Translating the output parameters of a dynamic appserver call into a JSON structure* 381 | 382 | The output of a dynamic appserver procedure looks as follows: 383 | 384 | { 385 | "output" : { 386 | "CharOutputParameter" : "...", 387 | "IntOutputParameter" : 100, 388 | "DecOutputParameter" : 210.50, 389 | "tableHandleOutputParameter" : {...}, 390 | "DatasetHandleOutputParameter": {...} 391 | }, 392 | "error" : "...." 393 | } 394 | 395 | The important things to understand about this JSON structure are: 396 | 397 | - At the root level of the JSON structure there are 2 nodes 398 | 399 | - "output" 400 | 401 | - Contains the contents of input-output and output parameters 402 | of the appserver procedure 403 | 404 | - In the order they are defined in the parameter signature 405 | 406 | - Table-handle and dataset-handle parameters are passed in 407 | write-json format 408 | 409 | - "error" 410 | 411 | - If an error occured while executing the appserver procedure 412 | (e.g. a appserver connection eror) then this parameter will 413 | contain error information 414 | 415 | ### *Using schemaproviders when passing a dataset-handle of table-handle as input* 416 | 417 | When passing temp-table data or dataset data as input in write-json 418 | format to an appserver procedure the table-handle or dataset-handle 419 | needs to have a metaschema structure before the appserver procedure is 420 | invoked. This as opposed to calling an appserver procedure that passes 421 | the data as output only where the metaschema structure can be inherited 422 | from the appserver program that is called. 423 | 424 | So in order to call an appserver procedure that takes a temp-table of a 425 | dataset as input or input-output you need to create a schema provider 426 | procedure. A schema provider is a program that does nothing other than 427 | pass the structure of the dataset/temp-table as output. 428 | 429 | Below is an example of a schema provider for a temp-table: 430 | 431 | /*------------------------------------------------------------------------ 432 | File : CustUpdTt-SchemaProvider.p Purpose : 433 | ------------------------------------------------------------------------*/ 434 | / ************************ Definitions *********************** / {Examples/CustUpdTt.i} 435 | DEFINE OUTPUT PARAMETER TABLE FOR ttCustomer. 436 | 437 | Below is an example of a schema provider for a dataset: 438 | 439 | /*------------------------------------------------------------------------ 440 | File : CustUpdDs-SchemaProvider.p Purpose : 441 | ------------------------------------------------------------------------*/ 442 | / ************************ Definitions *********************** / {Examples/CustUpdDs.i} 443 | DEFINE OUTPUT PARAMETER DATASET FOR dsCustomer. 444 | 445 | # 5. Code Samples: 446 | 447 | ## Code sample for calling a handler program: 448 | 449 | var conf = require("./config/config.json"); 450 | var node4progress = require("node4progressHttp")(conf); 451 | var handler="handlers/CustomerHandler.p"; 452 | var inputPars = 'NumCustomersToPull=2'; 453 | 454 | node4progress.callHandler(handler,inputPars,true,function(err,result){ 455 | console.log("CUSTOMER HANDLER RESULT"); 456 | console.log(result); 457 | }); 458 | 459 | ## Code sample for a dynamic appserver call: 460 | 461 | var conf = require("./config/config.json"); 462 | var node4progress = require("node4progressHttp")(conf); 463 | node4progress.setAppsvrProc("Examples/CustUpdDs.p","",false,true); 464 | 465 | node4progress.setParameter( 466 | "Imode", 467 | "character", 468 | "input", 469 | "GetCustomer", 470 | ""); 471 | node4progress.setParameter( 472 | "iInputParameters", 473 | "character", 474 | "input", 475 | "mode=FromTo|cust-num-from=1100|cust-num-to=9999",""); 476 | node4progress.setParameter( 477 | "dsCustomer", 478 | "dataset-handle", 479 | "input-output", 480 | "", 481 | "examples/CustUpdDs-SchemaProvider.p"); 482 | node4progress.setParameter( 483 | "oOutputPars", 484 | "character", 485 | "output", 486 | "", 487 | ""); 488 | node4progress.setParameter( 489 | "ErrMsg", 490 | "character", 491 | "output", 492 | "", 493 | ""); 494 | node4progress.invoke(function(err,result){ 495 | console.log(result); 496 | }; 497 | 498 | # 6. The node4progress dataset object 499 | 500 | If data needs to be passed as input to an appserver procedure that 501 | expects either a dataset or a temp-table as input then it is essential 502 | that the data is presented to the appserver in exactly to correct 503 | format. For this reason node4progress provides a dataset object. If you 504 | interact with the data through the methods provided with the dataset 505 | object then the data will be maintained in exactly the correct format. 506 | 507 | ## 6.1 Object structure of the node4progress dataset object 508 | 509 | Node4progress comes with a dataset object that is modelled after the 510 | PROGRESS prodataset object. 511 | 512 | The node4progress dataset architecture comes with the following objects, 513 | attributes and methods. 514 | 515 | +-----------------------+-----------------------+-----------------------+-----------------------+ 516 | | **Object** | **Methods/Attributes* | **Purpose** | **Input Parameters** | 517 | | | * | | | 518 | +-----------------------+-----------------------+-----------------------+-----------------------+ 519 | | Dataset | \$ | Returns a temp-table | -\>TableName | 520 | | | | object: Example: | | 521 | | | | Tt=dataset.\$(TtName) | | 522 | | | | ; | | 523 | +-----------------------+-----------------------+-----------------------+-----------------------+ 524 | | | copyDataset | Returns a copy of the | -\>isEmpty (when true | 525 | | | | dataset (optionally | an empty copy of the | 526 | | | | empty) | dataset is returned | 527 | +-----------------------+-----------------------+-----------------------+-----------------------+ 528 | | | emptyDataset | Removes all records | No input parameters | 529 | | | | from the dataset | | 530 | +-----------------------+-----------------------+-----------------------+-----------------------+ 531 | | | writeJson | Returns contents of | No input parameters | 532 | | | | the dataset as a JSON | | 533 | | | | string | | 534 | +-----------------------+-----------------------+-----------------------+-----------------------+ 535 | | TempTable | available  | returns true if a | No input parameters | 536 | | | | record in the | | 537 | | | | temp-table currently | | 538 | | | | has focus | | 539 | +-----------------------+-----------------------+-----------------------+-----------------------+ 540 | | | bufferCreate | Creates a record in | No input parameters | 541 | | | | the temp-table and | | 542 | | | | returns a buffer | | 543 | | | | object with the newly | | 544 | | | | created record | | 545 | +-----------------------+-----------------------+-----------------------+-----------------------+ 546 | | | bufferCopy | Copies the values of | -\>CopySource | 547 | | | | a JSON object or a | --\>Either a JSON | 548 | | | | buffer object passed | object or a buffer | 549 | | | | to the currently | object | 550 | | | | selected record | | 551 | +-----------------------+-----------------------+-----------------------+-----------------------+ 552 | | | bufferDelete | Deletes the currently | No parameters | 553 | | | | selected record from | | 554 | | | | the temp-table | | 555 | +-----------------------+-----------------------+-----------------------+-----------------------+ 556 | | | copyTempTable | Returns a copy of the | -\>isEmpty (when true | 557 | | | | temp-table object | an empty copy of the | 558 | | | | (optionally an empty | temp-table is | 559 | | | | copy) | returned | 560 | +-----------------------+-----------------------+-----------------------+-----------------------+ 561 | | | emptyTempTable | Removes all records | No parameters | 562 | | | | from the temp-table | | 563 | +-----------------------+-----------------------+-----------------------+-----------------------+ 564 | | | forEach | Loops through the | -\>callback (call | 565 | | | | records in the | back function that | 566 | | | | temp-table | will receive a buffer | 567 | | | | | object as input) | 568 | +-----------------------+-----------------------+-----------------------+-----------------------+ 569 | | | findFirst | retrieves the first | No input parameters | 570 | | | | record in the | | 571 | | | | temp-table and | | 572 | | | | returns a buffer | | 573 | | | | object with that | | 574 | | | | record | | 575 | +-----------------------+-----------------------+-----------------------+-----------------------+ 576 | | | findLast | retrieves the first | No input parameters | 577 | | | | record in the | | 578 | | | | temp-table and | | 579 | | | | returns a buffer | | 580 | | | | object with that | | 581 | | | | record | | 582 | +-----------------------+-----------------------+-----------------------+-----------------------+ 583 | | | writeJson | Returns a JSON string | No input parameters | 584 | | | | with the contents of | | 585 | | | | the temp-table | | 586 | +-----------------------+-----------------------+-----------------------+-----------------------+ 587 | | Buffer | \$ | Returns a bufferField | -\>FieldNm (Field | 588 | | | | object | name of the buffer | 589 | | | | bufField=buffer.\$(fi | field to retrieve) | 590 | | | | eldNm); | | 591 | +-----------------------+-----------------------+-----------------------+-----------------------+ 592 | | | display | Returns a formmated | -\>ListOfFields (a | 593 | | | | string with a number | list of fields to | 594 | | | | of fields that are | include in the string | 595 | | | | formatted as dictated | to formatted string | 596 | | | | by the format | to be returned) | 597 | | | | attributes in the | | 598 | | | | individual fields | | 599 | +-----------------------+-----------------------+-----------------------+-----------------------+ 600 | | | writeJson | Returns the contents | No input parameters | 601 | | | | of the currently | | 602 | | | | selected record as a | | 603 | | | | JSON string | | 604 | +-----------------------+-----------------------+-----------------------+-----------------------+ 605 | | BufferField | \$ | Returns the value of | -\>AttributeNm (Name | 606 | | | | the requested | of the attribute to | 607 | | | | BufferField attribute | retrieve) | 608 | | | | (valid attributes are | | 609 | | | | buffer-value, value, | | 610 | | | | format, initial, | | 611 | | | | label & screenValue) | | 612 | +-----------------------+-----------------------+-----------------------+-----------------------+ 613 | | | bufferValue | Changes the | -\>bufferValue (the | 614 | | | | BufferField value of | bufferField value to | 615 | | | | the currently | assign to this field) | 616 | | | | selected field | | 617 | +-----------------------+-----------------------+-----------------------+-----------------------+ 618 | | | setAttr | sets the value of a | -\>AttrName (Name of | 619 | | | | BufferField attribute | the attribute to set) | 620 | | | | (valid attributes are | -\>AttrValue (value | 621 | | | | buffer-value, value, | to set this attribute | 622 | | | | format, initial, | to) | 623 | | | | label & screenValue) | | 624 | +-----------------------+-----------------------+-----------------------+-----------------------+ 625 | 626 | ## 6.2 Running the node4progress dataset examples 627 | 628 | A set of examples is provided that show how to use the node4progress 629 | dataset object. 630 | 631 | As explained before in paragraph 3 (installation and configuration) 632 | Node4Progress comes out of the box with a configuration that allows for 633 | these examples to be run against an appserver running on an Amazon 634 | clould computer. The examples are written to show some basic features of 635 | the dataset and then exit. Though generally the expected use of 636 | node4progress would be as part of a node based server process, stripping 637 | the examples down to the essentials seemed the shortest and easiest way 638 | to illustrate how to use the dataset. 639 | 640 | The examples are centered around the following dataset features: 641 | 642 | - How to navigate the data in a dataset object 643 | 644 | - testDatasetCustomer.js, testDatasetOrder.js, testDatasetInvoice 645 | 646 | - Using the CallHandler approach 647 | 648 | - testCallHandler.js 649 | 650 | - How to do a set of basic add, update, delete operations with a 651 | dataset 652 | 653 | - custAddDs.js, custUpdDs.js & custDeleteDs.js 654 | 655 | - How to do a set of basic add, update, delete operations with a 656 | temp-table 657 | 658 | - custAddTt.js, custUpdTt.js & custDeleteTt.js 659 | 660 | Each example lists in the header which dataset methods it uses and 661 | contains comments what each statement accomplishes. 662 | 663 | For further instructions on how to get setup to run the examples please 664 | refer to paragraph 3. 665 | 666 | # 7. Troubleshooting 667 | 668 | The following are known issues that are currently being addressed: 669 | 670 | - Known installation problems node4progress 671 | 672 | - Installation on Linux fails with message that node version is 673 | not supported for node4progress 674 | 675 | - On linux with the following node is generally installed with 676 | the following commands 677 | 678 | - To install node 679 | 680 | - sudo apt-get install nodejs 681 | 682 | - To install npm 683 | 684 | - sudo apt-get install npm 685 | 686 | - This may however not install the latest version of node that 687 | is needed (version 10) 688 | 689 | - You can get the version of node that is installed with 690 | the following command 691 | 692 | - node -v 693 | 694 | - If you do not have the latest version of node you can can 695 | iinstall it with npm with the following commands 696 | 697 | - sudo npm cache clean -f 698 | 699 | - sudo npm install -g n 700 | 701 | - sudo n stable 702 | 703 | - Node4progress install failed with a "shashum check failed" error 704 | 705 | - This is more likely to happen if you have had node installed 706 | for a while and have allready installed a number of other 707 | modules 708 | 709 | - In this case reset you npm configuration as follows: 710 | 711 | - npm cache clean 712 | 713 | - npm config set registry http://registry.npmjs.org/ 714 | 715 | - npm set registry http://registry.npmjs.org/ 716 | 717 | - Then try to install node4progress again with 718 | 719 | - On windows (run as administrator) 720 | 721 | - npm install node4progress 722 | 723 | - On Linux/Unix 724 | 725 | - sudo npm install node4progress 726 | 727 | - On exiting a program that uses node4progress it sometimes takes a 728 | while for the winstone port to be released 729 | 730 | - This may result in the following error when you start up the 731 | program 732 | 733 | Exception: Error: connect ECONNREFUSED 734 | Error: connect ECONNREFUSED 735 | at errnoException (net.js:904:11) 736 | at Object.afterConnect [as oncomplete] (net.js:895:19) 737 | Exception: Error: socket hang up Error: socket hang up 738 | at createHangUpError (http.js:1472:15) 739 | at Socket.socketCloseListener (http.js:1522:23) 740 | at Socket.EventEmitter.emit (events.js:117:20) 741 | at TCP.close (net.js:465:12) 742 | 743 | - This error resolves itself 744 | 745 | - When you run the program again the error will disappear 746 | 747 | - Installing node4progress on linux gives an error 748 | 749 | []: ExampleOutput.png 750 | [1]: ConfigScreenshot.png 751 | --------------------------------------------------------------------------------