Sunday, 16 August 2020

Oracle Fusion Maintenance Cloud - Maintenance Asset Details Query

 SELECT 

  'KEY' AS "KEY",

ROWNUM SR_NO,

       CAB.ASSET_ID,

       CAB.ASSET_NUMBER,

       CAV.DESCRIPTION,

       (SELECT ASSET_NUMBER

          FROM CSE_ASSETS_B

         WHERE ASSET_ID = (SELECT PARENT_ASSET_ID

                             FROM CSE_AS_BUILT_RELATIONS_V

                            WHERE CHILD_ASSET_ID = CAB.ASSET_ID AND ROWNUM=1))

          PARENT_ASSET,

       (SELECT 

ESI.ITEM_NUMBER

FROM

EGP_SYSTEM_ITEMS_B ESI,

   EGP_SYSTEM_ITEMS_TL ESIT

WHERE

ESI.INVENTORY_ITEM_ID = ESIT.INVENTORY_ITEM_ID

AND ESI.ORGANIZATION_ID = ESIT.ORGANIZATION_ID

AND ESI.INVENTORY_ITEM_ID = CAB.ITEM_ID

AND ESIT.ORGANIZATION_ID=CAB.ITEM_ORGANIZATION_ID

)ITEM_NUMBER,

       (SELECT 

ESIT.DESCRIPTION

FROM

EGP_SYSTEM_ITEMS_B ESI,

   EGP_SYSTEM_ITEMS_TL ESIT

WHERE

ESI.INVENTORY_ITEM_ID = ESIT.INVENTORY_ITEM_ID

AND ESI.ORGANIZATION_ID = ESIT.ORGANIZATION_ID

AND ESI.INVENTORY_ITEM_ID = CAB.ITEM_ID

AND ESIT.ORGANIZATION_ID=CAB.ITEM_ORGANIZATION_ID

)     IETEM_DESC,

       CAB.SERIAL_NUMBER,

       (SELECT NAME

          FROM HR_ORGANIZATION_UNITS

         WHERE ORGANIZATION_ID=(select ITEM_ORGANIZATION_ID

from

CSE_ASSETS_HIST where TRANSACTED_ASSET_ID =

(select MIN(TRANSACTED_ASSET_ID) from CSE_ASSETS_HIST where asset_id = CAB.asset_id)) )

          MAINTANENCE_ORG,                                   --MAINTENANCE ORG

       (SELECT NAME

          FROM HR_ORGANIZATION_UNITS

         WHERE ORGANIZATION_ID = CAB.ITEM_ORGANIZATION_ID)

          OPERATING_ORG,                                       --OPERATING ORG

       CAB.CURRENT_LOCATION_CONTEXT,                          -- LOCATION TYPE

       (SELECT HP.ADDRESS1

        || ', '

        || HP.ADDRESS1

        || ', '

        || HP.ADDRESS3

        || ', '

        || HP.CITY

        || ', '

        || HP.COUNTRY FROM HZ_PARTIES HP WHERE HP.PARTY_ID=CAB.CONTACT_ID )

          LOCATION,                                               -- LOCATION,

       CAB.CONTACT_ID,

       (SELECT HP.PARTY_NAME FROM HZ_PARTIES HP WHERE HP.PARTY_ID=CAB.CONTACT_ID) CONTACT,                                     

       TO_CHAR(CAB.CREATION_DATE,'DD-MM-YY HH:MI:SS') CREATION_DATE,                              

       TO_CHAR(CAB.ACTIVE_END_DATE,'DD-MM-YY HH:MI:SS') ACTIVE_END_DATE,                                  

       CAB.ATTRIBUTE_CHAR1 ASSET_STATUS

  FROM CSE_ASSETS_B CAB,

       CSE_ASSETS_VL CAV

 WHERE     CAB.ASSET_ID = CAV.ASSET_ID

 AND ((TRUNC(CAB.LAST_UPDATE_DATE) BETWEEN TRUNC(:P_START_DT) AND TRUNC(:P_END_DT)) OR TRUNC(CAB.LAST_UPDATE_DATE)= TRUNC(SYSDATE))

No comments:

Post a Comment