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 29th October 2003, 06:32
Debdas Banerjee Debdas Banerjee is offline
Member
 
Join Date: Feb 2003
Location: Mumbai
Posts: 90
Debdas Banerjee is on a distinguished road
Baan: 4c4 - DB: sql-2000/ informix - OS: Advance server / unix
Table update problem

Hi

Friends,

I am doing customization and facing table update problem.I have two table i) tdcus855 ( main table) ii) tdcus851 ( dynamic stock).
For first time its update both files properly but when I modify the same records then update the main table properly but not functioning properly for tdcus851 ( stock file) for modification it act a frest entry and update the wrong data.

Please help .

Regards

Debdas

Code:
|******************************************************************************
|* tdcus9486deb  0  VRC B40C c4 test
|* Maintain Rack In/Out Status
|* test                          
|* 2003-10-20
|******************************************************************************
|* Main table tdcus855 Rack In/Out Status, Form Type 3
|******************************************************************************
                                                                                
|****************************** declaration section ***************************
declaration:

	table	ttdcus855	| Rack In/Out Status
	table   ttcmcs003	| Warehouse
	table   ttdcus850       | Rack Master
	table   ttiitm001  	| Item Master
	table   ttdcus851       | Rack stock
	double  currqty
	double  qty1
	
	
	extern domain   tcorno  slip

	after.update.db.commit:
	stock()
|****************************** form section **********************************

field.tdcus855.type:
after.input:
        if tdcus855.type = tdrack.rktf then
           message("Sorry For Inconvenient Soon It Will Be Available")	
           input.again()
        endif
           
        
|	select tdcus855.type
|	from   tdcus855
|	selectdo
|	selectempty
|	   Message ("Type Can Not Be Blank") 
| 	   choice.again()	
|	   |input.again()	
|	endselect   

field.tdcus855.cwar:
before.input:
    tdcus855.cwar ="F01"

after.input:
   if tdcus855.cwar<>"F01" then
      Message("Please Check The Ware House ") 
   
      input.again()
   endif   
   



|on.input:
|	select tcmcs003.cwar
|	from   tcmcs003
|	where  tcmcs003._index1 = {:tdcus855.cwar}
|	selectdo
|	selectempty
|
|	       Message("Warehouse Does not Exit ")
|	       input.again()	 
|	endselect
 
 field.tdcus855.slip:
 before.input:

	select max(tdcus855.slip):slip
 	from   tdcus855
 	selectdo
	endselect
	tdcus855.slip = slip+1
	
	
field.tdcus855.rack:

before.zoom:
	tdcus850.cwar = "F01"
 
  after.input:
 	select tdcus850.rack
	from   tdcus850
	where  tdcus850._index1 = {:tdcus855.cwar,:tdcus855.rack}
	selectdo
	selectempty
	       Message("This Rack No Does Not Exit In This Warehous")
	       input.again()	
	       |choice.again() 
	endselect


field.tdcus855.item:
 on.input:

	select tdcus605.item
	from   tdcus605
	where  tdcus605._index1 = {:tdcus855.item}
	selectdo
	selectempty
	       Message("Please Check The Item Code ")
	       input.again()	 
	endselect

field.tdcus855.qtyl:
 before.input:

 currqty = tdcus855.qtyl


 select tdcus851.stoc
 from   tdcus851
 where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
 selectdo
	tdcus855.stoc = tdcus851.stoc 
	display("tdcus855.stoc")
 selectempty
        tdcus855.stoc = 0
 endselect

 on.input:

 if tdcus855.qtyl = 0  or  tdcus855.qtyl <0 then
 	       Message("Quantity Can Not Blank  ")
	       input.again()	 
 endif
 
 if tdcus855.type = tdrack.rkut then
    	if tdcus855.qtyl  > tdcus855.stoc   then
	       Message("Quantity Can Not Be Greater Than Stock  ")
	       input.again()	 
	endif    
 endif
 
 when.field.changes:
 	qty1 = tdcus855.qtyl - currqty
	 |message("%d",qty1)
