View Single Post
  #9  
Old 22nd February 2017, 14:38
Aryaraj Aryaraj is offline
Member
 
Join Date: Oct 2013
Posts: 39
Aryaraj is on a distinguished road
Baan: LNFP7 - DB: MSSQL - OS: WindowsXP
User exit defined but not working

Dear Sir as per your suggestion I have developed the user exit . It is working fine for complete material but not working for partial material. For example My production order is for 100 Nos which required 100 qty of BOM item. If 100 RM is not available then system gives error . But our requirement is system should allow to release order for 100 qty. But if I have RM for 10 qty then system should allow to confirm the operation for 10 qty but for next 90 qty system should give an error message. Can you please help me on this. Please refer my script. given below.
******************************************************************************
|* tisfc010ue 0 VRC B61C a cust
|*
|* baan
|* 17-12-15 [18:15]
|******************************************************************************
|* Script Type: Library
|******************************************************************************
#ident "@(#)tisfc010ue tiB61Cacust fp9 Rev.No. 2 17 Dec 15 baan"
table ttisfc010
table ttcibd001
table tbptmm120
table twhwmd215
table tticst001

string header(10000),line(10000),filename(200),filepath(200),path1(200),file.open.mess1(200)
string header1(10000),line1(10000),filename1(200),filepath1(200),path2(200),file.open.mess2(200),detail.var(10000)
long seq.id,ret
long seq.id1,ret1
extern domain tcbool issued.flag,hours.flag,hrs.req
extern domain tisfc.prtm max.hrs,min.hrs,short.hrs
extern domain tiqcp1 actqty

#include <bic_dal>
#pragma used dll ottdllbw
#include <bic_dal>


function extern long ue.before.before.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
create.file()

issued.flag = FALSE
select ticst001.*
from ticst001
where ticst001._index2 = {:tisfc010.pdno,:tisfc010.opno}
selectdo
| if ticst001.ques <> ticst001.qucs then
| issued.flag = TRUE
get.item.desc()
get.on.hand.qty()

|if ticst001.ques <> actqty then
|if ticst001.ques > whwmd215.qhnd and ticst001.qucs <=0 then |Meghna 18/12/2016
if ticst001.iswh <1 then
issued.flag = TRUE
|endif
endif
line = concat$("|",ticst001.pono,ticst001.sitm,tcibd001.dsca,abs(ticst001.ques-ticst001.qucs),whwmd215.qhnd,ticst001.cwar)
seq.puts(line,seq.id)
| endif
endselect

| hours.flag = FALSE
| select bptmm120.*
| from bptmm120
| where bptmm120._index5 = {:tisfc010.pdno,:tisfc010.opno}
| selectdo
| cal.short.hrs()
| if (bptmm120.hrea <> 0 or bptmm120.hrma <> 0) and bptmm120.proc = tcyesno.no then
| hours.flag = TRUE
| endif
| endselect
| if hours.flag or hrs.req then
| short.hrs = abs(tisfc010.maho - bptmm120.hrea)
| line1 = concat$("|",tisfc010.opno,bptmm120.tano,bptmm120.cwoc,bptmm120.mcno,short.hrs)
| seq.puts(line1,seq.id1)
| endif

if issued.flag then
dal.set.error.message("tigenstring", "Material Not Issued, Report Operations Cannot be Completed")
endif
| if hours.flag then
| dal.set.error.message("tigenstring", "Hours Not Processed, Report Operations Cannot be Completed")
| endif
| if hrs.req then
| dal.set.error.message("tigenstring", "Required Hours do not Match")
| endif
| if issued.flag or hours.flag or hrs.req then
| return(DALHOOKERROR)
| endif
if issued.flag then
return(DALHOOKERROR)
endif
close.file()
break
endcase
return(0)
}

function extern long ue.after.before.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.before.after.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.after.after.save.object(long mode)
{
on case mode
case DAL_NEW:
break
case DAL_UPDATE:
break
endcase
return(0)
}

function extern long ue.before.before.destroy.object()
{
return(0)
}

function extern long ue.after.before.destroy.object()
{
return(0)
}

function extern long ue.before.after.destroy.object()
{
return(0)
}

function extern long ue.after.after.destroy.object()
{
return(0)
}

function create.file()
{
filename = "Material_Not Issued_"&dte$()&".xls"
filename1 = "Hours_Not_Accounted_"&dte$()&".xls"
filepath = "E:\"&filename
filepath1 = "E:\"&filename1
seq.id = seq.open(filepath,"w")
seq.id1 = seq.open(filepath1,"w")

header = concat$("|","Position No","Item","Description","Shortage Qty","On Hand Qty","Warehouse")
seq.puts(header,seq.id)
header1 = concat$("|","Operation No","Task","Work Center","Machine","Short Hours")
seq.puts(header1,seq.id1)
}

function close.file()
{
seq.close(seq.id)
seq.close(seq.id1)

if issued.flag or hours.flag or hrs.req then
if issued.flag then

path1 = "C:\temp\"&filename
exec_dll_function( "ottdllbw" , "server2client" , ret, filepath, path1, 0 )
endif
if hours.flag or hrs.req then

path2 = "C:\temp\"&filename1
exec_dll_function( "ottdllbw" , "server2client" , ret1, filepath1, path2, 0 )
endif
endif
if issued.flag then
app_start(path1, "", "", "", "")
endif
if hours.flag or hrs.req then
app_start(path2, "", "","", "")
endif
}

function get.item.desc()
{
select tcibd001.*
from tcibd001
where tcibd001._index1 = {:ticst001.sitm}
selectdo
endselect
}


function get.on.hand.qty()
{
select whwmd215.*
from whwmd215
where whwmd215._index2 = {:ticst001.sitm,:ticst001.cwar}
selectdo
endselect
}

function cal.short.hrs()
{
max.hrs = 0
min.hrs = 0
short.hrs = 0
hrs.req = FALSE
max.hrs = tisfc010.prtm + (5*tisfc010.prtm/100)
min.hrs = tisfc010.prtm - (5*tisfc010.prtm/100)
if (bptmm120.hrea < min.hrs or bptmm120.hrea > max.hrs) then
hrs.req = TRUE
endif

}
Reply With Quote