메뉴 건너뛰기

SAP 한국 커뮤니티

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

베어a 2022.11.08 01:11 조회 수 : 552

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

 

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

 

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.

번호 제목 글쓴이 날짜 조회 수
6414 alv grid 출력시 curr 타입필드 음수부호 앞으로 표시 어떻게 하는지 궁금합니다. [2] ddddd 2023.01.19 816
6413 인터널 테이블에 cbo 테이블 left join 하여 조건 처리 가능할까요? [1] 깻잎만두 2023.01.19 637
6412 S/O 생성 시 확정수량 0 오류 [1] 유반장 2023.01.09 231
6411 LVC_S_LAYO-FRONTEND 설정시 ALV 안 보이는 문제 [4] 누운소 2023.01.04 337
6410 백그라운드로 텍스트 파일 다운로드를 할 수 있을까요? [4] 수박세모 2022.12.29 344
6409 3개 테이블 merge 질문 드립니다 [1] nini 2022.12.29 396
6408 SAP 권한 관련 질문 드립니다. [5] name 2022.12.21 504
6407 공장 달력 관련 문의 드립니다. [2] 마늘맛쿨피스 2022.12.17 415
6406 ALV SORT 없이 셀 병합 질문입니다. [2] file hx 2022.12.02 734
6405 abap 단축기 ctrl+space 동작 여쭤봅니다. [2] file discod 2022.12.02 925
6404 SD_SALESDOCUMENT_CHANGE 오류 file 유반장 2022.12.01 161
6403 SAP PCE 버전에서 데이터 조회 속도문제 [1] 준서기 2022.11.26 368
6402 웹딘프로 환경설정 관련해서 질문있습니다 ㅇㅇㅇㅇㅇ 2022.11.22 142
6401 SAP 로그온 사번과 사용 사번을 다르게 하는 방법 [1] it쟁이 2022.11.15 484
6400 (초보)VIEW 데이터 저장관련 문의 드립니다. [2] file bapp 2022.11.12 245
6399 client 000 계정초기화 [2] 회기역미용실 2022.11.12 1906
6398 디버깅 실행 문의 [1] file dd 2022.11.11 214
6397 For all entries in 구문에 대하여 [2] 아밥린이 2022.11.10 2397
» loop 내 select 질문.. (코드첨부 주의..) [2] 베어a 2022.11.08 552
6395 sap hana랑 ecc 차이가 무엇이 있을까요? [2] 아밥린이 2022.11.04 1449