본문 바로가기
ABAP

Selection-screen 라디오 버튼 제어

by clode 2023. 2. 20.
728x90
반응형

라디오 버튼으로 화면을 제어해본다.

화면 구성

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE TEXT-005. "옵션
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(10) TEXT-006. "처리방식
PARAMETERS r1 RADIOBUTTON GROUP rg1 DEFAULT 'X' USER-COMMAND ra.
SELECTION-SCREEN COMMENT 25(10) TEXT-007 FOR FIELD r1. "엑셀 업로드
PARAMETERS r2 RADIOBUTTON GROUP rg1.
SELECTION-SCREEN COMMENT 40(10) TEXT-008 FOR FIELD r2. "개별 입력
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-003. "자재 일괄등록
PARAMETERS : p_fname  TYPE rlgrap-filename MODIF ID sc1. 
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH  FRAME TITLE TEXT-004 . "자재 개별등록
SELECT-OPTIONS : s_matnr FOR zmp_tmat-matnr NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_maktx FOR zmp_tmat-maktx NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_mtart FOR zmp_tmat-matnr NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_matkl FOR zmp_tmat-matkl NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_brgew FOR zmp_tmat-brgew NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_gewei FOR zmp_tmat-gewei NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_netpr FOR zmp_tmat-netpr NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_netwr FOR zmp_tmat-netwr NO INTERVALS NO-EXTENSION MODIF ID sc2,
                 s_waers FOR zmp_tmat-waers NO INTERVALS NO-EXTENSION MODIF ID sc2.
SELECTION-SCREEN END OF BLOCK b3.

MODIF ID는 SCREEN GROUP의 값을 할당해 Selection screen에서 parameter, select-options의 속성값을 변경한다. 라디오 버튼에 따라 보일 필드와 안보일필드에 다른 ID를 부여한다.

NO-EXTENSION Select-options에서 제공하는 다중선택을 제약한다. Low와 High값만을 입력할 수 있다.
NO INTERVALS High 필드에 대한 사용을 제약한다. Low필드만 보여지게 된다.


AT SELECTION-SCREEN OUTPUT

쉽게 PBO의 기능을 한다고 생각하면 된다.

AT SELECTION-SCREEN OUTPUT.
  PERFORM modify_screen.

가독성을 위해 로직이 길어질때는 PERFORM으로 빼주는 것이 보기 좋다.

FORM modify_screen.
  LOOP AT SCREEN.
     IF r1 = 'X'.
      IF screen-group1 = 'SC1'.
        screen-input = 1.
        screen-invisible = 0.
      ENDIF.

      IF screen-group1 = 'SC2'.
        screen-input = 0.
        screen-invisible = 1.
      ENDIF.

      MODIFY SCREEN.
    ELSEIF r2 = 'X'.
      IF screen-group1 = 'SC1'.
        screen-input = 0.
        screen-invisible = 1.
      ENDIF.

      IF screen-group1 = 'SC2'.
        screen-input = 1.
        screen-invisible = 0.
      ENDIF.

      IF screen-name = 'P_MATNR-LOW'.
        screen-input = 0.
      ENDIF.

      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDFORM.  

screen-name으로 필드를 제어할 때, parameter가 아닌 select-options로 그렸기 때문에 변수명만 적으면 로직을 타지 않는다. 반드시 low값인지, high값인지 명시해줘야 한다.

SCREEN-REQUIRED = 1 Field input mandatory
SCREEN-INPUT = 1 Field ready to accept input
SCREEN-OUTPUT = 1 Field will be displayed
SCREEN-INTENSIFIED = 1 Field highlighted
SCREEN-INVISIBLE = 1 Field invisible
SCREEN-LENGTH = 1 Field length
SCREEN-ACTIVE = 1 Field active

  • U02

화면 구성

SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE TEXT-004.
SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 01.
PARAMETERS: P_BEF RADIOBUTTON GROUP RG2 DEFAULT 'X' USER-COMMAND UCOMM MODIF ID ra2.
SELECTION-SCREEN COMMENT 05(16) TEXT-S11 FOR FIELD P_BEF MODIF ID ra2.

SELECTION-SCREEN POSITION 21.
PARAMETERS: P_AFT RADIOBUTTON GROUP RG2 MODIF ID ra2.
SELECTION-SCREEN COMMENT 25(20) TEXT-S12 FOR FIELD P_AFT MODIF ID ra2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION 01.
PARAMETERS: P_ZMPP RADIOBUTTON GROUP RG3 DEFAULT 'X' USER-COMMAND UCOMM MODIF ID ra3.
SELECTION-SCREEN COMMENT 05(16) TEXT-S13 FOR FIELD P_ZMPP MODIF ID ra3.

SELECTION-SCREEN POSITION 21.
PARAMETERS: P_ZMCO RADIOBUTTON GROUP RG3 MODIF ID ra3.
SELECTION-SCREEN COMMENT 25(20) TEXT-S14 FOR FIELD P_ZMCO MODIF ID ra3.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b4.

AT SELECTION-SCREEN OUTPUT

AT SELECTION-SCREEN OUTPUT.
  PERFORM RADIO_CONTROL.

FORM RADIO_CONTROL .
  LOOP AT SCREEN.
    CASE SCREEN-GROUP1.
      WHEN 'RA3'.
        IF P_BEF = 'X'.
          SCREEN-INVISIBLE = 1.
        ELSE.
          SCREEN-INVISIBLE = 0.
        ENDIF.
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.
ENDFORM.  
728x90
반응형

'ABAP' 카테고리의 다른 글

Selection-screen 버튼 그리기  (0) 2023.02.20
Selection-screen GUI Status 버튼 만들기  (0) 2023.02.20
Number range  (0) 2023.02.20
생산계획 엑셀업로드+BDC 프로그램 2  (0) 2023.02.20
생산계획 엑셀업로드+BDC 프로그램 1  (0) 2023.02.20

댓글