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 I_TravelExpenseGeneralData.
-- 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.
CREATE VIEW I_TravelExpenseGeneralData AS
SELECT
ptrv_head.pernr AS PersonnelNumber,
ptrv_head.reinr AS TravelTripNumber,
ptrv_head.hdvrs AS TravelExpnSequentialNumber,
perio.perio AS PeriodNumberOfTrip,
perio.pdvrs AS PeriodSequentialNumber,
estcost.TravelVersionNumber AS TravelVersionNumber,
estcost.TrvlReqArePlanReq AS TrvlReqArePlanReq,
ptrv_head.molga AS CountryGroup,
cast( ptrv_head.morei as vdm_tripprovisionvariant preserving type ) AS TripProvisionVariant,
ptrv_head.schem AS TripSchema,
cast( ptrv_head.kzrea as vdm_trvs4_statutory_trip_type preserving type ) AS TripTypeStatutory,
cast( ptrv_head.berei as vdm_trvs4_ttenterprise preserving type ) AS TripTypeEnterprise,
ptrv_head.kztkt AS TripActivityType,
cast(ptrv_head.zort1 as vdm_destination preserving type) AS TripDestination,
cast( ptrv_head.zland as vdm_ctry_reg preserving type) AS Country,
cast( ptrv_head.hrgio as vdm_maindestregion preserving type ) AS MainDestinationRegion,
cast( ptrv_head.ndnst as vdm_newadminofficename preserving type ) AS NewAdminOfficeName,
cast( ptrv_head.kunde as vdm_reason preserving type ) AS TripReasonText,
cast( ptrv_head.datv1 as vdm_datv1 preserving type ) AS TripDepartureDate,
ptrv_head.uhrv1 AS DepartureBeginTime,
cast( ptrv_head.datb1 as vdm_datb1 preserving type ) AS TripArrivalDate,
ptrv_head.uhrb1 AS ArrivalEndTime,
cast( ptrv_head.dath1 as vdm_bordertripdeptdate preserving type ) AS DomesticDeptDate,
ptrv_head.uhrh1 AS TravelExpenseOutBoundTime,
cast( ptrv_head.datr1 as vdm_bordertripreturndate preserving type ) AS DomesticArrvlDate,
cast( ptrv_head.uhrr1 as vdm_borderrettime preserving type ) AS TripRetTime,
cast( ptrv_head.agrz1 as vdm_tripctrygrpregion preserving type ) AS CountryGroupName,
cast( ptrv_head.grgio as vdm_rgnofrettripbrdrcrossing preserving type ) AS TripCtryReg,
cast( ptrv_head.grber as vdm_triptypeenterprisename preserving type ) AS TripTypeEnterpriseName,
cast( ptrv_head.uzkvg as vdm_movingcostsrefundconf preserving type ) AS MovingCostsRefundValue,
ptrv_head.zusag AS AdminOfficeMoveLabel,
cast( ptrv_head.endrg as vdm_diffntendoftrvlallwncdte preserving type ) AS DiffntEndOfTrvlAllwncDte,
cast(ptrv_head.depar as vdm_deptrfrmresidenceorwplc preserving type ) AS DepartureWork,
cast( ptrv_head.arrvl as vdm_ptrv_arrvl preserving type ) AS ArrivalWork,
ptrv_head.retrn AS ReturnWorkplaceValue,
ptrv_head.dates AS LastChangeDate,
ptrv_head.times AS LastChangedAtTime,
ptrv_head.uname AS ChangedByName,
ptrv_head.repid AS ChangeReportName,
ptrv_head.dantn AS TrvlExpnNmbrForCorrespgWrk,
cast( ptrv_head.fintn as vdm_tripnmbrofassocdbusret preserving type ) AS AssocdBusTripNrOfRet,
cast( ptrv_head.request as vdm_request preserving type ) AS TravelRequestIsExists,
cast( ptrv_head.travel_plan as vdm_plan preserving type ) AS TravelPlanIsExists,
cast( ptrv_head.expenses as vdm_expense preserving type ) AS TripHasExpenses,
cast( ptrv_head.st_trgtg as vdm_strtoftxnperdiemnallwncdte preserving type ) AS PerDiemSprtnAllwncTxnDte,
cast( ptrv_head.st_trgall as vdm_taxseparationallwnc preserving type ) AS SeparationAllwncTxnStartDate,
ptrv_head.periodenart AS PeriodType,
cast( ptrv_head.dat_reduc1 as vdm_dtereduc1 preserving type ) AS TrvlExpnAllwncLvl1Dte,
cast( ptrv_head.dat_reduc2 as vdm_dtereduc2 preserving type ) AS TrvlExpnAllwncLvl2Dte,
cast( ptrv_head.datv1_dienst as vdm_workstartdate preserving type ) AS WorkStartDate,
ptrv_head.uhrv1_dienst AS WorkCommencesTime,
cast( ptrv_head.datb1_dienst as vdm_workenddate preserving type ) AS WorkEndDate,
ptrv_head.uhrb1_dienst AS WorkEndsTime,
cast( ptrv_head.abordnung as vdm_assocdsprtnallwnc preserving type ) AS AssocdSuperiorSprtnAllwnc,
ptrv_head.st_trg_typ AS TrvlExpnHasTmpSprtnAllwnc,
cast( ptrv_head.st_wohn_typ as vdm_homesepallwnctxn preserving type ) AS HomeHasSeparationAllwncTxn,
ptrv_head.kein_reisegeld AS TrvlExpnHasPaidPerDiem,
cast( ptrv_head.tax_per_diem as vdm_mealsperdiemhastxn preserving type ) AS MealsPerDiemHasTxn,
cast( ptrv_head.tax_pd_man as vdm_mealsperdiemhasmnltxn preserving type ) AS MealsPerDiemHasMnlTxn,
cast( ptrv_head.tax_ov_man as vdm_acmdtnperdiemhasmnltxn preserving type ) AS AcmdtnPerDiemHasMnlTxn,
ptrv_head.exchange_date AS ReferenceDate,
ptrv_head.rounding AS TravelExpenseAmountIsRounded,
ptrv_head.dz_limit_180 AS DailyAllwncIsLmtdTo180,
ptrv_head.calid AS TrvlExpnFactoryCalendarID,
cast( ptrv_head.duration_trip_breaks as vdm_durnofprivatetripbreak preserving type ) AS TrvlExpnHasPrvtTripBrk,
ptrv_head.addr_depar AS AddressDepartureName,
ptrv_head.addr_arrvl AS AddressArrivalName,
cast( ptrv_head.curr_duty_land as vdm_currentdutycountry preserving type ) AS CurrentDutyCountry,
ptrv_head.curr_duty_region AS CurrentDutyRegion,
cast( ptrv_head.relocation_for_abord as vdm_sprtnallwncreloc preserving type ) AS SprtnAllwncRelocNmbr,
perio.pdatv AS DeparturePeriodDate,
cast( perio.puhrv as vdm_begintime preserving type ) AS TripBeginsAtTime,
perio.pdatb AS ArrivalPeriodDate,
cast( perio.puhrb as vdm_endtime preserving type ) AS TripEndsAtTime,
perio.druck AS TripPrintStatusValue,
perio.antrg AS TrvlExpnApprovalStatus,
cast( perio.abrec as vdm_settlementstatus preserving type ) AS SettlmtStatus,
cast( perio.ueblg as vdm_hrpayrolltransfer preserving type ) AS HumRscePayrollTransfer,
perio.uebrf AS TrvlExpnHasFinanceTransf,
cast( perio.uebdt as vdm_datamediumexchtransferind preserving type ) AS DataMdmExchIsTransf,
perio.tlock AS TripIsLocked,
perio.waers AS PaymentCurrency,
perio.abrj1 AS PayrollYear,
perio.abrp1 AS PayrollPeriod,
perio.perm1 AS PeriodModifier,
perio.abkr1 AS PayrollArea,
perio.begp1 AS SettlementPeriodBeginDate,
perio.endp1 AS SettlmtPeriodEndDate,
perio.begp2 AS SettlementPeriod2BeginDate,
perio.endp2 AS SettlementPeriod2EndDate,
perio.accdt AS TripSettlementDate,
perio.acctm AS TripSettlementTime,
cast( perio.runid as vdm_postingrunref preserving type ) AS PostingSequenceNumber,
cast(perio.verpa as vdm_de_stagg preserving type ) AS MealsPerDiem,
cast(perio.uebkz as vdm_de_stagg1 preserving type ) AS AccommodationHasPerDiem,
perio.anuep AS NrOfOvernightPerDiemNights,
perio.no_miles AS TrvlExpnHasMilesPerAcctg,
cast( perio.lstay as vdm_mealsperdiemreduction preserving type) AS TrvlExpnHasMealsPerDiemReducn,
perio.anuep AS MaxNrOfPerDiemNights,
cast( perio.tr_dopp_anzahl as vdm_dailyretaoutbnmbr preserving type ) AS TrvlExpnNrOfDaysOutbAndRet,
cast( perio.tr_einf_anzahl as vdm_dailyretooutbnmbr preserving type ) AS TrvlExpnNrOfDaysOutbOrRet,
perio.tr_entfernung AS DistanceToWorkPlaceValue,
perio.vu_ea_dopp_anz AS DaysOfOutbAndRetBfrMoveVal,
perio.vu_ea_einf_anz AS DaysOfOutbRetTripBfrMoveVal,
perio.nu_ea_dopp_anz AS DaysOfOutbAndRetAftMoveVal,
perio.nu_ea_einf_anz AS DaysOfOutbRetTripAftMoveVal,
perio.v_unentgeltlich AS MealsIsGratuitousForMonth,
cast( perio.u_unentgeltlich as vdm_gratuitousacmdtn preserving type ) AS AcmdtnIsGratuitousForMnth,
cast( perio.reduc_ergru as vdm_reimbmtgrpforreducnmeals preserving type ) AS TrvlExpenseReimbursementGroup,
perio.not_paid AS TrvlExpnHasReimbursement,
perio.weg_erh_max AS MaxTripSgmtReimbmtIsIncrd,
cast( perio.erh_dienst_int as vdm_significantofclintrst preserving type ) AS SignificantOfclHasIntrst,
perio.entf_wo_do AS ShortDistanceToWplcValue,
cast( perio.antrag_gwe as vdm_fulltripsgmtreimbmtisreqd preserving type ) AS FullTripReimbmtIsRequested,
perio.policy_violation AS PolicyHasViolation,
perio.exception_flag AS TravelExpenseHasException,
perio.nr_receipts AS TrvlExpnNumberOfRcpts,
perio.perm_trip_appr AS BusTripIsApproved,
perio.tr_nr_from_home AS TrvlExpnHomeRndTripNmbr,
perio.vat_status AS VatHasRefundStatus,
cast( perio.est_cost_plan as vdm_estdcost_plan preserving type ) AS TrvlExpnEstdCostFrmPlnAmt,
cast( perio.est_cost_req as vdm_estdcost_request preserving type ) AS TrvlExpnEstdCostFrmReqAmt,
cast( perio.reason as vdm_reasonfordifference preserving type ) AS ReasonForDifferenceText,
perio.lstay_acc AS AcmdtnPerDiemHasReducn,
cast( perio.excl_period_exc as vdm_statryexclsnperdexprd preserving type ) AS StatryExclsnPerdIsExpired,
perio.tax_trip AS WholeTripHasTaxation,
perio.number_persons AS NumberOfPersons,
perio.kitchen_temp_accomodation AS KitchenAmenities,
cast( estcost.TypeOfTripActivityValue as vdm_plan_activity preserving type ) AS TypeOfTripActivityValue,
estcost.TripActivityTypeName AS TripActivityTypeName,
estcost.EstimatedCost AS EstimatedCost,
estcost.EstimatedCostCrcy AS EstimatedCostCrcy,
case when perio.uebrf is initial and perio.ueblg is initial and perio.uebdt is initial and perio.abrec = '4' then concat(concat('R', perio.antrg), '0') when perio.uebrf is initial and perio.ueblg is initial and perio.uebdt is initial and perio.abrec <> '4' then concat(concat('R', perio.antrg), perio.abrec) else concat(concat('R', perio.antrg), '4') end as TripAuthznFctrVal AS antrg4endasTripAuthznFctrVal,
case when TravelPrivileges.bukrs <> '' then TravelPrivileges.bukrs else TravelOrgAssignment.bukrs end as CompanyCode AS bukrsendasCompanyCode,
case when TravelPrivileges.kostl <> '' then TravelPrivileges.kostl else TravelOrgAssignment.kostl end as CostCenter AS kostlendasCostCenter,
case when TravelPrivileges.werks <> '' then TravelPrivileges.werks else TravelOrgAssignment.werks end as PersonnelArea AS werksendasPersonnelArea,
TravelOrgAssignment.vdsk1 AS PersonWorkAgrmtAuthznGrpg,
cast( TravelPrivileges.ptzuo as vdm_emplgrpgfortrvlmgmt preserving type ) AS TrvlExpnEmplGrpg,
cast( TravelOrgAssignment.persg as persg preserving type ) AS TrvlExpnReimbmtGrpStatry,
cast( TravelOrgAssignment.persk as persk preserving type ) AS TrvlExpnReimbmtGrpEnt,
cast ( communication.UserID as sysid preserving type ) AS TravelEmployeeUserIdentifier,
cast( TravelOrgAssignment.ename as vdm_frmtdemplapplcntname preserving type ) AS TravelEmployeeName,
cast( concat_with_space(ptrv_head.zland, ptrv_head.hrgio, 1) as vdm_reg_ctry ) AS TravelCountryRegion,
cast( concat_with_space(ptrv_head.agrz1, ptrv_head.grgio, 1) as vdm_reg_ctry ) AS TravelCountryRegionGroup
FROM ptrv_head
INNER JOIN pa0001 AS TravelOrgAssignment ON /* join condition not captured in parsed metadata */
INNER JOIN pa0017 AS TravelPrivileges ON /* join condition not captured in parsed metadata */
INNER JOIN I_TravelRequestKeyField AS KeyField ON /* join condition not captured in parsed metadata */
LEFT OUTER JOIN E_TravelExpense AS _ExtensionTravelExpense ON PersonnelNumber = _ExtensionTravelExpense.PersonnelNumber AND TravelTripNumber = _ExtensionTravelExpense.TravelTripNumber AND TravelExpnSequentialNumber = _ExtensionTravelExpense.TravelExpnSequentialNumber -- association [0..1]
;