jojovalenton
16th November 2014, 14:26
hello,

anybody who know how to delete open line (sequence 2) in session timfc0101m000 using afs? i can find sequence 2 but the marked line showing the shipped line which is sequence 1. i tried to delete directly from the table but i can't close the production order. pls need help. thanks.

attachment: debug window

regards,

jojo

mark_h
17th November 2014, 03:18
I am not sure I understand - you can't delete it with AFS code or did you actually delete the line from the table directly? I am not familiar with that session.

jojovalenton
17th November 2014, 06:07
this is in fp7 using session timfc0101m000, i need to delete line 2 which is the open line status. the afs can find line 2 as shown in the debug window but in my get command it shows line 1 which is the shipped line status that is why error message display command disabled. previously i tried to delete in the table directly but i cant close the production order maybe there are still other related tables with link not allowing to close.

regards,

jojo

jojovalenton
17th November 2014, 07:25
hi,

how can i make a right click menu delete in afs?

thanks and regards,

jojo

bhushanchanda
17th November 2014, 10:36
Hi,

To close the order, please make the To Issue quantity as 0 for all the materials to be issued lines.

jojovalenton
17th November 2014, 10:44
hi,

thanks for reply, just making the to issue qty to 0 maybe not enough bec of this open status in timfc0101m000 which need to be deleted first and the to issue will automatically become 0.

regards,

jojo

bhushanchanda
17th November 2014, 10:48
Hi,

First try to delete it manually and try closing the Production Order. Next, if possible post your script.

jojovalenton
17th November 2014, 12:48
hi,

actually i tried already manually deleting from the table but its not consistent order is closing. the best options is deleting from session timfc0101m000 open status. i hope this can be possible.

|*afs
function extern clear.cst001.open.line(
domain tcpdno i.pdno,
domain tcpono i.pono,
domain tcitem i.sitm,
domain tcitem i.mitm)
{ |deleting open lines status
domain tcmcs.str100 error.msg
domain tcinh.ittp ittp.issue
domain timfc.otyp rtyp.prod
domain tclsel lsel.any
domain tcpdno o.pdno
domain tcitem o.sitm
domain tcmcs.st25m o.line.stat
long find.order, mark.order, find.rawcst, sync.rawcst
long mark.rawcst, find.rawmfc, mark.rawmfc, sync.rawmfc
boolean delete.mfc, update.cst
ittp.issue = tcinh.ittp.issue
rtyp.prod = timfc.otyp.sfc
lsel.any = tclsel.any
|* AFS Script
stpapi.put.field("tisfc0520m000","tisfc001.pdno",i.pdno) |report orders completed
stpapi.put.field("tisfc0520m000","tisfc001.mitm",i.mitm)
find.order = stpapi.find("tisfc0520m000",error.msg)
if find.order = 1 then
mark.order = stpapi.mark("tisfc0520m000", error.msg)
if mark.order = 1 then
stpapi.form.command("tisfc0520m000", 5, "material.to.issue",error.msg) |wh order session
stpapi.put.field("ticst0101m100","ticst001.pdno",i.pdno) |material to issue
stpapi.put.field("ticst0101m100","ticst001.pono",str$(i.pono))
stpapi.put.field("ticst0101m100","ticst001.sitm",i.sitm)
find.rawcst = stpapi.find("ticst0101m100",error.msg)
if find.rawcst = 1 then
mark.rawcst = stpapi.mark("ticst0101m100", error.msg)
if mark.rawcst = 1 then
sync.rawcst = stpapi.synchronize.dialog("ticst0101m100","modify",error.msg)
if sync.rawcst = 1 then
stpapi.form.command("ticst0101m100", 2, "timfc0101m000",error.msg) |session
stpapi.put.field("timfc0101m000","timfc001.pdno",i.pdno) |prod wh orders
stpapi.put.field("timfc0101m000","timfc001.pono",str$(i.pono))
stpapi.put.field("timfc0101m000","timfc001.effn","0")
stpapi.put.field("timfc0101m000","timfc001.seqn","2")
stpapi.put.field("timfc0101m000","timfc001.ittp",str$(etol(ittp.issue)))
stpapi.put.field("timfc0101m000","timfc001.rtyp",str$(etol(rtyp.prod)))
stpapi.put.field("timfc0101m000","line.status","Open")
find.rawmfc = stpapi.find("timfc0101m000",error.msg)
if find.rawcst = 1 then
mark.rawmfc = stpapi.mark("timfc0101m000", error.msg)
if mark.rawmfc = 1 then
stpapi.enum.answer("timfc0101m000", "ttstpq0100", tcyesno.yes)
stpapi.get.field("timfc0101m000","timfc001.pdno",o.pdno)
stpapi.get.field("timfc0101m000","timfc001.item",o.sitm)
stpapi.get.field("timfc0101m000","line.status",o.line.stat)
delete.mfc=stpapi.delete("timfc0101m000", true, error.msg) |delete
if not delete.mfc then
message(error.msg)
endif
endif
endif
endif
endif
endif
endif
endif
stpapi.end.session("timfc0101m000")
stpapi.end.session("ticst0101m100")
stpapi.end.session("tisfc0520m000")
}

regards,

jojo

bhushanchanda
17th November 2014, 13:09
Hi,

I guess, in your case, the status is Open, that means you have an Open Outbound Advise which is to be shipped. I guess, you can only delete the line when the status is planned. You might need to delete the outbound advice if the Warehouse Order has one.

jojovalenton
17th November 2014, 13:26
hi,

i can delete manually in the session timfc0101 the line with open status, once deleted, both warehouse outbound and ticst0101 are cleared, only struggle is deleting sequence 2 inside timfc0101.

regards,

jojo

bhushanchanda
17th November 2014, 13:33
Hi,

Did you tried deleting using DAL?

jojovalenton
17th November 2014, 13:46
hi,

not yet tried and i dont have any idea on the dal of these std tables. if you can give me sample scripts i can follow, i will try to simulate.

regards,

jojo

bhushanchanda
17th November 2014, 14:27
Hi,

Here is an example:-

declaration:
table ttimfc001
#include <bic_dam>
function main()
{
long ret
select timfc001.*
from timfc001 for update
where timfc001._index1 = {"210005791",10}
and timfc001.ittp = {tcinh.ittp.issue}
selectdo
ret = dal.destroy.object("timfc001")
if ret = 0 then
commit.transaction()
endif
endselect
}

I am trying to delete lines for Order 210005791 and position 10 with type as issue.

jojovalenton
17th November 2014, 14:33
hi,

i will try this sample to simulate and update you. thanks.

jojovalenton
18th November 2014, 06:45
hello,

thanks to bhushan, script working just like it is deleting from the session line. thanks to mark also.

regards,

jojo

mark_h
20th November 2014, 13:12
All bhushan here. Glad you got it working. Could you post the final code for others? Maybe they can use the technique also.

jojovalenton
23rd November 2014, 10:40
hi mark,

i used the same code as bhushan gave, i've just added parameter:

function extern del.cst001.open.line(
domain tcpdno i.pdno,
domain tcpono i.pono)
{ |clear remaining iswh
long ret.mfc, err.mfc
select timfc001.*
from timfc001 for update
where timfc001._index1={:i.pdno, :i.pono, 2, tcinh.ittp.issue}
and timfc001.rtyp={timfc.otyp.sfc}
selectdo
ret.mfc = dal.destroy.object("timfc001", err.mfc)
if ret.mfc = 0 then
commit.transaction()
endif
endselect
}

thanks,

jojo