smusba
16th September 2008, 10:42
Dear All,

see the code below. I want to accumulate this code in only one if block.
Please guide me thru the process.

if tcmcs910.type = tctype.perc then
element=lc.element.method1()
ele.pur.cur = (tdpur045.amnt*tdpur910.valu)/100
lc.curr = tdpur040.ccur
if tdpur040.ratf = 0 then
tdpur040.ratf = 1
endif
lc.rate = tdpur040.ratp/tdpur040.ratf
lc.rate.hist = tdpur040.ratp
lc.ratf.hist = tdpur040.ratf
insert.lc.history()
post.to.finance(1)
else
element=lc.element.method2()
ele.pur.cur = wt.element.value()
lc.curr = tdpur910.curr
if i.ratf = 0 then
i.ratf = 1
endif
lc.rate = i.ratp/i.ratf
lc.rate.hist = i.ratp
lc.ratf.hist = i.ratf
insert.lc.history()
post.to.finance(1)


endif

|if tcmcs910.type = tctype.perc then
|element=lc.element.method3()
|ele.pur.cur = (tdpur045.amnt*tdpur910.valu)/100
|lc.curr = tdpur040.ccur
|if tdpur040.ratf = 0 then
| tdpur040.ratf = 1
|endif
|lc.rate = tdpur040.ratp/tdpur040.ratf
|lc.rate.hist = tdpur040.ratp
|lc.ratf.hist = tdpur040.ratf
|insert.lc.history()
|post.to.finance(1)

|endif

mark_h
16th September 2008, 21:25
Without knowing the code or the subroutines this would be my guess.

| Assuming that lc.element.method2 and wt.element.value only return
| some values.
element=lc.element.method2()
ele.pur.cur = wt.element.value()
lc.curr = tdpur910.curr
if i.ratf = 0 then
i.ratf = 1
endif
lc.rate = i.ratp/i.ratf
lc.rate.hist = i.ratp
lc.ratf.hist = i.ratf
if tcmcs910.type = tctype.perc then
element=lc.element.method1()
ele.pur.cur = (tdpur045.amnt*tdpur910.valu)/100
lc.curr = tdpur040.ccur
if tdpur040.ratf = 0 then
tdpur040.ratf = 1
endif
lc.rate = tdpur040.ratp/tdpur040.ratf
lc.rate.hist = tdpur040.ratp
lc.ratf.hist = tdpur040.ratf
endif
insert.lc.history()
post.to.finance(1)


Not sure if this is what you are looking for or not.

smusba
17th September 2008, 10:28
Dear Mark,

No, this is not my soln.

See there are 3 methods. Method 1 and Method 2 is in same if block.
I want method3 also in same if block.

mark_h
17th September 2008, 15:43
I see nothing to distinguish method3 from method1. From the original code both get executed if tcmcs910.type = tctype.perc. So in that case it would look like this:

element=lc.element.method2()
ele.pur.cur = wt.element.value()
lc.curr = tdpur910.curr
if i.ratf = 0 then
i.ratf = 1
endif
lc.rate = i.ratp/i.ratf
lc.rate.hist = i.ratp
lc.ratf.hist = i.ratf
if tcmcs910.type = tctype.perc then
element=lc.element.method1()
ele.pur.cur = (tdpur045.amnt*tdpur910.valu)/100
lc.curr = tdpur040.ccur
if tdpur040.ratf = 0 then
tdpur040.ratf = 1
endif
lc.rate = tdpur040.ratp/tdpur040.ratf
lc.rate.hist = tdpur040.ratp
lc.ratf.hist = tdpur040.ratf

insert.lc.history()
post.to.finance(1)

element=lc.element.method3()
ele.pur.cur = (tdpur045.amnt*tdpur910.valu)/100
lc.curr = tdpur040.ccur
if tdpur040.ratf = 0 then
tdpur040.ratf = 1
endif
lc.rate = tdpur040.ratp/tdpur040.ratf
lc.rate.hist = tdpur040.ratp
lc.ratf.hist = tdpur040.ratf


endif
insert.lc.history()
post.to.finance(1)

Note I assumed the lc.element.method routines set tdpur table fields, otherwise you can remove some duplicate lines of code.