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: 

Intenal table logic

Former Member
0 Kudos

Hi Friends,

I need a logic for the below mentioned thing,

for all entries in i_tab i need to check makt table with makt-matnr = i_tab-matnr.

if subrc = 0.

  • need to determine eknam

Join tables marc and t024 . fill the i_tab-eknam field with the value T024-eknam where MARC-MATNR = I_TAB-MATNR and MARC-WERKS = '0001' and MARC-EKGRP = TO24-EKGRP

endif.

Thanks in advance

6 REPLIES 6

Former Member
0 Kudos

Hi,

Use <b>inner joins</b>..It nay work out.

Regards,

Srikanth.

Former Member
0 Kudos

Hi,

select count(*)

from makt

for all entries in i_tab

where matnr = i_tab-matnr.

loop at i_tab.

select aeknam into i_tab-eknam from T024 as a inner join MARC as b where bmatnr = I_TAB-MATNR and bWERKS = '0001' and b-EKGRP = aEKGRP.

endloop.

However there is a performance issue of using select inside loop.

Regards,

Tanveer.

Please mark helpful answers

former_member181962
Active Contributor
0 Kudos

if noti_tab[] is initial.

select *

from makt

into i_makt

for all entries in i_tab

where matnr = i_tab-matnr.

endif.

select *

from marc

into i_marc

for all entries in i_makt

where matnr = i_makt-matnr

and werks = '0001'.

select *

from t024

into i_t024.

loop at i_tab.

lv_tabix = sy-tabix.

read table i_marc with key matnr = i_tab-matnr.

if sy-subrc.

read table i_t024 with key ekgrp = i_marc-ekgrp.

if sy-subrc = 0.

i_tab-eknam = i_t024-eknam.

modify i_tab index lv_index.

endif.

endif.

endif.

endloop.

Regards,

Ravi

Former Member
0 Kudos

data: records type i.

records = lines( i_tab ).

Check records GT 0.

Select matnr from makt into i_makt for all entries in i_tab where matnr = i_tab-matnr.

Check sy-subrc EQ 0.

Select amatnr beknam into i_t024

from marc as A inner join t024 as B ON aekgrp = bekgrp

for all entries in i_makt

where a~matnr = i_makt-matnr

and a~werks = 0001.

Check sy-subrc EQ 0.

field-symbols: <fs_tab> type any.

Loop at i_tab assigninig <fs_tab>.

Read table i_t024 with key matnr = <fs_tab>-matnr binary search.

if sy-subrc eq 0.

<fs-tab>-eknam = i_t024-eknam.

endif.

Endloop.

Former Member
0 Kudos

Hi,

select count(*)

from makt

for all entries in i_tab

where matnr = i_tab-matnr.

loop at i_tab.

select aeknam into i_tab-eknam from T024 as a inner join MARC as b where bmatnr = I_TAB-MATNR and bWERKS = '0001' and b-EKGRP = aEKGRP.

endloop.

However there is a performance issue of using select inside loop.

Regards,

Tanveer.

Duplicate relpy added.

Former Member
0 Kudos

select *

from makt

into table i_makt

for all entries in i_tab

where i_tab-matnr = makt-matnr.

if sy-subrc = 0.

select matnr werks

into table i_marc

from marc

for all entries in i_tab

where matnr = i_tab-matnr

and werks = '0001'.

select *

from t024

for all entries in i_marc

where ekgrp = i_marc-ekgrp.

endif.

here, while selecting the entries from marc, you can get the relevant fields. Similarly you can get the relevant fields from T024.

Later you'll have to Loop on i_t024 table and in the loop read the corresponding entry from i_marc table and use the field values and append to a custom structure containing the relevant fields.

Let me know in case of any clarifications and do acknowledge the solution.

Regards,

Ameya