Programs that run on appserver

harpreet

New Member
Hello,

I have a program I run on webspeed through the appserver so i can generate an excel spreadsheet. All main webspeed programs sit on unix.

I have come accross a problem with one of my programs. the program takes a long time to run on the appserver causing there to be a timeout. if i transfer that same code into a procedure editor, the output is instant. does anyone know why the appserver does this?

example of the main part of code running on appserver:

Code:
FOR EACH 
	stkw001q USE-INDEX ITEM where
	stkw001q.YEAR = v-year AND
	(stkw001q.loc >= v-sloc and
	 stkw001q.loc <= v-floc) NO-LOCK BREAK BY stkw001q.loc BY stkw001q.v-type BY stkw001q.ITEM.
	
		ASSIGN
		vin = 0 
		vout = 0
		vnet = 0
		vunitvalue = 0 
		vextend = 0
		vqty = 0
		vvalue = 0
		iColumn = iColumn + 1.
   
		cColumn = STRING(iColumn).
		cRange = "A" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.loc.
		cRange = "B" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.item.
		cRange = "C" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.DESCRIPTION[1].
		cRange = "D" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.stock.
	
		cRange = "E" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-in[v-smonth] .
		cRange = "F" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-out[v-smonth].
		cRange = "G" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-net[v-smonth].
		cRange = "H" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.unit-value[v-smonth] .
		cRange = "I" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-extend[v-smonth].
		cRange = "J" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-qty[v-smonth].
		cRange = "K" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-value[v-smonth].
		cRange = "L" + cColumn.
		chWorkSheet:Range(cRange):Value = stkw001q.v-type.
	
		cRange = "M" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.assy * vnet).
		
		tot-assy = tot-assy + (stkw001q.assy * vnet).
		cRange = "N" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.moul * vnet).
		
		tot-moul = tot-moul + (stkw001q.moul * vnet).
	
		cRange = "O" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.trm * vnet).
		
		tot-trm = tot-trm + (stkw001q.trm * vnet).
	
		cRange = "P" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.cabl * vnet).
	   
		tot-cabl = tot-cabl + (stkw001q.cabl * vnet).
	
		cRange = "Q" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.metal * vnet).
		
		tot-metal = tot-metal + (stkw001q.metal * vnet).
		
		cRange = "R" + cColumn.
		chWorkSheet:Range(cRange):Value = (stkw001q.rubber * vnet).
		tot-rubber = tot-rubber + (stkw001q.rubber * vnet). 
	
IF LAST-OF(stkw001q.loc) THEN DO:
	 
	assign
	iColumn = iColumn + 1
	cColumn = STRING(iColumn)
	tot-time = 0
		
	cRange = "M" + cColumn
	chWorkSheet:Range(cRange):Value = tot-assy
	cRange = "N" + cColumn
	chWorkSheet:Range(cRange):Value = tot-moul
	cRange = "O" + cColumn
	chWorkSheet:Range(cRange):Value = tot-trm
	cRange = "P" + cColumn
	chWorkSheet:Range(cRange):Value = tot-cabl
	cRange = "Q" + cColumn
	chWorkSheet:Range(cRange):Value = tot-metal
	cRange = "R" + cColumn
	chWorkSheet:Range(cRange):Value = tot-rubber.
	ASSIGN
	m-value = m-value + tot-assy
	n-value = n-value + tot-moul
	o-value = o-value + tot-trm
	p-value = p-value + tot-cabl
	q-value = q-value + tot-metal
	r-value = r-value + tot-rubber.
	tot-time = ((tot-assy + tot-moul + tot-trm + tot-cabl + tot-metal + tot-rubber) / 60) * -1.
		
	cRange = "S" + cColumn.
	chWorkSheet:Range("S" + cColumn):Interior:ColorIndex = 6.
	chWorkSheet:Range(cRange):Value = tot-time.
		
	ASSIGN
	tot-assy = 0
	tot-moul = 0
	tot-trm = 0
	tot-cabl = 0
	tot-metal = 0
	tot-rubber = 0.
	iColumn = iColumn + 1.
	jColumn = jColumn + 1.
	aColumn = STRING(jColumn).
	bRange = "A" + aColumn.
	chWorkSheet2:Range(bRange):Value = stkw001q.loc.
	bRange = "B" + aColumn.
	chWorkSheet2:Range(bRange):Value = tot-time. 
	END.
	  
END.
 
what causes the delay

the delay is caused when writing to each individual cell in excel. its much faster to output to txt file then write to excel
 
Back
Top