Custom PNR Editor Script Samples for Train Service

On this page:

Overview

These scripts are for our TMC partners to use for obtaining data on train transactions from Deem.

Note:  Amadeus functionality does not currently support GDS write back of rail segments.  If rail is enabled on an Amadeus site, the reservation is only viewable online; no GDS PNR is created. 

Sabre PNR script samples

Note: Text marked in BOLD should be updated.

Function

Script

Error when Form of Payment is Declined

//AMTRAK RECORD LOCATOR - INVALID

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;
 if (rl.length() > 0)
{if (rl.RailSegment.length() > 0)
var rr = rl.RailSegment[0].RecordLocator.Locator.substring (0,9);
{if (rr =="B-REARDEN") {out.print("5H-SPCL-VERIFY TICKET STATUS W AMTRAK POSS DECLINED FOP");}
}}}

For when no confirmation is received from Amtrak regardless of the reason (other than declined FOP)


//AMTRAK RECORD LOCATOR - NOT RECEIVED

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;
 if (rl.length() > 0)
{if (rl.RailSegment.length() > 0)
var rr = rl.RailSegment[0].RecordLocator.Locator;
{if ((rr =="")||(rr==undefined))
{out.print("5H-SPCL-VERIFY TICKET STATUS WITH AMTRAK");}
}}}

Amtrak Confirmation Number

//AMTRAK RECORD LOCATOR

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&
(UserPnrData.UserBooking.RailBooking != undefined))
{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;
 if (rl.length() > 0)
{if (rl.RailSegment.length() > 0)
{out.print("5A$-AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}
}} 

No Passive Segments Needed

//AMTRAK RECORD LOCATOR when no passive segments are needed


if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&

(UserPnrData.UserBooking.RailBooking != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

 if (rl.length() > 0)

{if ((rl.RailSegment.length() > 0)&&((UserPnrData.UserBooking.HotelBooking != undefined)||(UserPnrData.UserBooking.CarBooking != undefined)))

{out.print("5H-AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}

}}

Class of Service Booked

//AMTRAK CLASS OF SERVICE

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "purchase_hold")) &&
(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))
{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;
 if (rl.length() > 0)
{if (rl.RailSegment.length() > 0)
{out.print("5A$-AMTRAK CLASS OF SVC " + rl.RailSegment[0].ClassCode);}
}}

Form of Payment

//RAIL FOP

if((UserPnrData.DataType=="purchase_hold")||(UserPnrData.DataType=="new")){with (UserPnrData.UserSession.PurchaseInfo.RailBilling) {
var cardtype;
 if (BrandType.substring(0,4) == "Visa") { cardtype = "VI"; } else if (BrandType.substring(0,4) == "Amer") { cardtype = "AX"; } else if (BrandType.substring(0,4) == "Mast") { cardtype = "CA"; } else if (BrandType.substring(0,4) == "Disc") { cardtype = "DS"; } else if (BrandType.substring(0,3) == "JCB") { cardtype = "JC"; } else if (BrandType.substring(0,4) == "Cart") { cardtype = "CB"; } else if (BrandType.substring(0,4) == "Dine") { cardtype = "DC"; } else if (BrandType.substring(0,4) == "Univ") { cardtype = "TP"; } else if (BrandType.substring(0,4) == "EnRo") { cardtype = "ER"; } else { cardtype = "XX" }

var year=ExpirationDate.Year;

var myyear=year.substring(2,4);

var mymonth=ExpirationDate.Month;

        if (mymonth == "JAN") {mymonth = "01";}
        else if (mymonth =="FEB") {mymonth = "02";}
        else if (mymonth == "MAR") {mymonth = "03";}
        else if (mymonth == "APR") {mymonth = "04";}
        else if (mymonth == "MAY") {mymonth = "05";}
        else if (mymonth == "JUN") {mymonth = "06";}
        else if (mymonth == "JUL") {mymonth = "07";}
        else if (mymonth == "AUG") {mymonth = "08";}
        else if (mymonth == "SEP") {mymonth ="09";}
        else if (mymonth =="OCT") {mymonth = "10";}
        else if (mymonth == "NOV") {mymonth = "11";}
        else if (mymonth =="DEC") {mymonth = "12";}

if (UserPnrData.UserSession.PurchaseInfo.RailBilling != undefined)
out.print("50/-*" + cardtype + CardNumber + "$" + mymonth + "/" + myyear + "-xn");}}

Total Fare

//FARE QUOTE - RAIL

if(((UserPnrData.DataType == "new") || (UserPnrData.DataType=="purchase_hold") || (UserPnrData.DataType == "change")) &&
(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))

{out.print("5A$AMK FARE QUOTE - " + UserPnrData.UserBooking.RailBooking.RailFare.RailTotalFare.TotalFare);}

Apollo PNR script samples

Note: Text marked in BOLD should be updated.

Function

Script

Error when
Form of Payment
is Declined

//AMTRAK RECORD LOCATOR - INVALID

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

var rr = rl.RailSegment[0].RecordLocator.Locator.substring (0,9);

{if (rr =="B-REARDEN") {out.print("@:5A/SPCL-VERIFY TICKET STATUS W AMTRAK POSS DECLINED FOP");}

}}}

