Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

error in append in loop

Former Member
0 Likes
1,160

this is my code :

LOOP AT git_areas INTO gs_areas.

if gs_areas-name ne 'Pu'.

AND gs_areas-name ne 'Co'.

AND gs_areas-name ne 'In'.

APPEND gs_areas to git_areas1.

ENDIF.

ENDLOOP.

I do not want to append values where name is pu, or co or in.

but it is not working.

how i can do this ?

Study SAP

10 REPLIES 10
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,117

I think you should use capitals in the name of the areas:

if gs_areas-name ne 'PU'
AND gs_areas-name ne 'CO'.
AND gs_areas-name ne 'IN'.

Read only

Former Member
0 Likes
1,117

Hi,

Make this change, Use OR logical operation.

LOOP AT git_areas INTO gs_areas.

if gs_areas-name ne 'Pu'.

OR gs_areas-name ne 'Co'.

OR gs_areas-name ne 'In'.

APPEND gs_areas to git_areas1.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
1,117

hii,

Try using OR operator with IF condition.

regards

twinkal

Read only

Former Member
0 Likes
1,117

Hi,

Also use CONSTANTS in Capital letters like PU,CO,IN.

Read only

Former Member
0 Likes
1,117

Hi,

Use as below and it will work...


LOOP AT git_areas INTO gs_areas.
  IF gs_areas-name EQ 'Pu' OR gs_areas-name EQ 'Co' OR gs_areas-name EQ 'In'.
  ELSE.
     APPEND gs_areas to git_areas1.
  ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
1,117

HI,

Try this...

LOOP AT GIT_AREAS INTO GS_AREAS.

IF GS_AREAS-NAME NE 'PU'.

OR GS_AREAS-NAME NE 'C0'.

OR GS_AREAS-NAME NE 'IN'.

APPEND GS_AREAS to GIT_AREAS1.

ENDIF.

ENDLOOP.

Hope this will help.

Regards,

Rohan.

Edited by: Rohan on Jan 23, 2009 10:50 AM

Read only

Former Member
0 Likes
1,117

Try this

LOOP AT git_areas INTO gs_areas where name <> 'PU' and

name <> 'CO' and name <> 'IN'.

APPEND gs_areas to git_areas1.

ENDIF.

ENDLOOP.

Thanks,

Prashant

Read only

matt
Active Contributor
0 Likes
1,117

>

> Try this

>

> LOOP AT git_areas INTO gs_areas where name <> 'PU' and

> name <> 'CO' and name <> 'IN'.

>

> APPEND gs_areas to git_areas1.

>

> ENDIF.

>

> ENDLOOP.

>

> Thanks,

> Prashant

I think you mean:

LOOP AT git_areas INTO gs_areas where name NE 'PU' and name NE 'CO' and name NE 'IN'. 
  APPEND gs_areas to git_areas1.
ENDLOOP.

Read only

Former Member
0 Likes
1,117

Hi

Try

LOOP AT git_areas INTO gs_areas.

if gs_areas-name not in ( 'Pu', 'Co', 'In').

APPEND gs_areas to git_areas1.

else.

continue.

ENDIF.

ENDLOOP.

Hope this helps

Regards,

Jayanthi.K

Read only

Former Member
0 Likes
1,117

Use OR instead of AND in your IF condition and use upper case while comparing values.

LOOP AT git_areas INTO gs_areas.
if gs_areas-name ne 'PU' OR
  gs_areas-name ne 'CO' OR
  gs_areas-name ne 'IN'.
APPEND gs_areas to git_areas1.

ENDIF.

ENDLOOP.

With luck,

Pritam.