drcelus
24th July 2013, 11:30
Is it possible to block a sales order from within a report script ?
We have a trivial requirement where we have to check whether some SO addresses match and if not, ideally block or warn the user about it.
No dev license here so I can only customize report scripts, that's why I was wondering if there is a function for blocking that I could use within a report.
Regards.
bhushanchanda
24th July 2013, 11:43
Hi,
From your profile, I will assume you are on LN. So, you can go for DAL to do this. We use DAL to block users while entering the records i.e. if some condition is not met, users are not allowed to enter the record. You can use dal for blocking SO approval as well. Its not necessary to use the report script and anyway, the report is printed after the record is saved.
In case, if you want to warn users, this can be done through DAL as well.
drcelus
24th July 2013, 12:19
Thanks Bhushan, but please note that I do not have a dev license at the moment so I can't touch DAL, since AFAIK you do need it to compile DAL objects.
Please correct me if I am wrong.
bhushanchanda
24th July 2013, 12:43
Does that mean you can't create your own scripts and customization's? I guess, you can create your own scripts and compile them and you cant modify or view the standard scripts. Right? So, you just need to add a DAL for the standard table and put the locks in there. If you want to know how, I can give you an example for that. But, let me know first, if you can create your scripts and compile them or not?
drcelus
26th July 2013, 11:35
No, I can't compile anything other than report scripts.
vamsi_gujjula
26th July 2013, 12:49
ttstpbaandoc run this for the documentation of dlls and objects. may b you can get a extern function to suffice your requirement
bhushanchanda
26th July 2013, 13:02
Pheww..
I can't imagine a life without customizations ;) That might be hec.
vamsi_gujjula
26th July 2013, 13:08
But Bhushan there might b Admin(application and DB) part still with out customization..
anyway i got one dll tdslsdll0091
mark_h
26th July 2013, 16:58
You would be amazed at what you can do in report scripts. I build several tables alone in report scripts. As a matter of fact I have used the reports from SQL queries to actually fix/update/delete problem records. So my answer to the original question is yes - what I can't do is give any code since this is ln and we don't use sales table so I do not know how to block an order. As a matter of fact I used to run AFS code(don't really recommend it) in a report to build some JV transactions from a summary report. They decided they wanted to review them first - so I pulled the code and now write to a table.
Bottom line is you can do I whole lot in a report script - I don't know about calling something in DAL, but you can call libraries. I do not know if LN is different or if our development license grants us more permissions.
bhushanchanda
26th July 2013, 18:46
Ok,
I just tried to use DAL within report script but its not possible. And, as drcelus said, he cant create scripts hence, he wont be able to create libraries (DLL's) as well. Right? So, calling a customized library is not an option.
Now, blocking sales order within report script will again depend on the parameter setup done by the functional people, like before approval of SO, the SO should be printed. Well, in our case, if SO is created no report is printed, the second is Approval where no report is printed and then its released to warehouse. And I guess, it will be too late to block it until then. So, first thing required will be to set the correct parameters for doing this.
The second way can be by Table data authorization. Like you can set conditions on tdsls400 table. I am not sure, what exactly is the requirement. Where should the block be applied?
Mark, correct me if I am wrong in assuming the above things. I am not aware of the dev licence thing so don't know how much work can be done and how it can be done.
abattoir
26th July 2013, 18:54
Hi,
You can use User exit DLL, assuming that when you say "you dont have development license" you actually mean that you cannot compile or change any standard scripts, DLL's, DAL's. But you can create your own customize Session, Script right? If that is the case, then blocking sales order can easily be done using UE DLL. Check programmers guide for its overview.
"A User Exit DLL (UEDLL) is a DLL that will reside outside the standard software. It will have the same name as a standard DAL with the extension 'ue' (for 'user exit'). E.g. 'whinh200ue' for table whinh200. Customers can implement a UEDLL in order to be able to define extra business logic before and after the standard 'before' and 'after' handling of saves and deletes, by means of specific hooks that will be executed by the 4GL engine and/or DAL Engine. In this way it is possible to e.g. conditionally publish data changes to the outside world."
Regards,
Ankur
bhushanchanda
26th July 2013, 19:22
Hi Abattoir,
I already gave that option but, as he said,
Drcelus Said:
No, I can't compile anything other than report scripts.
I don't think he can create any scripts.
mark_h
27th July 2013, 00:09
In the dev/test company in the report script you could just try something like this:
db.retry.point()
select tppss990.*
from tppss990 for update
where tppss990.code <>" "
selectdo
tppss990.code = " "
db.update(ttppss990,db.retry)
commit.transaction()
endselect
Here is something else you can try:
|******************************************************************************
declaration:
long count, up.error
string error.msg(120)
#pragma used dll ottstpapihand
before.program:
count = get.compnr()
testit()
functions:
function testit()
{
stpapi.put.field("tccom1101m000","tccom010.cuno","SOMECUST")
count = stpapi.find("tccom1101m000",error.msg)
if count = 1 then
message(" Record Found ")
stpapi.put.field("tccom1101m000","tccom010.nama","Cust Name1")
stpapi.put.field("tccom1101m000","tccom010.ccur","USD")
up.error = 0
up.error = stpapi.update("tccom1101m000",true,error.msg)
message("%s error.msg ",error.msg)
endif
stpapi.end.session("tccom1101m000")
}
I mean the only true way to figure out what you can and can't do is try it. So for example if you passed production order number to print in the detail layout - then in the before or after layout section you could select tisfc001.* for the production order number and update the record for what ever reason.
vamsi_gujjula
27th July 2013, 09:22
I do agree.....with mark....one can play around with it..... and coming back to blocking thing.....I hope he has done it.......after all these alternatives.. :p
vahdani
27th July 2013, 12:47
Hi drcelus,
you have to fill tdsls420 using DAL in LN-FP8.
Use something like the following in your report script:
declaration:
long g.ret
domain tcmcs.str132m g.emsg
#include <bic_dam>
before.xyz.1:
before.layout:
|block your order using tdsls420 DAL
db.retry.point()
g.emsg = ""
select tdsls420.*
from tdsls420
where tdsls420.orno = :your.order.number
selectdo
selectempty
dal.new.object("tdsls420")
dal.set.field("tdsls420.orno", your.order.number)
dal.set.field("tdsls420.hrea", your.reason.code)
|... fill other fields if required
g.ret = dal.save.object("tdsls420")
if g.ret <> 0 then
abort.transaction()
dal.get.error.message(g.emsg)
endif
endselect
commit.transaction()
bhushanchanda
28th July 2013, 07:16
Oh, it was bic_dam. I was trying bic_dal and was not allowing me. Learnt something new. Never knew, bic_dam can be used for DAL functions. I thought it was just for the progress indicators.
When writing a Data Access Layer, you must include bic_dal. To use progress indicators and Data Access Methods in your UI, you must include bic_dam.
This is what I found the the manual's.
So, this means, its a Data Access Method and not Data Access Layer.
drcelus
9th September 2013, 15:43
Hi drcelus,
you have to fill tdsls420 using DAL in LN-FP8.
Use something like the following in your report script:
declaration:
long g.ret
domain tcmcs.str132m g.emsg
#include <bic_dam>
before.xyz.1:
before.layout:
|block your order using tdsls420 DAL
db.retry.point()
g.emsg = ""
select tdsls420.*
from tdsls420
where tdsls420.orno = :your.order.number
selectdo
selectempty
dal.new.object("tdsls420")
dal.set.field("tdsls420.orno", your.order.number)
dal.set.field("tdsls420.hrea", your.reason.code)
|... fill other fields if required
g.ret = dal.save.object("tdsls420")
if g.ret <> 0 then
abort.transaction()
dal.get.error.message(g.emsg)
endif
endselect
commit.transaction()
Sorry for the late answer.
This works also for LN FP5, thank you vahdani .
I will have to check error reporting for those DAL functions but this is definitely the way to go.
sona@-@
13th October 2013, 14:20
Thanks for sharing.