jojovalenton
13th September 2018, 10:38
hi,

i just want to ask if anybody already did afs for sales order lines using tdsls4100m900 session. i checked here mostly i found was using baan4/5. thanks in advance.

regards,
jojo

Ajesh
14th September 2018, 09:28
May i ask, What exactly about it?

jojovalenton
14th September 2018, 11:00
hi Ajesh,

actually i started to do the script for afs on this tdsls4100m900 to insert lines but i'm having trouble when run appearing fatal error on tdsls401.disc field that is why i'm asking for sample afs.

regards,
jojo

BaanInOhio
17th September 2018, 03:30
Try to use DAL2 instead. You can easily create the sales order and lines by setting a few fields for the header then lines. Same for purchase orders. Unlike some tables/functions, the DAL2 usage for the order entry/edit sessions are pretty strong. I prefer to use a custom session with DAL instead of EDI due to the simplicity of the calls. Also easier to get the exception messages from the session than how you have to do it in AFS.

jojovalenton
18th September 2018, 15:04
hi,
thanks for dal2 suggestions, its working.
regards,
jojo

jojovalenton
20th September 2018, 08:22
hi,
i was able to insert lines but the only problem is i can't able to modify ldam(1) field and system saying the position field can't be modified in sales order line. any idea?
regards,
jojo

Ajesh
24th September 2018, 10:54
hi,
i was able to insert lines but the only problem is i can't able to modify ldam(1) field and system saying the position field can't be modified in sales order line. any idea?
regards,
jojo

Can you post your code?

BaanInOhio
24th September 2018, 22:12
The cause could be a one of a few issues. Make sure that you are calling dal.set.field using the 3rd (element) argument since the discount is an array field: dal.set.field("tdsls401.ldam", value.for.discount, 1).

It may be due to a condition in the standard DAL and the field value or when trying to modify a field that the DAL script has as being disabled. I try to model these by doing an insert in GTM using the same fields as in the code. After entering the package, module, table, company in ttaad4100, enter a '*' at the choice prompt to enable the DAL validation. Will show "DAL active" under the company name. If a data/condition issue, you will receive an error message after entering the field or saving the record.

jojovalenton
25th September 2018, 08:50
Thanks for additional inputs.

Ajesh
28th September 2018, 14:45
@ Jojo, Could you post your AFS code for going to Lines from Header, when its not the Same Multi Occ/Single Occ Session Combination?

Wanted to have a look as to how to go about doing it..

jojovalenton
29th September 2018, 07:02
hi Ajesh,

Below is how the scripts goes:

function extern add.sls.ord.header(
domain tccom.bpid i.ofbp.sls,
domain tccom.bpid i.cadr.sls,
domain tccom.ccnt i.ofcn.sls,
domain tccwoc i.sls.ord.cofc,
domain tccotp i.sls.ord.sotp,
domain tcccur i.sls.ord.ccur,
domain tcrtyp i.sls.ord.rtyp,
domain tccpay i.sls.ord.cpay,
ref domain tcorno o.sls.ord.orno)
{
long save.tdsls400
domain tcmcs.str100 error.msg
|dal2 script...
dal.new.object("tdsls400")
dal.set.field("tdsls400.orno",i.sls.ord.sotp)
dal.set.field("tdsls400.ofbp",i.ofbp.sls)
dal.set.field("tdsls400.ofad",i.cadr.sls)
dal.set.field("tdsls400.ofcn",i.ofcn.sls)
dal.set.field("tdsls400.stbp",i.ofbp.sls)
dal.set.field("tdsls400.stad",i.cadr.sls)
dal.set.field("tdsls400.stcn","")
dal.set.field("tdsls400.itbp",i.ofbp.sls)
dal.set.field("tdsls400.itad",i.cadr.sls)
dal.set.field("tdsls400.itcn","")
dal.set.field("tdsls400.pfbp",i.ofbp.sls)
dal.set.field("tdsls400.pfad",i.cadr.sls)
dal.set.field("tdsls400.pfcn","")
dal.set.field("tdsls400.corg",tdsls.corg.manual)
dal.set.field("tdsls400.sotp",i.sls.ord.sotp)
dal.set.field("tdsls400.odat",utc.num())
dal.set.field("tdsls400.mprm",tdsls.mprm.cumulative)
dal.set.field("tdsls400.ccur",i.sls.ord.ccur)
dal.set.field("tdsls400.ratt",i.sls.ord.rtyp)
dal.set.field("tdsls400.bpcl","")
dal.set.field("tdsls400.cfrw","TRU")
dal.set.field("tdsls400.ddat",utc.num())
dal.set.field("tdsls400.prdt",utc.num())
dal.set.field("tdsls400.odty",tdsls.odty.notappl)
dal.set.field("tdsls400.cofc",i.sls.ord.cofc)
dal.set.field("tdsls400.fdpt",i.sls.ord.cofc)
dal.set.field("tdsls400.cpay",i.sls.ord.cpay)
dal.set.field("tdsls400.oamt",0.0000)
dal.set.field("tdsls400.hdst",tdsls.hdst.free)
dal.set.field("tdsls400.hiss",tcyesno.yes)
dal.set.field("tdsls400.ehis",tcyesno.yes)
sls.order.num(i.sls.ord.sotp, o.sls.ord.orno)
save.tdsls400 = dal.save.object("tdsls400")
dal.get.error.message(error.msg)
mess("tcnpc.common", 0, error.msg)
if save.tdsls400 = 0 then
commit.transaction()
endif
}

