Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 7th October 2008, 15:35
gget79 gget79 is offline
Senior Member
 
Join Date: Nov 2006
Posts: 263
gget79 is on a distinguished road
Baan: 5 - DB: ORACLE - OS: UNIX
Problem with multi-thread processing
Baan: Other/Unknown
C/S: None/Unknown

Hi BaanFriends,

I am using Baan Vc.

I have made un program that it uses AFS functionality to Sales Ordes (tdsls4100m000) and this it works well when I do it in one process, but When I do it with five threads at the same time, firstly I got error 107(Record Locked), then I looked for the solution on the BaaNBoard and I found a solution to error107 (Record Locked) then I modified the db_resource file but now I don't get the 107 error, now I get a error that say me, the row already exists.

Anybody know that should I do?
Reply With Quote
  #2  
Old 7th October 2008, 22:35
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,906
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Is it possible the row actually exists? Is it possible that the data being processed is split or in two files being processed by different function servers. Just wondering if the data is synchronized between the 5 processes. For example; trying to add lines to a sales order in two different processes. Where both could potentially decide to use the same position number.

The only thing like this that I have seen is when we delete all of our GRP orders. There are 4 of us and we run anywhere from 4 to 5 processes each. This does generate errors, but once we get through, we reprocess those that errored out. Not as structured as it sounds but basically the last thing we do is run just one wide open to remove the final orders. Is it possible you track the error records and try them again as the final step?
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #3  
Old 8th October 2008, 17:05
gget79 gget79 is offline
Senior Member
 
Join Date: Nov 2006
Posts: 263
gget79 is on a distinguished road
Baan: 5 - DB: ORACLE - OS: UNIX
Hi Mark,

Your solution is good, but Why is happening this?. I know that Baan is multi-tasking and multi-user. Which argument should I take to explain this to my users?

Thank you for your advice.
Reply With Quote
  #4  
Old 8th October 2008, 19:34
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,906
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
I can't answer that question. Without source code I really can not tell why ours have problems like this. I know at times I have used suspend statements to slow things up, but that kind of defeats the purpose of multi-threads. So I am sorry, but I really do not know how to answer this for yours or our users.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #5  
Old 8th October 2008, 19:53
gget79 gget79 is offline
Senior Member
 
Join Date: Nov 2006
Posts: 263
gget79 is on a distinguished road
Baan: 5 - DB: ORACLE - OS: UNIX
Hi,

Thank for your time.

My soruce code is:

Code:
declaration:

 	table	ttdsls400	| Ordenes de Venta
	table	ttcmcs013	| Condiciones de pago
	table	ttcmcs002	| Divisas
	table	ttccom001	| Employees
	table	ttcmcs011	| Recargos por atrasos
	table	ttcmcs080	| Agentes de transporte
	table	ttcmcs010	| Países
	table	ttcmcs046	| Idiomas
	table	ttcmcs041	| Condiciones de entrega
	table	ttcmcs004	| Rutas
	table	ttcmcs031	| Sector
	table	ttcmcs045	| Zonas
	table	ttuint920	| ordenes PDA fza ventas
	table	ttuint100	| Parametros de Fuerza de ventas
	table	ttccom110	| Partners Clientes
	table	ttuint105	| Series por Ejecutivo
	table	ttuint921	| Detalle ordenes venta fuerza ventas
	table	ttuint003	| Parametros comunes Mabe.
	table	ttcibd001	| Datos generales de artículos

	extern	domain	tcmcs.str215	report.msg
	extern	domain	tcyesno       	txta.yn
	extern	domain	tcyesno       	flag_ok
	extern	domain	tcyesno       	flag.procesar
	extern	domain	tcyesno       	flag.cargar
	extern	domain	tfgld.btno     flag.entry
   extern	domain	tcorno        	orno.f
	extern	domain	tcorno        	orno.t
	extern	domain	tcmcs.str20   	ornopda.f
	extern	domain	tcmcs.str20   	ornopda.t
	extern	domain	tcyesno       	txta.yn
   extern   domain   tcncmp         empresa
   extern	domain   tcmcs.str100    arch.inp | Archivo de entrada
   extern	domain   tcmcs.str100    arch.out | Archivo de Salida (errores)
   extern	domain   tcrefa         refa
   extern	domain   tcmcs.str6     empr
   extern   domain   tcitem  item

   extern   domain   tcdate   fechora  |mjc.n

	domain	tcbool		   ok.proceso
	domain	tcmcs.str215	error.msg
	domain	tcmcs.str215	recover.msg
	domain	tcorno		   ovta.orno
	domain	tcpono		   ovta.pono
	domain	tcpono		   ovta.sqnb
	domain	tccom.bpid	   ovta.ofbp
  	domain	tcmcs.str80	   path
   domain	tcmcs.str80	   patho
	string	num.pedido(11)
	string	cli.pedido(25)
	string	f.pedido(10)
	string   fp.pedido(10)
	string	con1(1)
	string	con2(1)
	string	con3(1)
	string	con4(1)
	string	alm.pedido(6)
	string	tipo.pedido(3)
	string	ase.pedido(6)
   string   archivo(100)
   string   archivo.reporte(100)
	string   registro(400)
	string   flag.cuno(30)
	string   flag.crep(30)
	string   flag.cwar(30)
	string   flag.item(30)  |pronget01.n
	string   flag.ccrs(30)
	string   flag.cdel(30)
	string   errores(30)
	string   archivo.historia(300)
   string   formatoC(5000)


	long  fp,secu
	long	por.act
   long	ret
	long  codd1  |pronget01.n
	long	code0  |pronget01.n
	long	code1
	long	code2
	long	code3
	long	code4
	long	code5
	long  ll_ret
   long  longitud
	

   string tiempo(10) |mjc.n

	domain tcdate actual.date | NOVAGAC02.n
	domain tcdate actual.date.fin | NOVAGAC03.n

   |dyr1.sn
   string   dat(12) | Store current date and time in format MMDDYYHHMMSS
   long	out.fp      | Puntero archivo de salida
   extern	domain	tcmcs.str20    que.errfile
   string	err.line(250)        | Linea de errores
   |dyr1.en

   long genera |mjc01.n
	
	|pronget01.sn
	extern domain tcmcs.str100 err.mesg
	extern domain tcncmp ncmp.f
	extern domain tcmcs.long secu.f, secu.t
	|pronget01.en
	
	| 	Variables de ambiente
	|pronget01.sn
	extern domain tcmcs.long que.inicio
	extern domain tcmcs.long que.fin
	extern domain tcncmp		 que.cia
	|pronget01.en
	
	|pronget02.sn
	extern long    	puntero_tuint920,  puntero_tuint921
	extern string	buf.ttuint920(2048), buf.ttuint921(2048)
	extern long val_retu, val_retc
	|pronget02.en
	
	|pronget02.sn
	table	ttccom100	|partners
	table	ttccom111	|
	|pronget02.en

	
