본문 바로가기
ABAP

달의 마지막날 가져오는 function (RP_LAST_DAY_OF_MONTHS)

by clode 2023. 2. 14.
728x90
반응형

실행 화면

DB에 2020년 데이터가 없어서 아무것도 나오지 않는 것임



프로그램 로직

변수 선언

TABLES: sflight, sbook.

DATA: gr_salv_tab TYPE REF TO cl_salv_table.

DATA : BEGIN OF wa.
       INCLUDE TYPE spfli.
DATA : scarr TYPE scarr-carrname,
       fldate TYPE sflight-fldate,
       bookid TYPE sbook-bookid,
       customid TYPE sbook-customid,
       END OF wa,
       gt_itab LIKE TABLE OF wa.

data: gv_today type D, "오늘날짜 담을 변수
      gv_lastday like sy-datum. "마지막날짜 담을 변수 

화면 구성

SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_carrid TYPE sflight-carrid OBLIGATORY DEFAULT 'AA'. "필수값
SELECT-OPTIONS: s_connid FOR sflight-connid,
                s_fldate FOR sflight-fldate,
                s_book FOR sbook-bookid,
                s_custom FOR sbook-customid.
SELECTION-SCREEN END OF BLOCK b1.

초기값 설정

INITIALIZATION.

"날짜 계산
gv_today = sy-datum.
gv_today+6(2) = '01'.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
  EXPORTING
    day_in                  = gv_today
 IMPORTING
   LAST_DAY_OF_MONTH       = gv_lastday.


"SELECT-OPTIONS 초기값
  s_fldate-sign = 'I'.
  s_fldate-option = 'BT'. "BETWEEN
  s_fldate-low = gv_today.
  s_fldate-high = gv_lastday.
  APPEND s_fldate. CLEAR s_fldate.

RP_LAST_DAY_OF_MONTHS

데이터 SELECT

START-OF-SELECTION.

SELECT * FROM spfli AS a
  INNER JOIN sflight AS b
  ON a~carrid = b~carrid
  AND a~connid = b~connid
  INNER JOIN scarr AS c
  ON a~carrid = c~carrid
  INNER JOIN sbook AS d
  ON a~carrid = d~carrid
  AND a~connid = d~connid
  INTO CORRESPONDING FIELDS OF TABLE gt_itab
  WHERE  a~distance >= 9000
  and a~distid = 'KM'
  AND d~cancelled NE 'X'.
  and a~carrid = p_carrid
  and b~connid in s_connid
  and b~fldate in s_fldate
  and d~bookid in s_book 
  and d~customid in s_custom.


"int를 list로 출력해주는 구문
  CALL METHOD cl_salv_table=>factory 
    IMPORTING
      r_salv_table = gr_salv_tab
    CHANGING
      t_table      = gt_itab.

  gr_salv_tab->display( ).

START-OF-SELECTION
사용자가 F8, 실행 후 타는 로직이다.

728x90
반응형

'ABAP' 카테고리의 다른 글

Module-pool 2 (조회)  (0) 2023.02.14
Module-pool 1 (변경)  (0) 2023.02.14
조회조건 날짜 계산하여 기본값 넣기 (RP_CALC_DATE_IN_INTERVAL)  (0) 2023.01.24
Subscreen  (2) 2023.01.24
Parameter, Select-options, Initialization  (0) 2023.01.24

댓글