목표: 항공사 예약 프로그램 만들기
SBOOK 테이블
- 출력 조건 및 필드
- 출력 필드
- CARRID, CONNID, FLDATE, BOOKID, CUSTOMID, LOCCURAM, LOCCURKEY, ORDER_DATE, CANCELLED
- 검색 조건
- 파라미터: CARRID(필수 입력/초기값: 'AA'), CONNID(필수 입력/초기값: '0017'), FLDATE(필수 입력/초기값: '20171219')
- 셀렉트 옵션: CUSTOMID
- 라디오버튼 그룹(rad1): r1(All Booking), r2(Valid Booking), r3(Cancelled Booking)
- 라디오버튼 조건절:
IF r1 = 'X'.
AND CANCELLED = ''
ELSEIF r2 = 'X'.
AND CANCELLED <> 'X'.
ELSEIF r3 = 'X'.
AND CANCELLED = 'X'.
ENDIF.
- 라디오버튼 조건절:
- ALV 필드 옵션
- 고정 열 처리(key = 'X'): CARRID, CONNID, FLDATE, BOOKID
- 하이퍼링크 처리(hotspot = 'X'): CUSTOMID
- 출력 필드
- 구현 코드
*&---------------------------------------------------------------------*
*& Report Z7WEEK_ASSN
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z7WEEK_ASSN.
TABLES: sbook.
TYPE-POOLS: slis.
*Data Declaration
*----------------
TYPES: BEGIN OF t_sbook,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
customid TYPE sbook-customid,
loccuram TYPE sbook-loccuram,
loccurkey TYPE sbook-loccurkey,
order_date TYPE sbook-order_date,
cancelled TYPE sbook-cancelled,
END of t_sbook.
DATA: it_sbook TYPE STANDARD TABLE OF t_sbook,
wa_sbook TYPE t_sbook.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
DATA : t TYPE slis_t_sp_group_alv.
*SELECT OPTION
SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME TITLE text-001.
PARAMETERS p_carrid TYPE sbook-carrid OBLIGATORY DEFAULT 'AA'.
PARAMETERS p_connid TYPE sbook-connid OBLIGATORY DEFAULT '0017'.
PARAMETERS p_fldate TYPE sbook-fldate OBLIGATORY DEFAULT '20171219'.
SELECTION-SCREEN END OF BLOCK part1.
SELECTION-SCREEN BEGIN OF BLOCK part2 WITH FRAME TITLE text-002.
SELECT-OPTIONS s_cid FOR sbook-customid.
PARAMETERS: r1 RADIOBUTTON GROUP rad1 DEFAULT 'X',
r2 RADIOBUTTON GROUP rad1,
r3 RADIOBUTTON GROUP rad1.
SELECTION-SCREEN END OF BLOCK part2.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'CARRID'.
fieldcatalog-seltext_m = 'Airline Code'.
fieldcatalog-col_pos = 0.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'CONNIDE'.
fieldcatalog-seltext_m = 'Flight Connection Number'.
fieldcatalog-col_pos = 1.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'FLDATE'.
fieldcatalog-seltext_m = 'Flight date'.
fieldcatalog-col_pos = 2.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'BOOKID'.
fieldcatalog-seltext_m = 'Booking number'.
fieldcatalog-col_pos = 3.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'CUSTOMID'.
fieldcatalog-seltext_m = 'Customer Number'.
fieldcatalog-col_pos = 4.
fieldcatalog-hotspot = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LOCCURAM'.
fieldcatalog-seltext_m = 'Price of booking in local currency of airline'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LOCCURKEY'.
fieldcatalog-seltext_m = 'Local currency of airline'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ORDER_DATE'.
fieldcatalog-seltext_m = 'Booking Date'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'CANCELLED'.
fieldcatalog-seltext_m = 'Cancelation flag'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-zebra = 'X'.
* gd_layout-info_fieldname = 'LINE_COLOR'.
* gd_layout-def_status = 'A'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = it_sbook
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
FORM data_retrieval.
DATA: ld_color(1) TYPE c,
gs_where(20).
IF r1 = 'X'.
gs_where = ''.
ELSEIF r2 = 'X'.
gs_where = `CANCELLED <> 'X'`.
ELSEIF r3 = 'X'.
gs_where = `CANCELLED = 'X'`.
ENDIF.
SELECT carrid connid fldate bookid customid loccuram loccurkey order_date cancelled
INTO TABLE it_sbook
FROM sbook
WHERE carrid = p_carrid AND connid = p_connid AND fldate = p_fldate
AND customid IN s_cid
AND (gs_where).
ENDFORM. " DATA_RETRIEVAL
- 구현 결과
'강의 > SAP ERP' 카테고리의 다른 글
4주차 보충 자료 (0) | 2025.08.06 |
---|---|
[8주차 과제] 항공사 예약 프로그램(2) (0) | 2025.07.30 |
[6주차 과제] 검색 화면 만들기 (0) | 2025.07.30 |
[5주차 과제] 도움말 및 검색창 출력 (0) | 2025.07.30 |
[4주차 서브과제] 레이아웃 옵션 및 ALV 출력 (0) | 2025.07.30 |