Ankita Patel
5th August 2013, 09:52
Hi All,

I have generated wrapper on standard script. and attached with main session.

now how to handle DAL Using wrapper ... For Ex.
from purchase contract line we can maintain delivery contracts
but for that we need to check delivery contract available checkbox on purchase contract lines

now i have generated wrapper on purchase contract lines.
the code for delivery contract is

function extern boolean tdpur3104m000.is.allowed()
{
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id)
}

but it will give error because of its return type boolean

now if I modify script like

function extern boolean tdpur3104m000.is.allowed()
{
boolean retval
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id,retval)

return(retval)
}

but this will return always false(0)

and if I comment the code
the option delivery contract is activate for all even if that checkbox is not checked.


anybody having idea how to handle it???

bhushanchanda
5th August 2013, 11:07
Hi,

function extern boolean tdpur3104m000.is.allowed()
{
boolean ret_val
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id, ret_val)
return(ret_val)
}

This was already generated with the wrapper. Why was there a need to modify anything?

Anyway, I guess there was some problem while creating the macro. Also, please clarify what your requirement is?

Ankita Patel
5th August 2013, 12:33
Hi,

When I have generated wrapper,return values are not come by its own ,here I have attached my code for your ref and also My requirement.

In standard Purchase contract line session delivery contract is enabled when delivery contract available checkbox is checked. otherwise it is disable.

I need to customize purchase contract for one of my system AMC so I have generated wrapper on standard script.


function extern boolean tdpur3104m000.is.allowed()
{
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id)
}

this code is generated in wrapper
to enable or disable delivery contract

now if I add return value as I specified above post

function extern boolean tdpur3104m000.is.allowed()
{
boolean retval
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id,retval)
return(retval)
}

then it will always return false so delivery contract is always disable for my customised system though I have checked that checkbox that is mendatory for delivery contract.

What is the issue with return value I dont know...

bhushanchanda
5th August 2013, 13:05
Hi ,

Did you tried changing it to ret_val?

I am not sure if that will work or not. But you can always play with these variables and you never know if it works.

Anyway, here's the wrapper I got.

Ankita Patel
5th August 2013, 14:09
ret_val also not working... :(

bhushanchanda
5th August 2013, 16:57
Hi,

We don't use Purchase Contract but I just created a test scenario with this wrapper script which I have attached. And the session works normally.

Have you done any other changes to the wrapper? I have still not understood what you are trying to do. You can attach the screen shots to show where the problem is.

Ankita Patel
6th August 2013, 07:42
Hi bhushan,

Here I have attached screen shots. I hope this will usefull to identify problem. this is only one case I have explained.if this will solved out,I'm able to resolve the other cases.

bhushanchanda
6th August 2013, 08:09
Hi ,

Make these changes:-

Declare table :- ttdpur301

And in the function make this change:-

function extern boolean tdpur3104m000.is.allowed()
{
boolean ret_val
parent.object.function.id = get_function(parent.object.dll.id, "boolean tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id, ret_val)


if tdpur301.dsch = tcyesno.yes then
return(TRUE)
else
return(FALSE)
endif
}

Let me know, if it helps. I tried at my end and its working.

Ankita Patel
6th August 2013, 08:26
Hi,

Its working ... :)

Thank you..

bhushanchanda
6th August 2013, 08:31
Good.

Be sure to check do this for other check boxes as well, if you are using them.

Anyways, glad that worked for you. :)

vamsi_gujjula
6th August 2013, 12:43
My question is why will it return false always..?

i have checked the same scenario on sales orders something like

Cancel.sales.order.

function extern boolean cancel.order.is.allowed()
{
domain tcbool ret.cancel.order.is.allowed

if order.type.is.dm1() then |#620261.sn
return(false)
endif |#620261.en
|#022415.sn
if not check.tms.status()then
return(false)
endif
|#022415.en
ret.val("cancel.order.is.allowed",ret.cancel.order.is.allowed) | macro
return(ret.cancel.order.is.allowed)
}


i get the return value false and true

vamsi_gujjula
6th August 2013, 12:54
i am not sure about the issue ... do face the issue for all tcbool fuctions...?
can you check with

parent.object.function.id = get_function(parent.object.dll.id, "tdpur3104m000.is.allowed")

one issue with the code of bhushan is that

the function return is always depends of

tdpur301.dsch not on the standard fuction.

bhushanchanda
6th August 2013, 13:06
Yes Vamsi,

I got a PM from her asking about the same thing. Yes, there might be number of references, tables, variables and fields on which the function returns the value.

But, it will be quite tedious or can be impossible to track if you don't have std. scripts.



Hi,


Its working well but what if we are not aware of the conditions of enabling & disabling commands .. as we are not having standard scripts at our side..

any idea to handle it ? as method.is.allowed is written in DAL2 and it is returning value according to some conditions.

we should get the exact return value of DAL2 instead of defining conditions in our session script.

any idea??


Reply:-
Hi,

I don't think there is any way to track that. But, in the debugger, you can can collect all the related table field values and check why the return value is FALSE as there are dependencies. It can include multiple tables and variables too which are coming from the Program Script.

Also, you can put the bshell in debugger to track the program flow which can give you the related dll's and you can generate the documentation of those dll's and study them.

But well, that might be a tedious job. The simplest way is check if everything is working the same way as it works in standard. Take a user and let him perform the activities, if any problem found you can change the script likewise.

benito
6th August 2013, 14:10
maybe take out the boolean. hope this gives you a hint.

http://www.baanboard.com/baanboard/showthread.php?t=60213&highlight=rush+program+ticpr2210m000

Ankita Patel
6th August 2013, 15:09
yes vamsi,

for all tcbool functions, it returns false. do you have any idea about it ?

vamsi_gujjula
6th August 2013, 17:23
did you try what benito and i suggested i.e by removing the boolean. ?

bhushanchanda
6th August 2013, 20:03
Hi Vamsi, Benito,

No it doesn't work if boolean is removed.

Ankita Patel
7th August 2013, 08:20
did you try what benito and i suggested i.e by removing the boolean. ?

yes it didnt work...

Ankita Patel
8th August 2013, 12:49
Hi all,

I've tried removing boolean like

function extern boolean tdpur3104m000.is.allowed()
{
boolean ret_val
parent.object.function.id = get_function(parent.object.dll.id, "tdpur3104m000.is.allowed")
parent.object.error = exec_function(parent.object.dll.id, parent.object.function.id, ret_val)
return(ret_val)

}

and its finally working ..:)

bhushanchanda
8th August 2013, 15:20
Thanks for posting the solution.

Well, as Benito said, you need to play with them ;)

vamsi_gujjula
8th August 2013, 15:35
We were saying the same thing ... to remove the boolean while fetching the parent.function ID.

coz if you see the see the guide

Syntax:
function long get_function (long dll_id, string funct_name)

Description

This loads a specified function from a previously loaded DLL. It returns an identification number for the function.


Arguments
long dll_id The identification number of the DLL that contains the function, as returned by load_dll().

string funct_name The function name.