Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
SELECT
OBCONO,OBFACI, OBITNO,OAORTP,OKCFC0, OKCUCL,OKCUNO,
(SELECT MAX(MO.AHATAV)
FROM M3EDBPRD.MOATTR MO
WHERE MO.AHATNR = OL.OBATNR and MO.AHCONO = OL.OBCONO
AND OL.OBCONO = '500' AND (OBORST BETWEEN '22' AND '89')
AND (OBPLQT + OBALQT + OBRNQT) > 0
) PUTAWAY_CODE
FROM M3EDBPRD.OOLINE OL
Supposing you loaded first entire OOLINE and MOATTR tables in your script, you could try this:
Resulted_Table:
LOAD OBCONO, OBATNR, OBFACI, OBITNO,OAORTP,OKCFC0, OKCUCL,OKCUNO
resident OOLINE
where OBCONO = '500' AND (OBORST BETWEEN '22' AND '89')
AND (OBPLQT + OBALQT + OBRNQT) > 0;
left join
LOAD AHCONO as OBCONO, AHATNR as OBATNR, MAX(AHATAV) as PUTAWAY_CODE
resident MOATTR
group by AHATNR, AHCONO;
drop field OBATNR;
drop tables OOLINE, MOATTR;
Hope it helps
MR