Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to bring the select statement out of loop

Dear all,

Please bring out all select statements from the loop, with out affecting the original functionality.

LOOP AT s_mch1.

CONCATENATE s_mch1-low '%' INTO s_mch1-low.

SELECT matkl FROM t023 INTO r_mch1-low

WHERE matkl LIKE s_mch1-low.

r_mch1-sign = s_mch1-sign.

r_mch1-option = s_mch1-option.

APPEND r_mch1.

CLEAR r_mch1.

ENDSELECT.

ENDLOOP.

LOOP AT s_mch2.

CONCATENATE s_mch2-low '%' INTO s_mch2-low.

SELECT matkl FROM t023 INTO r_mch2-low

WHERE matkl LIKE s_mch2-low.

r_mch2-sign = s_mch2-sign.

r_mch2-option = s_mch2-option.

APPEND r_mch2.

CLEAR r_mch2.

ENDSELECT.

ENDLOOP.

LOOP AT s_mch3.

CONCATENATE s_mch3-low '%' INTO s_mch3-low.

SELECT matkl FROM t023 INTO r_mch3-low

WHERE matkl LIKE s_mch3-low.

r_mch3-sign = s_mch3-sign.

r_mch3-option = s_mch3-option.

APPEND r_mch3.

CLEAR r_mch3.

ENDSELECT.

ENDLOOP.

Thanks

Ravi

Former Member
Not what you were looking for? View more on this topic or Ask a question