Get rule set code not bound to a score definition
post/ruleSets/{ruleSetId}/mappedCode
Returns the code directly as text without being wrapped in a JSON model. The text can then be used to run the rule set based on mapping to a static input and output data set of SASEP.IN and SASEP.OUT rather than binding to a score definition.
1{2 "code": "/* Rule Set ppn_rs1 version 1.0 generated on Mon Jul 01 06:44:38 UTC 2024 */\n\nDS2_OPTIONS LOGICALEXPR = STANDARD;\nDS2_OPTIONS SCOND = WARNING;\nDS2_OPTIONS MISSING_NOTE;\n\n/* {PACKAGE_START} */\npackage BRM_51_RuleSet_0 / inline;\n\n\tdcl package logger _logger('App.demo');\n\tdcl package logger logr_variableTrace('App.TableServices.DS2.Runtime.TraceVariables');\n\tdcl varchar(100) \"RULE_NM\";\n\tdcl varchar(100) \"RULE_SET_NM\";\n\tdcl varchar(36) \"RULE_SET_ID\";\n\tdcl varchar(36) \"RULE_SET_VERSION_ID\";\n\tdcl varchar(36) \"RULE_ID\";\n\n\tdcl package hash ruleFireFlagOffsetHash;\n\tdcl integer ruleFiredFlagPosition;\n\tdcl integer ruleFiredBasePosition;\n\tdcl integer ruleFiredRecordingEnableFlag;\n\n\tmethod setruleFiredBasePosition(integer newBasePosition);\n\t\truleFiredBasePosition = newBasePosition;\n\tend;\n\n\tmethod enableRuleFiredRecording();\n\t\truleFiredRecordingEnableFlag = 1;\n\tend;\n\n\tmethod disableRuleFiredRecording();\n\t\truleFiredRecordingEnableFlag = 0;\n\tend;\n\n\tmethod initRuleFireHashes();\n\t\tif null(ruleFireFlagOffsetHash) then do;\n\t\t\truleFireFlagOffsetHash = _new_ [this] hash();\n\t\t\truleFireFlagOffsetHash.keys([RULE_ID]);\n\t\t\truleFireFlagOffsetHash.data([RULE_ID ruleFiredFlagPosition]);\n\t\t\truleFireFlagOffsetHash.defineDone();\n\t\t\truleFireFlagOffsetHash.clear();\n\t\tend;\n\t\truleFiredFlagPosition = ruleFiredBasePosition;\n\t\tRULE_ID = 'da5a5617-ebc8-4864-a18d-fd6c29acc5be';\n\t\truleFireFlagOffsetHash.ref();\n\t\truleFiredFlagPosition = ruleFiredFlagPosition+1;\n\t\tRULE_ID = '8d72248c-3e73-4ff7-af18-9015ada4ab8e';\n\t\truleFireFlagOffsetHash.ref();\n\t\truleFiredFlagPosition = ruleFiredFlagPosition+1;\n\tend;\n\n\t/* ---- RULE FIRED FLAG COUNT = 2 ---- */\n\tmethod getRuleFiredFlagCount() returns integer;\n\t\treturn 2 ;\n\tend;\n\n\tmethod recordRuleFired(\n\t\tin_out char ruleFiredFlags,\n\t\tin_out integer rulesFiredForRecordCount,\n\t\tchar(36) this_rule_id);\n\n\t\tif not(RuleFiredRecordingEnableFlag) then return;\n\t\tif (null(ruleFireFlagOffsetHash) = 0) then do;\n\t\t\tRULE_ID = this_rule_id;\n\t\t\tif (ruleFireFlagOffsetHash.find() = 0) then do;\n\t\t\t\tif (ruleFiredFlagPosition > 0) then do;\n\t\t\t\t\tsubstr(ruleFiredFlags,ruleFiredFlagPosition,1) = '1';\n\t\t\t\t\trulesFiredForRecordCount = sum(rulesFiredForRecordCount,1);\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\n\tmethod DataGrid_Clear(package datagrid aGrid)\n\t\treturns int;\n\t\taGrid.clear();\n\t\treturn 0;\n\tend;\n\n\tmethod DataGrid_toString(package datagrid aGrid)\n\t\treturns varchar;\n\t\treturn aGrid.serialize();\n\tend;\n\n\tmethod DataGrid_addRow(package datagrid aGrid)\n\t\treturns int;\n\t\tdcl int res rowCnt;\n\t\trowCnt = 0;\n\t\tres = aGrid.rowAdd();\n\t\tif (res = 0) then\n\t\trowCnt = aGrid.rowCount();\n\t\treturn rowCnt;\n\tend;\n\n\tmethod DataGrid_addRow(package datagrid aGrid, int numberOfRows)\n\t\treturns int;\n\t\tdcl int res rowCnt;\n\t\trowCnt = 0;\n\t\tres = aGrid.rowAdd(numberOfRows);\n\t\tif (res = 0) then\n\t\trowCnt = aGrid.rowCount();\n\t\treturn rowCnt;\n\tend;\n\n\tmethod DataGrid_columnExists(package datagrid aGrid,\n\t\tvarchar(255) col_name)\n\t\treturns int;\n\t\tif (aGrid.columnExists(col_name)) then do;\n\t\t\treturn aGrid.columnIndex(col_name);\n\t\tend;\n\t\treturn 0;\n\tend;\n\n\tmethod DataGrid_addCharacterColumn(package datagrid aGrid,\n\t\tvarchar(255) col_name)\n\t\treturns int;\n\t\treturn aGrid.columnAddCharType(col_name);\n\tend;\n\n\tmethod DataGrid_Set(package datagrid aGrid,\n\t\tvarchar(255) col_name,\n\t\tint row_index,\n\t\tvarchar(32767) value)\n\t\treturns int;\n\t\treturn aGrid.setValue(col_name, row_index, value);\n\tend;\n\n\tmethod initRdsp();\n\tend;\n\n\tmethod execute( in_out varchar \"r_char\",double \"r_int\",double \"r_number\",in_out package datagrid \"r_dg_out\",in_out char \"ruleFiredFlags\",in_out integer \"rulesFiredForRecordCount\");\n\t\tdcl double \"dg_index\";\n\n\t\t;\n\t\tif (\"r_char\" = 'Foundation') then do;\n\t\t\trecordRuleFired(ruleFiredFlags,rulesFiredForRecordCount,'da5a5617-ebc8-4864-a18d-fd6c29acc5be');\n\t\t\tif (DataGrid_columnExists(\"r_dg_out\",'r1_char_col') = 0) then do;\n\t\t\t\tDataGrid_addCharacterColumn(\"r_dg_out\",'r1_found_col');\n\t\t\tend;\n\t\t\tdg_index=DataGrid_AddRow(r_dg_out);\n\t\t\tDataGrid_Set(\"r_dg_out\",'r1_found_col', dg_index,'1 found');\n\t\t\tgoto \"end_da5a5617-ebc8-4864-a18d-fd6c29acc5be\";\n\t\tend;\n\t\telse do;\n\t\t\trecordRuleFired(ruleFiredFlags,rulesFiredForRecordCount,'8d72248c-3e73-4ff7-af18-9015ada4ab8e');\n\t\t\tif (DataGrid_columnExists(\"r_dg_out\",'r1_char_col') = 0) then do;\n\t\t\t\tDataGrid_addCharacterColumn(\"r_dg_out\",'r1_found_col');\n\t\t\tend;\n\t\t\tdg_index=DataGrid_AddRow(r_dg_out);\n\t\t\tDataGrid_Set(\"r_dg_out\",'r1_found_col', dg_index,'1 NOT found');\n\t\tend;\n\n\t\t\"end_da5a5617-ebc8-4864-a18d-fd6c29acc5be\":\n\n\t\trule_end: /* label for rule RETURN action */\n\tend;\n\n\tmethod term();\n\t\tif (null(ruleFireFlagOffsetHash) = 0) then ruleFireFlagOffsetHash.clear();\n\tend;\n\n\t/* {PACKAGE_END} */\nendpackage;\n\nDS2_OPTIONS LOGICALEXPR = STANDARD;\nDS2_OPTIONS SCOND = WARNING;\nDS2_OPTIONS MISSING_NOTE;\n\nthread brm_rules_execution_thread / inline;\n\tdcl package BRM_51_ruleset_0 ruleset();\n\tdcl integer \"rulesfiredforrecordcount\" having label 'Rules Fired Count';\n\tdcl char(36) \"_recordCorrelationKey\";\n\n\tdcl char(2) \"ruleFiredFlags\";\n\n\tdcl package datagrid \"r_dg_out_grid\" ('r_dg_out_grid');\n\tdcl varchar(10485760) \"r_dg_out\";\n\n\tdcl double \"r_int\";\n\tdcl double \"r_number\";\n\n\tretain \"rulesfiredforrecordcount\" 0;\n\n\tkeep \"rulesfiredforrecordcount\" \"_recordCorrelationKey\" \"ruleFiredFlags\" \"r_dg_out\";\n\tmethod resetruleFiredCounts( in_out char \"ruleFiredFlags\", in_out integer \"rulesfiredforrecordcount\");\n\t\truleFiredFlags = '';\n\n\t\t\"rulesfiredforrecordcount\"=0;\n\tend;\n\n\tmethod init();\n\n\t\truleset.enablerulefiredrecording();\n\t\truleset.setRuleFiredBasePosition(1);\n\t\truleset.initrulefirehashes();\n\t\tresetruleFiredCounts( \"ruleFiredFlags\", \"rulesfiredforrecordcount\");\n\n\tend;\n\n\t/* output execution thread code*/\n\tmethod run();\n\t\tdcl int localRC;\n\t\tset \"Public\".\"HMEQ_10\" (\n\t\tkeep=(\"LOAN\" \"REASON\" \"VALUE\" )\n\t\trename=( \"LOAN\"=\"r_number\"\n\t\t\"VALUE\"=\"r_int\"\n\t\t\"REASON\"=\"r_char\"\n\t\t) );\n\n\t\tresetruleFiredCounts(\"ruleFiredFlags\", \"rulesfiredforrecordcount\");\n\n\t\tlocalRC = ruleset.DataGrid_clear(\"r_dg_out_grid\");\n\n\t\truleset.execute(\n\t\t\"r_char\"\n\t\t, \"r_int\"\n\t\t, \"r_number\"\n\t\t, \"r_dg_out_grid\"\n\t\t, \"ruleFiredFlags\"\n\n\t\t, \"rulesFiredForRecordCount\");\n\t\t\"_recordCorrelationKey\" = uuidgen();\n\n\t\t\"r_dg_out\" = ruleset.DataGrid_toString(\"r_dg_out_grid\");\n\n\t\toutput;\n\tend;\nendthread;\n\nDS2_OPTIONS MSGORDER = STANDARD;\nDS2_OPTIONS LOGICALEXPR = STANDARD;\nDS2_OPTIONS SCOND = WARNING;\nDS2_OPTIONS MISSING_NOTE;\n\ndata \"Public\".\"ppn_rs1_Test_ppn_rs1_2024-07-01_06-44-38_output\" (overwrite=yes);\n\n\tdcl thread brm_rules_execution_thread _t;\n\tmethod run();\n\t\tset from _t threads=4;\n\t\toutput;\n\tend;\nenddata;\n",3 "codeType": "text/vnd.sas.source.ds2",4 "outputTableName": "ppn_rs1_Test_ppn_rs1_2024-07-01_06-44-38_output",5 "outputLibraryName": "Public",6 "version": 17}
Request containing hints and mappings to generate Mapped Code not bound to a score definition.
Name | Type | Required | Description |
---|---|---|---|
mappings | array [Mapping] | false | Array of mappings between Score Object variables and the table the code will be executed against. |
hints | object | false | Hints for generating the code. Hints are specific to the type of object which the code is being requested for. |
Status | Meaning | Description | ||
---|---|---|---|---|
200 | OK | The request succeeded. | Headers | Schema |
400 | Bad Request | The request was invalid. | Schema |