|************************ include section **********************************

	#pragma used dll ottstpapihand
	#include <bic_dam>
   #include <bic_tt>       | runtime dictionary information
   #pragma used dll ottdllbw     		|File Transfer and Appstart client2server
   #include  "ituint002"
   #include  "ituint003"
|************************ program section **********************************

before.program:
	|pronget01.sn
	err.mesg = "" 
	secu.f = 0
	secu.t = 999999
	|pronget01.en
	
	|pronget01.sn
	que.inicio = lval(getenv$("SECINI"))				
	que.fin    =  lval(getenv$("SECFIN"))
	que.cia	  =  lval(getenv$("CIA"))	
	secu.f = que.inicio
	secu.t = que.fin 
	ncmp.f = que.cia
		
	if que.inicio > 0 and que.fin > 0 then
		if que.inicio <= que.fin then
			execute(cont.process)
			end() 
		|pronget02.sn
		else
			end()
		|pronget02.en
		endif
	endif
	|pronget01.en
|pronget01.eo
|****************************** group section **********************************

group.2:
init.group:
	get.screen.defaults()
	flag.cargar = tcyesno.yes
	flag.procesar = tcyesno.yes

|****************************** choice section ********************************

choice.cont.process:
before.choice:
	|pronget01.sn
	if verifica.compania() then
		if ncmp.f <> 0 then
			switch.to.company(ncmp.f)
			tcmcs.dll0095.read.parm("tuint003")
			empresa=get.compnr() | NOVAGAC03.n
			leer.parametros()
			flag.cargar = tcyesno.yes
			flag.procesar = tcyesno.yes
			ok.indicador = true | NOVAGAC03.n
		else
			end()
		endif
	else
		end()
	endif
	|pronget01.en

   tiempo=str$(time.num())  |mjc.n

	local.to.utc(date.num(),0,actual.date) | NOVAGAC02.n
	local.to.utc(date.num(),86399,actual.date.fin) | NOVAGAC03.n

on.choice:

	ok.proceso = true
	if ok.proceso then
		read.main.table()
	endif
	end()    |dyr1.n
|****************************** field section *********************************

field.orno.f:
when.field.changes:
	orno.t = orno.f

|****************************** function section ******************************

functions:

function read.main.table()
{
   empresa=get.compnr()
   |Selecciono el directorio de donde se tomaran los datos del archivo de retorno
   select tuint100.*
   from tuint100
   where tuint100._index1 ={:empresa} | NOVAGAC03.n
   as set with 1 rows      |dyr.n
   selectdo
   endselect
   flag.cargar=tcyesno.yes |pronget01.n
   procesar.archivos()

}


function procesar.archivos()
{
	if flag.cargar = tcyesno.yes then
		dat = dte$()
		longitud = longitud + 9
	endif
	valid.all.data()  |Valida Cabecera
	check.all.data.detalle() |Valida Detalle
	validar.existencia.det_new()  |Valida si después de validaciones 	procesar.ordenes.vta()
}


function valid.all.data()
{
	err.mesg = ""
	
	|pronget01.sn
	select tuint920.*
|pronget02.o 	from   tuint920 for update
	from   tuint920  |pronget02.n
	where  tuint920._index1 inrange {:secu.f} and {:secu.t}
	and    tuint920.stfz = tuint.stad.free
	and    tuint920.fase = tucpe.fase.pro.subi
	selectdo
		lee.registro()
		|pronget01.sn
		select tccom110.ofbp
		from tccom110
		where tccom110._index1 = {:tuint920.bpid}
		selectdo
			code1 = 0
			flag.cuno = ""
		selectempty
			code1 = 1
			flag.cuno = "CLIENTE: " & strip$(tuint920.bpid)
		endselect
	
		select tccom001.emno
		from tccom001
		where tccom001._index1 = {:tuint920.crep}
		selectdo
			code2 = 0
			flag.crep = ""
		selectempty
			code2 = 1
			flag.crep = "REPRESENTANTE: " & strip$(tuint920.crep)
		endselect
	
		select tcmcs003.cwar
		from tcmcs003
		where tcmcs003._index1 = {:tuint920.cwar}
		selectdo
			code3 = 0
			flag.cwar =""
		selectempty
			code3 = 1
			flag.cwar = "ALMACEN: " & strip$(tuint920.cwar)
		endselect
		actualiza.tuint920.validaciones()  |pronget01.n
	endselect |pronget01.n
}

