안녕하세요. 올해 초에 가입하고 처음 글을 쓰고 도움을 구하는 것 같습니다...
일을 하면서 도저히 모르겠어서 코드 참고하여 올리게 되었습니다.
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.
SELECT 구문이 너무 많네요.
LOOP 이전에
SELECT 구문을 FOR ALL ENTIRES 로 하면 될것 같아요.
본인이 직접 공부하셔야 할것 같네요.