Tuesday, November 18, 2008

List Workbooks and their owners

-- Scripts
-- The following script lists all workbooks, their owners and who the workbook is shared with, if -- at all.

SELECT
DOC.DOC_NAME DOC_NAME ,
OWN_USR.EU_ID OWNER_ID,
OWN_USR.EU_USERNAME OWNER_NAME,
SH_USR.EU_ID GRANTEE_ID,
SH_USR.EU_USERNAME ACCESS_USER
FROM
EUL5_US.EUL5_EUL_USERS SH_USR,
EUL5_US.EUL5_ACCESS_PRIVS PRV,
EUL5_US.EUL5_DOCUMENTS DOC,
EUL5_US.EUL5_EUL_USERS OWN_USR
WHERE
PRV.AP_TYPE(+) = 'GD'
AND PRV.AP_EU_ID = SH_USR.EU_ID(+)
AND PRV.GD_DOC_ID(+) = DOC.DOC_ID
AND OWN_USR.EU_ID = DOC.DOC_EU_ID
ORDER BY DOC_NAME

Copy Discoverer Priviliges of one/several users to another

I acted as an interim Discoverer gatekeeper when our discoverer guru suddenly decided to quit. I am a database person and do not quite like the way some of the business functions are "supposed" to be performed. I like to dwell more on the database side to dig and tweak it from that end to get some of the stuff done. I must advice that this is not recommended and should not be done all the time. I however blatantly admit getting into trouble for retorting to this method, but shamefully I just cannot hide my weakness and do most of the time go to the database to get these kind of things done. Here is a sample common activity that one as a discoverer gatekeeper needs to perform in the IT world. Test the script in a dev database before running it in production.

--
--
declare
cursor cur_from_user IS
SELECT DISTINCT
doc_id
FROM
EUL5_us.EUL5_documents disco_docs,
EUL5_us.EUL5_access_privs disco_shares,
EUL5_us.EUL5_eul_users disco_users,
apps.fnd_user users1
where 1=1
and disco_users.EU_USERNAME='#'||users1.USER_ID
and disco_shares.AP_EU_ID=disco_users.EU_ID
and disco_docs.DOC_ID=disco_shares.GD_DOC_ID
and user_name IN ('AMITABH','DHARMENDRA');

cursor cur_to_user IS
SELECT
disco_users.EU_ID
FROM
EUL5_us.EUL5_eul_users disco_users,
apps.fnd_user users1
where 1=1
and disco_users.EU_USERNAME='#'||users1.USER_ID
and user_name='ABHISHEK';

l_ap_id NUMBER;
l_eu_id NUMBER;
l_temp NUMBER := NULL;

BEGIN

OPEN cur_to_user;
FETCH cur_to_user INTO l_eu_id;
CLOSE cur_to_user;

IF l_eu_id IS NULL THEN
Raise_application_error(-20011, 'Invalid FND User Name');
END IF;


FOR i_rec in cur_from_user
LOOP

select EUL5_id_seq.nextval INTO l_ap_id from dual;

BEGIN

select gd_doc_id INTO l_temp from EUL5_ACCESS_PRIVS
where gd_doc_id=i_rec.doc_id
and ap_eu_id = l_eu_id;

EXCEPTION WHEN NO_DATA_FOUND THEN

INSERT INTO EUL5_ACCESS_PRIVS ( AP_ID
, AP_TYPE
, AP_EU_ID
, AP_PRIV_LEVEL
, GP_APP_ID
, GBA_BA_ID
, GD_DOC_ID
, AP_ELEMENT_STATE
, AP_CREATED_BY
, AP_CREATED_DATE
, AP_UPDATED_BY
, AP_UPDATED_DATE
, NOTM )
VALUES ( l_ap_id
, 'GD'
, l_eu_id
, 0
, NULL
, NULL
, i_rec.doc_id
, 0
, '#2309'
, SYSDATE
, '#2309'
, SYSDATE
, 0);

END;


END LOOP;

END ;

commit;

How to Start and Stop Concurrent Manager

1) Login to the Linux apps Box as applmgr or as the OS user

2) Source the appsora.env file. This will set the Oracle Environment variables
In our installation we just have to execute $(sudo su - appldev) which sets Oracle env variables along with several other required variables. I have seen few more installations which seem to follow the same practice.

3) cd $APPLCSF
$pwd
/u04/DEV/applmgr/common/admin
4) Go to the scripts folder in admin area.

5) Inside this scripts folder you will find a directory with the name of db SID
For eg(/u04/DEV/applmgr/common/admin/scripts/)

6) Locate the shell script adcmctl.sh
adcmctl.sh stop apps/apps -- Stops the CM
adcmctl.sh status apps/apps -- Status of the CM
adcmctl.sh start apps/apps -- Starts the CM

7) $adcmctl.sh start apps/lang4test