|pronget01.sn
function actualiza.tuint920.validaciones()
{
	|pronget02.sn
	puntero_tuint920 = db.bind("ttuint920", buf.ttuint920)
	db.columns.to.record(puntero_tuint920) 
	db.retry.point()
		
	select tuint920.*
	from   tuint920 for update
	where  tuint920._index1 = {:tuint920.secu}
	selectdo
	|pronget02.en
		if code0+code1+code2+code3+code4+code5 > 0 then
			report.msg = "ERROR: Pedido " & strip$(tuint920.orno) & " No Existe: " & strip$(flag.cuno) & strip$(flag.crep) & strip$(flag.cwar) &      |dyr1.o
			strip$(flag.cdel) & strip$(flag.ccrs) & strip$(err.mesg)
			tuint920.stfz = tuint.stad.error
			|pronget01.o		tuint920.stat = tdcpe.esta.error
			|getsito
			tuint920.fase = tucpe.fase.pro.subi
		else
			report.msg = ""
			tuint920.stfz = tuint.stad.free
			|pronget01.o		tuint920.stat = tdcpe.esta.libre
			|getsito
			tuint920.fase = tucpe.fase.pro.vali
		endif
		tuint920.merr = strip$(report.msg)
		tuint920.erro = strip$(report.msg)
		local.to.utc(date.num(), time.num(), tuint920.dtrp)
		|pronget02.o 	db.retry.point()
		|pronget02.o 		db.update(ttuint920,db.retry,db.skip.dupl)
 		val_retu = db.update(ttuint920,DB.RETRY) |pronget02.n
		val_retc =commit.transaction() |pronget02.n		
	endselect |pronget02.n
	
	if tuint920.stfz = tuint.stad.error then
		actualiza.detalles.a.error("valida")
	endif
	
	|pronget02.sn
	db.record.to.columns(puntero_tuint920) 
	db.unbind(puntero_tuint920)
	|pronget02.en
}

function check.all.data.detalle()
{
	select tuint920.*
	from   tuint920
	where  tuint920._index1 inrange {:secu.f} and {:secu.t}
	and    tuint920.stfz = tuint.stad.free
|pronget01.o	and    tuint920.stat = tdcpe.esta.libre
	and    tuint920.fase = tucpe.fase.pro.vali
	selectdo
		select tuint921.*
|pronget02.o 		from   tuint921 for update
		from   tuint921 |pronget02.n
		where  tuint921._index1 = {:tuint920.orno}
		selectdo
			codd1 = 0
			select tcibd001.*
			from tcibd001
			where tcibd001._index1 = {:tuint921.item}
			selectdo
				codd1 = 0
				flag.item = ""
			selectempty
				codd1 = 1
				flag.item = "BLOQUEO ARTICULO"
			endselect
			actualiza.tuint921.validaciones()
		endselect
	endselect
}

function actualiza.tuint921.validaciones()
{
	|pronget02.sn
	puntero_tuint921 = db.bind("ttuint921", buf.ttuint921)
	db.columns.to.record(puntero_tuint921) 
	db.retry.point()
		
	select tuint921.*
	from   tuint921 for update
	where  tuint921._index1 = {:tuint921.orno}
	selectdo
	|pronget02.en
		if codd1 > 0 then
			report.msg = strip$(flag.item)
			tuint921.stfz = tuint.stad.error
			tuint921.stat = tdcpe.esta.error
			tuint921.fase = tucpe.fase.pro.subi
		else
			report.msg = ""
			tuint921.stfz = tuint.stad.free
			tuint921.stat = tdcpe.esta.libre
			tuint921.fase = tucpe.fase.pro.vali
		endif
		tuint921.merr = strip$(report.msg)
		tuint921.erro = strip$(report.msg)
|pronget02.o 		db.retry.point()
|pronget02.o 		db.update(ttuint921,db.retry,db.skip.dupl)
		val_retu = db.update(ttuint921,DB.RETRY) |pronget02.n
		val_retc = commit.transaction() |pronget02.n
	|pronget02.sn
	endselect
	
	db.record.to.columns(puntero_tuint921) 
	db.unbind(puntero_tuint921)
	|pronget02.en
}

|pronget01.en


function lee.registro()
{

	empr = tuint920.empr |pronget01.n
	select tuint061.*
	from tuint061
	|where tuint061.ncmp =:empresa NOVAGAC01.o
	where tuint061._index1 = {:empresa} | NOVAGAC01.n
	and tuint061.cddz=:empr
	selectdo
		|pronget01.sn
		code0 = 0
		err.mesg = ""
		|pronget01.en
	selectempty
		code0 = 1 |pronget01.n
		err.mesg = err.mesg & " |La Empresa Actual no corresponde a los datos que se encuentran en el Archivo que se desea procesar"  |pronget01.n
	endselect
	
	|Limpiamos las variables de almacenemiento
	num.pedido=""
	cli.pedido=""
	f.pedido=""
	fp.pedido=""
	con1=""
	con2=""
	con3=""
	con4=""
	alm.pedido=""
	tipo.pedido=""
	ase.pedido=""
}

