메뉴 건너뛰기

SAP 한국 커뮤니티

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

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

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

 

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

 

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.

번호 제목 글쓴이 날짜 조회 수
6457 type ~ 과 type table of ~ 의 차이점에 대해 설명이 필요해요 [2] ektkdwk1234 2023.07.05 594
6456 SAP GUI 로그인 문제: 10061 [1] file dhkwlsks 2023.06.29 284
6455 퀵뷰 다른언어로 로그인 시 덤프문제 (Quick Viewer) [3] file 아좀더 2023.06.29 181
6454 ABAP으로 무한루프 돌면서 리스너 같이 구현가능할까요? [4] 로우랜즈 2023.06.26 365
6453 혹시.. REGUH, REGUP 라는 테이블을 아시나요? [4] 초밥 2023.06.20 413
6452 Selection-Screen의 Obligatory와 user-command의 관계 [1] 리자몽워터 2023.06.19 175
6451 RFC 호출시 호출한 system id 알 수 있나요? [2] 웬디 2023.06.14 408
6450 운영중인 프로그램의 꽤 큰 기능추가시 보통 어떻게 진행하시나요? [4] 로우랜즈 2023.06.02 333
6449 생산 오더(COOIS) 강제 완료 방법 문의 [2] 미자나즈 2023.05.23 389
6448 프로그램 코드 다운로드, 업로드 방법을 알고 싶습니다. [2] yoon123 2023.05.21 345
6447 No more storage space available for extending an internal table. [3] repairbalm 2023.05.15 277
6446 ALV 열 합치기 문의 [1] lalabula256 2023.04.28 423
6445 개발패키지 전체 CTS 옵션 문의 [3] file 백상아리 2023.04.27 404
6444 BDC 프로그램을 위해 레코등을 하는데요 [1] yoon123 2023.04.23 267
6443 sap gui에서는 보이는 아이콘이 fiori에서는 안보이는 문제 [4] file sapsap 2023.04.20 311
6442 ABAP 디버깅시 모드대화상자에서 call screen 허용되지 않습니다. [1] 슈퍼맨 2023.04.19 210
6441 초보질문이요. parameter field is unknown. error.. [4] rioss1004 2023.04.14 334
6440 CBO 테이블 컬럼 크기 질문 [2] bonggu 2023.04.06 340
6439 ABAP 테이블 데이터에 각각의 파일 업로드 하는 방법 [2] GPARK 2023.04.03 324
6438 a테이블과 b테이블 조인시 값제외....도와주세요 [7] 먹다망고야 2023.03.17 1339