산넘어 산이군요.
IF sy-tcode EQ 'ZINV1' OR sy-tcode EQ 'ZINV3'.
SELECT
MAKT~MATNR
MAKT~MAKTX
MARA~MATKL
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM MAKT
INNER JOIN MARA ON MAKT~MATNR = MARA~MATNR
WHERE MARA~MATKL IN ('YG1','YG2','YG3').
ELSE.
SELECT
MAKT~MATNR
MAKT~MAKTX
MARA~MATKL
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM MAKT
INNER JOIN MARA ON MAKT~MATNR = MARA~MATNR
WHERE MARA~MATKL IN ('YG4','YG5','YG6').
ENDIF.
위와 같은 방법은 비효율적인것 같아서
('YG1','YG2','YG3')
이부분만 if 문으로 s_group 변수에 담아놓고 SQL은 한번만 실행시키고 싶습니다.
s_group 변수를 SQL문에 어떻게 적용해야하나요?
댓글 4
-
나왜이케매짜?
2010.05.27 23:35
-
rain shower
2010.05.27 23:47
s_group을 range변수선언하여서 in 문장으로 쓰심될것 같은데요..
ex> ranges : s_group for mara-matkl.
DEFINE mac_type.
s_group-sign = 'I'.
s_group-option = 'EQ'.
s_group-low = &1.
END-OF-DEFINITION.
IF sy-tcode EQ 'ZINV1' OR sy-tcode EQ 'ZINV3'.
mac_type 'Y1'.
mac_type 'Y2'.
mac_type 'Y3'.
else.
mac_type 'Y4'.
mac_type 'Y5'.
mac_type 'Y6'.
endif.
SELECT
MAKT~MATNR
MAKT~MAKTX
MARA~MATKL
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM MAKT
INNER JOIN MARA ON MAKT~MATNR = MARA~MATNR
WHERE MARA~MATKL IN s_group.
아니면
DATA cond_syntax TYPE string.
조건에 따라...
if sy-tcode EQ 'ZINV1' OR sy-tcode EQ 'ZINV3'.
concatenate .... into cond_syntax BY space.
else.
concatenate .... into cond_syntax BY space.
endif.
SELECT
MAKT~MATNR
MAKT~MAKTX
MARA~MATKL
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM MAKT
INNER JOIN MARA ON MAKT~MATNR = MARA~MATNR
WHERE (cond_syntax).
뭐..이렇게 하셔도 될것같은 느낌^^ 편한걸로 쓰심될것 같아요 ^^
-
모포
2010.05.28 00:29
어이구 감사합니다. 오오오
-
맑은하늘
2010.05.28 18:18
DATA conditon type table of string.
CLEAR CONDITION.
IF sy-tcode EQ 'ZINV1' OR sy-tcode EQ 'ZINV3'.
APPEND 'MARA~MATKL IN (`YG1`,`YG2`,`YG3`)' TO CONDITON.
ELSE.
APPEND 'MARA~MATKL IN (`YG4`,`YG5`,`YG6`)' TO CONDITON.
ENDIF.
SELECT
MAKT~MATNR
MAKT~MAKTX
MARA~MATKL
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM MAKT
INNER JOIN MARA ON MAKT~MATNR = MARA~MATNR
WHERE (CONDITION).
그냥 이렇게 하셔도 될 것 같은데요.^^
RANGES: r_matkl FOR mara-matkl.
CLEAR: r_matkl.
REFRESH r_matkl.
IF sy-tcode EQ 'ZINV1' OR sy-tcode EQ 'ZINV3'.
r_matkl-sign = 'I'.
r_matkl-option = 'EQ'.
r_matkl-low = 'YG1'.
APPEND r_matkl. CLEAR r_matkl.
r_matkl-sign = 'I'.
r_matkl-option = 'EQ'.
r_matkl-low = 'YG2'.
APPEND r_matkl. CLEAR r_matkl.
r_matkl-sign = 'I'.
r_matkl-option = 'EQ'.
r_matkl-low = 'YG3'.
APPEND r_matkl. CLEAR r_matkl.
ENDIF.
SELECT
makt~matnr
makt~maktx
mara~matkl
INTO CORRESPONDING FIELDS OF TABLE gt_data
FROM makt
INNER JOIN mara ON makt~matnr = mara~matnr
WHERE mara~matkl IN r_matkl.