function procesar.ordenes.vta()
{
	domain tcbool ok.error        | NOVAGAC01.n
	domain tcbool ok.error.lineas | NOVAGAC01.n
	
	report.msg = ""
	error.msg = ""
	ok.proceso = true
	ovta.orno = ""
	ovta.pono = 0
	ovta.sqnb = 0
	ovta.ofbp = ""

	reg.tot = 0    |dyr.n

	reg.act = 0

	|dyr.sn
   
	
	|SELECT PRINCIPAL
	select	tuint920.*
	from	tuint920 | NOVAGAC01.n
	|pronget01.sn
	where  tuint920._index1 inrange {:secu.f} and {:secu.t}
	and    tuint920.stfz = tuint.stad.free
|pronget01.o	and    tuint920.stat = tdcpe.esta.libre
	and    tuint920.fase = tucpe.fase.pro.vali
	|pronget01.en
	order by tuint920.crep,tuint920.secu |mjc.n
	selectdo
		reg.act = reg.act + 1
		ok.error = false | NOVAGAC01.n

		if not validar.ofbp(tuint920.bpid, error.msg) then
			ok.proceso = false
			report.msg = "ERROR: Orden PDA: " & shiftl$(shiftr$(tuint920.orno)) & " - " & error.msg
			continue
		endif
		|* Si ya se ha generado la orden de venta. No crear la cabecera
		|* Nuevamente. Asiganr la variable ovta.orno el valor
		|* tuint920.ornt. mabppf01

		if isspace(tuint920.ornt) then
			ovta.orno = ""
			if not crear.cabecera.ovta(ovta.orno, error.msg) then
				ok.proceso = false
				report.msg = "ERROR: Pedido " & tuint920.orno & error.msg
				tuint920.merr = report.msg
				tuint920.stfz = tuint.stad.error       |dyr1.n
				tuint920.erro = report.msg |pronget01.n
|pronget01.o				tuint920.stat = tdcpe.esta.error |pronget01.n
				actualiza.detalles.a.error("cabecera") |pronget01.n
				|getsito
				tuint920.fase = tucpe.fase.pro.subi |pronget01.n
				ok.error = true | NOVAGAC01.n
			else
				report.msg = "Orden PDA " & shiftl$(shiftr$(tuint920.orno)) & " - " & "MENSAJE: Se ha creado la orden de venta " &
					     str$(ovta.orno) & " cliente " & tuint920.bpid
				tuint920.ornt = str$(ovta.orno)
				tuint920.merr = report.msg
				tuint920.erro = "" |pronget01.n
|pronget01.o				tuint920.stat = tdcpe.esta.exito |pronget01.n
				|getsito
				tuint920.fase = tucpe.fase.pro.ovta |pronget01.n
			endif
			| NOVAGAC01.sn
			|pronget02.sn
			puntero_tuint920 = db.bind("ttuint920", buf.ttuint920)
			db.columns.to.record(puntero_tuint920) 
			|pronget02.en
			db.retry.point()
			select tuint920.*
			from tuint920 for update
			where tuint920._index2 = {:tuint920.orno} | NOVAGAC03.n
			selectdo
				if ok.error then
					tuint920.merr = report.msg
					tuint920.erro = report.msg |pronget01.n
|pronget01.o					tuint920.stat = tdcpe.esta.error |pronget01.n
					|getsito
					tuint920.fase = tucpe.fase.pro.subi |pronget01.n
					tuint920.stfz = tuint.stad.error
				else
					tuint920.ornt = str$(ovta.orno)
					tuint920.merr = report.msg
					tuint920.erro = "" |pronget01.n
|pronget01.o					tuint920.stat = tdcpe.esta.exito |pronget01.n
					|getsito
					tuint920.fase = tucpe.fase.pro.ovta |pronget01.n
				endif
 				val_retu = db.update(ttuint920, DB.RETRY)
				val_retc = commit.transaction()
			endselect
			|pronget02.sn
			db.record.to.columns(puntero_tuint920) 
			db.unbind(puntero_tuint920)
			|pronget02.en
			| NOVAGAC01.en
		else
			ovta.orno = tuint920.ornt
			revisa.bloqueo.aplicacion() | NOVAGAC04.n 
		endif
		| NOVAGAC01.sn
		if ok.error then
			| Si hubo error se debe regresar y no grabar las lineas de esta
			| Orden
			continue
		endif
		| NOVAGAC01.en

		rec.linea = 0     |dyr.n
		ovta.ofbp = tuint920.bpid
		ok.error.lineas = false | NOVAGAC01.n
		select	tuint921.*
		from	tuint921  | NOVAGAC01.n
		where	tuint921._index1 = { :tuint920.orno }
		|pronget01.sn
		and    tuint921.stfz = tuint.stad.free
		and    tuint921.stat = tdcpe.esta.libre
		and    tuint921.fase = tucpe.fase.pro.vali
		|pronget01.en
|pronget02.o 		order by tuint921.orno, tuint921.nuli     |dyr.n
		order by tuint921._index1     |pronget02.n
		selectdo
			reg.tot = reg.tot + 1
			rec.linea = rec.linea + 1      |dyr.n
			if not crear.linea.ovta(ovta.orno, ovta.pono, ovta.sqnb, error.msg) then
				ok.proceso = false
				ok.error.lineas = true | NOVAGAC01.n
				report.msg = "ERROR: Pedido " & strip$(shiftl$(tuint921.orno)) &
				     "/" & strip$(shiftl$(str$(tuint921.item))) &
				     ", No se pudo crear linea O/V " & strip$(shiftl$(str$(ovta.orno))) &
				     " : " & error.msg
				tuint921.merr = "O/V : " & strip$(shiftl$(str$(ovta.orno))) & error.msg
				tuint921.stfz = tuint.stad.error
				tuint921.erro = "O/V : " & strip$(shiftl$(str$(ovta.orno))) & error.msg |pronget01.n
				tuint921.stat = tdcpe.esta.error |pronget01.n
				tuint921.fase = tucpe.fase.pro.vali |pronget01.n
			else
				report.msg = "MENSAJE: Pedido " & strip$(shiftl$(str$(tuint921.orno))) &
				     "/" & strip$(shiftl$(str$(tuint921.item))) &
				     ", Linea O/V creada " &
				     str$(ovta.orno) & "/" & str$(ovta.pono)
				     & "/" & str$(ovta.sqnb)
				if not isspace(error.msg) then
					report.msg = report.msg & " : " & error.msg
				endif
				tuint921.merr = report.msg
				tuint921.stfz = tuint.stad.success
				tuint921.erro = "" |pronget01.n
				tuint921.stat = tdcpe.esta.exito |pronget01.n
				tuint921.fase = tucpe.fase.pro.ovtd |pronget01.n
			endif
			| NOVAGAC01.sn
			|pronget02.sn
			puntero_tuint921 = db.bind("ttuint921", buf.ttuint921)
			db.columns.to.record(puntero_tuint921) 
			|pronget02.en
			db.retry.point()
			select tuint921.*
			from tuint921 for update
			where tuint921._index1 = {:tuint921.orno,:tuint921.nuli,:tuint921.item}
			selectdo
				if ok.error.lineas then
					tuint921.merr = "O/V : " & strip$(shiftl$(str$(ovta.orno))) & error.msg
					tuint921.stfz = tuint.stad.error
					tuint921.erro = "O/V : " & strip$(shiftl$(str$(ovta.orno))) & error.msg |pronget01.n
					tuint921.stat = tdcpe.esta.error |pronget01.n
					tuint921.fase = tucpe.fase.pro.vali |pronget01.n
				else
					tuint921.merr = report.msg
					tuint921.stfz = tuint.stad.success
					tuint921.erro = "" |pronget01.n
					tuint921.stat = tdcpe.esta.exito |pronget01.n
					tuint921.fase = tucpe.fase.pro.ovtd |pronget01.n
				endif
 				val_retu = db.update(ttuint921, DB.RETRY)
				val_retc = commit.transaction()
			endselect
			|pronget02.sn
			db.record.to.columns(puntero_tuint921) 
			db.unbind(puntero_tuint921)
			|pronget02.en

			| NOVAGAC01.en
		endselect
		| NOVAGAC01.sn
		| Cuando hubo existo en subir TODAS LAS LINEAS DEL PEDIDO
		| Ahi actualizar el status de subida exitosamente en la cabecera
		|pronget02.sn
		puntero_tuint920 = db.bind("ttuint920", buf.ttuint920)
		db.columns.to.record(puntero_tuint920) 
		|pronget02.en
		db.retry.point()
		select tuint920.*
		from tuint920 for update
		where tuint920._index2 = {:tuint920.orno} | NOVAGAC03.n
		selectdo
			if not ok.error.lineas then
				tuint920.stfz = tuint.stad.success
|pronget01.o				tuint920.stat = tdcpe.esta.exito |pronget01.n
				|getsito
			else
				tuint920.stfz = tuint.stad.error
|pronget01.o				tuint920.stat = tdcpe.esta.error |pronget01.n
				|getsito
			endif
			tuint920.fech = utc.num() |pronget01.n
			tuint920.user = logname$  |pronget01.n
			val_retu = db.update(ttuint920, DB.RETRY)
			val_retc = commit.transaction()
		endselect
		|pronget02.sn
		db.record.to.columns(puntero_tuint920) 
		db.unbind(puntero_tuint920)
		|pronget02.en
		| NOVAGAC01.en
	selecteos
		COMMIT.transaction()
		| Ejecutar procesamiento directo y actualizar cantidad entregada
		stpapi.end.session("tdsls4501m000")
		if ok.proceso then
			report.msg = "MENSAJE: Proceso completado con exito!"
		else
			report.msg = "ERROR: Se produjeron errores durante el proceso! Revise el archivo  " & strip$(que.errfile)
		endif
	selectempty
		err.mesg = "No existen Ordenes de Venta a Procesar"  |pronget01.n
	endselect

	commit.transaction()
	| Cerrar ventana de lista - ordenes de venta
	stpapi.end.session("tdsls4500m000")
|  	appl.delete("tuint1221m100"&str$(get.compnr())) |pronget02.n
	actualiza.estado.ov()
}


