2011 Oct 06 12:49 PM
Hello
What is the best programming, putting selection in the inner join or in where clause. Below is some sample code that works but wondering if C~statu='X' would have been better in the Where part of the statement in stead as part of the inner join? Maybe don't need the Where in this select statment just code in the inner joins?
SELECT algnum abdatu btanum btapos atbnum btbpos b~werks
blgort bmatnr bmeins bmaktx bvsolm bvltyp b~vlpla
b~nlpla
INTO TABLE gt_ltak
FROM ltak AS a
INNER JOIN ltap AS b ON blgnum = algnum AND
btanum = atanum
INNER JOIN lrf_wkqu AS c ON clgnum = algnum AND
c~bname = sy-uname AND
cqueue = aqueue AND
c~statu = 'X'
INNER JOIN zis_prog_vars AS d ON d~pgm = 'ZRF_TRANS_03_0100' AND
d~fld = l_priority AND
dval1 = atbpri
WHERE a~lgnum = '170' AND
a~tanum = '0000001399'.
2011 Oct 06 4:23 PM
Hi,
Herewith the corrected version:
SELECT a~lgnum a~bdatu b~tanum b~tapos a~tbnum b~tbpos b~werks
b~lgort b~matnr b~meins b~maktx b~vsolm b~vltyp b~vlpla b~nlpla
INTO TABLE gt_ltak
FROM ltak AS a
INNER JOIN ltap AS b ON b~lgnum = a~lgnum AND
b~tanum = a~tanum
INNER JOIN lrf_wkqu AS c ON c~lgnum = a~lgnum AND
c~queue = a~queue AND
INNER JOIN zis_prog_vars AS d ON d~val1 = a~tbpri
WHERE a~lgnum = '170'
AND a~tanum = '0000001399'
AND c~bname = sy-uname
AND c~statu = 'X'
AND d~pgm = 'ZRF_TRANS_03_0100'
AND d~fld = l_priority.
Kr,
m.
Hello
What is the best programming, putting selection in the inner join or in where clause. Below is some sample code that works but wondering if C~statu='X' would have been better in the Where part of the statement in stead as part of the inner join? Maybe don't need the Where in this select statment just code in the inner joins?
SELECT algnum abdatu btanum btapos atbnum btbpos b~werks
blgort bmatnr bmeins bmaktx bvsolm bvltyp b~vlpla
b~nlpla
INTO TABLE gt_ltak
FROM ltak AS a
INNER JOIN ltap AS b ON blgnum = algnum AND
btanum = atanum
INNER JOIN lrf_wkqu AS c ON clgnum = algnum AND
c~bname = sy-uname AND
cqueue = aqueue AND
c~statu = 'X'
INNER JOIN zis_prog_vars AS d ON d~pgm = 'ZRF_TRANS_03_0100' AND
d~fld = l_priority AND
dval1 = atbpri
WHERE a~lgnum = '170' AND
a~tanum = '0000001399'.
2011 Oct 06 12:53 PM
i really would wonder if this select you coded worked at all or is compilable.
In join ONLY conditions that are neccessary to join the tables make sense. rest should be done in the where clause.
2011 Oct 06 4:23 PM
Hi,
Herewith the corrected version:
SELECT a~lgnum a~bdatu b~tanum b~tapos a~tbnum b~tbpos b~werks
b~lgort b~matnr b~meins b~maktx b~vsolm b~vltyp b~vlpla b~nlpla
INTO TABLE gt_ltak
FROM ltak AS a
INNER JOIN ltap AS b ON b~lgnum = a~lgnum AND
b~tanum = a~tanum
INNER JOIN lrf_wkqu AS c ON c~lgnum = a~lgnum AND
c~queue = a~queue AND
INNER JOIN zis_prog_vars AS d ON d~val1 = a~tbpri
WHERE a~lgnum = '170'
AND a~tanum = '0000001399'
AND c~bname = sy-uname
AND c~statu = 'X'
AND d~pgm = 'ZRF_TRANS_03_0100'
AND d~fld = l_priority.
Kr,
m.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |