kmcinc
8th March 2013, 16:50
I need a session to insert a new sales quote via AFS. Based on the code below I am able to create the header but the line insert fails. The error message I'm getting is "Enter a value for the Quotation field.". It appears that the provided quote number is not registered or is getting blanked out in the quotation lines session before the insert function call.
When manually creating a quote the sequence of sessions is as follows:
tdsls1500m000
tdsls1100s000
tdsls1501m000
tdsls1101s000
I show these indented to indicate the parent-child relationship. The process sequence when executing my AFS appears is this:
tdsls1500m000
tdsls1100s000
tdsls1501m000
tdsls1101s000
You can see that the last session - Sales Quotation Lines - is not spawned as a child. This may explain why tdsls1101s000 loses the value for tdsls101.qono and generates the error.
Here is the code:
tdslsdll1100.Quotation_Lines( error.msg )
tdslsdll1501.put.Quotation( evsls100.qono )
tdslsdll1501.set.view( "tdsls1501m000" )
tdslsdll1501.handle.sub.process( "tdsls1101s000", "add" )
tdslsdll1101.put.Quotation( evsls100.qono )
tdslsdll1101.put.Position( evsls101.pono )
rc = tdslsdll1101.find( error.msg )
populate.sls101.fields()
if rc = 1 then
rc = tdslsdll1101.update( true, error.msg )
else
rc = tdslsdll1101.insert( true, error.msg )
endif
Any advice on how to resolve this problem?
kmcinc
8th March 2013, 16:59
What is the AFS equivalent to double-clicking on a quotation line in an overview session of ERP LN? Double-clicking is the only way to get to the line detail.
mark_h
8th March 2013, 21:02
You can try stpapi.mark, but that just marks the record after the find. I do not think that is the equivalent of double clicking.
mark_h
8th March 2013, 21:17
Something else to try is stpapi.continue, just to see if it initiates the lines. I can't really say since I do not use LN and they really recommend using DAL2 funtionality for LN. I just do not know enough about this stuff.
kmcinc
8th March 2013, 23:50
Mark, thanks for your input. The quotation lines overview session does not have a 'Continue' choice. Instead I tried a 'stpapi.synchronized.dialog' call but that didn't help either.
vinceco252
9th March 2013, 01:03
This isn't for sales quotes, but it's the same idea. This is for entering a manual purchase invoice from maintain transactions:
stpapi.put.field( "tfgld1101m100", "tfgld101.year", str$(year.f) )
stpapi.put.field( "tfgld1101m100", "tfgld101.btno", curr.btno )
ret = stpapi.find( "tfgld1101m100", error )
stpapi.put.field( "tfgld1101m100", "tfgld101.ttyp", ttyp.f )
ret = stpapi.find( "tfgld1101m100", error)
if ret = 1 then
ret = stpapi.mark( "tfgld1101m100", error)
stpapi.form.command( "tfgld1101m100", 5, "enter.transactions", error)
...
I am not sure what the form command to zoom to lines is in sales quotes, but you should be able to find that by looking at the session in Maintain Sessions.
Hope it helps.
Vince
kmcinc
10th March 2013, 15:59
Vince, I looked through all form commands but none of them launch tdsls1101s000.
bhushanchanda
10th March 2013, 16:43
SYNTAX
long stpapi.synchronize.dialog(string session, string mode, ref string err.mesg)
ARGUMENTS
session Name of the multi-occurrence session this command is executed on.
mode The mode in which the synchronized dialog box must be started. The possible values are:
Add – the dialog box is started and synchronized in Edit mode, view fields are sent from the multi-occurrence session to the single-occurrence session; use this mode before a stpapi.insert() call
Modify – the dialog box is started and synchronized in Edit mode, use this mode before a stpapi.update() call
display – the dialog box is started in Display mode
“ ” – no dialog box is synchronized (for future use when multi-occurrence and single-occurrence sessions have the same code, focus is set to the multi-occurrence session)
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This function synchronizes a multi-occurrence session with its registered synchronized dialog box. Depending on the mode, the session with the editable window is synchronized or the read-only window.
RETURN VALUES
0 Sessions could not be synchronized (err.mesg is filled)
1 Sessions are synchronized (err.mesg is empty)
EXAMPLE
stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret then
ret = stpapi.synchronize.dialog("dtfsa1501m000", "modify", error.msg)
if ret then
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
ret = stpapi.update("dtfsa1501m000", true, error.msg)
endif
endif
Explanation:
The record is searched in the multi-occurrence session. When found, the synchronized dialog box is started, the field changed, and the record updated.
bhushanchanda
11th March 2013, 10:45
I found this code from my list. May be this will help you.
Pls note:- tdlvd401 is my customized table.
I am trying to insert a sales order line using DAL.
select tdlvd401.*
from tdlvd401 for update
where tdlvd401._index1 = {:tdlvd400.netw, :tdlvd400.orno}
and tdlvd401.proc = tcyesno.no
selectdo
target.item = get.target.item()
db.retry.point()
select tdsls401.*
from tdsls401
where tdsls401._index1 = {:tdsls400.orno, :tdlvd401.pono }
selectdo
selectempty
dal.new.object("tdsls401")
dal.set.field("tdsls401.orno", tdsls400.orno )
dal.set.field("tdsls401.ofbp", tdlvd411.bpid )
dal.set.field("tdsls401.pono", tdlvd401.pono )
dal.set.field("tdsls401.item", target.item )
dal.set.field("tdsls401.qoor", tdlvd401.qoor )
dal.set.field("tdsls401.cuqs", strip$(tdlvd401.cuqp) )
dal.set.field("tdsls401.cups", strip$(tdlvd401.cuqp) )
dal.set.field("tdsls401.pric", tdlvd401.pric )
dal.set.field("tdsls401.porg",tdgen.porg.manual)
if tcibd001.kitm = tckitm.cost then
dal.set.field("tdsls401.dltp", tdsls.dltp.sales )
else
dal.set.field("tdsls401.dltp", tdsls.dltp.warehousing )
endif
dal.set.field("tdsls401.odat", str$(utc.num()) )
dal.set.field("tdsls401.ddta", str$(tdlvd401.ddta) )
dal.set.field("tdsls401.cwar", tdsls039.cwar )
dal.set.field("tdsls401.stbp", tdlvd411.bpid )
ret = dal.save.object("tdsls401",db.return.error)
if ret <> 0 then
ret = dal.get.error.message(error.msg )
seq.puts(concat$("|", "Error during SO line creation", tdlvd400.orno, tdlvd401.pono, target.item, error.msg), seq.log )
error_found = TRUE
abort.transaction()
else
if not isspace(tdlvd400.cprj) then
update.project.parts()
endif
if ret = 0 then
tdlvd401.proc = tcyesno.yes
db.update(ttdlvd401, db.retry)
commit.transaction()
endif
endif
endselect
endselect
}
kmcinc
12th March 2013, 03:57
I'll try that. Thanks, bhushanchanda.
vinceco252
12th March 2013, 17:15
The "to.lines" form command opens the tdsls1501m000 session.
kmcinc
12th March 2013, 19:40
Yes, but there is not a form command to get from tdsls1501m000 to tdsls1101s000. I'm still playing with the synchronize.dialog function; it seems to do what I want it to do.
benito
13th March 2013, 15:10
i only use AFS in LN sparingly. advantages of LN over BaanIV are the use of DAL, DLLs and Business Methods. i haven't done sales quotations but there is a DLL tdslsdll1100 (generate sales quotations). there are several functions in this DLL including tdsls.dll1100.add.header.record(..) and tdsls.dll1100.add.line.record(..). I suggest you explore them first.
kmcinc
27th March 2013, 21:56
Benito,
Thanks to your suggestion I was able to complete the quotation generation including lines, using the DLL you mentioned. It wasn't without a challenge but I got it working. Appreciate everybody's help with this problem!
-Tom
benito
27th March 2013, 22:04
you're welcome. good to know it worked for you :D . again, the advantages of LN over the earlier version.