0% found this document useful (0 votes)
136 views

Useful SQL Scripts

The document contains useful SQL scripts for common tasks in Agresso like changing the status of requisitions and purchase orders, identifying and clearing ghost tasks, generating over-receipting alerts, and reporting on invoices in workflow. It also includes scripts for updating requisition details, retrieving user names and roles, interfacing with Northgate, and checking for duplicate roles.

Uploaded by

C Hutch
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views

Useful SQL Scripts

The document contains useful SQL scripts for common tasks in Agresso like changing the status of requisitions and purchase orders, identifying and clearing ghost tasks, generating over-receipting alerts, and reporting on invoices in workflow. It also includes scripts for updating requisition details, retrieving user names and roles, interfacing with Northgate, and checking for duplicate roles.

Uploaded by

C Hutch
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Useful SQL Scripts

Changing the Status of a Requisition

Update aporeqheader
set status = '&Desired_Status'
where order_id = '&requisition_number';

Update aporeqdetail
set status = '&Desired_Status'
where order_id = '&requisition_number';

Commit;

Changing the Status of a Purchase Order

Update apoheader
set status = '&Desired_Status'
where order_id like '&po_number';

Update apodetail
set status = '&Desired_Status'
where order_id = '&po_number';

Commit;

Identifying Ghost Tasks

select distinct(col1_value)
FROM awftask WHERE wf_status='ACT' AND col1_Descr = 'TransNo' AND
col2_descr = 'SuppID'
and col1_value not in (select cast(voucher_no as char) from asuvicrtrans) and
element_type = 'IIN' order by 1

Clearing a Ghost Task

Begin transaction GT
UPDATE awftask SET wf_status='FIN' WHERE wf_status='ACT' AND col1_Descr =
'TransNo' AND col2_descr = 'SuppID'
AND col1_value NOT IN (SELECT cast(voucher_no as char) FROM asuvicrtrans)
and element_type ='IIN';
commit;

Intel-Agent for Over-receipting Alert

select A.ORDER_ID ORDER_ID, A.USER_ID PO_USER_ID, A.AMOUNT


AMOUNT, A.COM_VAL QUANTITY, A.VOW_AMOUNT RECEIVED_AMOUNT,
A.VOW_VAL RECEIVED_QUANTITY,
A.VOW_AMOUNT-a.AMOUNT AMOUNT_DIFF, A.VOW_VAL-a.COM_VAL
QUANTITY_DIFF, B.USER_ID RECEIPT_USER_ID, A.ARTICLE_ID article_id
from AGRESSO.APODETAIL A, AGRESSO.ALGDELIVERY B
where a.vow_amount-a.amount > 2*a.amount and a.order_id=b.order_id and
A.ARTICLE_ID=B.ARTICLE_ID;

Invoices in Workflow report

SELECT v.voucher_no,
v.account,
v.process,
v.step,
--t.role_id,
v.wf_state,
v.apar_id,
V.EXT_INV_REF,
V.ARRIVAL_DATE as REGISTRATION_DATE,
v.last_update as arrival_date,
V.DUE_DATE,
v.apar_name as supplier_name,
v.dim_1 AS costc,
v.amount,
v.dim_3,
v.dim_4,
v.version_no,
v.voucher_date,
(select wf_user_id from agresso.awfviiin where v.voucher_no = voucher_no and
ROWNUM <= 1) as User_Id
from AGRESSO.AWFVIIIN V
where v.account not in ('B611110', 'B531120') and v.process != 'Incoming Invoice
Approval'
order by 3,4,1, USER_ID desc;

select col1_value, col2_descr from agresso.awftask where action_code like 'PA';


Invoices in Workflow report incl. Name and Role ID

SELECT v.voucher_no,
v.account,
v.process,
v.step,
v.wf_state,
v.apar_id,
V.EXT_INV_REF,
V.ARRIVAL_DATE as REGISTRATION_DATE,
v.last_update as arrival_date,
V.DUE_DATE,
v.apar_name as supplier_name,
v.dim_1 AS costc,
v.amount,
v.dim_3,
v.dim_4,
v.version_no,
v.voucher_date,
(select wf_user_id from agresso.awfviiin where v.voucher_no = voucher_no and
ROWNUM <= 1) as User_Id,
u.name,
t.role_id
from AGRESSO.AWFVIIIN V
inner join agresso.ahsresources u on v.client = u.client and v.wf_user_id =
u.resource_id
inner join agresso.awftask t on v.client = t.client and to_char (v.voucher_no) =
t.col1_value
order by 3,4, 1, USER_ID desc;

Updating a Requisition so it’s associated with a new user ID

update aporeqheader
set resource_id = '&resource_id'
where order_id like '&order_id';
commit;
update aporeqheader
set resource_id2 = '&resource_id2'
where order_id like '&order_id';
commit;
update aporeqheader
set responsible2 = '&responsible2'
where order_id like '&order_id';
commit;
update aporeqheader
set user_id = '&user_id'
where order_id like '&order_id';
commit;
SQL Query for name and “ZZ” role value

select (h.first_Name||' '||h.surname) as Name,


--h.resource_id, p.resource_id, p.post_id, r.dim_value, [These were here to check
was getting the correct info from each table]
r.role_id
from agresso.aprresourcepost p
inner join agresso.acrroleaccess r on r.dim_value = p.post_id
inner join agresso.ahsresources h on h.resource_id = p.resource_id
where p.client = 'PP'
and r.role_id like 'ZZ%'
and p.date_to > sysdate
and h.status = 'N'
order by Name

Northgate Interface

delete from apodetail where order_id in '&order_id';


commit;

delete from acrtransdetail where order_id in '&order_id';


commit;

delete from algdelivery where order_id in '&order_id';


commit;

update apodetail
set status = 'T'
where order_id like '&order_id';
commit;

Check for duplicate roles

select a.user_id, a.role_id, b.last_update, b.user_stamp, c.description from


aaguserdetail a, aaguserdetail b
left outer join agresso.agldimvalue c
on b.user_stamp = c.dim_value
and b.client = c.client
where a.client = 'PP'
and a.bflag = 1
and b.bflag = 0
and a.client = b.client
and a.user_id = b.user_id
and a.role_id = b.role_id
and c.attribute_id = 'GN'
and a.user_id not in ('156545','161361','163436')
order by 1;

You might also like