메뉴 건너뛰기

SAP 한국 커뮤니티

loop 내 select 질문.. (코드첨부 주의..)

베어a 2022.11.07 16:11 조회 수 : 417

안녕하세요. 올해 초에 가입하고 처음 글을 쓰고 도움을 구하는 것 같습니다...

 

일을 하면서 도저히 모르겠어서 코드 참고하여 올리게 되었습니다.

 

loop내 select를 지양하고 있는 것을 인지하고 있으며 바깥으로 꺼내는 와중에 

 

READ TABLE ~ WITH KEY를 사용하는 것으로 인지하고 있는데요.

 

그리고 SELECT * 또한 과도하게 데이터를 불러들여 과부하가 걸리는 원인에 대해서는 인지하고 있습니다.

 

현재 LOOP 문에서의 SELECT를 꺼내주시면 감사하겠습니다.. FUCNTION MODULE이라 얽힌 프로그램들이 많고 <= >= 경우 어떠하게 KEY를 선언하는지.. 모르겠습니다..

 

도움 주시면 정말로 감사하겠습니다..

 

 

IF lt_9001 IS NOT INITIAL.

    LOOP AT lt_9001 INTO ls_9001.

      ls_list-pernr = ls_9001-pernr.

      ls_list-orgeh = ls_9001-orgeh.

      ls_list-begda = ls_9001-begda.

      ls_list-endda = ls_9001-endda.

      ls_list-massn = ls_9001-massn.

      ls_list-massg = ls_9001-massg.

      ls_list-aedtm         = ls_9001-aedtm.  " 최종변경일

      ls_list-uname         = ls_9001-uname. "최종변경 사번

      ls_list-title    = ls_9001-appoint.      "발령내용 추가

 

      " 발령유형/사유 Text 취득.

      CALL FUNCTION 'ZHR_GET_MASSN_MASSG'

        EXPORTING

          iv_massn = ls_list-massn

          iv_langu = sy-langu

          iv_massg = ls_list-massg

        IMPORTING

          ev_mntxt = ls_list-mntxt

       ev_mgtxt = ls_list-mgtxt

          ev_psort = ls_list-psort.

 

      "조직txt 취득

      IF ls_9001-zzorgeh IS NOT INITIAL.

        SELECT SINGLE orgtx FROM t527x INTO ls_list-orgtx

          WHERE orgeh = ls_9001-zzorgeh

              AND  sprsl = sy-langu

              AND begda <= ls_9001-begda

              AND endda >= ls_9001-begda.

      ELSE.

        SELECT SINGLE orgtx FROM t527x INTO ls_list-orgtx

          WHERE orgeh = ls_9001-orgeh

              AND  sprsl = sy-langu

              AND begda <= ls_9001-begda

              AND endda >= ls_9001-begda.

      ENDIF.

 

 

      CLEAR: ls_orgeh_info.

      CALL FUNCTION 'ZHR_GET_ORGEH_TEAM'

        EXPORTING

          iv_objid  = ls_list-pernr

          iv_flag   = 'P'

          iv_begda  = ls_list-begda

          iv_endda  = ls_list-begda

          iv_o_text = 'X'

        IMPORTING

          es_info   = ls_orgeh_info.

      ls_list-orgeh = ls_orgeh_info-orgeh.

      ls_list-orgtx = ls_orgeh_info-orgtx.

 

      IF ls_9001-massn = 'A5' OR ls_9001-massn = 'A7'. "위촉 또는 재위촉

        IF ls_9001-endda = '99991231'.

          ls_list-endda = ls_9001-redat.

        ELSE.

          ls_list-endda = ls_9001-endda.

        ENDIF.

      ENDIF.

      IF lv_check_ok IS INITIAL.

        " 겸직일

        SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9002

          FROM pa9002

          WHERE pernr = ls_list-pernr

            AND docno = ls_9001-docno

            AND massn = ls_9001-massn.

        IF sy-subrc = 0.

          IF ls_9002-endda = '99991231'.

            ls_list-endda = ls_9002-redat.

          ELSE.

            ls_list-endda = ls_9002-endda.

          ENDIF.

          lv_check_ok = 'X'.

        ENDIF.

      ENDIF.

 

      IF lv_check_ok IS INITIAL.

        IF ls_9001-massn EQ 'N5'.   "복귀일

 

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9003

            FROM pa9003

            WHERE pernr = ls_list-pernr

              AND docno = ls_9001-docno.

          IF sy-subrc = 0.

            IF ls_9003-acdat_e IS NOT INITIAL.

              ls_list-begda = ls_9003-acdat_e.       "복귀발령일

              ls_list-endda = ls_9003-acdat_e.      "복귀발령일

            ENDIF.

            lv_check_ok = 'X'.

          ENDIF.

 

        ELSE.     "파견일

 

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9003

            FROM pa9003

            WHERE pernr = ls_list-pernr

              AND massn = ls_9001-massn

              AND begda = ls_9001-begda.

          IF sy-subrc = 0.

            IF ls_9003-endda = '99991231'.

              IF ls_9003-acdat_b IS NOT INITIAL.

                ls_list-begda = ls_9003-acdat_b. " 해외주재 발령일자

              ENDIF.

              ls_list-endda = ls_9003-redat.

            ELSE.

              ls_list-endda = ls_9003-endda.

              IF ls_9003-acdat_e IS NOT INITIAL.

                ls_list-endda = ls_9003-acdat_e. " 복귀 발령일자

              ENDIF.

              IF ls_9003-acdat_b IS NOT INITIAL.

                ls_list-begda = ls_9003-acdat_b. " 해외주재 발령일자

              ENDIF.

            ENDIF.

            lv_check_ok = 'X'.

          ENDIF.

        ENDIF.

      ENDIF.

 

      IF lv_check_ok IS INITIAL.

        "휴직일

        SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9005

          FROM pa9005

          WHERE pernr = ls_list-pernr

            AND docno = ls_9001-docno.

        IF sy-subrc = 0.

          IF ls_9005-endda = '99991231'.

            ls_list-endda = ls_9005-redat.

          ELSE.

            ls_list-endda = ls_9005-endda.

          ENDIF.

          lv_check_ok = 'X'.

        ENDIF.

      ENDIF.

 

 

      CLEAR: ls_9214, lv_endda_t.

      CASE ls_list-massn.

        WHEN 'W3'. " 운항 Rank

          CLEAR ls_9214.

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

              FROM pa9214

           WHERE pernr = ls_list-pernr

                AND gubun = '1'

                AND begda = ls_9001-begda.

          IF sy-subrc <> 0.

            ls_9214-flight_rank = ls_9001-flight_rank.

          ENDIF.

 

        WHEN 'W1'. "운항 보직

          CLEAR ls_9214.

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

              FROM pa9214

           WHERE pernr = ls_list-pernr

                AND docno = ls_9001-docno.

          IF sy-subrc <> 0.

            SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

                FROM pa9214

             WHERE pernr = ls_list-pernr

                  AND begda = ls_9001-begda

                  AND gubun = '2'.

            IF sy-subrc <> 0.

              ls_9214-flight_task = ls_9001-flight_task.

            ENDIF.

          ENDIF.

 

        WHEN 'W6'. "운항 보직 해임

          CLEAR ls_9214.

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

              FROM pa9214

           WHERE pernr = ls_list-pernr

                AND docno = ls_9001-docno.

          IF sy-subrc <> 0.

            lv_endda_t = ls_9001-begda - 1.

            SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

                FROM pa9214

             WHERE pernr = ls_list-pernr

                  AND endda = lv_endda_t

                  AND gubun = '2'.

            IF sy-subrc <> 0.

              ls_9214-flight_task = ls_9001-flight_task.

            ENDIF.

          ENDIF.

 

        WHEN 'W2'. "운항 교관

          CLEAR ls_9214.

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

              FROM pa9214

           WHERE pernr = ls_list-pernr

                AND docno = ls_9001-docno

                AND instructor = ls_9001-instructor.

          IF sy-subrc <> 0.

            SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

                FROM pa9214

             WHERE pernr = ls_list-pernr

                  AND begda = ls_9001-begda

                  AND gubun = '3'

                  AND instructor = ls_9001-instructor.

            IF sy-subrc <> 0.

              ls_9214-instructor = ls_9001-instructor.

            ENDIF.

          ENDIF.

 

        WHEN 'W7'. "운항 교관 해임

          CLEAR ls_9214.

          SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

              FROM pa9214

           WHERE pernr = ls_list-pernr

                AND docno = ls_9001-docno

                AND instructor = ls_9001-instructor.

          IF sy-subrc <> 0.

            lv_endda_t = ls_9001-begda - 1.

            SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_9214

                FROM pa9214

             WHERE pernr = ls_list-pernr

                  AND endda = lv_endda_t

                  AND gubun = '3'

                  AND instructor = ls_9001-instructor.

            IF sy-subrc <> 0.

              ls_9214-instructor = ls_9001-instructor.

          ENDIF.

          ENDIF.

      ENDCASE.

 

 

