FORM create_dynamic_tab .
DATA: lv_month_diff TYPE i.
DATA: lv_month_high TYPE n LENGTH 6.
DATA: lv_month_low TYPE n LENGTH 6.
DATA: lv_col_pos TYPE i VALUE 1.
DATA: lv_loop_cnt TYPE i.
lv_month_low = s_period-low.
lv_month_high = s_period-high.
gs_fcat-col_pos = lv_col_pos.
gs_fcat-fieldname = 'ZEDU'.
gs_fcat-coltext = '사원번호'.
gs_fcat-ref_table = 'ZED15_10'.
gs_fcat-ref_field = 'ZEDU'.
APPEND gs_fcat TO gt_fcat.
lv_col_pos = lv_col_pos + 1.
gs_fcat-col_pos = lv_col_pos.
gs_fcat-fieldname = 'ZNAME2'.
gs_fcat-coltext = '프로젝트명'.
gs_fcat-ref_table = 'ZED15_20'.
gs_fcat-ref_field = 'ZNAME2'.
APPEND gs_fcat TO gt_fcat.
lv_col_pos = lv_col_pos + 1.
IF lv_month_high IS INITIAL.
DO 12 TIMES.
gs_fcat-col_pos = lv_col_pos.
gs_fcat-fieldname = lv_month_low.
gs_fcat-coltext = lv_month_low.
gs_fcat-intlen = 'C'.
gs_fcat-inttype = '2'.
APPEND gs_fcat TO gt_fcat.
lv_col_pos = lv_col_pos + 1.
lv_month_low+4(2) = lv_month_low+4(2) + 1.
IF lv_month_low+4(2) > 12.
lv_month_low(4) = lv_month_low(4) + 1.
lv_month_low+4(2) = lv_month_low+4(2) - 13.
if lv_month_low+4(2) eq '00'.
lv_month_low+4(2) = '01'.
endif.
ENDIF.
ENDDO.
ELSE.
lv_month_diff = abs( lv_month_high(4) * 12 + lv_month_high+4(2) ) - ( lv_month_low(4) * 12 + lv_month_low+4(2) ).
IF lv_month_diff > 11.
lv_loop_cnt = 12.
ELSE.
lv_loop_cnt = lv_month_diff + 1.
ENDIF.
DO lv_loop_cnt TIMES.
gs_fcat-col_pos = lv_col_pos.
gs_fcat-fieldname = lv_month_low.
gs_fcat-coltext = lv_month_low.
gs_fcat-intlen = 'C'.
gs_fcat-inttype = '2'.
APPEND gs_fcat TO gt_fcat.
lv_col_pos = lv_col_pos + 1.
lv_month_low+4(2) = lv_month_low+4(2) + 1.
IF lv_month_low+4(2) > 12.
lv_month_low(4) = lv_month_low(4) + 1.
lv_month_low+4(2) = lv_month_low+4(2) - 13.
if lv_month_low+4(2) eq '00'.
lv_month_low+4(2) = '01'.
endif.
ENDIF.
ENDDO.
ENDIF.
ENDFORM.
'SAP > ABAP 코드' 카테고리의 다른 글
(ABAP 코드) DATA_CHANGED (0) | 2022.01.25 |
---|---|
(ABAP 코드) 동적으로 생성한 테이블 필드 채웅 (0) | 2022.01.21 |
(ABAP 코드) 월 차이 계산 (0) | 2022.01.21 |
(ABAP 코드) 날짜 가공하는 Class (0) | 2021.10.29 |
(ABAP 코드) 금액 총 합계 (DATA_CHANGED_FINISHED) (0) | 2021.10.28 |