smusba
25th November 2014, 15:33
I want to restrict user from decreasing the price from Sales Order Price field which by default get the prices from Price Book; any how I want to give them the authority to increase the price when needed. So, I created a User Exit dll as below which is not working.

function extern long ue.before.before.save.object(long mode) {
on case mode
case DAL_NEW:
domain tcsess calling.session
import("prog.name$", calling.session)
if (calling.session = "tdsls4100m900") then
select tdpcg031.*
from tdpcg031
where tdpcg031._index1 = {:1,"10000006",:tdsls401.item}
order by tdpcg031.exdt desc
as set with 1 rows
selectdo
if tdsls401.pric < tdpcg031.bapr then
else
dal.set.error.message("tigenstring","Updating processed records not allowed")
return(DALHOOKERROR)
endif
endif
endselect
break
return(0)
case DAL_UPDATE:
break
endcase
return(0)
}

soumya093
25th November 2014, 16:06
Hi
You have to write the same in DAL_UPDATE

bhushanchanda
25th November 2014, 17:23
Hi,

As said, you need a DAL_UPDATE section to capture modifications after saving.

Also, if you want to give the error if price is below the price book price then the following will go wrong.

if tdsls401.pric < tdpcg031.bapr then
else
dal.set.error.message("tigenstring","Updating processed records not allowed")
return(DALHOOKERROR)
endif

You can use this

if tdsls401.pric < tdpcg031.bapr then | or if double.cmp( tdsls401.pric, tdpcg031.bapr, 0.0001 ) = 1 then
dal.set.error.message("tigenstring","Updating processed records not allowed")
return(DALHOOKERROR)
endif

smusba
25th November 2014, 18:26
Should I make this in Customised VRC or standard VRC
as tdsls401ue

smusba
25th November 2014, 18:27
Is my logic right?

bhushanchanda
25th November 2014, 21:13
Hi,

As suggested write the same in DAL_UPDATE section as well and also try making the change I suggested.

Do it in your customized VRC.

smusba
26th November 2014, 08:12
What should be the Script Type."General" , "DAL" or other.

bhushanchanda
26th November 2014, 08:32
Hi,

Just create a new script with name tdsls401ue and the type will be set by default.

smusba
26th November 2014, 09:16
Created. but the above script is not able to select anything from
select tdpcg031.*
from tdpcg031
where tdpcg031._index1 = {1,"10000006",:tdsls401.item}
and tdpcg031.efdt <=:tdsls401.odat
order by tdpcg031.efdt desc
as set with 1 rows

smusba
26th November 2014, 09:59
Its working fine with the below code.
|******************************************************************************
|* tdsls401ue 0 VRC B61U a sfc
|* Sales Price Increase Authorization
|* baan
|* 14-11-25 [14:28]
|******************************************************************************
|* Script Type: Library
|******************************************************************************
|declaration:

table ttdsls401
table ttdpcg031

#include <bic_dal>


function extern long ue.before.before.save.object(long mode)
{
on case mode
case DAL_NEW:
domain tcsess calling.session
import("prog.name$",calling.session)
if (calling.session = "tdsls4100m900") then
|read.tdsls401()
select tdpcg031.*
from tdpcg031
where tdpcg031._index1 = {1,"100000006",:tdsls401.item}
and tdpcg031.efdt<=:tdsls401.odat
and tdpcg031.exdt>=:tdsls401.odat
order by tdpcg031.exdt desc
as set with 1 rows
selectdo
if logname$ <> "baan" or logname$ <> "yousri_d" then
else
if tdpcg031.bapr >= tdsls401.pric then
dal.set.error.message("@You are not authorised to decrease the Sales Order Price")
return(DALHOOKERROR)
else
endif

endif
endselect
endif

break
case DAL_UPDATE:
|read.tdsls401()
select tdpcg031.*
from tdpcg031
where tdpcg031._index1 = {1,"100000006",:tdsls401.item}
and tdpcg031.efdt<=:tdsls401.odat
and tdpcg031.exdt>=:tdsls401.odat
order by tdpcg031.exdt desc
as set with 1 rows
selectdo
if logname$ <> "baan" or logname$ <> "yousri_d" then
else
if tdpcg031.bapr >= tdsls401.pric then

dal.set.error.message("@You are not authorised to decrease the Sales Order Price")
return(DALHOOKERROR)
else
endif

endif
endselect
break
endcase
return(0)


}

function extern long ue.after.before.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.before.after.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.after.after.save.object(long mode)
{
on case mode
case DAL_NEW:


break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.before.before.destroy.object()
{
return(0)
}

function extern long ue.after.before.destroy.object()
{
return(0)
}

function extern long ue.before.after.destroy.object()
{
return(0)
}

function extern long ue.after.after.destroy.object()
{
return(0)
}

smusba
26th November 2014, 10:01
I want to show the Fianance user the MAUC price when they want to decrease the price.

I have written select whina137.* statement
but how can I popup a message for finance user if they want to decrese the price.

dal.set.message("MAUC Price %d", mauc.pri) is showing error.

sachinbaan
26th November 2014, 10:59
hi,

dal.set.message() will push your message to buffer, to pop up message box use dal.set.error.message() and return(DALHOOKERROR), and strat your message with "@".

smusba
26th November 2014, 11:10
If I use dal.set.error.message and return(DALHOOKERROR) the message is displayed but Im not able to change the required price.

bhushanchanda
26th November 2014, 13:51
Hi,

Use,
dal.set.info.message("@your_message")
show.dal.messages(MSG.INFO)


Related Thread (http://www.baanboard.com/baanboard/showthread.php?t=65393)

smusba
26th November 2014, 14:53
Thanks a lot Mr. Bhushan,

The problem with this message is it appears but minimize at the same time.
Any other dal.message where it will appear on top of the screen.

bhushanchanda
26th November 2014, 15:12
Hi,


Try this,

dal.set.warning.message("Your message")
show.dal.messages (MSG.WARNING)

smusba
28th November 2014, 14:12
Thanks a ton bhushan

smusba
30th November 2014, 07:52
I want to add one more thing in the script.

If any Sales Order line is having tdpur401.disc then tdpur401.pric should be same as tdpcg031.bapr