function extern domain tcbool validar.ofbp(
				    domain tccom.bpid ofbp,
				ref domain tcmcs.str215 error.msg)
{
| 	table	ttccom100	|partners
| 	table	ttccom110	|Clientes
| 	table	ttccom111	|

	domain	tcbool one.time.bp

	| * Validar estatus inactivo
	select	tccom100.*
	from	tccom100
	where	tccom100._index1 = { :ofbp }
	selectdo
		if tccom100.prst = tccom.prst.inactive then
			error.msg = "El partner " & ofbp & " tiene estatus " &
				    enum.descr$("tccom.prst", tccom100.prst)
			return(false)
		endif
	endselect

	| * Validar partner cliente
	select	tccom110.*
	from	tccom110
	where	tccom110._index1 = { :ofbp }
	selectdo
		if tccom110.bpst = tccom.prst.inactive then
			error.msg = "El partner cliente " & ofbp & " tiene estatus " &
				    enum.descr$("tccom.prst", tccom110.bpst)
			return(false)
		endif
	selectempty
		error.msg = "No se ha hallado partner cliente para partner " & ofbp
		return(false)
	endselect

	| * Validar partner receptor
	select	tccom111.*
	from	tccom111
	where	tccom111._index1 = { :ofbp }
	selectdo
		if tccom111.bpst = tccom.bpst.inactive then
			error.msg = "El partner receptor " & ofbp & " tiene estatus " &
				    enum.descr$("tccom.bpst", tccom111.bpst)
			return(false)
		endif
	selectempty
		error.msg = "No se ha hallado partner receptor para partner " & ofbp
		return(false)
	endselect

	|* Check whether BP is potential
	if tccom.dll4010.sold.to.potential(ofbp) then
		error.msg = form.text$("tdsls41014")
	   	|* Sales orders or sales contracts for prospects not allowed.
	endif

	|* below is needed because one time bp function return a true or a
	|* false, but tools could also return negative values.
	one.time.bp = (tccom.dll4000.one.time.business.partner(ofbp) =
		       true ? true : false)
	if one.time.bp then
		if not(tccom.dll4014.pay.by.bp.present(ofbp)) or
		   not(tccom.dll4012.invoice.to.bp.present(ofbp)) then
			error.msg = form.text$("td4100.1")
			error.msg = sprintf$(error.msg, ofbp)
			|* Pay-by and Invoice-to Business Partners must be
			|* defined for Business Partner %s.
			return(false)
		endif
	endif

	return(true)
}

