Skip to Content

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

collect statement

hi

I am having a problem while using COLLECT statement.

I have a table ITAB1 with field WERKS.

I want collect statement to run only if ITAB-WERKS is not equal to 2130. and the output is required in table ITAB.

This is the code i have written. without IF statement the output is coming as expected but with IF statemnt its not working . can anyone suggest what is to be done.

code:

LOOP AT ITAB1.

IF ITAB1-WERKS NE '2130'.

MOVE CORRESPONDING ITAB1 INTO ITAB.

COLLECT ITAB.

ELSE.

MOVE CORRESPONDING ITAB1 INTO ITAB.

ENDIF.

ENDLOOP.

Tags:
Former Member
replied

Hello Gautam,

Try this way:

LOOP AT ITAB1 where WERKS NE '2130'.
MOVE CORRESPONDING ITAB1 INTO ITAB.
COLLECT ITAB.
endloop.

LOOP AT ITAB1 where WERKS EQ '2130'.
MOVE CORRESPONDING ITAB1 INTO ITAB.
append itab.
ENDLOOP.

Regards,

Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question