krushna
3rd November 2015, 20:35
Hi Guys,

I am trying to update field tisfc010.rsdt using DAL but am getting error message: - "The Data Access Layer doesn't allow the operation update on table tisfc010".
Here is the program for the same:-

ret = dal.change.object("tisfc010")
dal.set.field("tisfc010.rsdt",utc)
ret = dal.save.object("tisfc010")
if ret = 0 then
commit.transaction()
else
dal.get.error.message(error)
abort.transaction()
endif

Also I tried AFS for session tisfc0110m000 but its also not updating the same, neither it is giving any error.

stpapi.put.field("tisfc0110m000","tisfc010.pdno",pdno)
stpapi.put.field("tisfc0110m000","tisfc0101.opno",str$(pono))
ret = stpapi.find("tisfc0110m000", error )
if ret = 1 then
ret = stpapi.mark("tisfc0110m000", error )
stpapi.synchronize.dialog("tisfc0110m000", "Modify" , error)
stpapi.put.field("tisfc0110m000","tisfc010.rsdt",str$(utc))
ret = stpapi.update("tisfc0110m000", false, error)
stpapi.save("tisfc0110m000", error)
endif
stpapi.end.session("tisfc0110m000")
stpapi.end.session("tisfc0110m000")

Please help me out on this.

Thanks,
Krishna

benito
3rd November 2015, 20:47
please try with:

dal.set.field("tisfc010.rsdt",utc.num())

BaanInOhio
3rd November 2015, 21:04
I have found that DAL doesn't work well (or at all) in tisfc010 and automation is best done in AFS. I think the mark that you have in your code may be the cause since it isn't needed for a synchronized dialog. I have something similar (but different fields) that works fine.


stpapi.put.field("tisfc0110m000","tisfc010.pdno",pdno)
stpapi.put.field("tisfc0110m000","tisfc0101.opno",str$(pono))
ret = stpapi.find("tisfc0110m000", error )
if ret = 1 then
| (not needed here since synchronized dialog) ret = stpapi.mark("tisfc0110m000", error)
ret = stpapi.synchronize.dialog("tisfc0110m000", "Modify" , error)
if (ret =1) then
stpapi.put.field("tisfc0110m000","tisfc010.rsdt",str$(utc))
ret = stpapi.update("tisfc0110m000", false, error)
stpapi.save("tisfc0110m000", error)
endif
endif
stpapi.end.session("tisfc0110m000")

mark_h
3rd November 2015, 22:10
Okay - I have to ask, even thou I do not know ln or baan 5. Are you basically sync'ing tisfc0110m000 with itself? When I read the documentation the put fields would go against the sync'ed session, or a subsession, and the update(or insert) would then then go against the main session. In the post it makes me wonder what the stpapi.sync is even doing.

krushna
4th November 2015, 12:58
I did tried by commenting stpapi.synchronize.dialog command but with no success.
Also I tried with commenting stpapi.mark but it still not updating the same.
This is LN FP7 version.

Please help me out if I am missing anything.

vahdani
4th November 2015, 14:39
Hi Krishna,

you cannot do in DAL something that you can not do manually. That is the whole purpose of DALs.

The DAL for tisfc010 has a method.is.allowed function which is called first in background before insert, update or delete actions. In tisfc010 DAL an update is not allowed if the order status is not correct.

So please check if you can do waht you want manually and if necessary check the production order status in your program.

mark_h
4th November 2015, 15:27
See the above answer first - this must be something that can be done manually first. So that means the session tisfc0110m000 must also allow the update to occur before AFS code will work. Besides that there are other considerations for AFS to work - session object version, stpapi libraries and even the porting set once impacted us. Anyway if you can update that field manually then in theory if all is correct AFS code should work also. The only code I have that works on 4c4 updates the warehouse. Mine is very simple and the suspend is in there to just give a pause before the program I have keeps running - it does other updates also.