function domain tcbool crear.cabecera.ovta(ref domain tcorno	   ovta.orno,
					   ref domain tcmcs.str215 error.msg)
{
	|pronget02.sn
	domain tccom.bpid q.bpid
	domain tccotp	  q.sotp
	domain tccotp	  q.sotp1
	domain tcseri 	  q.seri
	domain tccotp 	  q.sotd
	domain tcseri 	  q.serd
	domain tccdis     q.motv
	domain tcemno     q.crep
	domain tccwar 	  q.cwar
	domain tcdate     q.ddat 
	domain tcdate     q.odat 
	domain tccwoc     x.cofc 
	domain tccwoc     y.cofc 
	domain tcorno     q.orno
	domain tclong     q.secu
	domain tcrefa     q.refa
	|pronget02.en
	
	
	ovta.orno = ""
	error.msg = ""

	| Sincronizar con sesion single
	ret = stpapi.synchronize.dialog("tdsls4500m000", "add", error.msg)
	if not ret then
		error.msg = "Crear orden de venta. " &
			    "Sincronización con sesion tdsls4100s000: " & error.msg
		stpapi.end.session("tdsls4500m000")
		return(false)
	endif

	Select tuint100.*
	from tuint100
	where tuint100._index1 ={:empresa} | NOVAGAC03.n
	as set with 1 rows      |dyr
	selectdo
	endselect

	|pronget02.sn
	q.bpid = tuint920.bpid
	q.sotp = tuint920.sotp
	q.sotp1 = tuint100.sotp
	q.seri = tuint100.seri
	q.sotd = tuint100.sotd
	q.serd = tuint100.serd
	q.motv = tuint100.motv
	q.crep = tuint920.crep 
	q.cwar = tuint920.cwar 
	q.ddat = tuint920.ddat 
	q.odat = tuint920.odat 
	q.orno = tuint920.orno
	q.secu = tuint920.secu
	q.refa = tuint920.refa
	|pronget02.en
	
	
	| Llenar datos de cabecera de orden de venta
	stpapi.put.field("tdsls4100s000", "tdsls400.ofbp", q.bpid)             |partner
	if strip$(q.sotp)="VNO" or  strip$(q.sotp)="VNI" then
		stpapi.put.field("tdsls4100s000", "tdsls400.sotp", q.sotp)          |tipo de orden de venta
		stpapi.put.field("tdsls4100s000", "tdsls400.orno", q.seri)          |numero de la ovta
	else
		stpapi.put.field("tdsls4100s000", "tdsls400.sotp", q.sotd)             |tipo de orden de venta
		stpapi.put.field("tdsls4100s000", "tdsls400.orno", q.serd)             |tipo de orden de venta
		|Verificamos si es una VDI colocar el motivo de devolucion
		stpapi.put.field("tdsls4100s000", "tdsls400.retr", strip$(q.motv))             |Motivo de Devolucion
	endif
	stpapi.put.field("tdsls4100s000", "tdsls400.crep", q.crep)             |vendedor
	stpapi.put.field("tdsls4100s000", "tdsls400.cwar", q.cwar)             |Almacen
	stpapi.put.field("tdsls4100s000", "tdsls400.ddat", str$(q.ddat))       |fecha planificada de entrega  |mjc.n
	stpapi.put.field("tdsls4100s000", "tdsls400.odat", str$(q.odat))       |Fecha Orden
	stpapi.put.field("tdsls4100s000", "tdsls400.refa", str$(q.refa))       |REferencia Orden PDA
   
	select tccom110.*
	from tccom110
	where tccom110._index1={:tuint920.bpid}   |dyr.n
	selectdo
		|pronget02.sn
		x.cofc = tuint100.cofc
		y.cofc = tccom110.cofc
		|pronget02.en
		if len(strip$(tccom110.cofc))=0 then
			stpapi.put.field("tdsls4100s000", "tdsls400.cofc", str$(x.cofc))                  |Departamento de Ventas
		else
			stpapi.put.field("tdsls4100s000", "tdsls400.cofc", str$(y.cofc))                  |Departamento de Ventas
		endif
	endselect
	| NOVAGAC01.sn
	stpapi.put.field("tdsls4100s000", "tdsls400.corn", q.orno)
	stpapi.put.field("tdsls4100s000", "tdsls400.refb", q.orno&" - "&str$(q.secu))
	| NOVAGAC01.en
	
	| Grabar datos
	
	ret = stpapi.insert("tdsls4500m000", true, error.msg)
		
	
	if not ret then
		stpapi.recover("tdsls4100s000", recover.msg)
		error.msg = "Crear orden de venta. " &
			    "Guardar datos en sesion tdsls4100s000: " & error.msg
		stpapi.end.session("tdsls4100s000")
		stpapi.end.session("tdsls4500m000")
		return(false)
	endif
	stpapi.enum.answer("tdsls4100s000","tdslss0065", tcyesno.yes)
	stpapi.handle.subproc("tdsls4100s000","tdslss0065","ignore") |pronget02.n
	stpapi.get.field("tdsls4100s000", "tdsls400.orno", ovta.orno)
	stpapi.end.session("tdsls4100s000")
	stpapi.end.session("tdsls4500m000") | NOVAGAC01.n

	return(true)
}