|****************************** choice section ********************************

choice.mark.delete:
before.choice:
  message (" i am  before choice ")
on.choice:
  message (" i am  on choice ")

after.choice:
  message (" i am  after choice ")




choice.cont.process:
before.choice:
check.all.input()

|****************************** field section ********************************




main.table.io:
before.write:
 	if tdcus855.type = tdrack.rkin then	
	        |tdcus855.stoc = tdcus851.stoc + tdcus855.qtyl
	        tdcus855.stoc = tdcus855.stoc + (qty1)
	else
		|tdcus855.stoc = tdcus851.stoc - tdcus855.qtyl
		tdcus855.stoc = tdcus855.stoc - (qty1)
	endif        
	tdcus855.date = date.num()
	tdcus855.time = time.num()
	tdcus855.user = logname$
	commit.transaction()
	


functions:
	
function stock()		
{
	db.retry.point()
	
| 	select tdcus855.*
| 	from   tdcus855
| 	where  tdcus855._index1 = {:tdcus855.type,"F01",:tdcus855.slip}
| 	selectdo
| 	selectempty
| 		if tdcus855.item <>" " and  tdcus855.rack <> "" and tdcus855.qtyl<> 0 then
| 			tdcus855.type = tdcus855.type
| 			tdcus855.cwar = tdcus855.cwar
| 			tdcus855.slip = tdcus855.slip
| 			tdcus855.rack = tdcus855.rack
| 			tdcus855.item = tdcus855.item
| 			tdcus855.qtyl = tdcus855.qtyl
| 			tdcus855.stoc = tdcus855.stoc
| 			tdcus855.date = date.num()
| 			tdcus855.time = time.num()
| 			tdcus855.user = logname$
| 			db.insert(ttdcus855,db.retry)
| 		endif
| 	endselect
| 	commit.transaction()
	
	
        select tdcus855.*
 	from   tdcus855 |for update
 	where  tdcus855._index1 = {:tdcus855.type,:tdcus855.cwar,:tdcus855.slip}
 	selectdo 
 		select tdcus851.*
 		from   tdcus851 for update
 		where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
 		selectdo 
 			if tdcus855.type =  tdrack.rkin then		
 	        		tdcus851.stoc = tdcus851.stoc + qty1
 		        endif
 			if tdcus855.type =  tdrack.rkut then	
 	        		tdcus851.stoc = tdcus851.stoc - (qty1)
 	        	endif	        
 			db.update(ttdcus851,db.retry)
 			tdcus851.stoc = 0
 		selectempty	
 			if tdcus855.rack ="" then
 			    skip.io("")
 			endif    
 			if tdcus855.type = tdrack.rkin then	
 				tdcus851.item = tdcus855.item
 				tdcus851.cwar = tdcus855.cwar
 				tdcus851.rack = tdcus855.rack
 	 		     	tdcus851.stoc = tdcus851.stoc + tdcus855.qtyl
 		        	db.insert(ttdcus851,db.retry)
 		        	tdcus851.stoc = 0
 		        endif
 		endselect
 	endselect        
 	commit.transaction()
	
}
__________________
Deb
Arise Awake & Stop not till the Goal is Reached...........Swami Vivekananda.
Reply With Quote
  #2  
Old 29th October 2003, 21:21
vahdani's Avatar
vahdani vahdani is offline
Guru
 
Join Date: Aug 2002
Location: Cologne, Germany
Posts: 418
vahdani is on a distinguished road
Baan: all - DB: all - OS: Unix / Win2K
Hallo,

the main proplem is apparantly the lack of a before/after.rewrite section in your code. I have allowed myself to do a major facelift on your script showing the way I would have done the coding.

