cancel
Showing results for 
Search instead for 
Did you mean: 

Query on internal tables

Former Member
0 Kudos

Pls any body can tell i am putting data into some internal table and doing some manupulation.

Now i want to show data from that internal table based on selection screen fields.

E.g

Select * from mkpf into corresponding fields of table itab .

now i am doing manupulation i am adding lot of rows into the internal table.

if mkpf has thrown 10 rows , iam adding another 5 rows to it.

Now based on selection screen fields i want to show the data from the internal tables so how could i do that.

eg. in selection screen

select-options : material for mkpf-matnr.

select-options : plant for mkpf-werks.

now based on this selction i want to show data from the internal table.

WhatI am doing is

read table itab with key matnr = material werks = plant.

But it is not working

Thanks and Regards

Mave

I already did

data : dtab like itab occurs 0 with header line.

loop at itab where matnr in material and werks in plant.

move-corresponding itab to dtab.

append dtab.

endloop.

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Mave,

Firstly, why don't you use the select-options on the SELECT statement? I'm not sure why you would need any other data.

ie)

Select * from mkpf

. into corresponding fields of table itab

. where field1 in so_field1.

If you don't have all of the data yet, then you have 3 ways to do what I think you want.

If you need to preserve the data in the itab, then you will loop it, and only process entries that have valid data ie)

loop at itab.

. check matnr in material.

. check werks in plant.

. do your processing to display the data.

endloop.

If you don't need to preserve the data, you can delete it up front:

delete itab where not matnr in material.

delete itab where not werks in plant.

And the third way would be the way you mentioned at the bottom of your question.

HTH,

John

Former Member
0 Kudos

Hi Mave,

See select-option form itself an internal table.

Hence, now you have two tables ...You can compare both with the key of material.

Reg,

Arpit

Former Member
0 Kudos

Hi

what do you exactly want to do?

How do you want to add other rows?

While you're looping the table you could insert other rows, but we can't now the logic you want to use:

Do you want to add other 5 rows after 10?

data: idx_append type i,

idx_time type i value 1.

loop at itab where matnr in material and werks in plant.

do idx_time times.

move-corresponding itab to dtab.

append dtab.

enddo.

idx_append = idex_append + 1.

if idx_append = 10.

idex_time = 5.

idex_append = 0.

else.

idex_time = 1.

endif.

endloop.

But you should give us more details

Max

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

loop at itab where matnr in material and werks in plant.

move-corresponding itab to dtab.

append dtab.

endloop.

I think 'and condition in loop fails'.Just try to change it as

loop at itab where matnr in material or werks in plant.

move-corresponding itab to dtab.

append dtab.

endloop.

Former Member
0 Kudos

can you provide the part of the code which you wrote for this logic?

Former Member
0 Kudos

Hi Mave,

If u use read table command then it will read only once so u have to keep that command in a loop .If u want to do in other way u can do by using select statment.

Can you please tell me how you have defined the internal table.

Message was edited by: Narasimha

guillaume-hrc
Active Contributor
0 Kudos

Look at the following :


*_ Selection of Data
Select * from mkpf into corresponding fields of table itab.

* Declaration
data : dtab like itab occurs 0 with header line.

*_ Filtering data
loop at itab where matnr in material and werks in plant.
move-corresponding itab to dtab.
append dtab.
endloop.


* Here is the output Section !
LOOP AT dbtab.
  WRITE : / dbtab.
ENDLOOP.

Message was edited by: Guillaume Garcia