Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update sometime doesn't work -- very desperated, pls help

Status
Not open for further replies.

cat5ive

MIS
Dec 3, 2004
184
0
0
US
Hi,

I have 2 asp pages. page1 let user enter vendor#. Page2 list out all the invoices under that vendor and a check box next to each invoice. The check box is default checked. On page2 when user click submit, it submit itself. It checks for invoice that has check in check box and call cgi pgm to update flag in database. After finished processing the whole list then it uses response.redirect to page1.

The operation process is repeated, search for vendor(page1) then submit the list(apge2), then search for next vendor and submit listing, on and on for about 5-6 vendors per day.

Very often, one whole list did not get process. After user click submit on page2, it took her back to page1 like it suppose to. But actually it did not process any invoice in that list at all. If she repeat again then it's ok.
I don't know if this info is relavant but it's never happen on the first batch (vendor). It's ususally happen to only 1 out of those 5-6 vendors. But someday everything went fine. User always leave the check box checked.

I tried to set the flag 'updateok' and use that flag to redirect the page. But the fail batch and the successed batch always go to page1, nothing different.
Is it possible that the communicaton fail when it calls CGI program? How do I check?
Is there anywhere else that I can monitor the error (any error)?

Thank for any help/feedback.
Code:
if strrcdcnt <> ""  then  'record count > 0 after submit itself
                                                           
   for idx = 1 to strrcdcnt                                         
	  apprinv = "apprinv" & idx-1
	  varapprinv = request(apprinv)
	  inv = "inv" & idx-1	  
      bnkid = "bnkid" & idx-1	  

	 // check if check box being checked then call cgi
         // to update flag     
	  if varapprinv = "on" then
        strinvnumber = request.form(inv)
		strbankid = request.form(bnkid)       'rk02
						
        	as400url = "[URL unfurl="true"]http://172.16.1.10/cgi-bin2/xmv190?"+[/URL] username + "+" + strinvnumber + "+" + strbankid 
        Set xmldoc = ReadXMLFromAS400(as400url)          
	               
		updateok = "Y"  
	  end if  
    next   
   
     if (updateok = "Y") then
        newurl = "page1.asp"
        Response.redirect newurl 
      else         
        nodataerror =  "error.asp?error=processerror&reason=No update flag, cannot process payment approval." 
        Response.redirect nodataerror
      end if       
 
 end if     ' strrcdcnt <> ""

 %>

Code:
<%
// General function to read an XML document from the AS/400
  function ReadXMLFromAS400 (urlsource)
    dim xmldoc
    errorpage = "error.asp?error=server&backpage=tracking.asp"

    Set xmldoc = Server.CreateObject("MSXML2.DOMDocument")
    xmldoc.async = False
    xmldoc.setProperty "ServerHTTPRequest", true
    xmldoc.load (urlsource)
//    do until (xmldoc.readystate = 4)
//    Loop
    'Check for a successful load of the XML Document.
    if xmldoc.parseerror.errorcode <> 0 then 
      Response.redirect errorpage
      Response.Write xmldoc.text
      Response.Write "----------------------------" & "<BR>"
      Response.Write "Error Code : " & xmldoc.parseerror.errorcode & "<BR>"
      Response.Write "Reason : " & xmldoc.parseerror.reason & "<BR>"
      Response.End 
    end if
    set ReadXMLFromAS400 = xmldoc
  end function
%>
 
You have made some comments js style (//). It should be vbscript (').
 
Thank for response tsuji. I will try to change them tomorrow at work.
Do you think that is the cause of the problem? Why most of the times the process work?
Thanks
 
It should be the only reason, but it clouds the logic.

Just quick browse through, take a look of these.
[1] strcdcnt <> "" and after it depends on auto cast to number. Maybe you can improve on that.
[2]Your updateok flag may not be effective. In the function readxml..., if it encounters error (parseerror or else), you may consider return nothing rather than response.end which makes the script have an abrupt end. Instead something like this.
[tt]
'respond.end
set ReadXMLFromAS400=nothing
else
set ReadXMLFromAS400=xmldoc
end if
[/tt]
And in the main...
[tt]
Set xmldoc = ReadXMLFromAS400(as400url)
if xmldoc is nothing
updateok = "N"
else
updateok = "Y"
end if
[/tt]
At least I would feel more comfortable with this setting of flag. All the redirection happens in the main (and not possibly in the ReadXML... and possibly in the main...).
 
>[self]It should be the only reason.
I meant "It should [red]not[/red] be the only reason."
 
[1] strcdcnt <> "" and after it depends on auto cast to number. Maybe you can improve on that.

Can you please show me how? I'm a newbie.

Thanks
 
you can cast the variants to specific numeric datatypes with functions like cint() clng() and cdbl()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top