*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT A~VBELN
A~POSNR
A~MATNR
A~NETWR
A~WAERK
A~ZMENG
A~ZIEME
B~ERDAT
B~ERNAM
FROM VBAP AS A INNER JOIN VBAK AS B ON A~VBELN = B~VBELN
INTO CORRESPONDING FIELDS OF TABLE GT_DISP
WHERE A~VBELN IN S_VBELN
AND B~ERDAT IN S_ERDAT
AND B~ERNAM IN S_ERNAM.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form SETTING_ALV_0100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SETTING_ALV_0100 .
IF G_DOCKING IS INITIAL.
PERFORM CREATE_OBJECT.
PERFORM SET_LAYOUT.
PERFORM SET_FIELDCATALOG.
PERFORM SET_SORT.
PERFORM SET_TOOBAR.
PERFORM SET_EVENT.
PERFORM ALV_GRID_DISPLAY.
ELSE.
PERFORM ALV_REFRESH_TABLE.
ENDIF.
ENDFORM. " SETTING_ALV_0100
*&---------------------------------------------------------------------*
*& Form CREATE_OBJECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_OBJECT .
CREATE OBJECT G_DOCKING
EXPORTING
SIDE = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_LEFT
EXTENSION = CL_GUI_DOCKING_CONTAINER=>WS_MAXIMIZEBOX.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT G_GRID
EXPORTING
I_PARENT = G_DOCKING.
ENDFORM. " CREATE_OBJECT
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_LAYOUT .
CLEAR : GS_LAYOUT.
GS_LAYOUT-ZEBRA = 'X'.
GS_LAYOUT-CWIDTH_OPT = 'A'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
*& Form SET_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_FIELDCATALOG .
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'VBELN'.
GS_FIELDCAT-COL_POS = 1.
GS_FIELDCAT-COLTEXT = '판매오더번호'.
GS_FIELDCAT-KEY = 'X'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'POSNR'.
GS_FIELDCAT-COL_POS = 2.
GS_FIELDCAT-COLTEXT = '라인아이템'.
GS_FIELDCAT-KEY = 'X'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'MATNR'.
GS_FIELDCAT-COL_POS = 3.
GS_FIELDCAT-COLTEXT = '자재'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'NETWR'.
GS_FIELDCAT-COL_POS = 4.
GS_FIELDCAT-COLTEXT = '판매금액'.
GS_FIELDCAT-CFIELDNAME = 'WAERK'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'WAERK'.
GS_FIELDCAT-COL_POS = 5.
GS_FIELDCAT-COLTEXT = '단위'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'ZMENG'.
GS_FIELDCAT-COL_POS = 6.
GS_FIELDCAT-COLTEXT = '판매수량'.
GS_FIELDCAT-CFIELDNAME = 'ZIEME'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'ZIEME'.
GS_FIELDCAT-COL_POS = 7.
GS_FIELDCAT-COLTEXT = '단위'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'ERDAT'.
GS_FIELDCAT-COL_POS = 8.
GS_FIELDCAT-COLTEXT = '생성일'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
CLEAR : GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = 'ERNAM'.
GS_FIELDCAT-COL_POS = 9.
GS_FIELDCAT-COLTEXT = '생성자'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
ENDFORM. " SET_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form SET_SORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_SORT .
ENDFORM. " SET_SORT
*&---------------------------------------------------------------------*
*& Form SET_TOOBAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_TOOBAR .
CLEAR : gt_exclude, gt_exclude[].
"주석처리 안된 것 -> 제거 / 주석처리 한것 -> 화면에 제시"
PERFORM append_exclude_functions
TABLES gt_exclude[]
USING : cl_gui_alv_grid=>mc_fc_call_abc, " &ABC
cl_gui_alv_grid=>mc_fc_call_xxl,
cl_gui_alv_grid=>mc_fc_graph,
cl_gui_alv_grid=>mc_fc_info,
cl_gui_alv_grid=>mc_fc_loc_copy, " 행 카피.
cl_gui_alv_grid=>mc_fc_html,
cl_gui_alv_grid=>mc_fc_loc_copy_row, " 행 카피.
cl_gui_alv_grid=>mc_fc_loc_cut, " 잘라내기.
cl_gui_alv_grid=>mc_fc_loc_delete_row, " 행삭제.
cl_gui_alv_grid=>mc_fc_loc_insert_row, " 행삽입.
cl_gui_alv_grid=>mc_fc_loc_move_row,
cl_gui_alv_grid=>mc_fc_loc_append_row, " 라인생성.
cl_gui_alv_grid=>mc_fc_loc_paste, " 겹쳐쓰기.
cl_gui_alv_grid=>mc_fc_loc_paste_new_row, " 겹쳐쓰기.
cl_gui_alv_grid=>mc_fc_loc_undo, " 실행취소 &LOCAL&UNDO
cl_gui_alv_grid=>mc_fc_print,
cl_gui_alv_grid=>mc_fc_refresh,
cl_gui_alv_grid=>mc_fc_send,
cl_gui_alv_grid=>mc_fc_url_copy_to_clipboard,
cl_gui_alv_grid=>mc_fc_views,
cl_gui_alv_grid=>mc_fc_word_processor.
ENDFORM. " SET_TOOBAR
*&---------------------------------------------------------------------*
*& Form APPEND_EXCLUDE_FUNCTIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_EXCLUDE[] text
* -->P_CL_GUI_ALV_GRID=>MC_FC_CALL_AB text
*----------------------------------------------------------------------*
FORM APPEND_EXCLUDE_FUNCTIONS TABLES PT_TABLE
USING PV_VALUE.
DATA : LV_UI_FUNC TYPE UI_FUNC.
LV_UI_FUNC = PV_VALUE.
APPEND LV_UI_FUNC TO PT_TABLE.
ENDFORM. " APPEND_EXCLUDE_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form SET_EVENT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SET_EVENT .
DATA : GO_EVENT_RECEIVER TYPE REF TO lcl_event_receiver.
CREATE OBJECT GO_EVENT_RECEIVER.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter. "엔터 이벤트시
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified. "값 변경시
SET HANDLER : GO_EVENT_RECEIVER->handle_data_changed FOR g_grid,
GO_EVENT_RECEIVER->handle_double_click for g_grid.
ENDFORM. " SET_EVENT
*&---------------------------------------------------------------------*
*& Form ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_GRID_DISPLAY .
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME =
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
IS_LAYOUT = GS_LAYOUT
* IS_PRINT =
* IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = gt_exclude[]
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
* IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = GT_DISP
IT_FIELDCATALOG = GT_FIELDCAT
* IT_SORT =
* IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " ALV_GRID_DISPLAY
*&---------------------------------------------------------------------*
*& Form ALV_REFRESH_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ALV_REFRESH_TABLE .
DATA : L_STABLE TYPE LVC_S_STBL.
L_STABLE-ROW = 'X'.
L_STABLE-COL = 'X'.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = L_STABLE
* I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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. " ALV_REFRESH_TABLE
*&---------------------------------------------------------------------*
*& Form DATA_CHANGED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SENDER text
* -->P_ER_DATA_CHANGED text
*----------------------------------------------------------------------*
FORM DATA_CHANGED USING PO_SENDER
PER_DATA_CHANGED
TYPE REF TO cl_alv_changed_data_protocol.
DATA : LS_MODI TYPE LVC_S_MODI,
LS_dISP TYPE TY_DISP.
DATA : LT_CHANGED TYPE LVC_T_MODI,
LS_CHANGED TYPE LVC_S_MODI.
CASE PO_SENDER. " GRID 값이 어디에 있냐
WHEN G_GRID.
LT_CHANGED = PER_DATA_CHANGED->MT_GOOD_CELLS.
LOOP AT LT_CHANGED INTO LS_CHANGED.
CASE LS_CHANGED-FIELDNAME.
WHEN 'ERNAM'.
READ TABLE GT_DISP INTO LS_DISP INDEX LS_CHANGED-ROW_ID.
* LS_MODI-VALUE ==> 바뀐 값이므로 이를 통해 유효성 및 데이터 입력
ENDCASE.
ENDLOOP.
ENDCASE.
ENDFORM. " DATA_CHANGED
*&---------------------------------------------------------------------*
*& Form HANDLE_DOUBLE_CLICK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SENDER text
* -->P_E_ROW text
* -->P_E_COLUMN text
*----------------------------------------------------------------------*
FORM HANDLE_DOUBLE_CLICK USING
PO_SENDER
PE_ROW LIKE LVC_S_ROW
PE_COLUMN LIKE LVC_S_COL.
CASE PO_SENDER.
WHEN G_GRID.
CLEAR : GS_DISP.
READ TABLE GT_DISP INTO GS_DISP INDEX PE_row-index.
IF SY-SUBRC = 0.
IF PE_COLUMN-FIELDNAME = 'VBELN'.
IF GS_DISP-VBELN IS NOT INITIAL.
SET PARAMETER ID 'AUN' FIELD gs_DISP-VBELN.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " HANDLE_DOUBLE_CLICK
반응형
'SAP ABAP 개발 및 설명 > ABAP 템플릿 및 기능' 카테고리의 다른 글
GRID TEMPLETE 2022/01/09 #3. PBO / PAI (0) | 2022.01.09 |
---|---|
GRID TEMPLETE 2022/01/09 #2. TOP / CO1 / SEL 문 (0) | 2022.01.09 |
GRID TEMPLETE 2022/01/09 #1. MAIN 프로그램 (1) | 2022.01.09 |