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: 

Final internal table fetching

Former Member
0 Kudos

In my report.

I have select-option : for Material, Plant and Customer Region.

In my Ztable I have material group, Plant and Customer Region.

I want to fill my internal table as

Material

Plant

Customer Region.

How Can I do it, I am not getting the logic due to all in are in select-options.

Can anybody suggent me.

Thanks

kumar n

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

data : itab type table of ztable,
            wa type ztable.
  select-options : s_matnr for ztable-matnr,
                         s_werks for ztable-werks,
                         s_custom for ztable-cutomer region.

  select matnr
            werks
            customer region
            from ztable into table itab
            where matnr in s_matnr
            and werks in s_werks
            and customer region in s_custom.

loop at itab into wa.
---
endloop.

8 REPLIES 8

Former Member
0 Kudos

The variables you are using for select option, the same you can assign to an internal table.

If upper limit and lower limit are there,

lets say select option variable is var1

then give itab-var1 = var1-lower

itab-var1 = var1-upper

Former Member
0 Kudos

Can u please explain more.

from where u want to get data from selction-option or u r ztable.

regards,

Sanket.

0 Kudos

Hi,

I am getting matnr matkl from mara in where condition is s_matnr and P_matkl.

Now Matkl, werks, customer region from ztable in where condition I have selct option s_werks and s_customer_region .

I dont have field matnr on ztable.

Now i need matnr, werks and customer region in one internal table.

Hope u got it..

Please tell me how to do.

thanks

kumar n

0 Kudos

Hi Kumar,

Heres the rough logic that can be helpful to solve your problem:

SELECT * 
FROM ZTABLE
INTO IT_ZTAB
FOR ALL ENTRIES IN IT_MARA
WHERE MAKTL = IT_MARA-MAKTL AND
             WERKS = S_WERKS         AND 
             REGIO   = S_CUSTOMER_REGION.

LOOP AT IT_MARA INTO WA_MARA.

  LOOP AT IT_ZTAB INTO WA_ZTAB WHERE MAKTL = WA_MARA-MAKTL.

**Logic to append all the entries into a single internal table.
    MOVE-CORRESPONDING WA_MARA TO WA_FINAL_TAB.
    MOVE-CORRESPONDING WA_ZTAB  TO WA_FINAL_TAB.

APPEND WA_FINAL_TAB TO IT_FINAL_TAB.

  ENDLOOP.

ENDLOOP.

Here IT_FINAL_TAB contains all the fields required by you.

Regards,

Kunjal

0 Kudos

Thank you so much....

Former Member
0 Kudos

Hi Kumar,

what is the problem in logic? I think you are trying = in WHERE clause. If the field is SELECT-OPTION then you must use IN .

e.g SELECT material plant

FROM ztable

INTO itab

WHERE MATNR IN S_MATNR.

Try this.Hope this helps

Cheers,

Kothand

Former Member
0 Kudos

Hi

data : itab type table of ztable,
            wa type ztable.
  select-options : s_matnr for ztable-matnr,
                         s_werks for ztable-werks,
                         s_custom for ztable-cutomer region.

  select matnr
            werks
            customer region
            from ztable into table itab
            where matnr in s_matnr
            and werks in s_werks
            and customer region in s_custom.

loop at itab into wa.
---
endloop.

Former Member
0 Kudos

hi

try this way..

select

f1 f2 f3

from <table name>

into corressponding fields of table itab

where matnr in s_matnr

and mattype in s_matkl

and matgroup in s_matgrp.

loop at itab

write satatements..

endloop.

if u r fetching data from more than one table u can use inner join or for all entries

and if u r using more than one table then use READ TABLE

statement ...

regards

sachhidananda