function extern add.sls.ord.lines(
domain tcorno i.l.orno,
domain tcpono i.l.pono,
domain tcitem i.l.item,
domain tcpric i.l.pric,
domain tcqsl1 i.l.qoor,
domain tccwar i.l.cwar,
domain tccuni i.l.cuqs,
domain tccuni i.l.cups,
domain tcconv i.l.cvqs,
domain tccvat i.l.cvat,
domain tddiam i.l.ldam,
domain tccom.bpid i.l.ofbp,
domain tcmcs.st17m i.bsls1)
{
domain tcpsty i.l.styp
domain tcdate i.l.date
long i, save.tdsls401
string error.msg(120)
i = 0
error.msg=""
i.l.date=utc.num()
i.l.styp="MCSLS"
|*dal2 script
dal.new.object("tdsls401")
dal.set.field("tdsls401.orno",i.l.orno)
dal.set.field("tdsls401.pono",i.l.pono)
dal.set.field("tdsls401.sqnb",0)
dal.set.field("tdsls401.ofbp",i.l.ofbp)
dal.set.field("tdsls401.item",i.l.item)
dal.set.field("tdsls401.pric",i.l.pric)
dal.set.field("tdsls401.porg",tdgen.porg.manual)
dal.set.field("tdsls401.ddta",i.l.date)
dal.set.field("tdsls401.qoor",i.l.qoor)
dal.set.field("tdsls401.cuqs",i.l.cuqs) |sales unit
dal.set.field("tdsls401.ccty","SAU")
dal.set.field("tdsls401.cvat",i.l.cvat)
dal.set.field("tdsls401.bptc","SAU")
dal.set.field("tdsls401.bpcl","")
dal.set.field("tdsls401.cwar",i.l.cwar)
dal.set.field("tdsls401.cwoc","")
dal.set.field("tdsls401.cubs",i.l.cuqs) |*
dal.set.field("tdsls401.cvbs",i.l.cvqs)
save.tdsls401 = dal.save.object("tdsls401")
dal.get.error.message(error.msg)
mess("tcnpc.common", 0, error.msg)
if save.tdsls401 = 0 then
commit.transaction()
endif
}

Ajesh
29th September 2018, 10:17
Ohhh..... I thought you tried in pure AFS...

KaasKarthik
19th November 2020, 14:45
hello all,
how do i check what are the tables affected ,while inserting the record from excel to sales order......(i need to use AFS) for it ,
please guide me...
thank you.........
:confused:

jojovalenton
22nd November 2020, 06:53
hi,
you can't create sales order perfectly directly from excel, first use exchange to put excel lines to a temp table and from there use dal to populate your sales order header and lines and dal will take care of the reference table link to it. i tried afs but its more effective in dal and easy.
regards,
jojo