For when no
confirmation is
received
from Amtrak
regardless of
the reason
(other than
declined FOP)

//AMTRAK RECORD LOCATOR - NOT RECEIVED

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

var rr = rl.RailSegment[0].RecordLocator.Locator;

{if ((rr =="")||(rr==undefined))

{out.print("@:5A/SPCL-VERIFY TICKET STATUS WITH AMTRAK");}

}}}

Amtrak Confirmation
Number

//AMTRAK RECORD LOCATOR

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&

(UserPnrData.UserBooking.RailBooking != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

{out.print("@:5A/AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}

}}

No Passive Segments
Needed

//AMTRAK RECORD LOCATOR when no passive segments are needed

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&

(UserPnrData.UserBooking.RailBooking != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if ((rl.RailSegment.length() > 0)&&((UserPnrData.UserBooking.HotelBooking !=

undefined)||(UserPnrData.UserBooking.CarBooking != undefined)))

{out.print("@:5A/AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}

}}

Class of Service
Booked

//AMTRAK CLASS OF SERVICE

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "purchase_hold")) &&

(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

{out.print("@:5A/AMTRAK CLASS OF SVC " + rl.RailSegment[0].ClassCode);}

}}

Form of Payment

//RAIL FOP

if((UserPnrData.DataType=="purchase_hold")||(UserPnrData.DataType=="new")){with

(UserPnrData.UserSession.PurchaseInfo.RailBilling) {

var cardtype;

if (BrandType.substring(0,4) == "Visa") { cardtype = "VI"; } else if (BrandType.substring(0,4) == "Amer") { cardtype =

"AX"; } else if (BrandType.substring(0,4) == "Mast") { cardtype = "CA"; } else if (BrandType.substring(0,4) == "Disc") {

cardtype = "DS"; } else if (BrandType.substring(0,3) == "JCB") { cardtype = "JC"; } else if (BrandType.substring(0,4)

== "Cart") { cardtype = "CB"; } else if (BrandType.substring(0,4) == "Dine") { cardtype = "DC"; } else if

(BrandType.substring(0,4) == "Univ") { cardtype = "TP"; } else if (BrandType.substring(0,4) == "EnRo") { cardtype =

"ER"; } else { cardtype = "XX" }

var year=ExpirationDate.Year;

var myyear=year.substring(2,4);

var mymonth=ExpirationDate.Month;

if (mymonth == "JAN") {mymonth = "01";}

else if (mymonth =="FEB") {mymonth = "02";}

else if (mymonth == "MAR") {mymonth = "03";}

else if (mymonth == "APR") {mymonth = "04";}

else if (mymonth == "MAY") {mymonth = "05";}

else if (mymonth == "JUN") {mymonth = "06";}

else if (mymonth == "JUL") {mymonth = "07";}

else if (mymonth == "AUG") {mymonth = "08";}

else if (mymonth == "SEP") {mymonth ="09";}

else if (mymonth =="OCT") {mymonth = "10";}

else if (mymonth == "NOV") {mymonth = "11";}

else if (mymonth =="DEC") {mymonth = "12";}

if (UserPnrData.UserSession.PurchaseInfo.RailBilling != undefined)

out.print("F-*" + cardtype + CardNumber + "/D" + mymonth + myyear);}}

Total Fare

//FARE QUOTE - RAIL

if(((UserPnrData.DataType == "new") || (UserPnrData.DataType=="purchase_hold") || (UserPnrData.DataType ==

"change")) &&

(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))

{out.print("@:5A/AMK FARE QUOTE - " + UserPnrData.UserBooking.RailBooking.RailFare.RailTotalFare.TotalFare);}

Worldspan PNR script samples

Note: Text marked in BOLD should be updated.

Function

