P_PURDOCITEMCALCFIELD

CDS View

P_PURDOCITEMCALCFIELD is a CDS View in S/4HANA. It contains 2 fields. 1 CDS views read from this table.

CDS Views using this table (1)

ViewTypeJoinVDMDescription
C_PoItemMoniCalcField view from CONSUMPTION Calculation field for Monitor PO

Fields (2)

KeyField CDS FieldsUsed in Views
KEY PurchaseOrder PurchaseOrder 1
KEY PurchaseOrderItem PurchasingDocumentItem 1
@AbapCatalog.sqlViewName: 'PCALCFIELDPOITEM'
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #PRIVILEGED_ONLY
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.serviceQuality: #A
@ObjectModel.usageType.sizeCategory: #L
@ObjectModel.usageType.dataClass: #TRANSACTIONAL

define view P_PurDocItemCalcField
  as select from P_TotalGrInvQty as _TotalGRIR
  association [1..1] to I_PurchasingDocumentItem as _PurchasingDocumentItem on  $projection.PurchaseOrder     = _PurchasingDocumentItem.PurchasingDocument
                                                                            and $projection.PurchaseOrderItem = _PurchasingDocumentItem.PurchasingDocumentItem
  // used to fetch aggregated invoice qty , value and GR value from history table

  association [0..1] to P_PurOrdItemAggr_Accpo  as _POItemHistory         on  $projection.PurchaseOrder     = _POItemHistory.PurchaseOrder
                                                                                 and $projection.PurchaseOrderItem  = _POItemHistory.PurchaseOrderItem    //3226992


 // used to fetch GR Qty

  association [0..1] to P_POItemGRQuantity    as _POItemGRQuantity     on  _POItemGRQuantity.PurchaseOrder     = $projection.PurchaseOrder
                                                                       and _POItemGRQuantity.PurchaseOrderItem = $projection.PurchaseOrderItem            //3284643