function modify.estmat.warehouse()
{
stpapi.put.field("tisfc0110m000", "ticst001.pdno", str$(tisfc001.pdno))
stpapi.put.field("tisfc0110m000", "ticst001.pono", str$(ticst001.pono))
ret.code = stpapi.find("tisfc0110m000", fserr)
if(ret.code = 1) then
stpapi.put.field("tisfc0110m000", "ticst001.cwar", project.cwar)
ret.code = stpapi.update("tisfc0110m000", 1, fserr)
if(strip$(fserr)<>"") then
fserr = sprintf$("2a - Modify %s",fserr)
endif
else
fserr = sprintf$("2b - find. %s",fserr)
endif
stpapi.end.session("tisfc0110m000")
suspend(500)
}

benito
4th November 2015, 15:36
i tried this in my system and this works. i did spend a lot of time trying to make this to work with DAL before and was unsuccessful as well. before you can invoke the function below, you need to make your checks for production order status. etc, otherwise this field will not update.


function extern update.remainder.date()
{
domain tcpdno i_pdno
domain tcdate chg.date
string update.msg( 150 )
string end.msg( 150 )
string sess( 13 )
string err.id(100)
string err.msg(100)

i_pdno = "TR0000957"
chg.date = 1446538705

sess = "tisfc0110m000"
err.id = ""
err.msg = "" | reset

| find the operation for the production order
stpapi.put.field( sess, "tisfc010.pdno", ( i_pdno ) )
stpapi.put.field( sess, "tisfc010.opno", str$( 10 ) )

if ( stpapi.find( sess ) = 1 ) then
ret = stpapi.synchronize.dialog(sess, "modify", err.msg)
if ret then
stpapi.put.field( sess, "tisfc010.rsdt", str$( chg.date) )
ret = stpapi.update(sess, true, update.msg)
endif
endif
stpapi.end.session( sess, end.msg )
}

bhushanchanda
4th November 2015, 15:44
As said, I guess there seems to be an issue with the DAL. Probably a bug as there is no straightforward DAL allowed to modify (even if manually you can)

Another problem is with the AFS. The following code should have been worked but it doesn't (Instead of having all good return values)-

stpapi.put.field("tisfc0110m000","tisfc010.pdno",pdno)
stpapi.put.field("tisfc0110m000","tisfc0101.opno",str$(pono))
ret = stpapi.find("tisfc0110m000", error )
if ret = 1 then
| (not needed here since synchronized dialog) ret = stpapi.mark("tisfc0110m000", error)
ret = stpapi.synchronize.dialog("tisfc0110m000", "Modify" , error)
if (ret =1) then
stpapi.put.field("tisfc0110m000","tisfc010.rsdt",str$(utc))
ret = stpapi.update("tisfc0110m000", false, error)
stpapi.save("tisfc0110m000", error)
endif
endif
stpapi.end.session("tisfc0110m000")

Tried many variations with the above -
1. stpapi.update() with true
2. multiple stpapi.update()
3. splitting rsdt into .segment.1 and .segment.2
etc..

No luck!

mark_h: Okay - I have to ask, even thou I do not know ln or baan 5. Are you basically sync'ing tisfc0110m000 with itself? When I read the documentation the put fields would go against the sync'ed session, or a subsession, and the update(or insert) would then then go against the main session. In the post it makes me wonder what the stpapi.sync is even doing.

Mark, the session gives the error message saying "Update Not allowed on this session, use Sync" which is the reason to for that. Its the same session, just a double click for sync window. (Though, manually you don't need it) Weird! :)

Update- As Benito, already posted - The domain is what might be causing an issue for you. You might need to build the date in the format of domain tcutcs and then assign it to the field to make it work

benito
4th November 2015, 15:58
<snip> ... makes me wonder what the stpapi.sync is even doing.

mark, just to answer your question, in LN there are additional fields in "session" (see attached). since you need to get out of the list window and go to the sync dialog for update, the sync is needed.

mark_h
4th November 2015, 19:56
Thanks Bushan and benito!!