ABAP Report 개발시 아래와 같은 Templete 로 작성합니다...
*----------------------------------------------------------------------*
* Module/Sub-module:
*----------------------------------------------------------------------*
* T-CODE :
* Author :
* Date :
* Type :
* Description :
*----------------------------------------------------------------------*
* 변경이력 *
* ---------- ---------- ---------- ----------------------------- *
* 변경번호 변경일자 변경자명 변경내용 *
* ---------- ---------- ---------- ----------------------------- *
*
*----------------------------------------------------------------------*
report YFIBR0010 message-id OK.
*----------------------------------------------------------------------*
*..// include
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Types
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Tables
*----------------------------------------------------------------------*
tables : DD02L.
*----------------------------------------------------------------------*
*..// Internal Table & Workarea
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Global Valuable
*----------------------------------------------------------------------*
data : GO_DREF type ref to DATA.
*----------------------------------------------------------------------*
*..// Field Symbols
*----------------------------------------------------------------------*
field-symbols : <FS_ITAB> type TABLE.
*----------------------------------------------------------------------*
*..// Ranges
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Constants
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Macro
*----------------------------------------------------------------------*
*..// Clear ITAB
define $$CLEAR.
CLEAR : &1, &1[].
end-of-definition.
*..// Append Ranges Type
define $$SET_R.
MOVE : &2 TO &1-SIGN,
&3 TO &1-OPTION,
&4 TO &1-LOW,
&5 TO &1-HIGH.
APPEND &1. CLEAR &1.
end-of-definition.
*..// append itab.
define $$APPEND_ITAB.
PERFORM APPEND_ITAB TABLES &1
USING &2 &3 &4.
end-of-definition.
*..// append bdc
define $$APPEND_BDCDATA.
PERFORM APPEND_BDCDATA TABLES &1
USING &2 &3 &4.
end-of-definition.
*----------------------------------------------------------------------*
*..// local Class - Definition
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// local Class - Implementation
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Selection Screen
*----------------------------------------------------------------------*
selection-screen begin of block BLK1 with frame title TEXT-T01.
parameters : P_TABNM type DD02L-TABNAME obligatory.
selection-screen end of block BLK1.
*----------------------------------------------------------------------*
*..// Initialization
*----------------------------------------------------------------------*
initialization.
*----------------------------------------------------------------------*
*..// At selection screen
*----------------------------------------------------------------------*
at selection-screen.
*----------------------------------------------------------------------*
*..// At selection screen output
*----------------------------------------------------------------------*
at selection-screen output.
*----------------------------------------------------------------------*
*..// at selection screen request
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*..// Start-of-selection
*----------------------------------------------------------------------*
start-of-selection.
create data GO_DREF type table of (P_TABNM).
assign GO_DREF->* to <FS_ITAB>.
select *
into corresponding fields of table <FS_ITAB>
from (P_TABNM).
*----------------------------------------------------------------------*
*..// End -of-selection
*----------------------------------------------------------------------*
end-of-selection.
perform DISPLAY_SIMPLE_ALV tables <FS_ITAB>.
*----------------------------------------------------------------------*
*..// Sub-routines
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form APPEND_ITAB
*&---------------------------------------------------------------------*
* Append into Internal Table from Workarea..
*----------------------------------------------------------------------*
* ->PT_ITAB : ITAB with header line
* ->P_FLAG : S:start, (null):normal, E:End
* ->P_KEY : fieldname
* ->P_VALUE : fieldvalue
*----------------------------------------------------------------------*
form APPEND_ITAB tables PT_ITAB
using P_FLAG P_KEY P_VALUE.
field-symbols : <FS_ITAB> type any.
if P_FLAG eq 'S'.
clear : PT_ITAB.
endif.
assign component P_KEY of structure PT_ITAB to <FS_ITAB>.
move : P_VALUE to <FS_ITAB>.
case P_FLAG.
when 'S'. "..nothing
when ' '. "..nothing
when 'E'. append PT_ITAB. clear PT_ITAB.
when others.
endcase.
unassign <FS_ITAB>.
endform. " APPEND_ITAB
*&---------------------------------------------------------------------*
*& Form APPEND_BDCDATA
*&---------------------------------------------------------------------*
* BDC setting
*----------------------------------------------------------------------*
* -->P_BDCTAB : Batch 입력: 신규테이블 필드구조
* -->P_VAL1 : BDC 화면시작
* -->P_VAL2 : BDC 모듈 풀 / 필드이름
* -->P_VAL3 : BDC 화면번호 / BDC 필드값
*----------------------------------------------------------------------*
form APPEND_BDCDATA tables P_BDCTAB structure BDCDATA
using P_VAL1 P_VAL2 P_VAL3.
case P_VAL1.
when SPACE. "..field
P_BDCTAB-FNAM = P_VAL2.
P_BDCTAB-FVAL = P_VAL3.
when others. "..screen
P_BDCTAB-PROGRAM = P_VAL2.
P_BDCTAB-DYNPRO = P_VAL3.
P_BDCTAB-DYNBEGIN = P_VAL1.
endcase.
append P_BDCTAB. clear P_BDCTAB.
endform. " APPEND_BDCDATA
*&---------------------------------------------------------------------*
*& Form display_simple_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* ->PT_ITAB : ITAB with header line
*----------------------------------------------------------------------*
form DISPLAY_SIMPLE_ALV tables PT_ITAB.
data : LO_SALV type ref to CL_SALV_TABLE,
LO_FUNCS type ref to CL_SALV_FUNCTIONS_LIST,
LO_COLS type ref to CL_SALV_COLUMNS_LIST.
"..// create instance
try.
call method CL_SALV_TABLE=>FACTORY
importing
R_SALV_TABLE = LO_SALV
changing
T_TABLE = PT_ITAB[].
catch CX_SALV_MSG .
endtry.
"..// set functions
LO_FUNCS = LO_SALV->GET_FUNCTIONS( ).
LO_FUNCS->SET_ALL( ABAP_TRUE ).
"..// column optimize
LO_COLS = LO_SALV->GET_COLUMNS( ).
LO_COLS->SET_OPTIMIZE( ABAP_TRUE ).
"..// Display
LO_SALV->DISPLAY( ).
endform. "display_simple_alv