How to identify Onward and Return Segments?

527 views Asked by At

The below response is from Sabre TravelItineraryReadRQ

 <ReservationItems>
  <Item>
    <FlightSegment>
      <DestinationLocation>
        <LocationCode>RUH</LocationCode>
        <Terminal>TERMINAL 2</Terminal>
        <TerminalCode>2</TerminalCode>
      </DestinationLocation>
      <Equipment>
        <AirEquipType>320</AirEquipType>
      </Equipment>
      <MarketingAirline>
        <Code>SV</Code>
        <FlightNumber>0573</FlightNumber>
      </MarketingAirline>
      <Meal>
        <Code>M</Code>
      </Meal>
      <OriginLocation>
        <LocationCode>AUH</LocationCode>
        <Terminal>TERMINAL 1</Terminal>
        <TerminalCode>1</TerminalCode>
      </OriginLocation>
      <SupplierRef>
        <ID>123</ID>
      </SupplierRef>
      <UpdatedArrivalTime>06-27T21:50</UpdatedArrivalTime>
      <UpdatedDepartureTime>06-27T21:00</UpdatedDepartureTime>
      <AirMilesFlown>0483</AirMilesFlown>
      <ArrivalDateTime>06-27T21:50</ArrivalDateTime>
      <ConnectionInd>O</ConnectionInd>
      <DayOfWeekInd>6</DayOfWeekInd>
      <DepartureDateTime>2015-06-27T21:00</DepartureDateTime>
      <ElapsedTime>01.50</ElapsedTime>
      <eTicket>false</eTicket>
      <FlightNumber>0573</FlightNumber>
      <NumberInParty>01</NumberInParty>
      <ResBookDesigCode>V</ResBookDesigCode>
      <SegmentNumber>0001</SegmentNumber>
      <SmokingAllowed>false</SmokingAllowed>
      <SpecialMeal>false</SpecialMeal>
      <Status>HK</Status>
      <StopQuantity>00</StopQuantity>
    </FlightSegment>
    <RPH>1</RPH>
  </Item>
  <Item>
    <FlightSegment>
      <DestinationLocation>
        <LocationCode>LHR</LocationCode>
        <Terminal>TERMINAL 4</Terminal>
        <TerminalCode>4</TerminalCode>
      </DestinationLocation>
      <Equipment>
        <AirEquipType>77W</AirEquipType>
      </Equipment>
      <MarketingAirline>
        <Code>SV</Code>
        <FlightNumber>0107</FlightNumber>
      </MarketingAirline>
      <Meal>
        <Code>M</Code>
      </Meal>
      <OriginLocation>
        <LocationCode>RUH</LocationCode>
        <Terminal>TERMINAL 2</Terminal>
        <TerminalCode>2</TerminalCode>
      </OriginLocation>
      <SupplierRef>
        <ID>123</ID>
      </SupplierRef>
      <UpdatedArrivalTime>06-28T07:15</UpdatedArrivalTime>
      <UpdatedDepartureTime>06-28T02:20</UpdatedDepartureTime>
      <AirMilesFlown>3087</AirMilesFlown>
      <ArrivalDateTime>06-28T07:15</ArrivalDateTime>
      <ConnectionInd>I</ConnectionInd>
      <DayOfWeekInd>7</DayOfWeekInd>
      <DepartureDateTime>2015-06-28T02:20</DepartureDateTime>
      <ElapsedTime>06.55</ElapsedTime>
      <eTicket>false</eTicket>
      <FlightNumber>0107</FlightNumber>
      <NumberInParty>01</NumberInParty>
      <ResBookDesigCode>V</ResBookDesigCode>
      <SegmentNumber>0002</SegmentNumber>
      <SmokingAllowed>false</SmokingAllowed>
      <SpecialMeal>false</SpecialMeal>
      <Status>HK</Status>
      <StopQuantity>00</StopQuantity>
    </FlightSegment>
    <RPH>2</RPH>
  </Item>
  <Item>
    <FlightSegment>
      <DestinationLocation>
        <LocationCode>RUH</LocationCode>
        <Terminal>TERMINAL 2</Terminal>
        <TerminalCode>2</TerminalCode>
      </DestinationLocation>
      <Equipment>
        <AirEquipType>77W</AirEquipType>
      </Equipment>
      <MarketingAirline>
        <Code>SV</Code>
        <FlightNumber>0118</FlightNumber>
      </MarketingAirline>
      <Meal>
        <Code>M</Code>
      </Meal>
      <OriginLocation>
        <LocationCode>LHR</LocationCode>
        <Terminal>TERMINAL 4</Terminal>
        <TerminalCode>4</TerminalCode>
      </OriginLocation>
      <SupplierRef>
        <ID>123</ID>
      </SupplierRef>
      <UpdatedArrivalTime>07-16T03:35</UpdatedArrivalTime>
      <UpdatedDepartureTime>07-15T18:50</UpdatedDepartureTime>
      <AirMilesFlown>3087</AirMilesFlown>
      <ArrivalDateTime>07-16T03:35</ArrivalDateTime>
      <ConnectionInd>O</ConnectionInd>
      <DayOfWeekInd>3</DayOfWeekInd>
      <DepartureDateTime>2015-07-15T18:50</DepartureDateTime>
      <ElapsedTime>06.45</ElapsedTime>
      <eTicket>false</eTicket>
      <FlightNumber>0118</FlightNumber>
      <NumberInParty>01</NumberInParty>
      <ResBookDesigCode>V</ResBookDesigCode>
      <SegmentNumber>0003</SegmentNumber>
      <SmokingAllowed>false</SmokingAllowed>
      <SpecialMeal>false</SpecialMeal>
      <Status>HK</Status>
      <StopQuantity>00</StopQuantity>
    </FlightSegment>
    <RPH>3</RPH>
  </Item>
  <Item>
    <FlightSegment>
      <DestinationLocation>
        <LocationCode>AUH</LocationCode>
        <Terminal>TERMINAL 1</Terminal>
        <TerminalCode>1</TerminalCode>
      </DestinationLocation>
      <Equipment>
        <AirEquipType>E70</AirEquipType>
      </Equipment>
      <MarketingAirline>
        <Code>SV</Code>
        <FlightNumber>0578</FlightNumber>
      </MarketingAirline>
      <Meal>
        <Code>M</Code>
      </Meal>
      <OriginLocation>
        <LocationCode>RUH</LocationCode>
        <Terminal>TERMINAL 2</Terminal>
        <TerminalCode>2</TerminalCode>
      </OriginLocation>
      <SupplierRef>
        <ID>123</ID>
      </SupplierRef>
      <UpdatedArrivalTime>07-16T09:15</UpdatedArrivalTime>
      <UpdatedDepartureTime>07-16T06:30</UpdatedDepartureTime>
      <AirMilesFlown>0483</AirMilesFlown>
      <ArrivalDateTime>07-16T09:15</ArrivalDateTime>
      <ConnectionInd>I</ConnectionInd>
      <DayOfWeekInd>4</DayOfWeekInd>
      <DepartureDateTime>2015-07-16T06:30</DepartureDateTime>
      <ElapsedTime>01.45</ElapsedTime>
      <eTicket>false</eTicket>
      <FlightNumber>0578</FlightNumber>
      <NumberInParty>01</NumberInParty>
      <ResBookDesigCode>V</ResBookDesigCode>
      <SegmentNumber>0004</SegmentNumber>
      <SmokingAllowed>false</SmokingAllowed>
      <SpecialMeal>false</SpecialMeal>
      <Status>HK</Status>
      <StopQuantity>00</StopQuantity>
    </FlightSegment>
    <RPH>4</RPH>
  </Item>
