CREATE OR REPLACE VIEW R_REQUEST_V
(R_REQUEST_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, 
 CREATEDBY, UPDATED, UPDATEDBY, DOCUMENTNO, R_REQUESTTYPE_ID, 
 R_GROUP_ID, R_CATEGORY_ID, R_STATUS_ID, R_RESOLUTION_ID, R_REQUESTRELATED_ID, 
 PRIORITY, PRIORITYUSER, DUETYPE, SUMMARY, CONFIDENTIALTYPE, 
 ISESCALATED, ISSELFSERVICE, SALESREP_ID, AD_ROLE_ID, DATELASTACTION, 
 DATELASTALERT, LASTRESULT, PROCESSED, ISINVOICED, C_BPARTNER_ID, 
 AD_USER_ID, C_CAMPAIGN_ID, C_ORDER_ID, C_INVOICE_ID, C_PAYMENT_ID, 
 M_PRODUCT_ID, C_PROJECT_ID, A_ASSET_ID, M_INOUT_ID, M_RMA_ID, 
 AD_TABLE_ID, RECORD_ID, REQUESTAMT, R_MAILTEXT_ID, RESULT, 
 CONFIDENTIALTYPEENTRY, R_STANDARDRESPONSE_ID, NEXTACTION, DATENEXTACTION, STARTTIME, 
 ENDTIME, QTYSPENT, QTYINVOICED, M_PRODUCTSPENT_ID, C_ACTIVITY_ID, 
 STARTDATE, CLOSEDATE, C_INVOICEREQUEST_ID, M_CHANGEREQUEST_ID, TASKSTATUS, 
 QTYPLAN, DATECOMPLETEPLAN, DATESTARTPLAN, M_FIXCHANGENOTICE_ID)
AS 
SELECT R_REQUEST_ID,AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,
DOCUMENTNO,R_REQUESTTYPE_ID,R_GROUP_ID,R_CATEGORY_ID,R_STATUS_ID,R_RESOLUTION_ID,
R_REQUESTRELATED_ID,PRIORITY,PRIORITYUSER,DUETYPE,SUMMARY,CONFIDENTIALTYPE,ISESCALATED,
ISSELFSERVICE,SALESREP_ID,AD_ROLE_ID,DATELASTACTION,DATELASTALERT,LASTRESULT,PROCESSED,
ISINVOICED,C_BPARTNER_ID,AD_USER_ID,C_CAMPAIGN_ID,C_ORDER_ID,C_INVOICE_ID,C_PAYMENT_ID,
M_PRODUCT_ID,C_PROJECT_ID,A_ASSET_ID,M_INOUT_ID,M_RMA_ID,AD_TABLE_ID,RECORD_ID,REQUESTAMT,
R_MAILTEXT_ID,RESULT,CONFIDENTIALTYPEENTRY,R_STANDARDRESPONSE_ID,NEXTACTION,DATENEXTACTION,
STARTTIME,ENDTIME,QTYSPENT,QTYINVOICED,M_PRODUCTSPENT_ID,C_ACTIVITY_ID,STARTDATE,CLOSEDATE,
C_INVOICEREQUEST_ID,M_CHANGEREQUEST_ID,TASKSTATUS,QTYPLAN,DATECOMPLETEPLAN,DATESTARTPLAN,M_FIXCHANGENOTICE_ID
FROM R_Request
WHERE IsActive='Y' AND Processed='N'
  AND getdate() > DateNextAction;



