@AbapCatalog.sqlViewName: 'ISAFTGENLEDCUST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType: #COMPOSITE
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.personalData.blocking: #BLOCKED_DATA_INCLUDED
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass: #MIXED
@EndUserText.label: 'SAF-T Gen Ledger Customer'
define view I_SAFTGenLedgerCustomer
as select from I_JournalEntryItem as a
inner join P_SAFTGLMaxCustomer as GLMaxCustomer on GLMaxCustomer.SourceLedger = a.SourceLedger
and GLMaxCustomer.CompanyCode = a.CompanyCode
and GLMaxCustomer.FiscalYear = a.FiscalYear
and GLMaxCustomer.AccountingDocument = a.AccountingDocument
and GLMaxCustomer.LedgerGLLineItem = a.LedgerGLLineItem
and GLMaxCustomer.Ledger = a.Ledger
association [0..*] to I_SAFTCustTaxRegnNmbr as _CustLand
on a.Customer = _CustLand.CustomerNum
association [0..1] to P_SAFT_CONTACTPERSON as _ContactPerson
on a.Customer = _ContactPerson.Customer
{
@ObjectModel.foreignKey.association: '_SourceLedger'
key a.SourceLedger as SourceLedger,
@ObjectModel.foreignKey.association: '_CompanyCode'
key a.CompanyCode as CompanyCode,
@ObjectModel.foreignKey.association: '_FiscalYear'
key a.FiscalYear as FiscalYear,
@ObjectModel.foreignKey.association: '_JournalEntry'
key a.AccountingDocument as AccountingDocument,
key a.LedgerGLLineItem as LedgerGLLineItem,
@ObjectModel.foreignKey.association: '_Ledger'
key a.Ledger as Ledger,
@ObjectModel.foreignKey.association: '_ChartOfAccounts'
a.ChartOfAccounts,
@ObjectModel.foreignKey.association: '_GLAccountInChartOfAccounts'
a.GLAccount,
@ObjectModel.foreignKey.association: '_AccountingDocumentCategory'
a.AccountingDocumentCategory,
a.PostingDate,
@ObjectModel.foreignKey.association: '_Customer'
a.Customer,
case when a._JournalEntry._OperationalAcctgDocItem[ 1:FinancialAccountType = 'D' ].VATRegistration is not null
then
case
when a._JournalEntry._OperationalAcctgDocItem[ 1:FinancialAccountType = 'D' ].VATRegistration is not initial
then a._JournalEntry._OperationalAcctgDocItem[ 1:FinancialAccountType = 'D' ].VATRegistration
else a._Customer.VATRegistration
end
else a._Customer.VATRegistration
end as VATRegistration,
a._Customer.TaxNumber1,
a._Customer.TaxNumber2,
a._Customer.OrganizationBPName1,
a._Customer.OrganizationBPName2,
a._Customer.CityName,
a._Customer.PostalCode,
a._Customer.Country,
//a._Customer.StreetName,
a._Customer.IsOneTimeAccount,
a._Customer.AddressID,
a._Customer.Customer as CustomerNum,
a._Customer.AuthorizationGroup,
a._Customer._StandardAddress,
a._Customer._StandardAddress.StreetName as StreetName,
a._Customer._StandardAddress.StreetPrefixName as StreetPrefixName,
a._Customer._StandardAddress.AdditionalStreetPrefixName as AdditionalStreetPrefixName,
a._Customer._StandardAddress.StreetSuffixName as StreetSuffixName,
a._Customer._StandardAddress.AdditionalStreetSuffixName as AdditionalStreetSuffixName,
a._Customer._StandardAddress.HouseNumber as HouseNumber,
a._Customer.Region,
a._Customer._CustomerCompany[ 1:CompanyCode = a.CompanyCode ].ReconciliationAccount as ReconciliationAccount,
_ContactPerson.FirstName as PartnerFirstName,
_ContactPerson.LastName as PartnerLastName,
substring ( a._JournalEntry._OperationalAcctgDocItem[ 1:FinancialAccountType = 'D' ].VATRegistration, 1, 2 ) as DelivOfGoodsDestCountry,
_CustLand,
a._SourceLedger,
a._Customer._CustomerCompany,
a._CompanyCode,
a._FiscalYear,
a._JournalEntry,
a._Ledger,
_Customer,
_ChartOfAccounts,
_GLAccountInChartOfAccounts,
_AccountingDocumentCategory
} where a.FinancialAccountType = 'D'
and a._Customer.IsOneTimeAccount = ' '
/*
group by
a.SourceLedger,
a.CompanyCode,
a.FiscalYear,
a.AccountingDocument,
a.LedgerGLLineItem,
a.Ledger,
a.ChartOfAccounts,
a.GLAccount,
a.AccountingDocumentCategory,
a.PostingDate,
a.Customer,
a._Customer.VATRegistration,
a._Customer.TaxNumber1,
a._Customer.TaxNumber2,
a._Customer.OrganizationBPName1,
a._Customer.OrganizationBPName2,
a._Customer.CityName,
a._Customer.PostalCode,
a._Customer.Country,
a._Customer.StreetName,
a._Customer.IsOneTimeAccount,
a._Customer.AddressID,
a._Customer.Customer,
a._Customer.AuthorizationGroup,
a._Customer.Region,
a._Customer._CustomerCompany.ReconciliationAccount,
a._Customer._StandardAddress.StreetName,
a._Customer._StandardAddress.StreetPrefixName,
a._Customer._StandardAddress.AdditionalStreetPrefixName,
a._Customer._StandardAddress.StreetSuffixName,
a._Customer._StandardAddress.AdditionalStreetSuffixName,
a._Customer._StandardAddress.HouseNumber
*/
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ADDRESS",
"I_CUSTOMER",
"I_CUSTOMERCOMPANY",
"I_JOURNALENTRY",
"I_JOURNALENTRYITEM",
"I_OPERATIONALACCTGDOCITEM",
"P_SAFTGLMAXCUSTOMER",
"P_SAFT_CONTACTPERSON"
],
"ASSOCIATED":
[
"I_ACCOUNTINGDOCUMENTCATEGORY",
"I_ADDRESS",
"I_CHARTOFACCOUNTS",
"I_COMPANYCODE",
"I_CUSTOMER",
"I_CUSTOMERCOMPANY",
"I_FISCALYEARFORCOMPANYCODE",
"I_GLACCOUNTINCHARTOFACCOUNTS",
"I_JOURNALENTRY",
"I_LEDGER",
"I_SAFTCUSTTAXREGNNMBR",
"P_SAFT_CONTACTPERSON"
],
"BASE":
[
"I_CUSTOMER",
"I_JOURNALENTRYITEM"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/