Code:
|******************************************************************************
|* tdcus9486deb  0  VRC B40C c4 test
|* Maintain Rack In/Out Status
|* test
|* 2003-10-20
|******************************************************************************
|* Main table tdcus855 Rack In/Out Status, Form Type 3
|******************************************************************************
|* hv H.Vahdani (Baanboard member), 29.10.2003
|* major facelift showig correct programming practice only. No warranty on
|* business logic :)
|* Markings glossory:	.o = old
|*			.n = new
|*			.so= start old
|*			.eo= end old
|*			.sn= start new
|*			.en= end new
|****************************** declaration section ***************************
declaration:
#ident "@(#)hv H.Vahdani, 29.10.2003, major facelift :)"

	table	ttdcus855	| Rack In/Out Status
	table   ttcmcs003	| Warehouse
	table   ttdcus850       | Rack Master
	table   ttiitm001  	| Item Master
	table   ttdcus851       | Rack stock
	double  currqty
	double  qty1


	extern domain   tcorno  slip

|	after.update.db.commit:					|hv.so
|	stock()							|hv.eo
|****************************** form section **********************************

field.tdcus855.type:
|after.input:							|hv.o
check.input:							|hv.n
        if tdcus855.type = tdrack.rktf then
           message("Sorry For Inconvenient Soon It Will Be Available")
|          input.again()					|hv.o
           set.input.error("")					|hv.n
        endif


|	select tdcus855.type
|	from   tdcus855
|	selectdo
|	selectempty
|	   Message ("Type Can Not Be Blank")
| 	   choice.again()
|	   |input.again()
|	endselect

field.tdcus855.cwar:
before.input:
    tdcus855.cwar ="F01"
|after.input:							|hv.o
check.input:							|hv.n
   if tdcus855.cwar<>"F01" then
     	Message("Please Check The Warehouse ")
|	input.again()						|hv.o
	set.input.error("")					|hv.n
   endif




|on.input:
|	select tcmcs003.cwar
|	from   tcmcs003
|	where  tcmcs003._index1 = {:tdcus855.cwar}
|	selectdo
|	selectempty
|
|	       Message("Warehouse Does not Exit ")
|	       input.again()
|	endselect

 field.tdcus855.slip:
 before.input:
|	select max(tdcus855.slip):slip				|hv.so
| 	from   tdcus855
| 	selectdo
|	endselect
|	tdcus855.slip = slip+1					|hv.eo
	if update.status = add.set then				|hv.sn
		|slip number will be determined upon saving
		tdcus855.slip = 0
		attr.input = false
	endif							|hv.en


field.tdcus855.rack:
before.zoom:
	tdcus850.cwar = "F01"
|after.input:							|hv.o
check.input:							|hv.n
 	select tdcus850.rack
	from   tdcus850
	where  tdcus850._index1 = {:tdcus855.cwar,:tdcus855.rack}
	selectdo
	selectempty
	       Message("This Rack No Does Not Exit In This Warehous")
|	       input.again()					|hv.o
		set.input.error("")				|hv.n
	       |choice.again()
	endselect

field.tdcus855.item:
|on.input:
check.input:
	select tdcus605.item
	from   tdcus605
	where  tdcus605._index1 = {:tdcus855.item}
	selectdo
	selectempty
	       Message("Please Check The Item Code ")
|	       input.again()
		set.input.error("")
	endselect

field.tdcus855.qtyl:
before.input:
	currqty = tdcus855.qtyl
	select tdcus851.stoc
	from   tdcus851
	where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
	selectdo
		tdcus855.stoc = tdcus851.stoc
		display("tdcus855.stoc")
	selectempty
		tdcus855.stoc = 0
	endselect

|on.input:
check.input:
	if tdcus855.qtyl = 0  or  tdcus855.qtyl <0 then
	       Message("Quantity Can Not Blank  ")
|	       input.again()
		set.input.error("")
	endif
	if tdcus855.type = tdrack.rkut then
		if tdcus855.qtyl  > tdcus855.stoc   then
		       Message("Quantity Can Not Be Greater Than Stock  ")
|		       input.again()
			set.input.error("")
		endif
	endif
when.field.changes:
 	qty1 = tdcus855.qtyl - currqty
	 |message("%d",qty1)
|****************************** choice section ********************************

choice.mark.delete:
before.choice:
  message (" i am  before choice ")
on.choice:
  message (" i am  on choice ")

