I_PT_SAFTDeliveryHeader

DDL: I_PT_SAFTDELIVERYHEADER SQL: IPTSAFTDELHDR Type: view COMPOSITE

SAFT Movement of Goods Header Portugal

I_PT_SAFTDeliveryHeader is a Composite CDS View that provides data about "SAFT Movement of Goods Header Portugal" in SAP S/4HANA. It reads from 3 data sources (I_PT_DeliveryNumberRange, I_DeliveryDocument, I_PT_DeliveryDgtlSgntr) and exposes 41 fields with key field PortugueseDeliveryNumber. It has 6 associations to related views.

Data Sources (3)

SourceAliasJoin Type
I_PT_DeliveryNumberRange _MovementType inner
I_DeliveryDocument DeliveryDocument inner
I_PT_DeliveryDgtlSgntr DigitalSignature from

Associations (6)

CardinalityTargetAliasCondition
[0..1] I_PT_DeliveryShipFromAddress _ShipFromAddress _ShipFromAddress.DeliveryDocument = $projection.DeliveryDocument
[0..1] I_PT_SAFTDeliveryCustDetail _ShipToAddress _ShipToAddress.PortugueseDeliveryNumber = DigitalSignature.PortugueseDeliveryNumber
[0..1] I_PT_SDDocumentProcessFlow _SDDocumentProcessFlow _SDDocumentProcessFlow.DeliveryDocument = $projection.DeliveryDocument
[0..1] I_PT_SAFTHeaderGrossTotal _TotalForeignCurrency _TotalForeignCurrency.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber
[1..1] I_PT_SAFTDeliveryHeaderAmt _AmountTotals _AmountTotals.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber
[0..1] I_SAFTDeliverySupplier _DelSupplier _DelSupplier.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber

Annotations (12)

NameValueLevelField
AbapCatalog.sqlViewName IPTSAFTDELHDR view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
VDM.viewType #COMPOSITE view
AccessControl.authorizationCheck #CHECK view
ClientHandling.algorithm #SESSION_VARIABLE view
Metadata.ignorePropagatedAnnotations true view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #X view
ObjectModel.usageType.dataClass #MIXED view
AccessControl.personalData.blocking #NOT_REQUIRED view
EndUserText.label SAFT Movement of Goods Header Portugal view

Fields (41)