{ 발령내용 텍스트

      CLEAR ls_temp.

      MOVE-CORRESPONDING ls_list TO ls_temp.

 

**      9001(발령추가) 데이터 기준으로 출력(같은날짜 발령처리)

      IF ls_9001-model IS NOT INITIAL.

        ls_temp-model = ls_9001-model.

      ELSE.

        ls_temp-model  = ls_9214-model.

      ENDIF.

      IF ls_9001-flight_rank IS NOT INITIAL.

        ls_temp-flight_rank = ls_9001-flight_rank.

 

      ELSE.

        ls_temp-flight_rank = ls_9214-flight_rank.

      ENDIF.

      IF ls_9001-flight_task IS NOT INITIAL.

        ls_temp-flight_task = ls_9001-flight_task.

      ELSE.

        ls_temp-flight_task = ls_9214-flight_task.

      ENDIF.

      IF ls_9001-instructor IS NOT INITIAL.

        ls_temp-instructor = ls_9001-instructor.

      ELSE.

        ls_temp-instructor = ls_9214-instructor.

      ENDIF.

 

      PERFORM get_desc_action_content_ep CHANGING lv_erdat ls_temp .

      ls_list-title = ls_temp-title.

 

      APPEND ls_list TO et_list.

      CLEAR: ls_list, ls_9001, ls_9002, ls_9003, ls_9005, lv_check_ok.

    ENDLOOP.

번호 제목 글쓴이 날짜 조회 수
6432 SAP BSP 오류가 납니다. [2] yoon123 2023.03.05 199
6431 SAP 에러 "SAPMM07I 0731 화면에 대한 배치 입력 데이터가 없습?" [1] saq왕초보 2023.03.02 369
6430 LSMW with 펑션 [1] file 제니킴킴. 2023.02.23 166
6429 자재간 재고 이동 관련 문의 건 [1] 미자나즈 2023.02.23 343
6428 SAP MIGO 출고 시 문의 [2] 미자나즈 2023.02.22 228
6427 bdc 과제중 막혓어요 흑흑 [1] file 쭈니동 2023.02.22 987
6426 DB 테이블에 저장할때.... [1] file 아밥어린이 2023.02.22 227
6425 SAP 노츠 보는 법 [2] file 제니킴킴. 2023.02.20 359
6424 SAP 입고 날짜 변경 [1] 배기사 2023.02.13 212
6423 RFC를 통한 파일 다운로드, 업로드 [2] 누보야 2023.02.13 231
6422 GV_TITLE = SY-TITLE 어떨때 쓰는건가요? 안써도 상관없나요? [7] file 아밥어린이 2023.02.13 261
6421 ALV 기능추가에 대한 질문입니다!!! [2] file 아밥어린이 2023.02.04 275
6420 se80에서 오브젝트 우클릭하면 나오는 메뉴의 언어 (독일어로 나와요 ㅠㅜ) [2] file 흐르링 2023.02.02 251
6419 gs_layout-cwidth_opt = 'A'와 'X'의 차이가 있나요? [3] nnem 2023.02.02 454
6418 SAP GUI 렉발생 [2] file 엽떡 2023.02.01 301
6417 EASY ABAP 2.0 - Z11_08 예제 문의 [2] file hunseop2 2023.01.20 283
6416 alv grid 출력시 curr 타입필드 음수부호 앞으로 표시 어떻게 하는지 궁금합니다. [2] ddddd 2023.01.19 369
6415 인터널 테이블에 cbo 테이블 left join 하여 조건 처리 가능할까요? [1] 깻잎만두 2023.01.18 488
6414 S/O 생성 시 확정수량 0 오류 [1] 유반장 2023.01.09 184
6413 LVC_S_LAYO-FRONTEND 설정시 ALV 안 보이는 문제 [4] 누운소 2023.01.04 228