Application Development 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: 

how to control itab

Former Member
0 Kudos
144

Hi,

I have itab data like this.

SEL-ITEMMATERIAL--QTY

X -


10----abcdes-----10

-


20-----xbyen-----20

-


30-----nhbeu-----30

If 'SEL' field having more than one 'X' i want to give message.

ponts guarantedd

kaki

8 REPLIES 8

Former Member
0 Kudos
123

Hi Kaki,

look at following

count type i value '0'.
loop at itab.
if itab-sel = 'X'.
count = count + 1.
 if count gt '1'.
  your code.
  exit.*(if needed)
 endif.
endif.
endloop.

hope it helps,

Regards,

Amit

Former Member
0 Kudos
123

Kaki,

loop at iTab into waTab.

<b>if waTab-sel+0(1) = 'X'.

if waTab-sel+1(1) = 'X'.

message ...

endif.

endif.</b>

endloop.

count = 0.

loop at iTab into waTab where sel = 'X'.

count = count + 1.

if count > 1.

message ...

endif.

endloop.

Thanks

Kam

Message was edited by: Kam

Former Member
0 Kudos
123

data: v_count.

clear v_count.

Loop at itab.

if itab-sel = 'X'.

v_count = v_count + 1.

if v_count > 2.

message e000 with 'XXXXXXXXXXXXXXXX'.

endif.

endif.

endloop.

former_member188685
Active Contributor
0 Kudos
123

Hi

Take a temp table.

data: v_lines type i.

itab_tmp[] = itab[].

delete itab_tmp where sel = ' '.

describe itab_tmp lines v_lines.

if v_line > 1.

message....

endif.

Former Member
0 Kudos
123

Hi Kaki,

How are you displaying this data to the user? Instead of giving this as a checkbox, why not give it as a radiobutton to the user?

Srinivas

Former Member
0 Kudos
123

the condition should be v_count > 1.

Former Member
0 Kudos
123

data: wa like itab,

i type i.

i = 0.

loop at itab into wa.

if wa-sel = 'X'.

i = i + 1.

endif.

if i > 1.

exit.

endif.

endloop.

regards,

Hemendra

Former Member
0 Kudos
123

HI

READ TABLE with where condition

or

Put the records in another internal table using where clause.

And then check value of SY-TFILL

SY-TFILL : contains the number of lines in the relevant internal table

If it is greater than 1.Show a message.

MESSAGE eid(MSGCLASS) WITH text.

Or else Use Radio Button.So that user is not able to select two records.

For Sample code or Radio Button.

GO TO SE38:

Program name: <b>DEMO_AT_SELECTION_ON_RADIO</b>

Cheers,

Vijay Raheja