× Discuss on any other topics

calculate a value in in a multi value set

  • safzalhussain
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 9 months ago - 9 years 9 months ago #16892 by safzalhussain
calculate a value in in a multi value set was created by safzalhussain
multi value set

Broker.No.1
Quantity.Recvd.1
Broker.Price.1

Broker.No.2
Quantity.Recvd.2
Broker.Price.2

Broker.No.3
Quantity.Recvd.3
Broker.Price.3

L.Broker.Amount.1
L.Broker.Amount.2
L.Broker.Amount.3

Requirement: if user enter amount in L.Broker.Amount field then on validating a DEAL, system should calculate field PRICE.1 based on Quantity.Recvd1
i.e. Price=L.Broker.Amount/Quantity.Recvd

I have write BELOW Mentioned routine and called it in field validation of Price field in a version but facing below mentioned issues:


$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.SC.EXE.SEC.ORDERS
CALL GET.LOC.REF("SC.EXE.SEC.ORDERS","L.BROKER.AMOUNT",L.BROKER.AMOUNT.POS)
Y.TOT.CNT = DCOUNT(R.NEW(SC.ESO.BROKER.NO),VM)
FOR I.BT = 1 TO Y.TOT.CNT
R.NEW(SC.ESO.PRICE)<1,I.BT> = R.NEW(SC.ESO.LOCAL.REF)<1,L.BROKER.AMOUNT.POS,I.BT>/R.NEW(SC.ESO.NOMINAL.RECD)<1,I.BT>
NEXT I.BT
CALL REBUILD.SCREEN
RETURN
END


Problem:1 system is calculating price if two multivalue set of broker is open for 1 L.Broker.Amount field, then user has to remove Last multi value set to make 1 to 1 combination of values.

Similarly, system is calculating price if 3 multivalued set of broker is open for 2 L.Broker.Amount field, then user has to remove Last multivalue set to make 2 of 2 combination of values.

and so on case for more then 2 combinations.

Query : what should i do so that user don't have to open extra multivalue set

Problem:2 On validating a DEAL, system calculates a price and this value also viewable in the field as well, but system is not saving this price on committing a deal.
If User click on a PRICE field, remove last digit and then enter the same digit in a field, now system save the record while committing a deal.

Query: why system is not saving a price field directly at first time WITHOUT entering any modification in value.
Last edit: 9 years 9 months ago by safzalhussain.

Please Log in or Create an account to join the conversation.

  • armin
  • armin's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • “So long - and thanks for all the fish!”
More
9 years 9 months ago #16893 by armin
Replied by armin on topic calculate a value in in a multi value set
Why not attaching the routine to your local field and trigger calculation only for one broker at a time ?
This might also solve your second problem.
And keep in mind that there are other price types, e.g. percentage ...
$INSERT I_COMMON
$INSERT I_EQUATE
$INSERT I_F.SC.EXE.SEC.ORDERS
$INSERT I_F.SECURITY.MASTER
$INSERT I_F.PRICE.TYPE
 
IF COMI THEN
    R.NEW(SC.ESO.LOCAL.REF)<1,AV,AS> = COMI
END

AMOUNT  =  R.NEW(SC.ESO.LOCAL.REF)<1,AV,AS>
NOMINAL = R.NEW(SC.ESO.NOMINAL.RECD)<1,AS>

IF AMOUNT THEN     ;* to avoid divide by zero
    CALL DBR("SECURITY.MASTER":FM:SC.SCM.PRICE.TYPE,R.NEW(SC.ESO.SECURITY.NO),PRICE.TYPE)
    R.PRICE.TYPE = ''
    F.PRICE.TYPE = ''
    CALL OPF('F.PRICE.TYPE',F.PRICE.TYPE)
    CALL F.READ('F.PRICE.TYPE',PRICE.TYPE,R.PRICE.TYPE,F.PRICE.TYPE,ER)
    PERCENTAGE = R.PRICE.TYPE<SC.PRT.PERCENTAGE>
    IF PERCENTAGE = "Y" THEN PERC.FACTOR = 100 ELSE PERC.FACTOR = 1
    MULT.FACTOR = R.PRICE.TYPE<SC.PRT.MULTIPLY.FACTOR>

    R.NEW(SC.ESO.PRICE)<1,AS> = ((AMOUNT / NOMINAL) / MULT.FACTOR)  * PERC.FACTOR
    * round the price to significant decimals ...   
    CALL REBUILD.SCREEN
END
RETURN

END

using R11 on Unix

Please Log in or Create an account to join the conversation.

  • safzalhussain
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 9 months ago #16901 by safzalhussain
Replied by safzalhussain on topic calculate a value in in a multi value set
attaching routine to local field ..did worked...

Thanks for the support.

God Bless You!!!!

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds