jdhc3m
15th October 2010, 21:13
Hellllppp

I have a session of insertion. I'm trying to insert two or more than once.
Example: I place an order, and wanted him to insert the two lines of this order in my main table.
I used db.insert (), but it's wrong because I am entering the main Tabled session, then it is already entering, if I give the db.insert () it inserts two times, giving error.
I put only commit.transaction (), it reads the two records, but only the last record.

HOW DO I INSERT 2 RECORDS IN MY MAIN TABLE!!

sameer.don
16th October 2010, 07:03
Please post screenshot of session and program script. It will be easy then to find exact solution for ur requirement.

jdhc3m
18th October 2010, 16:10
Recalling that the main session is qmptc400.
There are two lines to be inserted in qmptc400, and only one to be inserted in qmptc110 and 115, but it inserts only one on each table.


function insert.data()
{


select qmptc100.iorn, qmptc100.item, qmptc100.sams, qmptc120.pono
from qmptc100, qmptc120
where qmptc100.orno = :qmptc400.orno.o
and qmptc120.orno = :qmptc400.orno.o
and qmptc120.rsta <> qmptc.rsta.closed
selectdo
select qmptc110.saml
from qmptc110
where qmptc110.iorn = :qmptc100.iorn
selecteos
qmptc400.saml.o = qmptc110.saml + 1
selectempty
qmptc400.saml.o = 1
endselect

select qmptc101.pono, qmptc101.char, qmptc101.ctyp, qmptc101.norm, qmptc101.tuni, qmptc101.tare, qmptc101.emno, qmptc101.inst
from qmptc101 |, qmptc400 for update
where qmptc101._index1 = {:qmptc100.iorn , :qmptc400.pono.o}
order by qmptc101.pono
selectdo
qmptc400.orno.o = qmptc400.orno.o
qmptc400.iorn.o = qmptc100.iorn
qmptc400.item.o = qmptc100.item
qmptc400.sams.o = qmptc100.sams
qmptc400.saml.o = qmptc400.saml.o
qmptc400.smdt.o = utc.num()
qmptc400.pono.o = qmptc101.pono
qmptc400.char.o = qmptc101.char
qmptc400.norm.o = qmptc101.norm
qmptc400.llmt.o = qmptc101.llmt
qmptc400.ulmt.o = qmptc101.ulmt
qmptc400.tuni.o = qmptc101.tuni
qmptc400.tare.o = qmptc101.tare
qmptc400.emno.o = qmptc101.emno
qmptc400.inst.o = qmptc101.inst
commit.transaction()
selectempty
set.input.error("qmptco006o")
endselect
selectempty
set.input.error("qmptco007o")
endselect
}


function insert.qmptc110()
{

qmptc110.iorn = qmptc400.iorn.o
qmptc110.saml = qmptc400.saml.o
qmptc110.item = qmptc400.item.o
qmptc110.smdt = qmptc400.smdt.o
qmptc110.squa = qmptc400.squa.o
qmptc110.tqua = qmptc400.squa.o
qmptc115.iorn = qmptc400.iorn.o
qmptc115.saml = qmptc400.saml.o
qmptc115.pono = qmptc400.pono.o
qmptc115.srno = 1
qmptc115.tsdt = qmptc400.smdt.o
qmptc115.mval = qmptc400.mval.o
qmptc115.mopt = qmptc400.mopt.o
qmptc115.tare = qmptc400.tare.o
qmptc115.emno = qmptc400.emno.o
qmptc115.inst = qmptc400.inst.o

if (qmptc400.resl.o = "Bom") then
qmptc115.resl = qmptc.resl.good
else
qmptc115.resl = qmptc.resl.bad
endif
db.insert(tqmptc110, db.retry)
db.insert(tqmptc115, db.retry)

commit.transaction()
}

baan_fun
18th October 2010, 22:12
Hi,

If the user enters one record in the session and you want to generate in the background anther reocrds based on the input report you can either programm this in the after.update.db.commit: (commiting of the record on the screen, here no record in locked,no insert is started and you can select your table and select what you need on selectempty).

Giving the fact that you are on LN FP3 you can create an User Exit for your Table and on after.after.save.object you can insert again in your table what you need

Regards

MilindV
19th October 2010, 08:09
Hi,

If you want to insert 1 more record.

function extern long after.save.object(long type)
{
long ret_val

if type = DAL_NEW then
ret_val = insert.one.more.record()
endif
return (ret_val)
}

In function where u ll be inserting one more record, use db.insert instead of dal.new. As dal.new will result in again calling dal hooks before/after save object and which will give error for recursion.
No need to worry about transaction handling.

-- MilindV