파일에 있는 그림의 화면에서요
박스체크를 안하고 INSERT를 하면 제일위에 상단에 라인이 추가되고요
앞에 박스를 체크하고 INSERT를 하면 체크된 라인의 바로 아랫부분에 라인이 추가되는건데요
커서값으로하는건 되는데 커서값이 아닌 박스로 체크하는거는 잘모르겠습니다 소스 는
TOP
TABLES : ztdd4130. "역활
*[ZTDD4130 역할] 데이터 선언
DATA : BEGIN OF itab4130 OCCURS 0,
box(1) TYPE c,
rollcode LIKE ztdd4130-rollcode, "역할
rolltxt LIKE ztdd4130-rolltxt. "역할내역
DATA : END OF itab4130.
*[ZTDD4130 역할]
DATA : BEGIN OF gt_4130 OCCURS 0.
INCLUDE STRUCTURE ztdd4130.
DATA : box.
DATA : END OF gt_4130.
* table_control
CONTROLS tc_400 TYPE TABLEVIEW USING SCREEN 400.
DATA : g_mode(2) TYPE n VALUE '03'.
DATA : fcode TYPE TABLE OF sy-ucomm.
DATA : gv_okcode TYPE sy-ucomm.
DATA :g_change.
DATA : gv_line TYPE c.
*-GET CURSOR, SET CURSOR-------------------------------------
DATA : gc_line TYPE i.
DATA : gc_field TYPE c.
DATA : danswer.
PBO
PROCESS BEFORE OUTPUT.
MODULE status_0400.
* MODULE set_cursor.
MODULE tc_400-lines.
LOOP AT itab4130 WITH CONTROL tc_400 CURSOR tc_400-current_line.
MODULE modify_screen400.
ENDLOOP.
PAI
PROCESS AFTER INPUT.
MODULE exit400 AT EXIT-COMMAND.
* MODULE get_cursor.
LOOP AT itab4130.
FIELD itab4130-rollcode MODULE rollcode-check ON REQUEST.
MODULE modify_table400.
ENDLOOP.
MODULE user_command_0400.
O01
*&---------------------------------------------------------------------*
*& Module status_0400 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0400 OUTPUT.
CLEAR fcode.
* CLEAR g_mode.
CASE g_mode.
WHEN '03'.
APPEND 'SAVE' TO fcode.
APPEND 'DISPLAY' TO fcode.
LOOP AT SCREEN.
IF screen-group1 = 'G1'.
screen-invisible = 1.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
WHEN OTHERS.
APPEND 'CHANGE' TO fcode.
ENDCASE.
SET PF-STATUS '0200' EXCLUDING fcode.
SET TITLEBAR 'TITLE2'.
ENDMODULE. " status_0400 OUTPUT
*&---------------------------------------------------------------------*
*& Module TC_400-LINES OUTPUT
*&---------------------------------------------------------------------*
MODULE tc_400-lines OUTPUT.
DESCRIBE TABLE itab4130 LINES tc_400-lines.
ENDMODULE. " TC_400-LINES OUTPUT
*&---------------------------------------------------------------------*
*& Module MODIFY_SCREEN400 OUTPUT
*&---------------------------------------------------------------------*
MODULE modify_screen400 OUTPUT.
LOOP AT SCREEN.
CASE g_mode.
WHEN '03'. "조회.
IF screen-name = 'ITAB4130-ROLLCODE'.
screen-input = 0.
ENDIF.
IF screen-name = 'ITAB4130-ROLLTXT'.
screen-input = 0.
ENDIF.
WHEN OTHERS. "변경.
IF screen-name = 'ITAB4130-ROLLTXT'.
screen-input = 1.
ENDIF.
IF itab4130-rollcode IS INITIAL.
IF screen-name = 'ITAB4130-ROLLCODE'.
screen-input = 1.
ENDIF.
ENDIF.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE. " MODIFY_SCREEN400 OUTPUT
I01
*&---------------------------------------------------------------------*
*& Module EXIT400 INPUT
*&---------------------------------------------------------------------*
MODULE exit400 INPUT.
CASE gv_okcode.
WHEN 'BACK'.
LEAVE TO SCREEN 100.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
ENDCASE.
CLEAR : gv_okcode.
ENDMODULE. " EXIT400 INPUT
*&---------------------------------------------------------------------*
*& Module MODIFY_TABLE400 INPUT
*&---------------------------------------------------------------------*
MODULE modify_table400 INPUT.
MODIFY itab4130 INDEX tc_400-current_line.
IF sy-subrc <> 0.
INSERT itab4130 INDEX tc_400-current_line.
ENDIF.
ENDMODULE. " MODIFY_TABLE400 INPUT
*&---------------------------------------------------------------------*
*& Module ROLLCODE-CHECK INPUT
*&---------------------------------------------------------------------*
MODULE rollcode-check INPUT.
DATA : lv_itab4130 LIKE itab4130 OCCURS 0 WITH HEADER LINE.
lv_itab4130[] = itab4130[].
READ TABLE lv_itab4130 WITH KEY rollcode = itab4130-rollcode.
IF sy-subrc = 0.
MESSAGE w032.
ENDIF.
ENDMODULE. " ROLLCODE-CHECK INPUT
*&---------------------------------------------------------------------*
*& Module user_command_0400 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0400 INPUT.
CASE gv_okcode.
WHEN 'INSERT'.
PERFORM insert_line4.
WHEN 'DELETE'.
PERFORM delete_line4.
WHEN 'SAVE'.
PERFORM save_data4.
WHEN 'CHANGE'.
g_mode = '02'.
WHEN 'DISPLAY'.
g_mode = '03'.
REFRESH itab4130.
PERFORM select_data400.
ENDCASE.
CLEAR : gv_okcode.
ENDMODULE. " user_command_0400 INPUT
fom
*&---------------------------------------------------------------------*
*& Form select_data400
*&---------------------------------------------------------------------*
FORM select_data400 .
IF itab4130[] IS INITIAL.
CLEAR : itab4130, itab4130[].
SELECT *
INTO CORRESPONDING FIELDS OF TABLE itab4130
FROM ztdd4130.
ENDIF.
g_mode = '03'.
ENDFORM. " select_data400
*&---------------------------------------------------------------------*
*& Form insert_line4
*&---------------------------------------------------------------------*
FORM insert_line4 .
IF gv_line IS INITIAL.
INSERT INITIAL LINE INTO itab4130 INDEX tc_400-top_line.
ELSE.
gc_line = gc_line + tc_400-top_line." - 1하면 위로 INSERT
INSERT INITIAL LINE INTO itab4130 INDEX gc_line.
ENDIF.
gv_line = 'x'.
ENDFORM. " insert_line4
*&---------------------------------------------------------------------*
*& Form delete_line4
*&---------------------------------------------------------------------*
FORM delete_line4 .
READ TABLE itab4130 WITH KEY box = 'X'.
* IF itab4130-box = 'X'.
CALL FUNCTION 'POPUP_TO_CONFIRM_LOSS_OF_DATA'
EXPORTING
textline1 = '데이터를 삭제하시겠습니까?'
* TEXTLINE2 = ' '
titel = '삭제'
IMPORTING
answer = danswer.
IF danswer = 'J'.
LOOP AT itab4130.
READ TABLE itab4130 WITH KEY box = 'X'.
IF sy-subrc = 0.
DELETE itab4130 INDEX sy-tabix.
ENDIF.
ENDLOOP.
MESSAGE s024.
ELSE.
MESSAGE w031.
ENDIF.
ENDFORM. " delete_line4
*&---------------------------------------------------------------------*
*& Form save_data4
*&---------------------------------------------------------------------*
FORM save_data4 .
CLEAR :gt_4130, gt_4130[].
LOOP AT itab4130.
gt_4130-rollcode = itab4130-rollcode.
gt_4130-rolltxt = itab4130-rolltxt.
gt_4130-box = itab4130-box.
APPEND gt_4130.
ENDLOOP.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
textline1 = '저장하시겠습니까?'
* TEXTLINE2 = ' '
titel = '저장'
* START_COLUMN = 25
* START_ROW = 6
cancel_display = ' '
IMPORTING
answer = danswer.
IF danswer = 'J'.
DELETE FROM ztdd4130.
* INSERT ztdd4130 FROM TABLE gt_4130.
MODIFY ztdd4130 FROM TABLE gt_4130.
SORT itab4130 BY rollcode ASCENDING.
IF sy-subrc = 0.
MESSAGE s011 .
ELSE.
MESSAGE i030 .
ROLLBACK WORK.
ENDIF.
ELSE.
MESSAGE w027.
ENDIF.
ENDFORM. " save_data4
댓글 4
-
Jaden
2009.03.20 03:36
-
gold club
2009.03.20 03:39
소트버튼은 사용하지 않고 조회버튼을 눌렀을때 입력한 값들에 대해서 소트 되도록 했습니다..
-
SAYA
2009.03.20 04:03
SCREEN LAYOUT 에서 TABLE CONTROL 속성창을 열고
하단 부분 FIXED COLUMNS 위에 있는
W/SELCOLUMN 에 필드를 하나 생성해야 합니다.
EX) ITAB4130-MARK
체크는 PAI 부분에서 적용하면 되겠죠.
LOOP AT ITAB4130.
IF ITAB4130-MARK EQ 'X'.
ENDIF.
ENDLOOP.
-
gold club
2009.03.23 20:24
감사합니다 많은 도움되었네요
sort 버튼을 사용하시지 않는다는 전제에..
itab4130 에 라인체크용 필드를 하나 추가하시고
data g_count type i.
clear g_count.
loop at itab4130.
g_count = g_count + 1.
if 마크 NE 'X'.
itab4130-line = g_count.
modify itab4130. clear itab4130.
else.
itab4130-line = g_count.
modify itab4130. clear itab4130.
itab4130-line = g_count + 1.
append itab4130. clear itab4130.
endif.
sort itab4130 by line.
endloop.
이렇게 하시면 어떠실지..ㅎ