-
Dynamic Selection ScreenSAP/ABAP 2013. 4. 15. 16:51
Selection Screen에서 파라미터나 셀렉트 옵션의 갯수가 동적으로 변할 경우 적용.
다음은 라디오버튼 예제이다.
테이블에 들어있는 데이터에 따라 미리 생성한 20개의 파라미터에 순서대로 매핑하여 출력한다.
PARAMETERS: all RADIOBUTTON GROUP fta USER-COMMAND UCF, "전체
" 확장을 위한 Dynamic selection screen
ftacd01 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd02 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd03 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd04 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd05 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd06 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd07 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd08 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd09 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd10 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd11 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd12 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd13 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd14 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd15 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd16 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd17 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd18 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd19 RADIOBUTTON GROUP fta MODIF ID FC,
ftacd20 RADIOBUTTON GROUP fta MODIF ID FC.DATA : BEGIN OF gt_ftacd OCCURS 0,
ftacd TYPE z4mmftam03-ftacd,
ftanm TYPE z4mmftam03-ftanm,
END OF gt_ftacd.
DATA : BEGIN OF gt_ipara OCCURS 0,
name(132) TYPE c,
text(132) TYPE c,
ftacd TYPE z4mmftam03-ftacd,
END OF gt_ipara.AT SELECTION-SCREEN OUTPUT.
PERFORM modify_screen.*---------------------------------------------------------------------*
* Form modify_screen
*---------------------------------------------------------------------*
FORM modify_screen.
DATA : lv_tot TYPE i,
lv_ind TYPE sy-tabix,
lv_pnt TYPE i VALUE 7. " 파라미터 인덱스 조정용
DATA : rsseltexts1 TYPE TABLE OF rsseltexts WITH HEADER LINE.
IF gt_ftacd[] IS INITIAL.
SELECT DISTINCT ftacd ftanm
INTO TABLE gt_ftacd
FROM z4mmftam03
WHERE svald <= sy-datum
AND evald >= sy-datum.
SORT gt_ftacd BY ftanm.
LOOP AT SCREEN.
IF screen-group1 = 'FC' AND screen-group3 = 'PAR'.
gt_ipara-name = screen-name.
lv_ind = screen-group4 - lv_pnt.
READ TABLE gt_ftacd INDEX lv_ind.
gt_ipara-text = gt_ftacd-ftanm.
gt_ipara-ftacd = gt_ftacd-ftacd.
APPEND gt_ipara.
CLEAR gt_ipara.
ENDIF.
ENDLOOP.
SORT gt_ipara BY name.
ENDIF.
DESCRIBE TABLE gt_ftacd LINES lv_tot.
ADD lv_pnt TO lv_tot.
LOOP AT gt_ipara.
rsseltexts1-name = gt_ipara-name.
rsseltexts1-kind = 'P'.
CONCATENATE gt_ipara-text 'FTA협정세율' INTO rsseltexts1-text
SEPARATED BY space.
APPEND rsseltexts1.
CLEAR rsseltexts1.
ENDLOOP.
CALL FUNCTION 'SELECTION_TEXTS_MODIFY'
EXPORTING
program = sy-repid
TABLES
seltexts = rsseltexts1
EXCEPTIONS
program_not_found = 1
program_cannot_be_generated = 2
OTHERS = 3.
LOOP AT SCREEN .
IF screen-group1 = 'FC'
AND screen-group3 = 'PAR'
AND screen-group4 > lv_tot.
screen-input = '0'.
screen-active = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDFORM. " modify_screen라디오버튼을 선택후 후속처리는 다음처럼 각자 알아서 하시란.
*---------------------------------------------------------------------*
* Form select_fta
*---------------------------------------------------------------------*
FORM select_fta .
DATA : lv_index(2) TYPE n.
DATA : lv_param TYPE string.
FIELD-SYMBOLS : <fs_param> TYPE ANY.
CLEAR: s_ftacd. REFRESH: s_ftacd.
CHECK all IS INITIAL. " 전체조회가 아닐경우 조건 생성
DO 20 TIMES.
lv_index = sy-index.
CONCATENATE 'FTACD' lv_index INTO lv_param.
ASSIGN (lv_param) TO <fs_param>.
IF <fs_param> IS ASSIGNED AND <fs_param> EQ 'X'.
READ TABLE gt_ipara WITH KEY name = lv_param
BINARY SEARCH.
s_ftacd-sign = 'I'.
s_ftacd-option = 'EQ'.
s_ftacd-low = gt_ipara-ftacd.
APPEND s_ftacd. CLEAR s_ftacd.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " select_fta'SAP > ABAP' 카테고리의 다른 글
테이블 90도 뒤집기(가로배열을 세로배열로) (0) 2013.04.19 한글포함여부 체크 (0) 2013.04.17 환율 그리고 독특한 날짜필드 TCURR-GDATU (0) 2013.04.11 ALV 셀별 스타일 지정 (0) 2013.03.25 배치잡 수행후 사용자에게 메시지 알림 (0) 2013.03.25