KeyFieldSource TableSource FieldDescription
KEY PortugueseDeliveryNumber PortugueseDeliveryNumber
DeliveryDocument I_DeliveryDocument DeliveryDocument
ShipToParty ShipToParty
CreationDate I_PT_DeliveryDgtlSgntr PortugueseDigitalSignatureDate
CreationTime I_PT_DeliveryDgtlSgntr PortugueseDigitalSignatureTime
CompanyCode I_PT_DeliveryDgtlSgntr CompanyCode
DeliveryDocumentType I_PT_DeliveryDgtlSgntr DeliveryDocumentType
PortugueseReferenceDocument I_PT_DeliveryDgtlSgntr ReferenceDocumentNumber
PT_SeriesIdentifier
PTDgtlSgntrSystemDateTimeText PTDgtlSgntrSystemDateTimeText
CreatedByUser I_DeliveryDocument CreatedByUser
BillingPriceSource
PortugueseDigitalSignature PortugueseDigitalSignature
PortugueseDgtlSgntrKeyVersion PortugueseDgtlSgntrKeyVersion
TransportationPlanningDate I_DeliveryDocument TransportationPlanningDate
PT_SeriesDocumentNumber I_PT_DeliveryDgtlSgntr PT_SeriesDocumentNumber
PortugueseSgntrCertificate PortugueseSgntrCertificate
Supplier _DelSupplier Supplier
DeliveryDate I_PT_DeliveryDgtlSgntr DeliveryDate
CityNameendasShipToPartyCityName
CountryendasShipToPartyCountry
PostalCodeendasShipToPartyPostalCode
StreetNameendasShipToPartyStreetName
ShipToPartyHouseNumber
CustAddressNumber
CustomerRegion
HouseNumber _ShipFromAddress HouseNumber
StreetName _ShipFromAddress StreetName
SupplierAddress _ShipFromAddress SupplierAddress
CityName _ShipFromAddress CityName
PostalCode _ShipFromAddress PostalCode
Region _ShipFromAddress Region
Country _ShipFromAddress Country
TransportationPlanningTimeZone
TotalTaxAmount
TotalNetAmount
TotalGrossAmount
InvoiceAmountInFrgnCurrency _TotalForeignCurrency InvoiceAmountInFrgnCurrency
GoodsIssueTime I_DeliveryDocument GoodsIssueTime
ExchangeRateelse0endasExchangeRate
_SDDocumentProcessFlow _SDDocumentProcessFlow
@AbapCatalog.sqlViewName: 'IPTSAFTDELHDR'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@VDM.viewType: #COMPOSITE
@AccessControl.authorizationCheck: #CHECK
@ClientHandling.algorithm: #SESSION_VARIABLE
@Metadata.ignorePropagatedAnnotations:true
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #X
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking: #NOT_REQUIRED
@EndUserText.label: 'SAFT Movement of Goods Header Portugal'
define view I_PT_SAFTDeliveryHeader
  as select from I_PT_DeliveryDgtlSgntr   as DigitalSignature
    inner join   I_DeliveryDocument       as DeliveryDocument on DeliveryDocument.DeliveryDocument = DigitalSignature.DeliveryDocument

  // ATCUD change for VAT determination

 //   inner join   I_CompanyCode            as _CompanyCode     on _CompanyCode.CompanyCode = DigitalSignature.CompanyCode


    inner join   I_PT_DeliveryNumberRange as _MovementType    on  _MovementType.CompanyCode          = DigitalSignature.CompanyCode
                                                              and _MovementType.DeliveryDocumentType = DigitalSignature.DeliveryDocumentType

  association [0..1] to I_PT_DeliveryShipFromAddress as _ShipFromAddress       on _ShipFromAddress.DeliveryDocument = $projection.DeliveryDocument

  association [0..1] to I_PT_SAFTDeliveryCustDetail  as _ShipToAddress         on _ShipToAddress.PortugueseDeliveryNumber = DigitalSignature.PortugueseDeliveryNumber

  association [0..1] to I_PT_SDDocumentProcessFlow   as _SDDocumentProcessFlow on _SDDocumentProcessFlow.DeliveryDocument = $projection.DeliveryDocument
  //  association [0..1] to I_DeliveryDocumentItem       as DeliveryDocumentItem   on  DeliveryDocumentItem.DeliveryDocument = $projection.DeliveryDocument

  association [0..1] to I_PT_SAFTHeaderGrossTotal    as _TotalForeignCurrency  on _TotalForeignCurrency.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber
  //association [0..1] to I_PurchasingDocument        as _PurchasingDocument    on  _PurchasingDocument.PurchasingDocument = DeliveryDocument._Item


  //association [0..1] to C_PT_SAFTDeliveryDocTotCheck as  _SAFTDeliveryDocTotCheck     on _SAFTDeliveryDocTotCheck.CompanyCode = $projection.CompanyCode

  association [1..1] to I_PT_SAFTDeliveryHeaderAmt   as _AmountTotals          on _AmountTotals.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber

  association [0..1] to I_SAFTDeliverySupplier       as _DelSupplier           on _DelSupplier.PortugueseDeliveryNumber = $projection.PortugueseDeliveryNumber
{
  key  PortugueseDeliveryNumber                                                                                      as PortugueseDeliveryNumber,
       DeliveryDocument.DeliveryDocument,
       ShipToParty,
       DigitalSignature.PortugueseDigitalSignatureDate                                                               as CreationDate,
       DigitalSignature.PortugueseDigitalSignatureTime                                                               as CreationTime,
       DigitalSignature.CompanyCode,
       DigitalSignature.DeliveryDocumentType,

       // ATCUD relevant changes

       DigitalSignature.ReferenceDocumentNumber                                                                      as PortugueseReferenceDocument,
 //    cast( substring(_CompanyCode.VATRegistration, 3, 18) as stceg)                                                as VATRegistration,

       cast( DigitalSignature.PortugueseDgtlSignatureSeries as glo_pt_series_id)                                     as PT_SeriesIdentifier,

       // 0                                                                                                                                 as   DocumentIndex,


       case
             when _SDDocumentProcessFlow.PrecedingDocumentCategory is null or _SDDocumentProcessFlow.PrecedingDocumentCategory = ''
        then
        cast( case when  DigitalSignature.GoodsMovementIsCancelled = 'X'
       then  'A'
        else 'N'
         end as char1)
        else
        case
       when _SDDocumentProcessFlow.PrecedingDocumentCategory = 'R'
       then  'N'
        else 'A'
         end
        end                                                                                                          as GoodsMovementStatus,

       PTDgtlSgntrSystemDateTimeText,
       DeliveryDocument.CreatedByUser                                                                                as CreatedByUser,
       'P'                                                                                                           as BillingPriceSource,
       PortugueseDigitalSignature,
       PortugueseDgtlSgntrKeyVersion,
       DeliveryDocument.TransportationPlanningDate,
    
    
    //ATCUD Changes

     
     cast (case 
     when DigitalSignature.PT_SeriesDocumentType <> ''
     then
     DigitalSignature.PT_SeriesDocumentType
     else
     _MovementType.DeliveryType
     end as glo_pt_series_dt)  as PT_SeriesDocumentType,
     
     DigitalSignature.PT_SeriesDocumentNumber,

       PortugueseSgntrCertificate,
       //CustomerID

       case _ShipToAddress.IsOneTimeAccount
         when 'X'
       then
         case
       when  _ShipToAddress._OnetimeCustomer.PortugueseCustomerWithVersion  is not initial
         then  _ShipToAddress._OnetimeCustomer.PortugueseCustomerWithVersion
       else concat(ShipToParty,'_0') //ShipToParty

         end
       else
         case
       when   _ShipToAddress.PortugueseCustomerWithVersion  is not initial
         then   _ShipToAddress.PortugueseCustomerWithVersion
         else concat(ShipToParty,'_0') //ShipToParty

         end
       end                                                                                                           as PortugueseCustomerWithVersion,

       // **SupplierID - Check the Vendor from the corresponding Purchase Order. EKKO-LIFNR

       _DelSupplier.Supplier                                                                                         as Supplier,
       //EACCode - Out of Scope

       //MovementComments - Out of scope

       DigitalSignature.DeliveryDate                                                                                 as DeliveryDate,



       //Ship To Address - From VBPA get the PARVW 'WE' details and extract VBPA-ADRNR. Also extract the details from the History table for all the fields


       case _ShipToAddress.IsOneTimeAccount
        when 'X'
        then _ShipToAddress._OnetimeCustomer.CityName
        else
        _ShipToAddress.CityName

        end                                                                                                          as ShipToPartyCityName,
       case _ShipToAddress.IsOneTimeAccount
       when 'X'
       then _ShipToAddress._OnetimeCustomer.Country
       else
       _ShipToAddress.Country

        end                                                                                                          as ShipToPartyCountry,
       case _ShipToAddress.IsOneTimeAccount
       when 'X'
       then _ShipToAddress._OnetimeCustomer.PostalCode
       else
       _ShipToAddress.PostalCode

       end                                                                                                           as ShipToPartyPostalCode,

       case _ShipToAddress.IsOneTimeAccount
        when 'X'
        then _ShipToAddress._OnetimeCustomer.StreetName
        else
          _ShipToAddress.StreetName

          end                                                                                                        as ShipToPartyStreetName,
       _ShipToAddress._Addr.HouseNumber                                                                              as ShipToPartyHouseNumber,


       concat ( _ShipToAddress._Addr.StreetName,   _ShipToAddress._Addr.HouseNumber)                                 as CustAddressNumber,
       _ShipToAddress._Addr.Region                                                                                   as CustomerRegion,



       // Ship From Address - "Get the Shipping Point Details from LIKP-VSTEL. Get adress number from TVST-ADRNR. If doc_category is 'GS' Get the Plant Details from LIKP-WERKS. Get adress number from T001w-ADRNR

       _ShipFromAddress.HouseNumber                                                                                  as HouseNumber,
       _ShipFromAddress.StreetName                                                                                   as StreetName,
       _ShipFromAddress.SupplierAddress                                                                              as SupplierAddress,
       _ShipFromAddress.CityName                                                                                     as CityName,
       _ShipFromAddress.PostalCode                                                                                   as PostalCode,
       _ShipFromAddress.Region                                                                                       as Region,
       _ShipFromAddress.Country                                                                                      as Country,

       concat (concat(DeliveryDocument.TransportationPlanningDate,'/'), DeliveryDocument.TransportationPlanningTime) as TransportationPlanningTimeZone,

       // Totals


       cast( ROUND(_AmountTotals.TotalTaxAmount, 2) as abap.dec(11,2) )                                              as TotalTaxAmount,
       cast( ROUND(_AmountTotals.TotalNetAmount, 2) as abap.dec(11,2) )                                              as TotalNetAmount,
       ROUND(( ROUND(_AmountTotals.TotalTaxAmount, 2) + ROUND(_AmountTotals.TotalNetAmount, 2)), 2)                  as TotalGrossAmount,

       _TotalForeignCurrency.InvoiceAmountInFrgnCurrency                                                             as InvoiceAmountInFrgnCurrency,

       DeliveryDocument.GoodsIssueTime                                                                               as GoodsIssueTime,

       case
       when DeliveryDocument._SalesOrganization._CompanyCode.Currency <> _DelSupplier.TransactionCurrency
       then _DelSupplier.ExchangeRate
       else 0
       end                                                                                                           as ExchangeRate,

       case
       when DeliveryDocument._SalesOrganization._CompanyCode.Currency <> _DelSupplier.TransactionCurrency
       then _DelSupplier.TransactionCurrency
       else ''
       end                                                                                                           as TransactionCurrency,



       _SDDocumentProcessFlow

}

where
  PortugueseDigitalSignature <> ''
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ADDRESS_2",
"I_COMPANYCODE",
"I_DELIVERYDOCUMENT",
"I_PT_DELIVERYDGTLSGNTR",
"I_PT_DELIVERYNUMBERRANGE",
"I_PT_DELIVERYSHIPFROMADDRESS",
"I_PT_SAFTDELIVERYCUSTDETAIL",
"I_PT_SAFTDELIVERYHEADERAMT",
"I_PT_SAFTDELIVERYONETIMECUST",
"I_PT_SAFTHEADERGROSSTOTAL",
"I_PT_SDDOCUMENTPROCESSFLOW",
"I_SAFTDELIVERYSUPPLIER",
"I_SALESORGANIZATION"
],
"ASSOCIATED":
[
"I_PT_DELIVERYSHIPFROMADDRESS",
"I_PT_SAFTDELIVERYCUSTDETAIL",
"I_PT_SAFTDELIVERYHEADERAMT",
"I_PT_SAFTHEADERGROSSTOTAL",
"I_PT_SDDOCUMENTPROCESSFLOW",
"I_SAFTDELIVERYSUPPLIER"
],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/