</ReservationItems>

from the above response i want to identify the return and onward segments. Rph = 1,2 are Onward and Rph = 3,4 are Retrun.

I need a way to identify these as I am reading this information from PNR. So i cannot compare it with any other requests also.

I am not looking for a code to do this, I am asking if any one having knowledge of Sabre, is there a way to get the response with some identifiers to identify Onward and Return, like MarriageGrp.

2

There are 2 answers

2
jdweng On

Try this. Code is very simple

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq; 

namespace ConsoleApplication2
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            var results = doc.Descendants("Item")
                .Select(x => new { rph = x.Elements("RPH").FirstOrDefault().Value,
                                   flight = x.Descendants("FlightNumber").FirstOrDefault().Value
                })
                .ToList();

        }
    }
}
​
0
Nuel On

I know this question is probably old, but I saw it and i think i should just answer it as it may help some other person (should in case you already found a way around it) as there is no node like MarriageGrp or any other of sort that

Here is the flow I would go.

1. When a user searches, save the route information in a table say (Lhr->DXB->Lhr)
2. When the user picks an itinerary from the result and you submit the details to EnhancedAirbook, you get that ReservationItem node which is not grouped (like they were under OriginDestionationOptions in OTA_AILOW
3. The next step is pretty important. 
 a. Extract out all the destionations (in this case it would be DXB,LHR) into a variable say $paxDestLocations; Also we will have a variable say $FlightLegs - that will hold the Legs and the FlightSegments in each legs.

 If there are no more ReservationItems, then you are done. If there are more, then goto C.
 c. Let $totalSegments = count($reservationItems); 
    $usedSegmentsCounter = 0; // Will help know how much of ReservationItems we have used.
    Start a loop like the below..
    // $i will represent each leg of the flight.
    // $pL will equal total destinations
    // $pL = count($paxDestLocations);
    for ($i=0; $i<= $pL-1; $i++){
      $FlightLeg[$i]['FlightSegments'] = [];

      // We wana start counting from usedSegmentsCounter
      $s = $usedSegmentsCounter ;
      for ($j=$s; $j<=$totalSegments-1; $j++){
         // If we just started assigning segments for this leg, then just give the first segment to this leg, we will deal with the other segments in the else block..
         if(empty($FlightLeg[$i]['FlightSegments'])){
           $FlightLeg[$i]['FlightSegments'] = $reservationItems[$j];                                 
         }
         # Pick the segment..and just add it to the current leg
         else{
           $FlightLeg[$i]['FlightSegments'][count($FlightLeg[$i]['FlightSegments'])] = $reservationItems[$j];
         }

         // And below, we check if the current flight segment's destinationCode matched the destionationCode we are currently in..
         if($reservationItem[$j]['FlightSegment']['DestinationLocation']['LocationCode'] == $paxDestLocations[$i]){
             // We are done with the segments in this leg,
             break 2;
         }
      }

    }

    At the end of this loop, you will have an array of this Structure below:

    $FlightLeg = [
          // Leg 1
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
          // Leg 2
          [
            ['FlightSegents' = [
             [ // ReservationItem 1],
             [ // ReservationItem 2]
            ]
          ],
    ]

I know you said you are not looking for code - but I guess using the code blocks above was easier for explanation purpose.