after.choice:
  message (" i am  after choice ")




choice.cont.process:
before.choice:
	check.all.input()

|****************************** field section ********************************




main.table.io:
before.write:
	| In the follwing there is no need for the		|hv.sn
	| on.main.table construct as no record is returned!
	select max(tdcus855.slip):slip
 	from   tdcus855
 	selectdo
	endselect
	tdcus855.slip = slip+1

	update.stock()						|hv.en

| 	if tdcus855.type = tdrack.rkin then			|hv.so
|	        |tdcus855.stoc = tdcus851.stoc + tdcus855.qtyl
|	        tdcus855.stoc = tdcus855.stoc + (qty1)
|	else
|		|tdcus855.stoc = tdcus851.stoc - tdcus855.qtyl
|		tdcus855.stoc = tdcus855.stoc - (qty1)
|	endif       						|hv.eo
	tdcus855.stoc = tdcus851.stoc				|hv.n
	tdcus855.date = date.num()
	tdcus855.time = time.num()
	tdcus855.user = logname$
|	commit.transaction()					|hv.o

before.rewrite:							|hv.sn
	update.stock()
	tdcus855.stoc = tdcus851.stoc				|hv.en


functions:

|function stock()						|hv.so
|{
|	db.retry.point()
|
|| 	select tdcus855.*
|| 	from   tdcus855
|| 	where  tdcus855._index1 = {:tdcus855.type,"F01",:tdcus855.slip}
|| 	selectdo
|| 	selectempty
|| 		if tdcus855.item <>" " and  tdcus855.rack <> "" and tdcus855.qtyl<> 0 then
|| 			tdcus855.type = tdcus855.type
|| 			tdcus855.cwar = tdcus855.cwar
|| 			tdcus855.slip = tdcus855.slip
|| 			tdcus855.rack = tdcus855.rack
|| 			tdcus855.item = tdcus855.item
|| 			tdcus855.qtyl = tdcus855.qtyl
|| 			tdcus855.stoc = tdcus855.stoc
|| 			tdcus855.date = date.num()
|| 			tdcus855.time = time.num()
|| 			tdcus855.user = logname$
|| 			db.insert(ttdcus855,db.retry)
|| 		endif
|| 	endselect
|| 	commit.transaction()
|
|
|        select tdcus855.*
| 	from   tdcus855 |for update
| 	where  tdcus855._index1 = {:tdcus855.type,:tdcus855.cwar,:tdcus855.slip}
| 	selectdo
| 		select tdcus851.*
| 		from   tdcus851 for update
| 		where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
| 		selectdo
| 			if tdcus855.type =  tdrack.rkin then
| 	        		tdcus851.stoc = tdcus851.stoc + qty1
| 		        endif
| 			if tdcus855.type =  tdrack.rkut then
| 	        		tdcus851.stoc = tdcus851.stoc - (qty1)
| 	        	endif
| 			db.update(ttdcus851,db.retry)
| 			tdcus851.stoc = 0
| 		selectempty
| 			if tdcus855.rack ="" then
| 			    skip.io("")
| 			endif
| 			if tdcus855.type = tdrack.rkin then
| 				tdcus851.item = tdcus855.item
| 				tdcus851.cwar = tdcus855.cwar
| 				tdcus851.rack = tdcus855.rack
| 	 		     	tdcus851.stoc = tdcus851.stoc + tdcus855.qtyl
| 		        	db.insert(ttdcus851,db.retry)
| 		        	tdcus851.stoc = 0
| 		        endif
| 		endselect
| 	endselect
| 	commit.transaction()
|
|}								|hv.eo

