use hide or read line statements... in your at user-command event check this program... report yh640_030403 line-size 70. *---------------------------------------------------------------------* * program name: flight details * * creation: 07/12/2006* * * * sap name : yh640_030403 application: test * * * * author : sai ramesh p type: 1 * *_____________________________________________________________________* * description : this program allows the user to select one or more * * carrier ids on the basic list and displays the flight * * information from sflight table on the secondary list * * with some additional options on the application bar * * like select all , deselect all . * *_____________________________________________________________________* * inputs: * * tables: * * spfli - flight schedule * * sflight - flight * * select options: * * n/a * * parameters: * * n/a * * * * outputs: displays fight details * *_____________________________________________________________________* * external routines * * function modules: no * * transactions : no * * programs : no * *_____________________________________________________________________* * return codes: no * *_____________________________________________________________________* * ammendments: * * programmer date req. # action * * ================ ========== ====== ==============================* * * *********************************************************************** *" type declarations................................................... *"--------------------------------------------------------------------* *type declaration of the structure to flight schedule from spfli table* *"--------------------------------------------------------------------* types : begin of type_s_spfli, carrid type spfli-carrid, " airline carrierid. connid type spfli-connid, " connection id airpfrom type spfli-airpfrom, " departure airport airpto type spfli-airpto, " destination airport deptime type spfli-deptime, " departure time arrtime type spfli-arrtime, " arrival time check(1) type c, end of type_s_spfli.
*"--------------------------------------------------------------------* *type declaration of structure to flight details from sflight table * *"--------------------------------------------------------------------* types : begin of type_s_sflight, carrid type sflight-carrid, " airline carrid. connid type sflight-connid, " connectin id fldate type sflight-fldate, " flight date. seatsmax type sflight-seatsmax, " maximum no.of seats seatsocc type sflight-seatsocc, " occupied seats. end of type_s_sflight. *"--------------------------------------------------------------------* * internal table to hold flight schedule data * *"--------------------------------------------------------------------* data : t_spfli type standard table of type_s_spfli initial size 0. *"--------------------------------------------------------------------* * work area to hold flight schedule data * *"--------------------------------------------------------------------* data wa_spfli type type_s_spfli. *" data declarations................................................... *"--------------------------------------------------------------------* * work variables * *"--------------------------------------------------------------------* data: w_box(1) type c, " checkbox. w_index type i. *"--------------------------------------------------------------------* * top-of-page event * *"--------------------------------------------------------------------* top-of-page. perform list_headings. *"--------------------------------------------------------------------* * top-of-page during line-selection event * *"--------------------------------------------------------------------* top-of-page during line-selection. perform headings. *"--------------------------------------------------------------------* * start-of-selection event * *"--------------------------------------------------------------------* start-of-selection. perform retrieve_spfli. *"--------------------------------------------------------------------* * end-of-selection event *
*"--------------------------------------------------------------------* end-of-selection. set pf-status 'display'. perform flight_schedule. *"--------------------------------------------------------------------* * at user-command event * *"--------------------------------------------------------------------* at user-command. if sy-lsind lt 2. case sy-ucomm. when 'sflight'. perform display_sflight. when 'selectall'. perform display_all. when 'deselecta'. perform deselect_all. endcase. " case sy-ucomm. endif. " if sy-lsind lt 2. *&---------------------------------------------------------------------* *& form retrieve_spfli *&---------------------------------------------------------------------* * this subroutine retrieves the flight schedule data from spfli * *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form retrieve_spfli . select carrid " airline carrierid. connid " connection id airpfrom " departure airport airpto " destination airport deptime " departure time arrtime " arrival time into table t_spfli from spfli. endform. " form retrieve_spfli *&---------------------------------------------------------------------* *& form display_sflight *&---------------------------------------------------------------------* * this subroutine displays the flight details for user selected * * records. *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form display_sflight. *declaration of internal table to hold flight details ... data lt_sflight type standard table
of type_s_sflight initial size 0. *declaration of internal table to hold flight schedule data... data lt_spfli type standard table of type_s_spfli initial size 0. * work area to hold flight schedule data... data lwa_spfli type type_s_spfli. * work area to hold flight schedule data... data lwa_sflight type type_s_sflight. *declaration of work variables ... data: lw_lines type i, " holds no.of lines in t_spfli lw_linno type i value 5, lw_count type i. describe table t_spfli lines lw_lines. do lw_lines times. read line lw_linno field value : w_box into w_box, wa_spfli-carrid into lwa_spfli-carrid, wa_spfli-connid into lwa_spfli-connid, wa_spfli-check into wa_spfli-check. if w_box = 'x' and wa_spfli-check ne '*' . add 1 to : lw_count, w_index. append lwa_spfli to lt_spfli. wa_spfli-check = '*'. modify current line field value wa_spfli-check field format w_box input off. endif. " if w_box = 'x' and... clear w_box. add 1 to lw_linno. enddo. if lw_count eq 0 and w_index ge 27. message 'all the records have been read'(002) type 'e'. elseif lw_count eq 0. message 'select at least one record'(003) type 'e'. else. select carrid " airline carrid. connid " connection id fldate " fight date. seatsmax " maximum no.of seats seatsocc " occupied no.of seats into table lt_sflight
from sflight for all entries in lt_spfli where carrid eq lt_spfli-carrid and connid eq lt_spfli-connid. if sy-subrc eq 0. set pf-status space. loop at lt_sflight into lwa_sflight. write : / lwa_sflight-carrid, 10 lwa_sflight-connid, 25 lwa_sflight-fldate, 45 lwa_sflight-seatsmax, 57 lwa_sflight-seatsocc. endloop. else. message 'no data found'(004) type 'e'. endif. " if sy-subrc eq 0. clear lwa_sflight. endif. " if lw_count=0 and w_index>= 27. endform. " display_sflight *&---------------------------------------------------------------------* *& form display_all *&---------------------------------------------------------------------* * this subroutine selects all the records in the basic list. * *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form display_all . *declaration of work variables... data: lw_lines type i, " holds no.of lines in t_spfli lw_linno type i value 5. describe table t_spfli lines lw_lines. do lw_lines times. read line lw_linno field value wa_spfli-check into wa_spfli-check. if wa_spfli-check ne '*'. w_box = 'x'. modify line lw_linno field value w_box . endif. " if wa_spfli-check ne '*'. add 1 to lw_linno. clear wa_spfli-check. enddo. " do lw_lines times. endform. " display_all *&---------------------------------------------------------------------* *& form deselect_all *&---------------------------------------------------------------------* * this subroutine deselects all the lines selected on the list * *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------* form deselect_all . data: lw_lines type i, " holds no.of lines in t_spfli lw_linno type i value 5, lw_count type i. describe table t_spfli lines lw_lines. do lw_lines times. read line lw_linno field value wa_spfli-check into wa_spfli-check. if wa_spfli-check ne '*'. w_box = ' '. modify line lw_linno field value w_box . add 1 to lw_count . endif. " if wa_spfli-check ne '*'. add 1 to lw_linno. clear wa_spfli-check. enddo. " do lw_lines times. endform. " form deselect_all *&---------------------------------------------------------------------* *& form flight_schedule *&---------------------------------------------------------------------* * this subroutine prints the flight schedule on basic list. *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form flight_schedule . loop at t_spfli into wa_spfli. write : / w_box as checkbox, 5 wa_spfli-carrid, 12 wa_spfli-connid, 20 wa_spfli-airpfrom, 30 wa_spfli-airpto, 40 wa_spfli-deptime, 52 wa_spfli-arrtime, 65 wa_spfli-check . endloop. " loop at t_spfli into wa_spfli. clear wa_spfli. endform. " form flight_schedule *&---------------------------------------------------------------------* *& form headings *&---------------------------------------------------------------------* * this subroutine displays the top of page during line selection.* *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form headings. write : 'flight information'(001), 65 sy-lsind.
uline. format color col_heading. write: /'carrid'(005),10 'connid'(006),25 'flight date'(007), 48 'max.seats'(008),62 'occ.seats'(009). format color off. uline. endform. " form headings *&---------------------------------------------------------------------* *& form list_headings * *&---------------------------------------------------------------------* * this subroutine displays the top of page * *----------------------------------------------------------------------* * there are no interface parameters to be passed to this subroutine. * *----------------------------------------------------------------------* form list_headings . format color col_heading. write: /3'carrid'(005),10 'connid'(006),18 'airp-fr'(010), 27 'airp-to'(011),40 'dep-time'(012), 52 'arr-time'(013),66 'check'(014). format color off. uline. endform. " list_headings