Thursday, June 14, 2012

calendar in Oracle-sqlplus

SELECT SUBSTR(LPAD( Month, 20-(20-LENGTH(month))/2 ),1,20) Month,
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
FROM (SELECT TO_CHAR(DT,'fmMonthfm YYYY') month, TO_CHAR(dt+1,'iw') week,
MAX(DECODE(TO_CHAR(dt,'d'),'1',LPAD(TO_CHAR(dt,'fmdd'),2))) "Sun",
MAX(DECODE(TO_CHAR(dt,'d'),'2',LPAD(TO_CHAR(dt,'fmdd'),2))) "Mon",
MAX(DECODE(TO_CHAR(dt,'d'),'3',LPAD(TO_CHAR(dt,'fmdd'),2))) "Tue",
MAX(DECODE(TO_CHAR(dt,'d'),'4',LPAD(TO_CHAR(dt,'fmdd'),2))) "Wed",
MAX(DECODE(TO_CHAR(dt,'d'),'5',LPAD(TO_CHAR(dt,'fmdd'),2))) "Thu",
MAX(DECODE(TO_CHAR(dt,'d'),'6',LPAD(TO_CHAR(dt,'fmdd'),2))) "Fri",
MAX(DECODE(TO_CHAR(dt,'d'),'7',LPAD(TO_CHAR(dt,'fmdd'),2))) "Sat"
FROM ( SELECT TRUNC(SYSDATE,'y')-1+ROWNUM dt FROM all_objects
WHERE ROWNUM <= ADD_MONTHS(TRUNC(SYSDATE,'y'),12) - TRUNC(SYSDATE,'y'))
GROUP BY TO_CHAR(dt,'fmMonthfm YYYY'), TO_CHAR( dt+1, 'iw' ))
ORDER BY TO_DATE( month, 'Month YYYY' ), TO_NUMBER(week);

SRW Example

FUNCTION CREATETAB RETURN BOOLEAN IS
BEGIN
SRW.DO_SQL('CREATE TABLE CHECK (EMPNO NUMBER NOT NULL
            PRIMARY KEY, SAL NUMBER (10,2)) PCTFREE 5
            PCTUSED 75');
RETURN(TRUE);
EXCEPTION
WHEN SRW.DO_SQL_FAILURE THEN
 SRW.MESSAGE(100, 'ERROR WHILE CREATING CHECK TABLE.');
 SRW.MESSAGE(50, 'REPORT WAS STOPPED BEFORE THE RUNTIME
 PARAMETER FORM.');
 RAISE SRW.PROGRAM_ABORT;
END;
/* Suppose you want to create a "table of contents" by getting the
** first character of a column's value, and page number on which its
** field fires to print.  Assume that you want to put the "table of contents"
** into a table named SHIP.  You could write the following construct:
*/

DECLARE
  PAGE_NO      NUMBER;
  PAGE_FOR     INDEX NUMBER;
  SORT_CHAR    CHAR(1);
  CMD_LINE     CHAR(200);
BEGIN
  SORT_CHAR := :SORT_NAME ;
  IF :CALLED = 'Y' THEN
    SRW.GET_PAGE_NUM(PAGE_FOR_INDEX);
    SRW.USER_EXIT('RWECOP PAGE_FOR_INDEX
                   P_START_PAGENO');
    SRW.MESSAGE(2,TO_CHAR(:P_START_PAGENO));
  END IF;
  SRW.GET_PAGE_NUM(PAGE_NO);
  CMD_LINE := 'INSERT INTO SHIP VALUES
       ('''||SORT_CHAR||''','||TO_CHAR(PAGE_NO)||')';
  SRW.MESSAGE(2,CMD_LINE);
  SRW.DO_SQL(CMD_LINE);
  COMMIT;
EXCEPTION
  WHEN DUP_VAL_ON_INDEX THEN
       NULL;
  WHEN SRW.DO_SQL_FAILURE THEN
       SRW.MESSAGE(1,'FAILED TO INSERT ROW INTO SHIP
TABLE');
  WHEN OTHERS THEN
       COMMIT;
END;

Friday, June 8, 2012

Link for operating unit,inv_org & warehouse code


SELECT hou.NAME operating_unit_name,houn.internal_address_line,
         hou.short_code,
         hou.organization_id operating_unit_id,
         hou.set_of_books_id,
         hou.business_group_id,
         ood.organization_name inventory_organization_name,
         ood.organization_code Inv_organization_code,
         ood.organization_id Inv_organization_id,
         ood.chart_of_accounts_id,
         msci.secondary_inventory_name whse_code
    FROM hr_operating_units hou, org_organization_definitions ood,hr_all_organization_units houn,mtl_secondary_inventories msci
   WHERE 1 = 1 AND hou.organization_id = ood.operating_unit
   AND hou.organization_id=houn.organization_id
   AND ood.organization_id=msci.organization_id
   --AND ood.organization_code='WPO'
   AND houn.internal_address_line=NVL(:P_OPERRATING_UNIT, houn.internal_address_line) --'CCUS'
   AND ood.organization_code= NVL(:P_INVENTORY_ORG_CODE,ood.organization_code)--'WPO'
   AND msci.secondary_inventory_name=NVL(:P_WAREHOUSE_CODE,msci.secondary_inventory_name)--'WPFG'
ORDER BY hou.organization_id ASC

To get concurrent programs and value set details to compare P23 instance and P26 Instance


SELECT   SUBSTR(descriptive_flexfield_name, 7) end_user_column_name,
         fdf.description,
         enabled_flag,
         DEFAULT_VALUE,
         required_flag,
         display_flag,
         form_left_prompt,
         srw_param token,
         flex_value_set_name
--  fdf.creation_date,
--  fdf.last_updated_by,
-- fdf.last_update_date,
-- fdf.flex_value_set_id
FROM     fnd_descr_flex_col_usage_vl fdf,
         fnd_flex_value_sets ffv
WHERE    (application_id = 20003)
AND      fdf.flex_value_set_id = ffv.flex_value_set_id
AND      (descriptive_flexfield_name IN ('$SRS$.SH001801', '$SRS$.FM00501'))
ORDER BY descriptive_flexfield_name;

1) Enter your ALL Concurrent PROGRAM short names IN above QUERY "IN" clause ("here $SRS$." IS MANDATORY )
2) CONVERT output TO csv FILE. Get output FROM P23 AND P26
3) Compare above two files USING "ExamDiff" tool (OR you can USE ANY other tool which compare two files)