function update.stock()						|hv.sn
{
	select tdcus851.*
	from   tdcus851 for update
	where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
	selectdo
		if tdcus855.type =  tdrack.rkin then
			tdcus851.stoc = tdcus851.stoc + tdcus855.qty1
	        endif
		if tdcus855.type =  tdrack.rkut then
			tdcus851.stoc = tdcus851.stoc - tdcus855.qty1
		endif
		db.update(ttdcus851,db.retry)
		tdcus851.stoc = 0
	selectempty
		if tdcus855.type = tdrack.rkin then
			tdcus851.item = tdcus855.item
			tdcus851.cwar = tdcus855.cwar
			tdcus851.rack = tdcus855.rack
		     	tdcus851.stoc = tdcus851.stoc + tdcus855.qtyl
	        	db.insert(ttdcus851,db.retry)
	        	tdcus851.stoc = 0
	        endif
	endselect
}								|hv.en
__________________
May the force be with you!
Reply With Quote
  #3  
Old 30th October 2003, 15:41
Debdas Banerjee Debdas Banerjee is offline
Member
 
Join Date: Feb 2003
Location: Mumbai
Posts: 90
Debdas Banerjee is on a distinguished road
Baan: 4c4 - DB: sql-2000/ informix - OS: Advance server / unix
Hi

H.Vahdani

Thanks for taking pain for me .
But till it is not working for modification of existing recorts.
It update only main table (tdcus855) , but I want to update the table tdcus851 whrer I maintain stock .
Please can you check again and help me out . Can you do one thing, you just remore unwanted line and write u line . You are right I am doing mistake in after.rewrite area.

Regards

Debdas

Code:
|******************************************************************************
|* tdcus9486deb 0 VRC B40C c4 test 
|* Maintain Rack In/Out Status
|* test
|* 2003-10-20 
|****************************************************************************** 
|* Main table tdcus855 Rack In/Out Status, Form Type 3
|******************************************************************************
|* hv H.Vahdani (Baanboard member), 29.10.2003 
|* major facelift showig correct programming practice only. No warranty on 
|* business logic :) 
|* Markings glossory: .o = old 
|* .n = new 
|* .so= start old 
|* .eo= end old 
|* .sn= start new 
|* .en= end new 
|****************************** declaration section *************************** 
declaration:
 |#ident "@(#)hv H.Vahdani, 29.10.2003, major facelift :)" 
 table ttdcus855 | Rack In/Out Status 
 table ttcmcs003 | Warehouse 
 table ttdcus850 | Rack Master 
 table ttiitm001 | Item Master 
 table ttdcus851 | Rack stock 
 
 double currqty 
 double qty1 
 extern domain tcorno slip 

|after.update.db.commit: 
|****************************** form section ********************************** field.tdcus855.type: 
 field.tdcus855.type: 
after.input: 

 if tdcus855.type = tdrack.rktf  then 
 	message("Sorry For Inconvenient Soon It Will Be Available") 
	input.again() 
 endif 

 select tdcus855.type 
 from tdcus855 
 selectdo 
 selectempty 
 Message ("Type Can Not Be Blank") 
 	 choice.again() 
 	 input.again() 
 endselect 
 field.tdcus855.cwar: 
 before.input: 
 tdcus855.cwar ="F01" 

after.input: 
if tdcus855.cwar<>"F01" then 
	Message("Please Check The Warehouse ") 
 	input.again() 
endif 

on.input: 
 select tcmcs003.cwar 
 from tcmcs003 
 where tcmcs003._index1 = {:tdcus855.cwar} 
 selectdo 
 selectempty 
	 Message("Warehouse Does not Exit ") 
 	input.again() 
 endselect 

 field.tdcus855.slip:
 before.input: 

 select max(tdcus855.slip):slip 
 from   tdcus855
 selectdo
 endselect	

if  update.status = add.set then 
   |slip number will be determined upon saving
   tdcus855.slip = 0 
   attr.input = false 
endif 


field.tdcus855.rack: 
before.zoom: 
tdcus850.cwar = "F01" 

after.input: 
 select tdcus850.rack
 from tdcus850 
 where tdcus850._index1 = {:tdcus855.cwar,:tdcus855.rack}
 selectdo 
 selectempty 
	 Message("This Rack No Does Not Exit In This Warehous") 
	choice.again() 
endselect 

