zhilenko_myu
6th December 2022, 04:50
hello
when inserting a row, if there are errors in the data, then afs does not show errors.
for example, if there is no such product in the database.

session = "tdsls4101m000"

stpapi.put.field(session, "tdsls401.orno", orno.o)
error.msg = get.string.arg(1)
retval = stpapi.change.view(session, error.msg)
put.string.arg(1, error.msg)
IF retval = 0 THEN
retval = stpapi.synchronize.dialog(session, "add", error.msg)
session1 = "tdsls4101m000"
IF retval THEN
stpapi.put.field(session1, "tdsls401.item.segment.1", "")
stpapi.put.field(session1, "tdsls401.item.segment.2", zrsfc121.item(1;38))

SELECT *
FROM zazir101
WHERE zazir101.onum = :onum.i
SELECTDO
effn.i = zazir101.effn
ENDSELECT
stpapi.put.field(session1, "tdsls401.effn", str$(effn.i))
stpapi.put.field(session1, "tdsls401.cprj", cprj.i)
stpapi.put.field(session1, "tdsls401.cact", "1")
stpapi.put.field(session1, "tdsls401.qoor", "1")
| stpapi.put.field(session1, "tdsls401.odat", str$(ddat))
stpapi.put.field(session1, "tdsls401.stbp", stbp)
stpapi.put.field(session1, "tdsls401.stad", ofad)
stpapi.put.field(session1, "tdsls401.pric", "10000")
stpapi.put.field(session1, "tdsls401.oamt", "10000")
stpapi.put.field(session1, "tdsls401.ccty", "1")
stpapi.put.field(session1, "tdsls401.cvat", cvat)
retval = stpapi.insert(session1, true, error.msg)
IF not isspace(error.msg) THEN
print.errors(
"1",
session1,
error.msg,
trim$(zrsfc121.item),
orno.o)

ENDIF
IF retval THEN
session2 = "tdsls4830s000"
stpapi.put.field(session2, "inventory.short", str$(etol(tdsls.ssop.no.action)))
stpapi.end.session (session2, error.msg)
retval = stpapi.save(session1, error.msg)
IF not isspace(error.msg) THEN
print.errors(
"2",
session1,
error.msg,
trim$(zrsfc121.item),
orno.o)

ENDIF
ENDIF
ENDIF
ENDIF
stpapi.end.session(session1, error.msg)

stpapi.end.session(session, error.msg)

mark_h
6th December 2022, 14:13
I typically validate data before I insert a record. Is there anything in error message when you do the stpapi.synchronize.dialog? From the example in the documentation looks like you put the fields to the session opened and then do an insert on the main session.


ret = stpapi.synchronize.dialog("dtfsa1501m000", "add", error.msg)
if ret then
stpapi.put.field("dtfsa1101s000", "dtfsa101.seno", str$(new.seno)
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
ret = stpapi.insert("dtfsa1501m000", true, error.msg)
if not ret then
ret = stpapi.recover("dtfsa1101s000", error.msg)
endif
endif
stpapi.end.session("dtfsa1501m000", error.msg)

mark_h
6th December 2022, 14:19
I recommend searching the AFS/DDC/OLE: Function servers forum for tdsls4101m000. Lots of threads and it appears DAL might be best. Just some sample threads below - one talks dal and the other mentions a main and sub with same name - no solution.

http://www.baanboard.com/baanboard/showthread.php?t=67511&highlight=tdsls4101m000
http://www.baanboard.com/baanboard/showthread.php?t=71357&highlight=tdsls4101m000

zhilenko_myu
7th December 2022, 05:15
I typically validate data before I insert a record. Is there anything in error message when you do the stpapi.synchronize.dialog? From the example in the documentation looks like you put the fields to the session opened and then do an insert on the main session.


ret = stpapi.synchronize.dialog("dtfsa1501m000", "add", error.msg)
if ret then
stpapi.put.field("dtfsa1101s000", "dtfsa101.seno", str$(new.seno)
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
ret = stpapi.insert("dtfsa1501m000", true, error.msg)
if not ret then
ret = stpapi.recover("dtfsa1101s000", error.msg)
endif
endif
stpapi.end.session("dtfsa1501m000", error.msg)

that's just the point the error message does not give

zhilenko_myu
7th December 2022, 05:16
I recommend searching the AFS/DDC/OLE: Function servers forum for tdsls4101m000. Lots of threads and it appears DAL might be best. Just some sample threads below - one talks dal and the other mentions a main and sub with same name - no solution.

http://www.baanboard.com/baanboard/showthread.php?t=67511&highlight=tdsls4101m000
http://www.baanboard.com/baanboard/showthread.php?t=71357&highlight=tdsls4101m000

DAL cannot be used, there are extensions for this session

mark_h
7th December 2022, 15:05
I still recommend you search the threads. I do not have access to LN and I have never used it. The first thread - shows a where they copied the session and turned something off. That technique might work for you. The next thread has in the final post something that someone else did - not sure it will work on LN I did not look closely.

http://www.baanboard.com/baanboard/showthread.php?t=60611&highlight=tdsls4101m000
http://www.baanboard.com/baanboard/showthread.php?t=60611&highlight=tdsls4101m000

OmeLuuk
11th January 2023, 15:26
DAL cannot be used, there are extensions for this session

And consider to move the extensions on the session to extensions on the table tdsls401, then use the DAL method and the table extension will also work