{
  key _TotalGRIR.PurchaseOrder      as PurchaseOrder,
  key _TotalGRIR.PurchaseOrderItem  as PurchaseOrderItem,
      _PurchasingDocumentItem.PurchaseRequisition, //added by EAM team

      _PurchasingDocumentItem.PurchaseRequisitionItem, //added by EAM team

      _PurchasingDocumentItem.PurchasingDocumentDeletionCode, //added by EAM team

      /*Stock Keeping Quantity*/
      /*case
           when _PurchasingDocumentItem.BaseUnit <> ' '       // Base Unit of Measure

           then case
                when (_PurchasingDocumentItem.OrderQuantityUnit <> _PurchasingDocumentItem.BaseUnit)
                      and (_PurchasingDocumentItem.OrderItemQtyToBaseQtyDnmntr <> 0 )
                then cast((_PurchasingDocumentItem.OrderQuantity) *
                division (_PurchasingDocumentItem.OrderItemQtyToBaseQtyNmrtr,_PurchasingDocumentItem.OrderItemQtyToBaseQtyDnmntr,2 )
                as abap.quan(13,3))
                else _PurchasingDocumentItem.OrderQuantity
                end
            else 0
      end                           as  GoodsReceiptQty, //GFNC still required.. used temporary for testing purposes..StockKeepQuantity ,


      _PurchasingDocumentItem.BaseUnit,*/

      /*StillTo Deliver Quantity*/
      case
      when _PurchasingDocumentItem.IsCompletelyDelivered <> '' or _PurchasingDocumentItem.GoodsReceiptIsExpected = ''    //3368705

      then 0
      else
        case
        when _TotalGRIR.GoodsReceiptQty is not null
        then  cast(_PurchasingDocumentItem.OrderQuantity - abs(_TotalGRIR.GoodsReceiptQty) as abap.quan(13,3))
        else  _PurchasingDocumentItem.OrderQuantity
        end
      end                           as StillToBeDeliveredQuantity,

      /*Still To Deliver Value*/
      case
       when _PurchasingDocumentItem.IsReturnsItem = 'X'                                         //3284643

        then
            case when _POItemGRQuantity.GoodsReceiptQty is null  or _POItemGRQuantity.GoodsReceiptQty = 0
                  then -abs(_PurchasingDocumentItem.NetAmount)  
             else -abs(-abs(_PurchasingDocumentItem.NetAmount) - _POItemHistory.GoodsReceiptAmount)
             end
      when _PurchasingDocumentItem.IsCompletelyDelivered <> '' or _PurchasingDocumentItem.GoodsReceiptIsExpected = ''      //3368705

           or _PurchasingDocumentItem.GoodsReceiptIsNonValuated  = 'X' //CS20210001888821 - Keep in sync with MPOI

      then 0
      else
        case
      //CS20210001888821 Value shouldnt appear blank for Service Limits

      //        when _PurchasingDocumentItem.OrderQuantity <> 0

        when _PurchasingDocumentItem.OrderQuantity <> 0
            or ( _PurchasingDocumentItem.PurchasingDocumentItemCategory = 'A'
                and _PurchasingDocumentItem.ProductType = '2')
        then
            case
                when _TotalGRIR.GoodsReceiptQty is not null or _TotalGRIR.GoodsReceiptQty != 0
                then _PurchasingDocumentItem.NetAmount - _TotalGRIR.PurchaseOrderAmount //changes done to incoporate the scenario,

      //when posting is done in currency other than document currency, PurchaseOrderAmount gives the converted amount in document currency.

      //                then cast((_PurchasingDocumentItem.OrderQuantity - abs(_TotalGRIR.GoodsReceiptQty)) *

      //                 division (_PurchasingDocumentItem.NetAmount,_PurchasingDocumentItem.OrderQuantity,3)

      //                 as abap.curr(15,3))                        //2838634

                  else cast(_PurchasingDocumentItem.NetAmount as abap.curr(15,3))   //2838634

      //                else cast((_PurchasingDocumentItem.OrderQuantity) *

      //                 division (_PurchasingDocumentItem.NetAmount,_PurchasingDocumentItem.OrderQuantity,3)

      //                 as abap.curr(15,2))

            end
            else 0
         end
      end                           as StillToBeDeliveredValue,

      /*Still to Invoice Quantity*/
      case
      when _PurchasingDocumentItem.IsFinallyInvoiced = 'X' then 0
      when _PurchasingDocumentItem.InvoiceIsExpected = ' ' then 0
      else case
           when _PurchasingDocumentItem.GoodsReceiptIsExpected = 'X' and (_PurchasingDocumentItem.IsCompletelyDelivered <> ''     //3368705

                                                                          or _TotalGRIR.GoodsReceiptQty > _PurchasingDocumentItem.OrderQuantity )

           then cast(abs(_TotalGRIR.GoodsReceiptQty) - abs(_TotalGRIR.InvoiceReceiptQuantity)as abap.quan(13,3))
           else
              case
              when _TotalGRIR.GoodsReceiptQty is not null
              then cast(_PurchasingDocumentItem.OrderQuantity - abs(_TotalGRIR.InvoiceReceiptQuantity) as abap.quan(13,3))
              else _PurchasingDocumentItem.OrderQuantity
              end
           end
      end                           as StillToInvoiceQuantity,



      @Semantics.quantity.unitOfMeasure: 'OrderQuantityUnit'
      cast(
      case
        when _TotalGRIR.InvoiceReceiptQuantity is null
        then 0
        else
            case when _PurchasingDocumentItem.IsReturnsItem = 'X'
            then -1 * _TotalGRIR.InvoiceReceiptQuantity
            else _TotalGRIR.InvoiceReceiptQuantity
            end
      end as vdm_invoicereceiptqty) as InvoiceReceiptQty,

      case when _POItemHistory.InvoiceReceiptAmount is null then cast (0 as abap.curr( 21, 5))
      else _POItemHistory.InvoiceReceiptAmount
      end                                    as InvoiceReceiptAmount,                   //3226992


      _PurchasingDocumentItem.OrderQuantityUnit,

      _PurchasingDocumentItem,
      _TotalGRIR.GoodsReceiptQty    as GoodsReceiptQty //2833125

}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_PURCHASINGDOCUMENTITEM",
"P_POITEMGRQUANTITY",
"P_PURORDITEMAGGR_ACCPO",
"P_TOTALGRINVQTY"
],
"ASSOCIATED":
[
"I_PURCHASINGDOCUMENTITEM",
"P_POITEMGRQUANTITY",
"P_PURORDITEMAGGR_ACCPO"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/