FORM PRODRESULT.
DATA :
L_MATNR LIKE MARD-MATNR,
L_LGORT LIKE MARD-LGORT,
L_MAKTX LIKE MAKT-MAKTX,
L_LABST LIKE MARD-LABST,
L_NAME1 LIKE T001W-NAME1,
L_CHARG LIKE MCHB-CHARG.
SELECT
B~MATNR
B~MAKTX
A~LGORT
A~LABST
E~NAME1
D~CHARG
INTO CORRESPONDING FIELDS OF TABLE GT_PRODRESULT
FROM MARD AS A
INNER JOIN MAKT AS B
ON A~MATNR = B~MATNR
INNER JOIN T001W AS E
ON A~WERKS = E~WERKS
INNER JOIN MCHB AS D
ON A~LGORT = D~LGORT
WHERE A~LGORT IN S_LGORT1
AND E~SPRAS = SY-LANGU.
END FORM.
여기서 MCHB를 억지로 MARD 끌어오려고 했더니 결과 값이 이상해져서
INTERNAL 테이블(ACTIVITY)을 하나 더 생성해서
PRODRESULT(배치재고)에 중간에 LOOP를 돌리고
배치재고가 아닌 것은 새로운 테이블(ACTIVITY)에서 SELECT문을 돌려서
한페이지에 결과 값을 뿌려주고 싶습니다.
그래서 제가 생각한 것이
PRODRESULT 에서는
SELECT
B~MATNR
B~MAKTX
A~LGORT
A~LABST
INTO CORRESPONDING FIELDS OF TABLE GT_PRODRESULT
FROM MARD AS A
INNER JOIN MAKT AS B
ON A~MATNR = B~MATNR
WHERE A~LGORT IN S_LGORT1
AND E~SPRAS = SY-LANGU.
LOOP AT GT_PRODRESULT
END LOOP.
그리고 ACTIVITY 에서는
FORM ACTIVITY.
SELECT
A~NAME1
D~CHARG
INTO CORRESPONDING FIELDS OF TABLE GT_ACTIVITY
FROM T001W AS A
INNER JOIN MAKT AS B
ON A~MATNR = B~MATNR
WHERE E~SPRAS = SY-LANGU.
라고 하려고하는데...
개선 방법 조언 부탁드립니다...__--__
SELECT
A~MATNR
A~LGORT
A~LABST
B~CHARG
INTO CORRESPONDING FIELDS OF TABLE GT_PRODRESULT
FROM MARD AS A
INNER JOIN MCHB AS B
ON A~MATNR = B~MATNR
AND A~WERKS = B~WERKS
AND A~LGORT = B~LGORT
WHERE A~LGORT IN S_LGORT1.
LOOP AT GT_PRODRESULT.
SELECT SINGLE MAKTX INTO GT_PRODRESULT-MAKTX
FROM MAKT
WHERE MATNR = GT_PRODRESULT-MATNR
AND SPRAS = SY-LANGU.
SELECT SINGLE NAME1 INTO GT_PRODRESULT-NAME1
FROM T001W
WHERE WERKS = GT_PRODRESULT-WERKS.
MODIFY GT_PRODRESULT.
ENDLOOP.
이렇게 해보세요 ^^;;