This is the code that generates our drop down box
*****************************************************************
<!--#include file="COMMON.INC"-->
<!--#include file="SESSION.INC"-->
<!--#include file="navbarall.inc"-->
<%
' printSQL = -1
st = timer
DIM SLM
SLM = REQUEST("SLM")
NAM = REQUEST("NAM")
If len(SLM)<>4 AND len(SLM)<>6 Then
SLM = ""
End If
If len(SLM) = 6 Then
LTR = mid(SLM,6,1)
SLM = mid(SLM,1,4)
End If
strDB = SESSION("STRDB")
Set con = CreateObject("ADODB.Connection")
con.Open strDB
Set rs = CreateObject("ADODB.Recordset")
If printSQL Then response.write "ORA_SLMS_ALL=" & SESSION("ORA_SLMS_ALL") & "<HR>" End If
SQL = "SELECT TO_CHAR(ADD_MONTHS(TRUNC(TO_DATE(TO_CHAR(SYSDATE,'MON-YYYY'),'MON-YYYY'),'YEAR'),-48),'YYYY') START_YEAR FROM DUAL"
If printSQL Then Response.Write SQL & "<HR>" End If
Set rs = con.Execute(SQL)
START_YEAR = RS("START_YEAR") - 1
SQL = "SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY') TODAY FROM DUAL"
If printSQL Then Response.Write SQL & "<HR>" End If
Set rs = con.Execute(SQL)
TODAY = RS("TODAY")
CURRENT_DAY = cint(MID(TODAY,4,2)) - 1
CURRENT_MONTH = cint(MID(TODAY,1,2))
SQL = "SELECT TO_CHAR(LAST_DAY(SYSDATE),'MM/DD/YYYY') LAST_DAY FROM DUAL"
If printSQL Then Response.Write SQL & "<HR>" End If
Set rs = con.Execute(SQL)
LAST_DAY = cint(mid(RS("LAST_DAY"),4,2))
If printSQL Then Response.Write "START_YEAR=" & START_YEAR & " TODAY=" & TODAY & " CURRENT_DAY=" & CURRENT_DAY & " LAST_DAY=" & LAST_DAY & "<HR>" End If
If printSQL then SESSION("TERRITORY") = "" End If
' SQL BELOW returns Territory Number & Name
' Example = 0027 & Bueller, Ferris
If SESSION("TERRITORY") = "" Then
SQL = "SELECT DISTINCT TERRITORY, SUBSTR(JRS.NAME,1,LEAST(INSTR(JRS.NAME||'-','-')-1,25)) NAME FROM APPS.WEB_SALES_HISTORY_SLM_MV WSS, " & _
"AR.RA_TERRITORIES RT, AR.RA_SALESREP_TERRITORIES RST, JTF.JTF_RS_SALESREPS JRS " & _
"WHERE WSS.TERRITORY=RT.SEGMENT1 " & _
"AND RT.TERRITORY_ID=RST.TERRITORY_ID " & _
"AND RST.SALESREP_ID=JRS.SALESREP_ID " & _
"AND RST.END_DATE_ACTIVE IS NULL "
If SESSION("USER") <> "TERRITORYSALES" Then
SQL = SQL & "AND RT.SEGMENT1 IN (" & session("ORA_SLMS") & ") "
End If
SQL = SQL & "AND RT.SEGMENT2='ALL' " & _
"ORDER BY TERRITORY"
If printSQL Then Response.Write SQL & "<HR>" End If
Set rs = con.Execute(SQL)
Do While Not rs.EOF
SLM_CHECK = rs("TERRITORY")
If SLM_OK(SLM_CHECK) Then
If instr(LOADED,"/" & SLM_CHECK & "/") = 0 Then
inBuffer = inBuffer + "<SLMS><SLM>" & rs("TERRITORY") & "</SLM><NAM>" & clean(rs("NAME")) & "</NAM></SLMS>"
LOADED = LOADED & "/" & SLM_CHECK & "/"
End If
' If printSQL Then response.write "SLM_CHECK=" & SLM_CHECK & "<HR>" End IF
End If
rs.MoveNext
Loop
' SQL BELOW returns Territory Number & Letter_Code & Name
' Example = 0027 & A & Bueller, Ferris
SQL = "SELECT DISTINCT TERRITORY, LETTER_CODE, SUBSTR(JRS.NAME,1,LEAST(INSTR(JRS.NAME||'-','-')-1,25)) NAME FROM APPS.WEB_SALES_HISTORY_SLM_MV WSS, " & _
"AR.RA_TERRITORIES RT, AR.RA_SALESREP_TERRITORIES RST, JTF.JTF_RS_SALESREPS JRS " & _
"WHERE WSS.TERRITORY=RT.SEGMENT1 " & _
"AND RT.TERRITORY_ID=RST.TERRITORY_ID " & _
"AND RST.SALESREP_ID=JRS.SALESREP_ID " & _
"AND RST.END_DATE_ACTIVE IS NULL " & _
"AND RT.SEGMENT1 IN (" & session("ORA_SLMS") & ") " & _
"AND RT.SEGMENT2='ALL' " & _
"ORDER BY TERRITORY, LETTER_CODE"
If printSQL Then Response.Write SQL & "<HR>" End If
Set rs = con.Execute(SQL)
Do While Not rs.EOF
SLM_CHECK = rs("TERRITORY") & rs("LETTER_CODE")
If SLM_OK(SLM_CHECK) Then
If instr(LOADED,"/" & SLM_CHECK & "/") = 0 Then
inBuffer = inBuffer + "<SLMS><SLM>" & rs("TERRITORY") & "-" & rs("LETTER_CODE") & "</SLM><NAM>" & clean(rs("NAME")) & "</NAM></SLMS>"
LOADED = LOADED & "/" & SLM_CHECK & "/"
End If
' If printSQL Then response.write "SLM_CHECK=" & SLM_CHECK & "<HR>" End IF
End If
rs.MoveNext
Loop
SESSION("TERRITORY") = inBuffer
Else
Inbuffer = SESSION("TERRITORY")
End If
If SLM<>"" Then
SQL = SQL & " AND TERRITORY='" & SLM & "'"
End If
If LTR <> "" Then
SQL = SQL & " AND LETTER_CODE='" & LTR & "'"
End If
If SLM<>"" Then '***********************************
SQL = "INSERT INTO XKFI.WEB_TRACKING (TRACKING_ID, TRACKING_DATE, USER_NAME, TRACKING_ACTION, ATTRIBUTE1,ORG_ID) " & _
"VALUES (XKFI.WEB_TRACKING_S.NEXTVAL,SYSDATE,'" & SESSION("USER") & "','SALES_HISTORY','" & SLM<R & "'," & SESSION("ORG_ID") & ")"
If printSQL then Response.Write SQL & "<HR>" End IF
rs = con.Execute(SQL)
Set rs = Nothing
con.close
Set con = Nothing
End If '***********************************
inBuffer = "<SALESMAN><NAME>" & SLM & LTR & " - " & NAM & "</NAME>" & inBuffer & TMPA & "</SALESMAN>"
dim styleFile
styleFile = Server.MapPath("SLMSALES.XSL")
dim source
set source = Server.CreateObject("Microsoft.XMLDOM")
source.async = false
source.loadXML(inBuffer)
dim style
set style = Server.CreateObject("Microsoft.XMLDOM")
style.async = false
style.load(styleFile)
result = source.transformNode(style)
Response.Write(result)
Private Function SLM_OK(Src)
TMPOK = 0
TMPA = split(REPLACE(MID(SESSION("ORA_SLMS_ALL"),2),"//","/"),"/")
TMPN = UBound(TMPA)
For TMPL = 0 to TMPN - 1
' If printSQL Then RESPONSE.WRITE "SRC = " & SRC & "-" & TMPA(TMPL) & " - " & tmpn & "<HR>" End If
If TMPA(TMPL) = mid(SRC,1,len(TMPA(TMPL))) Then
TMPOK = -1
End If
Next
SLM_OK = TMPOK
End Function
%>
This is the 3rd SQL statement. We need to use our query string as the variables TO this statement. This will return a list of only those items assigned to 8111-B Bueller, Ferris.
*****************************************************************
sql = "SELECT " & _
"PARTY_NAME, CITY, STATE, POSTAL_CODE, MONTH_N, YEAR_N, SALES_AMT, TERRITORY, LETTER_CODE " & _
"FROM " & _
"APPS.WEB_CUSTOMER_ADDRESSES_V V, KFI_CUSTOMER_TERRITORY_HEADER H, APPS.WEB_SALES_HISTORY_CUST_MV S " & _
"where LETTER_CODE='A' " &_
"AND V.LOCATION=H.CUSTOMER_SITE_ID " &_
"and H.TERRITORY ='" & territory & "'" & _
"AND V.SITE_USE_CODE='BILL_TO' " &_
"AND V.STATUS='A' " &_
"AND V.SITE_STATUS='A' " &_
"AND V.ACCT_SITE_STATUS='A' " &_
"AND H.EFFECTIVE_END_DATE IS NULL " &_
"AND S.CUSTOMER_SITE_ID=V.LOCATION " &_
"AND S.YEAR_N>=2008 " &_
"AND S.SALES_AMT<>0 " &_
"ORDER BY POSTAL_CODE "
Overview.doc
The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications
TRUSTED BY