KaasKarthik
16th December 2020, 15:48
:confused:\
hello sir,
i am inserting the value to sales order using wrapper script ,so there is no need to do that for my condition,
in my concept i insert all fields ,the order number which was created automatically from order type field, after save button is prssedwhile we call the save function update.db we are getting error.(bdp)314 unknown sql statement error ,how to resolve this and how to create ordernumber for sales order ...........................
waiting for reply...........
Thank you.
:confused::confused::confused:

KaasKarthik
16th December 2020, 15:51
even though the dal was easy ,
but our task is to do with wrapper script ,but the dal type seems to be easy.


thank you for your reply..

jojovalenton
17th December 2020, 12:52
hi,
you can view the error details in the server log to see what 314 means in your db, this might have some overflow values. if your not using dal.new.object you need to read manually in the script the last number in tcmcs050 and plus 1 after saving your sales order.
regards,

Predator
27th December 2020, 09:36
Hi,

I have the AFS, please PM me.

TQ

vk1971bhardwaj
17th September 2022, 11:15
Successfully created line and Approved same through AFS

function create.so.lines()
{
domain tcorno orno.f
string pono.f(4)
stpapi.put.field("tdsls4101m000","tdsls401.orno", str$(tdmfc503.orno))

ret = stpapi.find("tdsls4101m000", err.msg)
if isspace(err.msg) then
ret = stpapi.mark("tdsls4101m000", err.msg)
ret = stpapi.synchronize.dialog("tdsls4101m000", "add", err.msg)
if isspace(err.msg) then
stpapi.put.field("tdsls4101m000","tdsls401.orno", str$(tdmfc503.orno))
stpapi.put.field("tdsls4101m000","tdsls401.pono", str$(10))
stpapi.put.field("tdsls4101m000","tdsls401.seqn", str$(0))
stpapi.put.field("tdsls4101m000","tdsls401.cwar", str$(sel.cwar))
stpapi.put.field( "tdsls4101m000", "tdsls401.item.segment.1", "" )
stpapi.put.field( "tdsls4101m000", "tdsls401.item.segment.2", tdmfc501.item(10;38))
stpapi.put.field("tdsls4101m000","tdsls401.ofbp", str$(tdmfc503.bpid))
stpapi.put.field("tdsls4101m000","tdsls401.qoor", str$(tdmfc503.bags))
stpapi.put.field("tdsls4101m000","tdsls401.cuqs", str$(tdmfc506.cuni))
stpapi.put.field("tdsls4101m000","tdsls401.pric", str$(tdmfc501.pric))
stpapi.put.field("tdsls4101m000","tdsls401.ddta", str$(utc.num()))
stpapi.put.field("tdsls4101m000","tdsls401.rdta", str$(utc.num()))
stpapi.put.field("tdsls4101m000","tdsls401.stbp", str$(tdmfc503.bpid))
stpapi.put.field("tdsls4101m000","tdsls401.stad", str$(tdmfc503.bpid))
stpapi.put.field("tdsls4101m000","tdsls401.ccty", str$("IN"))
stpapi.put.field("tdsls4101m000","tdsls401.cvat", str$(tdmfc506.cvat))
stpapi.put.field("tdsls4101m000","tdsls401.bptc", str$("IN"))
ret = stpapi.insert("tdsls4101m000", 1, err.msg)
|message("Sale Order Line Generated for S.No. %d", err.msg)
if isspace(err.msg) then
stpapi.get.field("tdsls4101m000", "tdsls401.orno", orno.f)
stpapi.get.field("tdsls4101m000", "tdsls401.pono", pono.f)
approves.so.order()
else
message("Error : %s", err.msg)
ret = stpapi.recover("tdsls4101m000",err.msg)
endif
else
message("Error : %s", err.msg)
endif
else
message("Error : %s", err.msg)
endif
stpapi.end.session("tdsls4101m000")

stpapi.end.session("tdsls4101m000")

}

function approve.so.order()
{
stpapi.put.field("tdsls4100m000","tdsls400.orno", str$("orno.f"))
ret = stpapi.find("tdsls4100m000",err.msg)
ret = stpapi.mark("tdsls4100m000", err.msg)
stpapi.form.command("tdsls4100m000", 18, "approve.sales.order", error)
stpapi.end.session("tdsls4211m000")
stpapi.end.session("tdsls4100m000")
}