Validation routine in a Version

Posted by

In a version, you can manipulate fields contents by using a validation routine. It is defined in a version using the two fields: 58. 1 VALIDATION.FLD 59. 1 VALIDATION.RTN where VALIDATION.FLD is the field that should -once populated- trigger a routine, and VALIDATION.RTN is the routine name.

Multiple utilization examples such as:

	- once field X is filled, feed field Y with the result of any formulae
	- once field X is filled, feed field Y with the content of another fields from another table
	- etc...

Such a routine does not need arguments. Special reserved keywords to be used: AF = the current field number, matching VALIDATION.FLD AV = the current sub-value marker, matching VALIDATION.FLD (if applied) COMI = the value currently input in the current field by the user. R.NEW(field_name) = the content of other field_names already input by the user. Example: For FX option, once amount1 is input, calculate the alternate amount using the strike price

IF (R.NEW(DX.TRA.EXCHANGE.CODE) = "1" AND R.NEW(DX.TRA.TRADE.TYPE) = "OPTION" AND AF = DX.TRA.PRI.LOTS) THEN ;* e.g. all OTC Options
    AMOUNT1 = COMI
    CCY1 = R.NEW(DX.TRA.TRADE.CCY)
    STRIKE = R.NEW(DX.TRA.STRIKE.PRICE)
    CCY2 = R.NEW(DX.TRA.DLV.CCY)
    AMOUNT2 = ""
    CALL EXCHRATE("1", CCY1, AMOUNT1, CCY2, AMOUNT2, '', STRIKE,'','',RET.CODE)
    R.NEW(DX.TRA.PRI.DLV.AMT)<1,AV> = AMOUNT2
    CALL REBUILD.SCREEN
END

Once compiled, the routine must be: – declared in PGM.FILE – attached in a version in field 59.x using a @ prefix. Example:

   PGM.FILE            V.DX.RESET.COMM
------------------------------------------------------
 1 TYPE.............. S
 5 PRODUCT........... DX
 8. 1 APPL.FOR.SUBR.. DX.TRADE            Trade Entry
	VERSION
58. 1 VALIDATION.FLD. PRI.LOTS
59. 1 VALIDATION.RTN. @V.DX.RESET.COMM

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.