function domain tcbool ubicar.marcar.ovta(  domain tcorno	ovta.orno,
					ref domain tcmcs.str215 error.msg)
{
	| Ubicar la orden de venta
	stpapi.put.field("tdsls4500m000", "tdsls400.orno", ovta.orno)
	ret = stpapi.find("tdsls4500m000", error.msg)
	if ret <> 1 then
		error.msg = "ERROR: No se pudo encontrar la orden de venta " &
			     ovta.orno & " : " & error.msg
		return(false)
	endif

	| Marcar registro para llamar sesion de detalle de transacciones
	ret = stpapi.mark("tdsls4500m000", error.msg)
	if not ret then
		error.msg = "ERROR: No se pudo seleccionar " &
			    "la orden de venta " & ovta.orno
		return(false)
	endif

	return(true)
}

function domain tcbool crear.linea.ovta(domain tcorno	    ovta.orno,
				    ref domain tcpono	    ovta.pono,
				    ref domain tcpono	    ovta.sqnb,
				    ref domain tcmcs.str215 error.msg)
{
	domain 	tcmcs.str10	aux.pono
	domain	tcmcs.str10	aux.sqnb
	
	|pronget02.sn
	domain tcitem q.item
	domain tcqsl1 q.quap
	domain tcorno q.orno1
	domain tclong q.nuli 
	
	
	q.item = tuint921.item
	q.quap = tuint921.quap
	q.orno1 = tuint921.orno
	q.nuli = tuint921.nuli
	|pronget02.en

	error.msg = ""
	ovta.pono = 0
	ovta.sqnb = 0

	leer.datos.articulo(q.item)

	| Ubicar orde. de venta
	stpapi.put.field("tdsls4501m000", "tdsls401.orno", ovta.orno)
	ret = stpapi.change.view("tdsls4501m000", error.msg)
	
	if not isspace(error.msg) then  | NOVAGAC05.n 
		error.msg = "No se encontró la orden " & ovta.orno &
			    ": " & error.msg
		return(false)
	endif

	| Sincronizar con sesion single tdsls4101s000 - Lineas de orden vta
	ret = stpapi.synchronize.dialog("tdsls4501m000", "add", error.msg)
	if not ret then
		error.msg = "Crear linea orden vta. " &
			    "Sincronización con sesion tdsls4101s000: " & error.msg
		return(false)
	endif

	| Llenar datos de linea de orden de venta
| 	stpapi.put.field("tdsls4101s000", "tdsls401.item.segment.1", tcibd001.item)  |pronget01.n SOLO PARA QUE FUNCIONE EN NOVATECH
	stpapi.put.field("tdsls4101s000", "tdsls401.item", q.item)
	stpapi.handle.subproc("tdsls4101s000","tdsls11033","ignore")
	stpapi.put.field("tdsls4101s000", "tdsls401.oqua", str$(q.quap))

	|Enviamos Kill al mensaje de Stock
|pronget02.o 	stpapi.handle.subproc("tdsls4101s000","tdsls4811s000","kill")
	| NOVAGAC01.sn
	stpapi.put.field("tdsls4101s000", "tdsls401.corn", q.orno1)
	stpapi.put.field("tdsls4101s000", "tdsls400.corp", str$(q.nuli))
	| NOVAGAC01.en
	| Grabar datos
	stpapi.handle.subproc("tdsls4101s000","00009057","ignore")
	stpapi.handle.subproc("tdsls4101s000","tdsls4811s000","kill")
	
	ret = stpapi.insert("tdsls4501m000", true, error.msg)
	
	
	if not ret then
		stpapi.recover("tdsls4101s000", recover.msg)
		error.msg = "Sesión tdsls4101s000: " & error.msg
		stpapi.end.session("tdsls4101s000")
		stpapi.end.session("tdsls4501m000")
		return(false)
	endif

	stpapi.get.field("tdsls4101s000", "tdsls401.pono", aux.pono)
	stpapi.get.field("tdsls4101s000", "tdsls401.sqnb", aux.sqnb)

	ovta.pono = lval(aux.pono)
	ovta.sqnb = lval(aux.sqnb)

	stpapi.end.session("tdsls4101s000")

	return(true)
}

function leer.parametros()
{
	select	tuint100.*
	from	tuint100
	where tuint100._index1 ={:empresa} | NOVAGAC03.n
	as set with 1 rows   |dyr.n
	selectempty
|pronget01.o 		message("No existen parametros de Fuerzas de Ventas")
	err.mesg = err.mesg & " |No existen parametros de Fuerzas de Ventas"
	end()
	endselect
}

function leer.datos.articulo(domain tcitem item)
{
	| Leer datos de artículo en base a clave de acceso II  y regresa
	| el codigo del articulo
	select	tcibd001.*
	from	tcibd001
	where tcibd001._index1={:item}    |dyr.n
	selectdo
	endselect
}