Script

Error when Form
of Payment is Declined

//AMTRAK RECORD LOCATOR – INVALID

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

var rr = rl.RailSegment[0].RecordLocator.Locator.substring (0,9);

{if (rr =="B-REARDEN") {out.print("5.O SPCL-VERIFY TICKET STATUS W AMTRAK POSS DECLINED FOP");}

}}}

For when no
confirmation is
received from
Amtrak regardless
of the reason
(other than
declined FOP)

//AMTRAK RECORD LOCATOR - NOT RECEIVED

if((UserPnrData.DataType=="hold")||(UserPnrData.DataType=="new"))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

var rr = rl.RailSegment[0].RecordLocator.Locator;

{if ((rr =="")||(rr==undefined))

{out.print("5.O SPCL-VERIFY TICKET STATUS WITH AMTRAK");}

}}}

Amtrak Confirmation
Number

//AMTRAK RECORD LOCATOR

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&

(UserPnrData.UserBooking.RailBooking != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

{out.print("5.O AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}

}}

No Passive Segments
Needed

//AMTRAK RECORD LOCATOR when no passive segments are needed

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "hold")) &&

(UserPnrData.UserBooking.RailBooking != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if ((rl.RailSegment.length() > 0)&&((UserPnrData.UserBooking.HotelBooking !=

undefined)||(UserPnrData.UserBooking.CarBooking != undefined)))

{out.print("5.O AMTRAK LOC " + rl.RailSegment[0].RecordLocator.Locator);}

}}

Class of Service
Booked

//AMTRAK CLASS OF SERVICE

if ( ((UserPnrData.DataType=="new") || (UserPnrData.DataType == "purchase_hold")) &&

(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))

{var rl = UserPnrData.UserBooking.RailBooking.RailLeg;

if (rl.length() > 0)

{if (rl.RailSegment.length() > 0)

{out.print("5.O AMTRAK CLASS OF SVC " + rl.RailSegment[0].ClassCode);}

}}

Form of Payment

//RAIL FOP

if((UserPnrData.DataType=="purchase_hold")||(UserPnrData.DataType=="new")){with

(UserPnrData.UserSession.PurchaseInfo.RailBilling) {

var cardtype;

if (BrandType.substring(0,4) == "Visa") { cardtype = "VI"; } else if (BrandType.substring(0,4) == "Amer") { cardtype =

"AX"; } else if (BrandType.substring(0,4) == "Mast") { cardtype = "CA"; } else if (BrandType.substring(0,4) == "Disc") {

cardtype = "DS"; } else if (BrandType.substring(0,3) == "JCB") { cardtype = "JC"; } else if (BrandType.substring(0,4)

== "Cart") { cardtype = "CB"; } else if (BrandType.substring(0,4) == "Dine") { cardtype = "DC"; } else if

(BrandType.substring(0,4) == "Univ") { cardtype = "TP"; } else if (BrandType.substring(0,4) == "EnRo") { cardtype =

"ER"; } else { cardtype = "XX" }


var year=ExpirationDate.Year;

var myyear=year.substring(2,4);

var mymonth=ExpirationDate.Month;


if (mymonth == "JAN") {mymonth = "01";}

else if (mymonth =="FEB") {mymonth = "02";}

else if (mymonth == "MAR") {mymonth = "03";}

else if (mymonth == "APR") {mymonth = "04";}

else if (mymonth == "MAY") {mymonth = "05";}

else if (mymonth == "JUN") {mymonth = "06";}

else if (mymonth == "JUL") {mymonth = "07";}

else if (mymonth == "AUG") {mymonth = "08";}

else if (mymonth == "SEP") {mymonth ="09";}

else if (mymonth =="OCT") {mymonth = "10";}

else if (mymonth == "NOV") {mymonth = "11";}

else if (mymonth =="DEC") {mymonth = "12";}


if (UserPnrData.UserSession.PurchaseInfo.RailBilling != undefined)

out.print("50/-*" + cardtype + CardNumber + "$" + mymonth + "/" + myyear + "-xn");}}

Total Fare

//FARE QUOTE - RAIL

if(((UserPnrData.DataType == "new") || (UserPnrData.DataType=="purchase_hold") || (UserPnrData.DataType ==

"change")) &&

(UserPnrData.UserBooking.RailBooking.PassengerInfo != undefined))

{out.print("5.O AMK FARE QUOTE - " + UserPnrData.UserBooking.RailBooking.RailFare.RailTotalFare.TotalFare);}