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

Check in constant Array

Former Member
0 Likes
1,987

Hi,

I want to check some values inside the loop to avoid those values...

Loop at itab.

if itab-name = 'BSA-RETRIVE'.

Return.

elseif itab-name = 'FSI-RETRIVE'.

Retrun.

else.

Append itab to lt_itab.

endloop.

For this,

I have list of values maintained as constants...

Constants:

Begin of gc_tab,

Bsa(20) type c value 'BSA-RETRIVE',

fsi(20) type c value 'FSI-RETRIVE',

......

end of gc_tab.

In my program,

I want to check as like

Loop at itab.

if itab-mname is in any of the constants, then Return.else.

append.

endloop.

How to achive this...any ideas...

8 REPLIES 8
Read only

Former Member
0 Likes
1,335

hi,

Use and in the if condition

if itab-name = 'BSA-RETRIVE' and itab-name = 'FSI-RETRIVE'

return
else
endif.

Regards

Sarves

Read only

Former Member
0 Likes
1,335

Hi,

thanks for the reply...

The problem is not with the operator...

I want to maintain as constant array...

cos later if we want to add , we can just add in the constant array...

Read only

0 Likes
1,335

Hi,

Then you can achieve this using ranges. keep all the constant values hardcoded in the range and in the loop give an if condition, saying

loop at itab-name.
if itab-name in range.
return
else.
endif.

Regards

Sarves

Read only

0 Likes
1,335

How to get the data in Range??

I am having the values in the constants which is in the Private section of the class.

Whenever I get a new value, I will just include that in the Array of constants...I dont want to touch the method again and again...This is the purpose I am doing this...

I have the data in the constants..

in the method How to refer the constants or hopw to get it in the range tab....

Read only

0 Likes
1,335

Hello


loop at itab.
  search gc_tab for itab-mname.
  if sy-subrc = 0.
    return.
  else.
* do anything here
  endif.
endloop.

Read only

Former Member
0 Likes
1,335

Hi,

Take RANGES ..r_names and fill all your constants.

Loop at itab where not name in r_names

append lt_itab.

endloop.

Regards,

Kumar Bandanadham

Read only

Former Member
0 Likes
1,335

USE BELOW CODE :

REPORT ZZZZZTEST .

CONSTANTS: BEGIN OF GC_TAB,

CON1 TYPE CHAR10 VALUE 'NARESH',

CON2 TYPE CHAR10 VALUE 'PATEL',

CON3 TYPE CHAR10 VALUE 'VINIT',

END OF GC_TAB.

DATA: BEGIN OF IT OCCURS 0,

NAME TYPE CHAR10,

END OF IT.

IT-NAME = 'NARESH'.

APPEND IT.

IT-NAME = 'PATEL'.

APPEND IT.

IT-NAME = 'VINIT'.

APPEND IT.

IT-NAME = 'PATEL1'.

APPEND IT.

IT-NAME = 'NARESH'.

APPEND IT.

IT-NAME = 'VINIT1'.

APPEND IT.

IT-NAME = 'PATEL'.

APPEND IT.

LOOP AT IT.

CASE IT-NAME.

WHEN GC_TAB-CON1.

WRITE:/ IT-NAME.

WHEN GC_TAB-CON2.

WRITE:/ IT-NAME.

WHEN GC_TAB-CON3.

WRITE:/ IT-NAME.

ENDCASE.

ENDLOOP.

Read only

Former Member
0 Likes
1,335

Hi,

I hope this will solve your problem.

DATA: typ1 TYPE c LENGTH 1,

comp1 TYPE i,

v_flag.

DATA: BEGIN OF itab OCCURS 0,

name(20),

END OF itab.

CONSTANTS: BEGIN OF lc_cons,

con1(20) VALUE 'Hello',

con2(20) VALUE 'Hai',

con3(20) VALUE 'Hi',

END OF lc_cons.

FIELD-SYMBOLS: <temp> TYPE ANY.

START-OF-SELECTION.

itab-name = 'hook'.

APPEND itab.

itab-name = 'Hai'.

APPEND itab.

DESCRIBE FIELD lc_cons TYPE typ1 COMPONENTS comp1.

LOOP AT itab.

CLEAR v_flag.

DO comp1 TIMES.

ASSIGN COMPONENT sy-index OF STRUCTURE lc_cons TO <temp>.

IF <temp> EQ itab-name.

v_flag = 'X'.

EXIT.

ENDIF.

ENDDO.

IF v_flag NE 'X'.

  • append itab to lt_itab.

ENDIF.

ENDLOOP.

Regards,

Kumar Bandanadham