field.tdcus855.item: 
on.input: 
check.input:
 select tdcus605.item 
 from tdcus605
 where tdcus605._index1 = {:tdcus855.item}
 selectdo 
 selectempty 
 Message("Please Check The Item Code ") 
 set.input.error("")
 endselect
 
 field.tdcus855.qtyl: 
 before.input:
 
  currqty = tdcus855.qtyl 
 select tdcus851.stoc 
 from tdcus851
 where tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
 selectdo
	 tdcus855.stoc = tdcus851.stoc 
 selectempty 
 	tdcus855.stoc = 0 
 endselect 
 display("tdcus855.stoc") 


check.input: 

if tdcus855.qtyl = 0 or tdcus855.qtyl <0 then 
	Message("Quantity Can Not Blank ") 
 	set.input.error("") 
endif 

if tdcus855.type = tdrack.rkut then 
	if tdcus855.qtyl > tdcus855.stoc then 
		Message("Quantity Can Not Be Greater Than Stock ") 
 		set.input.error("") 
 	endif
 endif 
 when.field.changes:
  qty1 = tdcus855.qtyl - currqty 
|****************************** choice section ******************************** choice.mark.delete: before.choice: message (" i am before choice ") on.choice: message (" i am on choice ") after.choice: message (" i am after choice ") choice.cont.process: before.choice: check.all.input() 
|****************************** field section ********************************
 main.table.io: 
 before.write: 

 |construct as no record is returned! 
 select max(tdcus855.slip):slip 
 from tdcus855 
 selectdo 
 endselect 
 tdcus855.slip = slip+1 
 update.stock() 

    tdcus855.date = date.num()
    tdcus855.time = time.num() 
    tdcus855.user = logname$ 
    commit.transaction() 
 
 |update.stock() 
 tdcus855.stoc = tdcus851.stoc 

functions: 

function update.stock() 

{
select tdcus851.*
from tdcus851 for update
where tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
selectdo 
	if tdcus855.type = tdrack.rkin then 
	   tdcus851.stoc = tdcus851.stoc + tdcus855.qtyl
	    
	endif 
	if tdcus855.type = tdrack.rkut then
	   tdcus851.stoc = tdcus851.stoc - tdcus855.qtyl
	   
	endif 
	db.update(ttdcus851,db.retry) 
	tdcus851.stoc = 0 
selectempty 
	if tdcus855.type = tdrack.rkin then 
		tdcus851.item = tdcus855.item 
		tdcus851.cwar = tdcus855.cwar 
		tdcus851.rack = tdcus855.rack 
		tdcus851.stoc = tdcus851.stoc + tdcus855.qtyl 
		db.insert(ttdcus851,db.retry) 
		tdcus851.stoc = 0 
	endif 
endselect 

 }
__________________
Deb
Arise Awake & Stop not till the Goal is Reached...........Swami Vivekananda.
Reply With Quote
Sponsored Links
  #4  
Old 30th October 2003, 19:10
vahdani's Avatar
vahdani vahdani is offline
Guru
 
Join Date: Aug 2002
Location: Cologne, Germany
Posts: 418
vahdani is on a distinguished road
Baan: all - DB: all - OS: Unix / Win2K
Hi Debdas,

I've given it another try but remember I can not compile this because I don't have your customized domain and table defs! Please consider this script only as a basis for your development.

Follwing points are also important:

1- Your session can only have a single occ (type 1) form. In a Multi Occ Form your tdcus855.stoc (and hence any error messages) will not be correct!

2- Multiple user entries is also not allowed as the tdcus855.stoc field can become stale if another person updates stock before you save your data!

So remember single occ for single user; anything else requires total rewrite (and rethink!) of your application.

Code:
|******************************************************************************
|* tdcus9486deb  0  VRC B40C c4 test
|* Maintain Rack In/Out Status
|* test
|* 2003-10-20
|******************************************************************************
|* Main table tdcus855 Rack In/Out Status, Form Type 3
|******************************************************************************
|* hv H.Vahdani (Baanboard member), 29.10.2003
|* major facelift showig correct programming practice only. No warranty on
|* business logic :)
|****************************** declaration section ***************************
declaration:
#ident "@(#)hv H.Vahdani, 29.10.2003, major facelift :)"

	table	ttdcus855	| Rack In/Out Status
	table   ttcmcs003	| Warehouse
	table   ttdcus850       | Rack Master
	table   ttiitm001  	| Item Master
	table   ttdcus851       | Rack stock

