Friday, July 13, 2012

Kill all non-windows apps

Ever wanted to kill all running apps except windows ones? Below batch script will do the job..

Save it as kill.bat
@echo off
title Kill all running apps - Bharat Balegere - AgniPulse.com
cd c:\windows\System32
for /f "skip=3 tokens=1" %%i in ('TASKLIST /FI "USERNAME eq %userdomain%\%username%" /FI "STATUS eq running"') do (
if not "%%i"=="svchost.exe" (
if not "%%i"=="explorer.exe" (
if not "%%i"=="cmd.exe" (
if not "%%i"=="tasklist.exe" (
echo.
taskkill /f /im "%%i" 
echo.
)
)
)
)
)
pause

Reference: http://www.technibble.com/kill-all-running-apps-bat-repair-tool-of-the-week/

Monday, July 2, 2012

How to delete BI Publisher Templates/Data Definitions

When you try to update BI Publisher templates/data definitions you will notice that some fields are protected from update. What if you have an RTF template and one day you want to use Excel template instead? 

You can "end date" the current and create a new one.. but you will have to change the template code and change the Report "Short Name" in its Concurrent Program to pick up the new template.

If you don't wanna go through this hassle, use below code.
DECLARE
  -- Change the following two parameters
  VAR_TEMPLATECODE  VARCHAR2(100) := 'XXSD_POXRCIPS'; -- Template/Data Defintion Code
  BOO_DELETEDATADEF BOOLEAN := TRUE; -- delete the associated Data Defintion.
BEGIN
  FOR RS IN (SELECT NVL(T1.APPLICATION_SHORT_NAME,
                        T2.APPLICATION_SHORT_NAME) TEMPLATE_APP_NAME
                   ,NVL(T1.DATA_SOURCE_CODE, T2.DATA_SOURCE_CODE) DATA_SOURCE_CODE
                   ,T2.APPLICATION_SHORT_NAME DEF_APP_NAME
               FROM XDO_TEMPLATES_B T1, XDO_DS_DEFINITIONS_B T2
              WHERE NVL(T1.TEMPLATE_CODE, T2.DATA_SOURCE_CODE) =
                    VAR_TEMPLATECODE
                AND T1.DATA_SOURCE_CODE(+) = T2.DATA_SOURCE_CODE) LOOP
    -- Deleting Template
    APPS.XDO_TEMPLATES_PKG.DELETE_ROW(RS.TEMPLATE_APP_NAME,
                                      VAR_TEMPLATECODE);
  
    DELETE FROM XDO_LOBS
     WHERE LOB_CODE = VAR_TEMPLATECODE
       AND APPLICATION_SHORT_NAME = RS.TEMPLATE_APP_NAME
       AND LOB_TYPE IN ('TEMPLATE_SOURCE', 'TEMPLATE');
  
    DELETE FROM XDO_CONFIG_VALUES
     WHERE APPLICATION_SHORT_NAME = RS.TEMPLATE_APP_NAME
       AND TEMPLATE_CODE = VAR_TEMPLATECODE
       AND DATA_SOURCE_CODE = RS.DATA_SOURCE_CODE
       AND CONFIG_LEVEL = 50;
  
    DBMS_OUTPUT.PUT_LINE('Template ' || VAR_TEMPLATECODE ||
                         ' deleted.');
    -- Deleting Data Definition
    IF BOO_DELETEDATADEF THEN
      APPS.XDO_DS_DEFINITIONS_PKG.DELETE_ROW(RS.DEF_APP_NAME,
                                             RS.DATA_SOURCE_CODE);
    
      DELETE FROM XDO_LOBS
       WHERE LOB_CODE = RS.DATA_SOURCE_CODE
         AND APPLICATION_SHORT_NAME = RS.DEF_APP_NAME
         AND LOB_TYPE IN ('XML_SCHEMA',
                          'DATA_TEMPLATE',
                          'XML_SAMPLE',
                          'BURSTING_FILE');
    
      DELETE FROM XDO_CONFIG_VALUES
       WHERE APPLICATION_SHORT_NAME = RS.DEF_APP_NAME
         AND DATA_SOURCE_CODE = RS.DATA_SOURCE_CODE
         AND CONFIG_LEVEL = 30;
    
      DBMS_OUTPUT.PUT_LINE('Data Defintion ' ||
                           RS.DATA_SOURCE_CODE || ' deleted.');
    END IF;
  END LOOP;

  DBMS_OUTPUT.PUT_LINE('Issue a COMMIT to make the changes or ROLLBACK to revert.');
EXCEPTION
  WHEN OTHERS THEN
    COMMIT;
    ROLLBACK;
    DBMS_OUTPUT.PUT_LINE('Unable to delete XML Publisher Template ' ||
                         VAR_TEMPLATECODE);
    DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM, 1, 200));
END;

Sunday, July 1, 2012

Force Autocomplete (Remember Passwords) in Internet Explorer

Some websites or in my case (Oracle E-Business Suite Login page) may opt out of using autocomplete by using autocomplete="off" in the form tag as shown below:

<form name="form1" id="form1" method="post" autocomplete="off"
  action="http://www.example.com/form.cgi">
[...]
</form>
Internet Explorer you will not be able to remember passwords if autocomplete is off. Other browsers like Chrome overrides this so no need to use this workaround with it. If you have to use Internet Explorer (Like my case) then there is a workaround for this problem. It's a simple javascript code which scans the html code and changes the autocomplete property from off to on.. 


Open this post in Internet Explorer, right click below link and click "Add to favorites.."

Force Autocomplete

Follow the below steps to use it with Oracle E-Business Suite.
  1. Navigate to EBS Login Page & run the javascript code link.
  2. Navigate to the password field then to the user field and login.
  3. You will see now a Save/Cancel dialogue (Autocomplete is on).
  4. Click Save to remember your username and password.
  5. Log out of Application (Autocomplete is off again).
  6. Repeat steps 1 & 2 then double click in the user field.

Dependent LOV for TO_DATE = 10 days + FROM_DATE

I had a special requirement in a Concurrent Program to make second date parameter dependent on the first. It's value should be the as the 1st but plus 10 days. I found a solution to generate dates from a specific point of time. I then included it in a view for later usage.


CREATE OR REPLACE VIEW XXSD_FND_DATES_VIEW AS
SELECT TRUNC(SYSDATE - ROWNUM + 1) DATE_COL
    FROM DUAL
   WHERE 1 = 1
  CONNECT BY ROWNUM >= 1
         AND TRUNC(SYSDATE - ROWNUM) BETWEEN TO_DATE('30-04-2009', 'DD-MM-YYYY') AND SYSDATE;



And I used it in the date parameter Value Set and with a bit :$FLEX$ ..



It worked..

References: http://www.seankilleen.com/2012/02/how-to-list-all-dates-for-sysdate-30-in.html