function actualiza.estado.ov()
{
	domain tcbool ok.error | NOVAGAC01.n
	domain tcbool ok.paso  |pronget02.n
	
	ok.paso = false |pronget02.n
	
	db.retry.point()
	select	tuint920.*
	from	tuint920 for update
	where  tuint920._index1 inrange {:secu.f} and {:secu.t}  |pronget01.n
	order by tuint920._index1          |dyr.n
	selectdo
		ok.error = false | NOVAGAC01.n
		select	tuint921.*
		from	tuint921
		where	tuint921._index1 = { :tuint920.orno }
		and	tuint921.stfz = tuint.stad.error
		as set with 1 rows | NOVAGAC01.n
		selectdo
			ok.error = true | NOVAGAC01.n
			tuint920.stfz = tuint.stad.error       |dyr1.n
			tuint920.stat = tdcpe.esta.error			|pronget01.n
			tuint920.erro = "Algunas líneas en error"			|pronget01.n
 			val_retu = db.update(ttuint920, DB.RETRY)		   |pronget02.n
			val_retc = commit.transaction() |pronget02.n
		selectempty
			ok.paso = true |pronget02.n
			tuint920.stat = tdcpe.esta.exito
			val_retu = db.update(ttuint920,DB.RETRY) |pronget02.n		
			val_retc = commit.transaction() |pronget02.n
		|pronget01.en
		endselect
		| NOVAGAC01.sn
|pronget02.o 		if not ok.error then
 		if not ok.error and ok.paso then  |pronget02.o
			| Verificar si tiene lineas en status libre
			|pronget02.sn
			puntero_tuint920 = db.bind("ttuint920", buf.ttuint920)
			db.columns.to.record(puntero_tuint920) 
			db.retry.point()
			select	tuint920.*
			from	tuint920 for update
			where   tuint920._index1 = { :tuint920.secu }  |pronget01.n
			order by tuint920._index1          |dyr.n
			selectdo
			|pronget02.en
				select	tuint921.*
				from	tuint921
				where	tuint921._index1 = { :tuint920.orno }
				and	tuint921.stfz = tuint.stad.free
				as set with 1 rows | NOVAGAC01.n
				selectdo
					| Hay lineas libres no debe cambiar status de
					| Cabecera
				selectempty
					| NO hay lineas con error ni libres
					| Debe poner en exitosa la cabecera
					tuint920.stfz = tuint.stad.success
					tuint920.stat = tdcpe.esta.exito  |pronget01.n
					db.update(ttuint920, DB.RETRY)   |pronget02.n
					val_retc = commit.transaction() |pronget02.n
				endselect
			endselect |pronget02.n
			|pronget02.sn
			db.record.to.columns(puntero_tuint920) 
			db.unbind(puntero_tuint920)
			|pronget02.en
		endif
		| NOVAGAC01.en
	endselect
|pronget02.o 	commit.transaction()
}

|pronget01.sn
function validar.existencia.det_new()
{
	db.retry.point()
	select	tuint920.*
	from	tuint920 for update
	where  tuint920._index1 inrange {:secu.f} and {:secu.t}
	and    tuint920.stfz = tuint.stad.free
|pronget01.o	and    tuint920.stat = tdcpe.esta.libre
	and    tuint920.fase = tucpe.fase.pro.vali
	selectdo
		select	tuint921.*
		from	tuint921
		where	tuint921._index1 = { :tuint920.orno }
		order by tuint921.orno,tuint921.nuli
		selectdo
		selectempty
			report.msg = "ERROR: Orden PDA: " & shiftl$(shiftr$(tuint920.orno)) & " - " & "No existen lineas de detalle"
			tuint920.merr = report.msg
			tuint920.erro = report.msg
			tuint920.stfz = tuint.stad.error
|pronget01.o			tuint920.stat = tdcpe.esta.error |aqui estaba libre
			|getsito
			tuint920.fase = tucpe.fase.pro.subi
 			val_retu = db.update(ttuint920, DB.RETRY)   |pronget02.n
			val_retc = commit.transaction() |pronget02.n
		endselect
	endselect
|pronget02.o 	commit.transaction()
}
|pronget01.sn


function revisa.bloqueo.aplicacion()
{
	domain tcmcs.str70 que.clave 

	table tttadv998 
	
	| revisas si hay un bloqueo para ovta.orno 
	| Si hay algun bloqueo eliminarlo automáticamente.
	db.retry.point()
	que.clave = "tdsls400"& strip$(ovta.orno)
	select ttadv998.*
	from  ttadv998 for update  
	where ttadv998._compnr = 000 
	  and ttadv998._index1 = {:que.clave}
	selectdo
			db.delete(tttadv998,db.retry)
	endselect
	commit.transaction()
	
}
| NOVAGAC04.en
|pronget01.sn
function domain tcbool verifica.compania()
{
	
	domain tcmcs.long que.compania, que.resultado
	domain tcbool que.valor
	
	que.compania = get.compnr()
	
	if que.compania<>0 then		
		que.resultado = switch.to.company(0)
	endif
	
	que.valor = false
	
	select ttaad100.*
	from   ttaad100
	where  ttaad100._index1 = {:ncmp.f}
	selectdo
		que.valor = true
	endselect
	
	que.resultado = switch.to.company(que.compania)
	
	return(que.valor)
}

function actualiza.detalles.a.error(domain tcmcs.str8 que.indica)
{
	select tuint921.*
	from   tuint921 for update
	where  tuint921._index1 = {:tuint920.orno}
	selectdo
		tuint921.stfz = tuint.stad.error
		tuint921.stat = tdcpe.esta.error
		if strip$(que.indica)="cabecera" then
			tuint921.erro = "No se pudo crear cabecera"
		else
			tuint921.erro = "Cabecera no paso validaciones"
		endif
		val_retu = db.update(ttuint921, DB.RETRY)	
		val_retc = commit.transaction()
	endselect
|pronget02.o 	commit.transaction()
}
|pronget01.en

Last edited by george7a : 9th October 2008 at 10:18. Reason: adding baan code tags
Reply With Quote
Sponsored Links
  #6  
Old 9th October 2008, 16:51
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,906
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Well the AFS code looks fine from what I can see. What I was really thinking when I said source code - was the source code of the session itself. For example in my case the Delete GRP production orders will error out every so often. If I had the source for deleting GRP order I might be able to trace it to the code causing the problems. As it is we just keep re-running them until all the orders are deleted.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem when I process with multi threads by ba6.2 gget79 Tools Development 5 27th August 2008 15:56
Input in multi session problem Glisha Miscellaneous 1 9th October 2006 09:00
Problem with the processing speed of tfgld4201m000 anubhav.bansal Tools Development 3 14th July 2006 16:49
PDF Processing Problem Eddie Monster Tools Development 1 18th October 2002 16:23


All times are GMT +2. The time now is 04:08.


©2001-2017 - Baanboard.com - Baanforums.com