|****************************** form section **********************************

|****************************** field section ********************************
field.tdcus855.type:
check.input:
        if tdcus855.type = tdrack.rktf then
           message("Sorry For Inconvenient Soon It Will Be Available")
           set.input.error("")
        endif

field.tdcus855.cwar:
before.input:
	tdcus855.cwar ="F01"
check.input:
	if tdcus855.cwar<>"F01" then
		Message("Please Check The Warehouse ")
		set.input.error("")
	endif

field.tdcus855.slip:
before.input:
	if update.status = add.set then
		|slip number will be determined upon saving
		tdcus855.slip = 0
		attr.input = false
	else
		if choice <> def.find then
			attr.input = false
		endif
	endif


field.tdcus855.rack:
before.zoom:
	tdcus850.cwar = "F01"
check.input:
 	select tdcus850.rack
	from   tdcus850
	where  tdcus850._index1 = {:tdcus855.cwar,:tdcus855.rack}
	selectdo
	selectempty
		Message("This Rack No Does Not Exit In This Warehous")
		set.input.error("")
	endselect

field.tdcus855.item:
check.input:
	select tdcus605.item
	from   tdcus605
	where  tdcus605._index1 = {:tdcus855.item}
	selectdo
	selectempty
		Message("Please Check The Item Code ")
		set.input.error("")
	endselect

field.tdcus855.qtyl:
before.input:
	select tdcus851.stoc
	from   tdcus851
	where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
	selectdo
		tdcus855.stoc = tdcus851.stoc
	selectempty
		tdcus855.stoc = 0
	endselect
	display("tdcus855.stoc")
check.input:
	if tdcus855.qtyl <= 0 then
		Message("Quantity not allowed!")
		set.input.error("")
	endif
	if tdcus855.type = tdrack.rkut then
		if tdcus855.qtyl  > tdcus855.stoc   then
		       Message("Quantity Can Not Be Greater Than Stock!")
			set.input.error("")
		endif
	endif
|****************************** choice section ********************************
choice.cont.process:
before.choice:
	check.all.input()

|************************** main table io section ****************************
main.table.io:
before.write:
	| In the follwing there is no need for the
	| on.main.table construct as no record is returned!
	tdcus855.slip = 0
	select max(tdcus855.slip):tdcus855.slip
 	from   tdcus855
 	selectdo
	endselect
	tdcus855.slip = tdcus855.slip + 1
	update.item.rack.stock()
	tdcus855.stoc = tdcus851.stoc
	tdcus855.date = date.num()
	tdcus855.time = time.num()
	tdcus855.user = logname$

before.rewrite:
	update.item.rack.stock()
	tdcus855.stoc = tdcus851.stoc


functions:

function update.item.rack.stock()
{
	select tdcus851.*
	from   tdcus851 for update
	where  tdcus851._index1 = {:tdcus855.item,:tdcus855.rack}
	selectdo
		if tdcus855.type =  tdrack.rkin then
			tdcus851.stoc = tdcus851.stoc + tdcus855.qty1
	        else
			tdcus851.stoc = tdcus851.stoc - tdcus855.qty1
		endif
		db.update(ttdcus851,db.retry)
	selectempty
		if tdcus855.type = tdrack.rkin then
			tdcus851.item = tdcus855.item
			tdcus851.cwar = tdcus855.cwar
			tdcus851.rack = tdcus855.rack
		     	tdcus851.stoc = tdcus855.qtyl
	        	db.insert(ttdcus851,db.retry)
	        endif
	endselect
}
__________________
May the force be with you!
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
Table locking problem fcd123 Tools Development 2 25th July 2004 14:42
copy records c_siek Tools Development 9 18th June 2004 15:43
Problem with one table Haggis Tools Development 9 30th January 2002 18:18


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


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