P_GrossMarginUnion_2
P_GrossMarginUnion_2 is a Composite CDS View in SAP S/4HANA. It reads from 4 data sources (I_GLAccountLineItemRawData, I_GLAccountLineItemRawData, I_SemTagFuncArea, I_SemTagGLAccount) and exposes 144 fields with key fields Ledger, SourceLedger, CompanyCode, FiscalYear, AccountingDocument. It has 5 associations to related views.
Data Sources (4)
| Source | Alias | Join Type |
|---|---|---|
| I_GLAccountLineItemRawData | _GL | from |
| I_GLAccountLineItemRawData | _GL | union_all |
| I_SemTagFuncArea | I_SemTagFuncArea | inner |
| I_SemTagGLAccount | I_SemTagGLAccount | inner |
Parameters (1)
| Name | Type | Default |
|---|---|---|
| P_Ledger | fins_ledger |
Associations (5)
| Cardinality | Target | Alias | Condition |
|---|---|---|---|
| [1..1] | I_FiscalCalendarDate | _DocumentFiscalCalendarDate | $projection.DocumentDate = _DocumentFiscalCalendarDate.CalendarDate and $projection.FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant |
| [0..1] | I_ProfitCenter | _CurrentProfitCenter | $projection.ControllingArea = _CurrentProfitCenter.ControllingArea and $projection.ProfitCenter = _CurrentProfitCenter.ProfitCenter and _CurrentProfitCenter.ValidityStartDate <= $session.system_date and _CurrentProfitCenter.ValidityEndDate >= $session.system_date |
| [0..1] | I_FiscalYearForCompanyCode | _LedgerFiscalYear | $projection.LedgerFiscalYear = _LedgerFiscalYear.FiscalYear and $projection.CompanyCode = _LedgerFiscalYear.CompanyCode |
| [0..1] | I_SalesOrder | _SalesOrder | $projection.SalesOrder = _SalesOrder.SalesOrder |
| [0..1] | I_SalesOrderItem | _SalesOrderItem | $projection.SalesOrder = _SalesOrderItem.SalesOrder and $projection.SalesOrderItem = _SalesOrderItem.SalesOrderItem |
Annotations (7)
| Name | Value | Level | Field |
|---|---|---|---|
| AbapCatalog.sqlViewName | PGRSSMARGUNION2 | view | |
| VDM.viewType | #COMPOSITE | view | |
| AccessControl.authorizationCheck | #NOT_REQUIRED | view | |
| ClientHandling.algorithm | #SESSION_VARIABLE | view | |
| VDM.private | true | view | |
| AbapCatalog.preserveKey | true | view | |
| AbapCatalog.compiler.compareFilter | true | view |
Fields (144)
| Key | Field | Source Table | Source Field | Description |
|---|---|---|---|---|
| KEY | Ledger | |||
| KEY | SourceLedger | SourceLedger | Source Ledger | |
| KEY | CompanyCode | CompanyCode | Receiver Company Code | |
| KEY | FiscalYear | FiscalYear | G/L Fiscal Year | |
| KEY | AccountingDocument | AccountingDocument | Journal Entry | |
| KEY | LedgerGLLineItem | LedgerGLLineItem | Journal Entry Item | |
| KEY | GLAccountHierarchy | GLAccountHierarchy | ||
| KEY | SemanticTag | SemanticTag | Semantic Tag | |
| KEY | ValidityStartDate | ValidityStartDate | Validity Start Date | |
| KEY | ValidityEndDate | ValidityEndDate | ValidTo | |
| KEY | FinancialPlanningReqTransSqnc | |||
| KEY | FinancialPlanningDataPacket | |||
| KEY | FinancialPlanningEntryItem | |||
| DocumentDate | DocumentDate | Journal Entry Date | ||
| SalesOrganization | SalesOrganization | Sales Organization | ||
| CustomerGroup | CustomerGroup | Customer Group | ||
| Customer | Customer | Sold-to Party | ||
| FiscalQuarter | _FiscalCalendarDate | FiscalQuarter | ||
| FiscalPeriod | FiscalPeriod | Tax period | ||
| CompanyCodeCurrency | CompanyCodeCurrency | Local Currency | ||
| GlobalCurrency | GlobalCurrency | GM Billing Element: Global Currency | ||
| MaterialGroup | Product Sold Group | |||
| ProfitCenter | ProfitCenter | Profit Center | ||
| ControllingArea | ControllingArea | Controlling Area | ||
| SalesDistrict | SalesDistrict | Sales District | ||
| Segment | Segment | Segment number | ||
| DistributionChannel | DistributionChannel | RefDistCh-Cust/Mat. | ||
| SoldMaterial | SoldProduct | Product Sold | ||
| BusinessTransactionType | BusinessTransactionType | Bus.transaction | ||
| BusinessArea | BusinessArea | Business Area | ||
| CostCenter | CostCenter | Cost Center | ||
| CustomerSupplierCountry | CustomerSupplierCountry | Customer or Supplier Country/Region | ||
| FiscalYearPeriod | FiscalYearPeriod | Period/Year | ||
| AmountInCompanyCodeCurrency | AmountInCompanyCodeCurrency | Local Crcy Amt | ||
| AmountInGlobalCurrency | AmountInGlobalCurrency | Amount in Global Currency | ||
| AccountingDocumentCategory | AccountingDocumentCategory | Journal Entry Category | ||
| GLAccount | I_GLAccountLineItemRawData | GLAccount | General Ledger | |
| PostingDate | PostingDate | Posting Date for GR | ||
| CreationDate | CreationDate | Time Stamp | ||
| ChartOfAccounts | I_GLAccountLineItemRawData | ChartOfAccounts | Node Class | |
| LedgerFiscalYear | LedgerFiscalYear | Ref. Year1 | ||
| FinancialTransactionType | FinancialTransactionType | Transact. Type | ||
| TransactionCurrency | TransactionCurrency | Transaction Currency | ||
| AmountInTransactionCurrency | AmountInTransactionCurrency | Pt Crcy Amt | ||
| DebitCreditCode | DebitCreditCode | Single-Character Flag | ||
| AssignmentReference | AssignmentReference | Assignment Reference | ||
| PostingKey | PostingKey | Posting Key | ||
| AccountingDocCreatedByUser | AccountingDocCreatedByUser | User which created overhead document | ||
| GLAccountType | GLAccountType | G/L Account Type | ||
| Plant | Plant | Valuation Area | ||
| FinancialAccountType | FinancialAccountType | Fin. Account Type | ||
| SpecialGLCode | SpecialGLCode | Special G/L Ind | ||
| ClearingDate | ClearingDate | Clearing Date | ||
| ClearingAccountingDocument | ClearingAccountingDocument | Clearing Journal Entry | ||
| BillingDocumentType | BillingDocumentType | Billing Type | ||
| OrganizationDivision | OrganizationDivision | Org. Division | ||
| CustomerSupplierIndustry | CustomerSupplierIndustry | Industry | ||
| BillToParty | BillToParty | Inv. Recipient | ||
| ShipToParty | ShipToParty | Ship-To Party (obsolete) | ||
| SourceReferenceDocumentType | Ref. procedure | |||
| SourceReferenceDocument | Reference Doc. | |||
| OperatingConcern | Operating concern | |||
| TransactionTypeDetermination | TransactionTypeDetermination | Transaction Key | ||
| ControllingDebitCreditCode | Dr/Cr ind. CO | |||
| AccountingDocumentType | AccountingDocumentType | Journal Entry Type | ||
| ReferenceDocumentType | ReferenceDocumentType | Reference Document Type | ||
| FiscalYearVariant | FiscalYearVariant | FY Variant | ||
| JrnlEntryItemObsoleteReason | Obsolete Reason | |||
| CostAmountInCompanyCodeCrcy | ||||
| CostOfGoodsSoldAmtInGlobCrcy | ||||
| SalesDeductionAmountInGlobCrcy | ||||
| SalesDeductionAmtInCoCodeCrcy | ||||
| PlnRecognizedRevnAmtInCCCrcy | ||||
| PlnRecgdRevenueAmtInGlobCrcy | ||||
| PlnCostAmtInCompanyCodeCrcy | ||||
| PlnCostOfGdsSoldAmtInGlobCrcy | ||||
| PlnRecognizedMargAmtInCCCrcy | ||||
| PlnRecognizedMargAmtInGlobCrcy | ||||
| PlnSlsDeductionAmtInGlobCrcy | ||||
| PlnSlsDeductionAmtInCCCrcy | ||||
| PlnBilledRevenueAmtInGlobCrcy | ||||
| PlnBilledRevenueAmtInCCCrcy | ||||
| PlanningCategory | ||||
| PlanAmountInCompanyCodeCrcy | ||||
| PlanAmountInGlobalCurrency | ||||
| PlanAmountInTransactionCrcy | ||||
| FreeDefinedCurrency1 | FreeDefinedCurrency1 | Freely Defined Currency 1 | ||
| AmountInFreeDefinedCurrency1 | AmountInFreeDefinedCurrency1 | Amount in Freely Defined Currency 1 | ||
| PlanAmountInFreeDefinedCrcy1 | ||||
| FreeDefinedCurrency2 | FreeDefinedCurrency2 | Freely Defined Currency 2 | ||
| AmountInFreeDefinedCurrency2 | AmountInFreeDefinedCurrency2 | Amount in Freely Defined Currency 2 | ||
| PlanAmountInFreeDefinedCrcy2 | ||||
| FreeDefinedCurrency3 | FreeDefinedCurrency3 | Freely Defined Currency 3 | ||
| AmountInFreeDefinedCurrency3 | AmountInFreeDefinedCurrency3 | Amount in Freely Defined Currency 3 | ||
| PlanAmountInFreeDefinedCrcy3 | ||||
| FreeDefinedCurrency4 | FreeDefinedCurrency4 | Freely Defined Currency 4 | ||
| AmountInFreeDefinedCurrency4 | AmountInFreeDefinedCurrency4 | Amount in Freely Defined Currency 4 | ||
| PlanAmountInFreeDefinedCrcy4 | ||||
| FreeDefinedCurrency5 | FreeDefinedCurrency5 | Freely Defined Currency 5 | ||
| AmountInFreeDefinedCurrency5 | AmountInFreeDefinedCurrency5 | Amount in Freely Defined Currency 5 | ||
| PlanAmountInFreeDefinedCrcy5 | ||||
| FreeDefinedCurrency6 | FreeDefinedCurrency6 | Freely Defined Currency 6 | ||
| AmountInFreeDefinedCurrency6 | AmountInFreeDefinedCurrency6 | Amount in Freely Defined Currency 6 | ||
| PlanAmountInFreeDefinedCrcy6 | ||||
| FreeDefinedCurrency7 | FreeDefinedCurrency7 | Freely Defined Currency 7 | ||
| AmountInFreeDefinedCurrency7 | AmountInFreeDefinedCurrency7 | Amount in Freely Defined Currency 7 | ||
| PlanAmountInFreeDefinedCrcy7 | ||||
| FreeDefinedCurrency8 | FreeDefinedCurrency8 | Freely Defined Currency 8 | ||
| AmountInFreeDefinedCurrency8 | AmountInFreeDefinedCurrency8 | Amount in Freely Defined Currency 8 | ||
| PlanAmountInFreeDefinedCrcy8 | ||||
| BaseUnit | BaseUnit | Unit of Measure | ||
| Quantity | Quantity | Value | ||
| IsSimulation | ||||
| AuthorizationGroup | _Customer | AuthorizationGroup | AuthorizGroup | |
| _FiscalYear | _FiscalYear | |||
| _CompanyCodeCurrency | _CompanyCodeCurrency | |||
| _GlobalCurrency | _GlobalCurrency | |||
| _SalesOrganization | _SalesOrganization | |||
| _Customer | _Customer | |||
| _SalesDistrict | _SalesDistrict | |||
| _Segment | _Segment | |||
| _SalesOrder | _SalesOrder | |||
| _SalesOrderItem | _SalesOrderItem | |||
| _DistributionChannel | _DistributionChannel | |||
| _BusinessArea | _BusinessArea | |||
| _CostCenter | _CostCenter | |||
| _ControllingArea | _ControllingArea | |||
| _CustomerSupplierCountry | _CustomerSupplierCountry | |||
| _CompanyCode | _CompanyCode | |||
| _CustomerGroup | _CustomerGroup | |||
| _SemanticTag | _SemanticTag | |||
| _GLAccountInChartOfAccounts | _GLAccountInChartOfAccounts | |||
| _ChartOfAccounts | _ChartOfAccounts | |||
| _LedgerFiscalYear | _LedgerFiscalYear | |||
| _TransactionCurrency | _TransactionCurrency | |||
| _Plant | _Plant | |||
| _BillingDocumentType | _BillingDocumentType | |||
| _BillToParty | _BillToParty | |||
| _ShipToParty | _ShipToParty | |||
| _ControllingDebitCreditCode | _ControllingDebitCreditCode | |||
| _FiscalYearVariant | _FiscalYearVariant | |||
| _FiscalPeriodForVariant | _FiscalPeriodForVariant | |||
| _GLAccountInCompanyCode | _GLAccountInCompanyCode | |||
| _CurrentProfitCenter | _CurrentProfitCenter |
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_GrossMarginUnion_2.
-- 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: PGRSSMARGUNION2
-- Parameters: P_Ledger : fins_ledger
CREATE VIEW P_GrossMarginUnion_2 AS
SELECT
$parameters.P_Ledger AS Ledger,
SourceLedger,
CompanyCode,
FiscalYear,
AccountingDocument,
LedgerGLLineItem,
GLAccountHierarchy,
SemanticTag,
ValidityStartDate,
ValidityEndDate,
cast(cast('00000000000000000000000' as abap.numc(23))as rspm_request_tsn) AS FinancialPlanningReqTransSqnc,
cast(cast('000000' as abap.numc(6)) as rsdatapid) AS FinancialPlanningDataPacket,
cast(0 as rsarecord) AS FinancialPlanningEntryItem,
DocumentDate,
SalesOrganization,
CustomerGroup,
Customer,
_FiscalCalendarDate.FiscalQuarter AS FiscalQuarter,
FiscalPeriod,
CompanyCodeCurrency,
GlobalCurrency,
cast(SoldProductGroup as fins_matkl_pa) AS MaterialGroup,
ProfitCenter,
ControllingArea,
SalesDistrict,
Segment,
DistributionChannel,
SoldProduct AS SoldMaterial,
BusinessTransactionType,
BusinessArea,
CostCenter,
CustomerSupplierCountry,
FiscalYearPeriod,
AmountInCompanyCodeCurrency,
AmountInGlobalCurrency,
AccountingDocumentCategory,
_GL.GLAccount AS GLAccount,
PostingDate,
CreationDate,
_GL.ChartOfAccounts AS ChartOfAccounts,
LedgerFiscalYear,
FinancialTransactionType,
TransactionCurrency,
AmountInTransactionCurrency,
DebitCreditCode,
AssignmentReference,
PostingKey,
AccountingDocCreatedByUser,
GLAccountType,
Plant,
FinancialAccountType,
SpecialGLCode,
ClearingDate,
ClearingAccountingDocument,
BillingDocumentType,
OrganizationDivision,
CustomerSupplierIndustry,
BillToParty,
ShipToParty,
cast(SourceReferenceDocumentType as fins_src_awtyp) AS SourceReferenceDocumentType,
cast(SourceReferenceDocument as fins_src_ref_doc) AS SourceReferenceDocument,
cast(OperatingConcern as fins_erkrs preserving type) AS OperatingConcern,
TransactionTypeDetermination,
cast(ControllingDebitCreditCode as fins_debit_credit_indicator_co preserving type) AS ControllingDebitCreditCode,
AccountingDocumentType,
ReferenceDocumentType,
FiscalYearVariant,
cast(JrnlEntryItemObsoleteReason as fins_obs_reason) AS JrnlEntryItemObsoleteReason,
case when SemanticTag = 'RECO_COS' then AmountInCompanyCodeCurrency end AS CostAmountInCompanyCodeCrcy,
case when SemanticTag = 'RECO_COS' then AmountInGlobalCurrency end AS CostOfGoodsSoldAmtInGlobCrcy,
case when SemanticTag = 'SALES_DED' then AmountInGlobalCurrency end AS SalesDeductionAmountInGlobCrcy,
case when SemanticTag = 'SALES_DED' then AmountInCompanyCodeCurrency end AS SalesDeductionAmtInCoCodeCrcy,
cast(0 as fis_reco_rev_hsl_p) AS PlnRecognizedRevnAmtInCCCrcy,
cast(0 as fis_reco_rev_ksl_p) AS PlnRecgdRevenueAmtInGlobCrcy,
cast(0 as fis_cost_hsl_p) AS PlnCostAmtInCompanyCodeCrcy,
cast(0 as fis_cogs_ksl_p) AS PlnCostOfGdsSoldAmtInGlobCrcy,
cast(0 as fis_rec_margin_hsl_p) AS PlnRecognizedMargAmtInCCCrcy,
cast(0 as fis_rec_margin_hsl_p) AS PlnRecognizedMargAmtInGlobCrcy,
cast(0 as fis_sales_ded_ksl_p) AS PlnSlsDeductionAmtInGlobCrcy,
cast(0 as fis_res_masd_hsl_p) AS PlnSlsDeductionAmtInCCCrcy,
cast(0 as fis_bill_rev_ksl_p) AS PlnBilledRevenueAmtInGlobCrcy,
cast(0 as fis_bill_rev_hsl_p) AS PlnBilledRevenueAmtInCCCrcy,
cast(cast( 'ACT01' as abap.char( 5 )) as fcom_category) AS PlanningCategory,
cast(0 as fis_hsl) AS PlanAmountInCompanyCodeCrcy,
cast(0 as fis_ksl) AS PlanAmountInGlobalCurrency,
cast(0 as fis_wsl) AS PlanAmountInTransactionCrcy,
FreeDefinedCurrency1,
AmountInFreeDefinedCurrency1,
cast(0 as fis_plan_osl) AS PlanAmountInFreeDefinedCrcy1,
FreeDefinedCurrency2,
AmountInFreeDefinedCurrency2,
cast(0 as fis_plan_vsl) AS PlanAmountInFreeDefinedCrcy2,
FreeDefinedCurrency3,
AmountInFreeDefinedCurrency3,
cast(0 as fis_plan_bsl) AS PlanAmountInFreeDefinedCrcy3,
FreeDefinedCurrency4,
AmountInFreeDefinedCurrency4,
cast(0 as fis_plan_csl) AS PlanAmountInFreeDefinedCrcy4,
FreeDefinedCurrency5,
AmountInFreeDefinedCurrency5,
cast(0 as fis_plan_dsl) AS PlanAmountInFreeDefinedCrcy5,
FreeDefinedCurrency6,
AmountInFreeDefinedCurrency6,
cast(0 as fis_plan_esl) AS PlanAmountInFreeDefinedCrcy6,
FreeDefinedCurrency7,
AmountInFreeDefinedCurrency7,
cast(0 as fis_plan_fsl) AS PlanAmountInFreeDefinedCrcy7,
FreeDefinedCurrency8,
AmountInFreeDefinedCurrency8,
cast(0 as fis_plan_gsl) AS PlanAmountInFreeDefinedCrcy8,
BaseUnit,
Quantity,
'' AS IsSimulation,
_Customer.AuthorizationGroup AS AuthorizationGroup
FROM I_GLAccountLineItemRawData AS _GL
INNER JOIN I_SemTagGLAccount ON /* join condition not captured in parsed metadata */
INNER JOIN I_SemTagFuncArea ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN I_FiscalCalendarDate AS _DocumentFiscalCalendarDate ON DocumentDate = _DocumentFiscalCalendarDate.CalendarDate AND FiscalYearVariant = _DocumentFiscalCalendarDate.FiscalYearVariant -- association [1..1]
LEFT OUTER JOIN I_ProfitCenter AS _CurrentProfitCenter ON ControllingArea = _CurrentProfitCenter.ControllingArea AND ProfitCenter = _CurrentProfitCenter.ProfitCenter AND _CurrentProfitCenter.ValidityStartDate <= $session.system_date AND _CurrentProfitCenter.ValidityEndDate >= $session.system_date -- association [0..1]
LEFT OUTER JOIN I_FiscalYearForCompanyCode AS _LedgerFiscalYear ON LedgerFiscalYear = _LedgerFiscalYear.FiscalYear AND CompanyCode = _LedgerFiscalYear.CompanyCode -- association [0..1]
LEFT OUTER JOIN I_SalesOrder AS _SalesOrder ON SalesOrder = _SalesOrder.SalesOrder -- association [0..1]
LEFT OUTER JOIN I_SalesOrderItem AS _SalesOrderItem ON SalesOrder = _SalesOrderItem.SalesOrder AND SalesOrderItem = _SalesOrderItem.SalesOrderItem -- association [0..1]
-- UNION ALL with additional select branch(es): I_GLAccountLineItemRawData
;
Learn More
- VDM (Virtual Data Model) in SAP S/4HANA Explained
- Types of CDS Views: Basic, Composite, Consumption, and Transactional
- CDS View Annotations — A Complete Guide
- What Is a CDS View in SAP S/4HANA?
- SAP Tables vs CDS Views — Key Differences
- Understanding Data Lineage in SAP S/4HANA
- CDS View Field Mapping and Associations
- Understanding the SAP S/4HANA Data Model
- CDS View Extensions and Custom Fields in SAP S/4HANA
- Released APIs and Stability Contracts in SAP S/4HANA
- BSEG to ACDOCA: The Universal Journal Migration
- Business Partner Migration: KNA1/LFA1 to BUT000
- Material Document Migration: MSEG/MKPF to MATDOC
- How to Find the Right CDS View for an SAP Table
- BW Extractor to CDS View Migration Guide
- S/4HANA CDS View Deprecation: What You Need to Know
- ABAP CDS View Tutorial — From Basics to Real-World Examples
- RAP and CDS Views — Building Transactional Apps in SAP S/4HANA
- Sales Document Status Migration: VBUP/VBUK Removal in S/4HANA
- CO Tables in S/4HANA: COEP, COBK, COSS, COSP to ACDOCA