Commercial Fixed Wing
Flight Crew Instrument; Flight Crew Commercial; Flight Crew Multiengine; Flight Crew Air Transport Pilot (ATP)
Human-Machine Interface; Communication Breakdown
Conflict Airborne Conflict; Deviation - Track / Heading All Types; Deviation / Discrepancy - Procedural Clearance; Deviation / Discrepancy - Procedural Published Material / Policy
Air Traffic Control Issued Advisory / Alert; Flight Crew Became Reoriented; Flight Crew Took Evasive Action
Human Factors
On departure from RWY XXL from ZZZ; we were to fly the RNAV departure to ZZZZZ. When we took the runway; I saw ZZZZZ on my lower display screen. We took off and at 400 feet [and] I called for LNAV. Soon after VNAV was engaged; the aircraft turned left. I looked over the yoke to see where the aircraft was headed; I saw ZZZZZ1 as the active waypoint. It was at this time ATC asked if we were turning to ZZZZZ; we said we were flying the departure route. They told us to turn to heading 300; then shortly after; said make an immediate turn to 320 [heading]. I disengaged the autopilot and made a sharp right turn to 320 [heading]; I could see another aircraft off to our left that looked to be somewhere between 500 to 1;000 feet below us. We rejoined the departure route with no other incident. In our turn to the 320 heading; we did receive one traffic warning from our TCAS. This could have been avoided had I not let myself get rushed and double checked the First Officer's FMC route inputs. He had mistakenly put in RWY XYL not RWY XXL; which was our departure runway. I also should have looked over the yoke to make sure of the first point on the RNAV route. I failed to slow down and double check; it is my fault the incident happened.
It was the Captain's leg and we were cleared for takeoff on Runway XXL in ZZZ on the RNAV departure procedure with the appropriate 'ZZZZZ RNAV' phraseology; and had an uneventful takeoff. During climbout; all standard operating procedures were followed and the autopilot was selected to center command for the departure procedure. As we climbed through an altitude of approximately 1;100 feet indicated; ATC questioned if we were in the depicted turn to ZZZZZ; which was the next fix for sequencing in the FMC 'Flight Management Computer.' Simultaneously; while realizing our aircraft track was incorrect; the Tower issued an immediate turn to a heading of 300 degrees. While in the assigned right turn; we received a 'TRAFFIC' annunciation from the aircraft TCASS warning system; and the Tower then issued an immediate turn to a heading of 320. During the additional turn; the Captain selected the autopilot off to provide a better turn radius for the new heading. Once established on this heading and continuing our climb to the depicted altitude of 10;000 feet; the Captain called for the autopilot to again be selected to center command. We were issued a frequency change to the assigned ZZZ Departure frequency; and the new controller provided a number for the Tower to call after landing; based on this course deviation.Once we were at a safe altitude; I began to review the RVAV procedure and all associated inputs in the FMC. I quickly realized that the incorrect runway was line selected; which was Runway XYL instead of the correct runway; XXL. This incorrect runway created the off course path; which required the immediate turn for course correction. In retrospect; the line selection for Runway XXL was very close to Runway XYL; which I completely selected in error; and then with my routine check of all inputted data; I did not identify my error. In addition with all briefings of both graphical and textual data for the departure procedure; the error was not discovered. Also; with runway verification; I did not notice that XYL was depicted in the FMC and on the primary flight display. Having never been in this position before after flying jets for over 18 years; I was completely sick to my stomach with this very simple; but extremely problematic error. At this point going forward; I will be extremely vigilant with runway selection while flying an RNAV procedure at a busy airport with multiple runways utilized for departure. I will also provide an additional check of runway selection in the FMC before positioning on the active runway; and hopefully this will never happen again.
Air carrier flight crew reported improper FMS programing resulted in an airborne conflict.