Accessing Staged Field Values

The following application class code illustrates how to reference data elements that reside at the Staging level.

Note:

In the following code, only the code formatted in bold can be changed by the developer. Rest of the code is required to successfully run or reference staging field values.

import SCC_FILE_PARSER:UTIL:FieldCalculationAbstract;
import SCC_FILE_PARSER:MODEL:Results:ResultsField;
import SCC_FILE_PARSER:MODEL:Results:ResultsRecord;
import SCC_FILE_PARSER:MODEL:Results:ResultsCollection;
import SCC_FILE_PARSER:UTIL:Exception:FileParserException;
/**
* class FetchDegreeDescr
*
* @version 1.0
* @author Your Institution
*
* Module: Your Application
* Description: Your Description
*/
/**
* This Application Class is designed to read the incoming Degree value 
* residing on the mapped/staged Record Definition: SCC_STG_EXTDEGR, Field: DEGREE, 
* and then obtain the description from the table PS_DEGREE_TBL.
*
* If found, pass back the description, else pass back the string ’NOT FOUND’.
*/
class FetchDegreeDescr extends SCC_FILE_PARSER:UTIL:FieldCalculationAbstract
/* public methods */
method FetchDegreeDescr();
method calculateValue(&ResultsFieldIn As SCC_FILE_PARSER:MODEL:Results:ResultsField,
&ResultsCollectionIn As SCC_FILE_PARSER:MODEL:Results:ResultsCollection) Returns any;
private
method GetFileData();
method GetFieldReferences();
instance string &Degree;
instance string &DegreeDescrOut;
instance SCC_FILE_PARSER:MODEL:Results:ResultsField &ResultsField;
instance SCC_FILE_PARSER:MODEL:Results:ResultsCollection &ResultsCollection;
instance SCC_FILE_PARSER:MODEL:Results:ResultsField &DegreeField;
end-class;
/**
* Instantiate the App. Class.
*/
method FetchDegreeDescr
%Super = create SCC_FILE_PARSER:UTIL:FieldCalculationAbstract();
end-method;
/**
* This method is the main driver that passes back the derived value.
*/
method calculateValue
/+ &ResultsFieldIn as SCC_FILE_PARSER:MODEL:Results:ResultsField, +/
/+ &ResultsCollectionIn as SCC_FILE_PARSER:MODEL:Results:ResultsCollection +/
/+ Returns Any +/
/+ Extends/implements SCC_FILE_PARSER:UTIL:FieldCalculationAbstract.CalculateValue +/
&ResultsCollection = &ResultsCollectionIn;
&ResultsField = &ResultsFieldIn;
%This.GetFileData();
/**
* Pass back the derived value to the field calling this Calculated Application Class.
*/
Return &DegreeDescrOut;
end-method;
/**
* This method uses the obtained degree value as the key in the criteria to obtain the
* description from the table PS_DEGREE_TBL.
*/
method GetFileData
Local string &DegreeDescr;
/**
* Call the method GetFieldReferences to obtain the incoming degree value.
*/
If &DegreeField = Null Then
%This.GetFieldReferences();
End-If;
&Degree = "";
/**
* Test to see if we found a degree value. If so, execute the SQL statement to 
* obtain the description.
*/
If &DegreeField <> Null Then
&Degree = &DegreeField.FieldValue;
SQLExec("SELECT A.DESCR FROM PS_DEGREE_TBL A WHERE A.DEGREE =:1 AND A.EFF_STATUS =
’A’ AND A.EFFDT = (SELECT MAX(A1.EFFDT) FROM PS_DEGREE_TBL A1 WHERE A1.DEGREE =
A.DEGREE AND A1.EFFDT <= %DateIn(:2))", &Degree, %Date, &DegreeDescr);
/**
* Test to see if we found a degree description. If so, assign the value to be 
* passed back.
* Otherwise, assign the text string ’NOT FOUND’.
*/
If &DegreeDescr = "" Then
&DegreeDescrOut = "NOT FOUND";
Else
&DegreeDescrOut = &DegreeDescr;
End-If;
End-If;
end-method;
method GetFieldReferences
Local integer &SegmentNbr;
Local integer &RecordRow;
Local SCC_FILE_PARSER:MODEL:Results:ResultsRecord &obj_SCC_STG_EXTDEGR;
&SegmentNbr = &ResultsField.ResultsRecord.SegmentNbr;
&RecordRow = &ResultsField.ResultsRecord.RecordRow;
/**
* Establish a reference to the staging record definition 
* containing the incoming mapped field.
*/
&obj_SCC_STG_EXTDEGR = &ResultsCollection.GetResultsRecord(&SegmentNbr,
"SCC_STG_EXTDEGR", &RecordRow);
/**
* If the reference exists, establish a reference to the staging mapped field.
*/
If &obj_SCC_STG_EXTDEGR <> Null Then
&DegreeField = &obj_SCC_STG_EXTDEGR.GetResultsField("DEGREE");
End-If;
end-method;