已阅读5页,还剩76页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
*&-*& report sapbc400cid_code_inspector_1 *&-*& *& this program contains some bad programming techniques *& that should be found by the code inspector . *& *&-* is this ok ?report my_program.* selection text ?parameters pa_carr type s_carr_id.data wa_conn type sdyn_conn.* what is missing here ?authority-check object s_carrid id carrid field pa_carr id actvt field 03.select * from spfli into corresponding fields of wa_conn where carrid = pa_carr.* performance ? select single carrname from scarr into wa_conn-carrname where carrid = wa_conn-carrid. write: / wa_conn-carrname, wa_conn-carrid, wa_conn-connid, wa_conn-cityfrom, wa_conn-cityto, wa_conn-deptime, wa_conn-arrtime.endselect.* is this ok ?break-point.if sy-subrc ne 0.* translation ? write no connections found !.endif.*&-*& report sapbc400cid_code_inspector_2 *&-*& *& corrected version of sapbc400cid_code_inspector_1 *& *&-*report sapbc400cid_code_inspector_2 .parameters pa_carr type s_carr_id.data wa_conn type sdyn_conn.authority-check object s_carrid id carrid field pa_carr id actvt field 03.if sy-subrc ne 0. write authority check failed !(acf). exit.endif.select * from bc400_cisd_fli select from a buffered view into corresponding fields of wa_conn where carrid = pa_carr. write: / wa_conn-carrname, wa_conn-carrid, wa_conn-connid, wa_conn-cityfrom, wa_conn-cityto, wa_conn-deptime, wa_conn-arrtime.endselect.if sy-subrc ne 0. write no connections found !(ncf).endif.*&-*& report sapbc400ddd_array_fetch *&-*& *& reading one database table via array fetch (select . into table) *& *&-*report sapbc400ddd_array_fetch.data: itab_spfli type sbc400_t_spfli, wa_spfli like line of itab_spfli.select carrid connid airpfrom cityfrom countryfr airpto cityto countryto deptime from spfli into corresponding fields of table itab_spfli.loop at itab_spfli into wa_spfli. write: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-airpfrom, wa_spfli-cityfrom, wa_spfli-countryfr, wa_spfli-airpto, wa_spfli-cityto, wa_spfli-countryto, wa_spfli-deptime.endloop.*&-*& report sapbc400ddd_select_endselect *&-*& *& reading one database table via select . endselect. *& *&-*report sapbc400ddd_select_endselect.parameters pa_car type s_carr_id.data wa_sbc400focc type sbc400focc.select carrid connid fldate seatsmax seatsocc from sflight into wa_sbc400focc where carrid = pa_car. wa_sbc400focc-percentage = wa_sbc400focc-seatsocc * 100 / wa_sbc400focc-seatsmax. write: / wa_sbc400focc-carrid, wa_sbc400focc-connid, wa_sbc400focc-fldate, wa_sbc400focc-seatsmax, wa_sbc400focc-seatsocc, wa_sbc400focc-percentage, %.endselect.*&-*& report sapbc400ddd_select_inner_join *&-*& *& read data from two database tables via apab inner join : *& *& select . from . inner join . *& *&-*report sapbc400ddd_select_inner_join .types: begin of wa_type, carrid type scarr-carrid, carrname type scarr-carrname, connid type spfli-connid, airpfrom type spfli-airpfrom, cityfrom type spfli-cityfrom, countryfr type spfli-countryfr, airpto type spfli-airpto, cityto type spfli-cityto, countryto type spfli-countryto, deptime type spfli-deptime, end of wa_type.data wa_join type wa_type.* selecting from inner join (to avoid nested select loops)select scarrcarrid scarrcarrname spfliconnid spfliairpfrom spflicityfrom spflicountryfr spfliairpto spflicityto spflicountryto spflideptime into corresponding fields of wa_join from scarr inner join spfli on scarrcarrid = spflicarrid. write: / wa_join-carrid, wa_join-carrname, wa_join-connid, wa_join-airpfrom, wa_join-cityfrom, wa_join-countryfr, wa_join-airpto, wa_join-cityto, wa_join-countryto, wa_join-deptime.endselect.*&-*& report sapbc400ddd_select_single *&-*& *& reading single entry from database : select single *& *&-*report sapbc400ddd_select_single .parameters pa_car type s_carr_id.data wa_scarr type scarr.select single * from scarr into corresponding fields of wa_scarr where carrid = pa_car.if sy-subrc = 0. write: / wa_scarr-carrid, wa_scarr-carrname, wa_scarr-currcode.else . write: / text-001 color col_negative.endif.*&-*& report sapbc400ddd_select_view *&-*& *& *&-*report sapbc400ddd_select_view .parameters pa_anum type s_agncynum.data wa_sbc400_booking type sbc400_booking.select mandt carrid connid fldate bookid customid class name street city country agencynum from sbc400_booking into wa_sbc400_booking where agencynum = pa_anum. write: / wa_sbc400_booking-carrid, wa_sbc400_booking-connid, wa_sbc400_booking-fldate, wa_sbc400_booking-bookid, wa_sbc400_booking-customid, wa_sbc400_booking-class, wa_sbc400_booking-name, wa_sbc400_booking-street, wa_sbc400_booking-city, wa_sbc400_booking-country, wa_sbc400_booking-agencynum.endselect.*&-*& report sapbc400dds_authority_check *&-*report sapbc400dds_authority_check.constants actvt_display type activ_auth value 03.data wa_flight type sbc400focc.parameters pa_car type s_carr_id.* check if user is authorized to read data of the specified carrierauthority-check object s_carrid id carrid field pa_car id actvt field actvt_display.case sy-subrc. when 0. user is authorized select carrid connid fldate seatsmax seatsocc from sflight into corresponding fields of wa_flight where carrid = pa_car. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. write: / wa_flight-carrid color col_key, wa_flight-connid color col_key, wa_flight-fldate color col_key, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, %. endselect. if sy-subrc ne 0. write: no , pa_car, flights found !. endif. when others. user is not authorized write: / authority-check error(001).endcase.*&-*& report sapbc400dds_authority_check_2 *&-*report sapbc400dds_authority_check_2.constants actvt_display type activ_auth value 03.data: it_flight type sbc400_t_sbc400focc, wa_flight like line of it_flight.parameters pa_car type s_carr_id.* check if user is authorized to read data of the specified carrier ?authority-check object s_carrid id carrid field pa_car id actvt field actvt_display.case sy-subrc. when 0. user is authorized select carrid connid fldate seatsmax seatsocc from sflight into corresponding fields of wa_flight where carrid = pa_car. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. append wa_flight to it_flight. endselect. if sy-subrc = 0. sort it_flight by percentage. loop at it_flight into wa_flight. write: / wa_flight-carrid color col_key, wa_flight-connid color col_key, wa_flight-fldate color col_key, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, %. endloop. else. write: no , pa_car, flights found !. endif. when others. user is not authorized write: / authority-check error(001).endcase.*&-*& report sapbc400dds_select_array_fetch *&-*report sapbc400dds_select_array_fetch.data: it_flight type sbc400_t_sbc400focc, wa_flight like line of it_flight.parameters pa_car type s_carr_id.*-* - use array fetch to fill internal table * - loop at internal table to set the percentage value of each row * - sort and list internal table *-select carrid connid fldate seatsmax seatsocc from sflight into corresponding fields of table it_flight where carrid = pa_car.if sy-subrc = 0. loop at it_flight into wa_flight. wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax. modify it_flight from wa_flight index sy-tabix transporting percentage. endloop. sort it_flight by percentage. loop at it_flight into wa_flight. write: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, %. endloop.else. write: no , pa_car, flights found !.endif.*&-*& report sapbc400dds_select_sflight *&-*& solution for exercise reading data from one database table *&-*report sapbc400dds_select_sflight.parameters pa_car type s_carr_id.data wa_flight type sbc400focc.* select all flights belonging to carrier specified in pa_car :select carrid connid fldate seatsmax seatsocc from sflight into corresponding fields of wa_flight where carrid = pa_car.* calculate occupation of the current flight wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax.* create list write: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsmax, wa_flight-seatsocc, wa_flight-percentage, %.endselect.if sy-subrc ne 0. write: no , pa_car, flights found !.endif.*&-*& report sapbc400dds_select_sflight_tab *&-*report sapbc400dds_select_sflight_tab .data: it_flight type sbc400_t_sbc400focc, wa_flight like line of it_flight.parameters pa_car type s_carr_id.* select all flights belonging to carrier specified in pa_car :select carrid connid fldate seatsmax seatsocc from sflight into corresponding fields of wa_flight where carrid = pa_car.* calculate occupation of flight wa_flight-percentage = 100 * wa_flight-seatsocc / wa_flight-seatsmax.* insert flight into internal table insert wa_flight into table it_flight.* (if you are using standard tables, append wa_flight to it_flight.* would be the same as the above insert-statement.)endselect.if sy-subrc = 0.* sort internal table sort it_flight by percentage.* create list loop at it_flight into wa_flight. write: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate, wa_flight-seatsocc, wa_flight-seatsmax, wa_flight-percentage, %. endloop.else. write: no , pa_car, flights found !.endif.*&-*& report sapbc400ias_ewt *&-*report sapbc400ias_ewt .data gdt_spfli type sbc400_t_spfli.data ok_code like sy-ucomm.data: container_r type ref to cl_gui_custom_container, grid_r type ref to cl_gui_alv_grid.start-of-selection.* fill internal table select * from spfli into table gdt_spfli.* where . call screen 100.*&-*& module user_command_0100 input*&-* text*-*module user_command_0100 input. case ok_code. when back. set screen 0. when exit. leave program. endcase.endmodule. user_command_0100 input*&-*& module status_0100 output*&-* text*-*module status_0100 output. set pf-status status_100.* set titlebar xxx.endmodule. status_0100 output*&-*& module create_control output*&-* text*-*module create_control output. if container_r is initial. create object container_r exporting container_name = container_1. create object grid_r exporting i_parent = container_r. call method grid_r-set_table_for_first_display exporting i_structure_name = spfli changing it_outtab = gdt_spfli. else. call method grid_r-refresh_table_di
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025全国水利安全生产知识竞赛试题及答案
- 2026-2031中国女装市场深度分析及十五五前景预测报告
- 智慧城市物联中台合同
- 民间借贷担保人连带责任
- 2025年工会协理员考试题及答案
- 客户问题处理管理制度及相应的应急预案
- 2025年全民反诈知识竞赛题库及答案
- 2025年反假货币与知识竞赛题库及答案
- 2025《网络安全建设与网络社会治理》考试题库(含参考答案)
- 2025年非免疫规划疫苗考试题库及答案
- 二元一次方程组的应用(1)课件北师大版八年级数学上册
- DR成像技术操作规范与管理
- 第一讲 决胜“十四五”奋发向前行
- 中国石化2026年度毕业生招聘备考考试题库附答案解析
- 神奇的圆周率课件
- 2025年版民间借款合同范本全文
- 加油站油料安全培训内容课件
- 有机化学教改课题申报书
- 初中英语语法思维导图全册
- 生产现场5S管理实施方案详解
- 瑞幸咖啡财务舞弊案例分析
评论
0/150
提交评论