Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view P_FIARCN_CUST_BALANCE07.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
-- SQL view name: PVFIARCNCUSTBAL7
-- Parameters: P_CompanyCode : bukrs, P_FiscalYear : gjahr, P_Language : sylangu, P_CurrencyRole : fac_crcyrole
CREATE VIEW P_FIARCN_CUST_BALANCE07 AS
SELECT
Period.CompanyCode AS CompanyCode,
Period.FiscalYear AS FiscalYear,
Period.FiscalPeriod AS FiscalPeriod,
GLAccount,
AlternativeGLAccount,
_Customer._CustomerToBusinessPartner._BusinessPartner.BusinessPartner AS BusinessPartner,
Bal.Customer AS Customer,
Supplier,
SpecialGLCode,
ProfitCenter,
Segment,
BusinessArea,
AccountingDocumentType,
DisplayCurrency,
TransactionCurrency,
AssignmentReference,
_Customer.CustomerName AS CustomerName,
_Customer.BPCustomerName AS BPCustomerName,
_Customer.OrganizationBPName1 AS OrganizationBPName1,
_Customer.OrganizationBPName2 AS OrganizationBPName2,
_Customer.CustomerAccountGroup AS CustomerAccountGroup,
_Customer.TaxNumber5 AS CustomerVATRegistration,
_Customer._AddressRepresentation.Country AS CustomerCountry,
_Customer._AddressRepresentation.CityName AS CustomerCityName,
_Customer._AddressRepresentation.Region AS CustomerRegion,
_Customer._CustomerToBusinessPartner._BusinessPartner.BusinessPartnerName AS BusinessPartnerName,
_CustomerSearch.CustomerSearchText AS CustomerSearchText,
_AccountText(P_Language: :P_Language).GLAccountName AS GLAccountName,
_AlternativeGLAccountText.GLAccountName AS AlternativeGLAccountName,
case when Bal.FiscalPeriod = '000' then AmountInDisplayCurrency else cast(0 as abap.curr( 23, 2 )) end as BalCarFwdAmtInDspCrcy AS curr232endasBalCarFwdAmtInDspCrcy,
case when Bal.FiscalPeriod < Period.FiscalPeriod then AmountInDisplayCurrency else cast(0 as abap.curr( 23, 2 )) end as StartingBalAmtInDspCrcy AS curr232endasStartingBalAmtInDspCrcy,
case when Bal.FiscalPeriod <= Period.FiscalPeriod then AmountInDisplayCurrency else cast(0 as abap.curr( 23, 2 )) end as EndingBalAmtInDspCrcy AS curr232endasEndingBalAmtInDspCrcy,
case when Bal.FiscalPeriod = Period.FiscalPeriod then DebitAmountInDspCrcy else cast(0 as abap.curr( 23, 2 )) end as DebitAmountInDspCrcy AS curr232endasDebitAmountInDspCrcy,
case when Bal.FiscalPeriod = Period.FiscalPeriod then CreditAmountInDspCrcy else cast(0 as abap.curr( 23, 2 )) end as CreditAmountInDspCrcy AS curr232endasCreditAmountInDspCrcy,
case when Bal.FiscalPeriod > '000' and Bal.FiscalPeriod <= Period.FiscalPeriod then DebitAmountInDspCrcy else cast(0 as abap.curr( 23, 2 )) end as YTDDebitAmtInDspCrcy AS curr232endasYTDDebitAmtInDspCrcy,
case when Bal.FiscalPeriod > '000' and Bal.FiscalPeriod <= Period.FiscalPeriod then CreditAmountInDspCrcy else cast(0 as abap.curr( 23, 2 )) end as YTDCrdtAmtInDspCrcy AS curr232endasYTDCrdtAmtInDspCrcy,
case when Bal.FiscalPeriod = '000' then AmountInTransactionCurrency else cast(0 as abap.curr( 23, 2 )) end as BalCarFwdAmtInTransacCrcy AS curr232endasBalCarFwdAmtInTransacCrcy,
case when Bal.FiscalPeriod = Period.FiscalPeriod then DebitAmountInTransCrcy else cast(0 as abap.curr( 23, 2 )) end as DebitAmountInTransCrcy AS curr232endasDebitAmountInTransCrcy,
case when Bal.FiscalPeriod = Period.FiscalPeriod then CreditAmountInTransCrcy else cast(0 as abap.curr( 23, 2 )) end as CreditAmountInTransCrcy AS curr232endasCreditAmountInTransCrcy,
case when Bal.FiscalPeriod <= Period.FiscalPeriod then AmountInTransactionCurrency else cast(0 as abap.curr( 23, 2 )) end as EndingBalanceAmtInTransCrcy AS curr232endasEndingBalanceAmtInTransCrcy,
case when Bal.FiscalPeriod > '000' and Bal.FiscalPeriod <= Period.FiscalPeriod then DebitAmountInTransCrcy else cast(0 as abap.curr( 23, 2 )) end as YTDDebitAmtInTransCrcy AS curr232endasYTDDebitAmtInTransCrcy,
case when Bal.FiscalPeriod > '000' and Bal.FiscalPeriod <= Period.FiscalPeriod then CreditAmountInTransCrcy else cast(0 as abap.curr( 23, 2 )) end as YTDCrdtAmtInTransCrcy AS curr232endasYTDCrdtAmtInTransCrcy
FROM P_FIARCN_CUST_BALANCE04
INNER JOIN P_FIARCN_TOTAL_PERIODS ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_Customer AS _Customer ON Customer = _Customer.Customer -- association [1..1]
LEFT OUTER JOIN I_CustomerCompany AS _CustomerCompany ON Customer = _CustomerCompany.Customer AND CompanyCode = _CustomerCompany.CompanyCode -- association [1..1]
LEFT OUTER JOIN C_CN_CustVH AS _CustomerSearch ON Customer = _CustomerSearch.Customer -- association [1..1]
LEFT OUTER JOIN P_FIARCN_ACCOUNTTEXT AS _AccountText ON CompanyCode = _AccountText.CompanyCode AND GLAccount = _AccountText.GLAccount -- association [1..1]
LEFT OUTER JOIN P_CN_AlternativeGLAccountText AS _AlternativeGLAccountText ON CompanyCode = _AlternativeGLAccountText.CompanyCode AND AlternativeGLAccount = _AlternativeGLAccountText.GLAccount AND _AlternativeGLAccountText.Language = $session.system_language -- association [1..1]
;