CREATE VIEW AS PMX_CUSTOMVIEW_CUST AS SELECT PMX_LUID.SSCC, PMX_MVLI."DestLogUnitIdentKey" LUID, PMX_PLPL."BaseType", ORDR.TrnspCode--, --OSHP.* FROM PMX_LPLM WITH(NOLOCK) INNER JOIN PMX_PLLI WITH(NOLOCK) ON PMX_LPLM."PickListDocEntry" = PMX_PLLI."DocEntry" AND PMX_LPLM."PickListLineNum" = PMX_PLLI."LineNum" INNER JOIN PMX_PLHE WITH(NOLOCK) ON PMX_PLLI."DocEntry" = PMX_PLHE."DocEntry" -- AND PMX_PLLI."LineStatus" = 'O' INNER JOIN PMX_MVLI WITH(NOLOCK) ON PMX_LPLM."MoveDocEntry" = PMX_MVLI."DocEntry" AND PMX_LPLM."MoveLineNum" = PMX_MVLI."LineNum" INNER JOIN PMX_LUID WITH(NOLOCK) ON PMX_LUID."InternalKey" = PMX_MVLI."DestLogUnitIdentKey" LEFT JOIN PMX_ITRI WITH(NOLOCK) ON PMX_MVLI."ItemTransactionalInfoKey" = PMX_ITRI."InternalKey" INNER JOIN OITM WITH(NOLOCK) ON OITM."ItemCode" = PMX_MVLI."ItemCode" INNER JOIN PMX_PLPL WITH(NOLOCK) ON PMX_PLPL."DocEntry" = PMX_PLLI."BaseEntry" AND PMX_PLPL."LineNum" = PMX_PLLI."BaseLine" AND PMX_PLLI."BaseType" = 'PMX_PLPH' LEFT JOIN OINV WITH(NOLOCK) ON PMX_PLPL."BaseType" = OINV."ObjType" AND PMX_PLPL."BaseEntry" = OINV."DocEntry" LEFT JOIN ORDR WITH(NOLOCK) ON ORDR."DocEntry" = PMX_PLPL."BaseEntry" AND ORDR."ObjType" = PMX_PLPL."BaseType" LEFT JOIN OWTQ WITH(NOLOCK) ON OWTQ."DocEntry" = PMX_PLPL."BaseEntry" AND OWTQ."ObjType" = PMX_PLPL."BaseType" LEFT JOIN OSHP WITH(NOLOCK) ON ORDR.TrnspCode = OSHP.TrnspCode WHERE OSHP.U_USERDEF_FIELD = 'UserDefinedValue_TRUE'