Dear Sir,
I am doing a program for purchase order generation. In this program I am retriveing the list of items that is to be ordered form a seperate table 'accesreq1'. The key feild in that particular table is 'reqno'. Now when the user is retriveing the list for generating the Purchase Order, the item is summed up and grouped up and shows the claculated value.Now When the use is saving the data then the ordered values should be saved in the 'accesreq1' table also.
e.g. Say there are three requirements say req1,req2,req3 and having itemcode I001 havin requirements 10,20 and 50 respectively. So when the PO is generated It is generated for the calculated value i.e. 80 and the user has ordered 75 quantity agings that 80 figure.So when the values are going to saved It should do following steps:
1.LOCATE FOR THE REQNO AND ITEMCODE IN THE 'ACCESREQ1' TABLE
2.DO WHILE FOUND
IT REPLACES THE VALUE IN 'ÓRDERED' FIELD IN 'ACCESREQ' TABLE WITH 10,20,45 RESPECTIVELY.
For Implementing this I have written the following code:
SELECT pono,itemcode,itemname,size,unitofmeas,qty,ordered,rate,total from xd INTO CURSOR xpodetail WHERE flag=.T.
(Retrives the value Form the Grid)
SELECT xord.reqno as reqno,xpodetail.itemcode as itemcode FROM xord INNER JOIN xpodetail ON xord.itemcode=xpodetail.itemcode INTO CURSOR xindstat
select xindstat
= CURSORSETPROP('Buffering', 5, 'accesreq1' )
xorder=xpodetail.ordered
DO WHILE !EOF("xindstat"
SELECT accesreq1
GO TOP
LOCATE FOR accesreq1.reqno==xindstat.reqno .and. itemcode=xindstat.itemcode
DO WHILE FOUND() .AND. xorder>0
IF accesreq1.qty>accesreq1.ordered
IF (accesreq1.qty-accesreq1.ordered)<xorder
xorder=xorder-(accesreq1.qty-accesreq1.ordered)
replace accesreq1.ordered WITH accesreq1.qty
ENDIF
IF (accesreq1.qty-accesreq1.ordered)>xorder
replace accesreq1.ordered WITH accesreq1.ordered+xorder
xorder=0
ENDIF
ENDIF
CONTINUE
ENDDO
= TABLEUPDATE(1,.F.,"accesreq1"
SKIP IN xindstat
ENDDO
BUt Its not working properly. It is giving correct value for the first record and Its not giving the desired results for the rest of the rest of the records.
So I request all Of U to Pls go through the code and sugest me how do I do This.
Thanx & Regards
Chandan
I am doing a program for purchase order generation. In this program I am retriveing the list of items that is to be ordered form a seperate table 'accesreq1'. The key feild in that particular table is 'reqno'. Now when the user is retriveing the list for generating the Purchase Order, the item is summed up and grouped up and shows the claculated value.Now When the use is saving the data then the ordered values should be saved in the 'accesreq1' table also.
e.g. Say there are three requirements say req1,req2,req3 and having itemcode I001 havin requirements 10,20 and 50 respectively. So when the PO is generated It is generated for the calculated value i.e. 80 and the user has ordered 75 quantity agings that 80 figure.So when the values are going to saved It should do following steps:
1.LOCATE FOR THE REQNO AND ITEMCODE IN THE 'ACCESREQ1' TABLE
2.DO WHILE FOUND
IT REPLACES THE VALUE IN 'ÓRDERED' FIELD IN 'ACCESREQ' TABLE WITH 10,20,45 RESPECTIVELY.
For Implementing this I have written the following code:
SELECT pono,itemcode,itemname,size,unitofmeas,qty,ordered,rate,total from xd INTO CURSOR xpodetail WHERE flag=.T.
(Retrives the value Form the Grid)
SELECT xord.reqno as reqno,xpodetail.itemcode as itemcode FROM xord INNER JOIN xpodetail ON xord.itemcode=xpodetail.itemcode INTO CURSOR xindstat
select xindstat
= CURSORSETPROP('Buffering', 5, 'accesreq1' )
xorder=xpodetail.ordered
DO WHILE !EOF("xindstat"
SELECT accesreq1
GO TOP
LOCATE FOR accesreq1.reqno==xindstat.reqno .and. itemcode=xindstat.itemcode
DO WHILE FOUND() .AND. xorder>0
IF accesreq1.qty>accesreq1.ordered
IF (accesreq1.qty-accesreq1.ordered)<xorder
xorder=xorder-(accesreq1.qty-accesreq1.ordered)
replace accesreq1.ordered WITH accesreq1.qty
ENDIF
IF (accesreq1.qty-accesreq1.ordered)>xorder
replace accesreq1.ordered WITH accesreq1.ordered+xorder
xorder=0
ENDIF
ENDIF
CONTINUE
ENDDO
= TABLEUPDATE(1,.F.,"accesreq1"
SKIP IN xindstat
ENDDO
BUt Its not working properly. It is giving correct value for the first record and Its not giving the desired results for the rest of the rest of the records.
So I request all Of U to Pls go through the code and sugest me how do I do This.
Thanx & Regards
Chandan