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

Not getting data in main table

Former Member
0 Likes
640

Hi experts,

Can anybody tell me why i not getting data in my 'main internal table', besides getting data in my individual tables.

Plz check my code

start-of-selection.

**************************************************************

select abanfn aekgrp aafnam atxz01 amatnr awerks algort abednr

amenge ameins abadat afrgdt aebeln aebelp bebeln bebelp b~GJAHR

bbelnr bbwart bbudat bmenge b~matnr

b~werks

from ( eban as a left outer join ekbe as b on

aebeln eq bebeln and

aebelp eq bebelp )

into corresponding fields of

table eban_ekbe

where a~ekgrp in s_ekgrp and

a~afnam in s_afnam and

a~matnr in s_matnr and

a~werks eq p_werks and

a~lgort in s_lgort and

a~badat in s_badat .

select banfn ekgrp afnam txz01 matnr werks lgort bednr menge meins

badat frgdt ebeln ebelp

into table itab_eban

from eban

where ekgrp in s_ekgrp and

afnam in s_afnam and

matnr in s_matnr and

werks eq p_werks and

lgort in s_lgort and

badat in s_badat.

if itab_eban[] is not initial .

select ebeln ebelp GJAHR belnr bwart budat menge matnr werks

into table itab_ekbe1

from ekbe

for all entries in itab_eban

where ebeln = itab_eban-ebeln and

ebelp = itab_eban-ebelp and

bwart = '105' and

matnr = itab_eban-matnr and

werks eq p_werks.

endif.

if itab_eban[] is not initial .

select ebeln ebelp GJAHR belnr bwart budat menge matnr werks

into table itab_ekbe

from ekbe

for all entries in itab_eban

where ebeln = itab_eban-ebeln and

ebelp = itab_eban-ebelp and

gjahr = year and

bwart = '103' and

matnr = itab_eban-matnr and

werks eq p_werks.

endif.

loop at eban_ekbe .

loop at itab_ekbe1.

loop at eban_ekbe where ebeln <> itab_eban-ebeln .

main_table-banfn = itab_eban-banfn.

main_table-afnam = itab_eban-afnam.

main_table-txz01 = itab_eban-txz01.

main_table-matnr = itab_eban-matnr.

main_table-bednr = itab_eban-bednr.

main_table-menge1 = itab_eban-menge.

main_table-meins = itab_eban-meins.

main_table-frgdt = itab_eban-frgdt.

main_table-ebeln = itab_eban-ebeln.

main_table-belnr = itab_ekbe-belnr.

main_table-bwart = itab_ekbe-bwart.

main_table-budat = itab_ekbe-budat.

append main_table.

clear main_table.

endloop.

endloop.

endloop.

Savita

5 REPLIES 5
Read only

vinod_vemuru2
Active Contributor
0 Likes
610

Hi savitha,

Problem lies here.

Where are u populating this field itab_eban-ebeln ?


loop at itab_ekbe1.
*loop at eban_ekbe where ebeln itab_eban-ebeln .*
"I thing this should be 
*loop at eban_ekbe where ebeln EQ itab_ekbe1-ebeln.*
main_table-banfn = itab_eban-banfn.
main_table-afnam = itab_eban-afnam.
main_table-txz01 = itab_eban-txz01.
main_table-matnr = itab_eban-matnr.
main_table-bednr = itab_eban-bednr.
main_table-menge1 = itab_eban-menge.
main_table-meins = itab_eban-meins.
main_table-frgdt = itab_eban-frgdt.
main_table-ebeln = itab_eban-ebeln.
main_table-belnr = itab_ekbe-belnr.
main_table-bwart = itab_ekbe-bwart.
main_table-budat = itab_ekbe-budat.

append main_table.
clear main_table.
endloop.
endloop.
endloop.

Put break point inside 1st loop and execute ur code. It may not be entering inside the 3rd loop because of the Where clause restrictions u have for the data u r trying to execute.

Read only

former_member195383
Active Contributor
0 Likes
610

declare a work area of the type main_table. say wa_main

then in the last loop write the following

wa_main-banfn = itab_eban-banfn.

wa_main-afnam = itab_eban-afnam.

wa_main-txz01 = itab_eban-txz01.

wa_main-matnr = itab_eban-matnr.

:

:

:

so on

then

append wa_main to main_table.

this will solve ur issue...

award point if the abv ans is helpful....

Read only

0 Likes
610

Rudra,

can u plz give an example

Read only

Pramanan
Active Participant
0 Likes
610

Hi,

Don't use loop statement inside other loop statement some times if the data is not available with one loop,automatically control comes out of the whole loop and no data will be append to the main table.

Tips:

Use for all entries

Use read table statement

These will improve the performance and for secure data retrival.

Plz let me know if u want further clarification regarding this.

Read only

Pramanan
Active Participant
0 Likes
610

hi,

Make use of this for a sample code for forall entries and read table.

tables: zemptab1 ,zemptabtwo , zemptab3.

data: fieldcat type slis_t_fieldcat_alv with header line.

types: begin of block1,

id like zemptab1-id,

name like zemptab1-name,

qualification like zemptab1-qualification,

city like zemptab1-city,

age like zemptab1-age,

dcode like zemptabtwo-dcode,

desig like zemptabtwo-desig,

exp like zemptabtwo-exp,

bp like zemptab3-bp,

da like zemptab3-da,

ta like zemptab3-ta,

hra like zemptab3-hra,

pa like zemptab3-pa,

ea like zemptab3-ea,

ma like zemptab3-ma,

sal like zemptab3-sal,

end of block1.

data: inttab type table of block1 with header line,

int_tab1 type STANDARD TABLE OF zemptab1 with header line.

data: int_tab2 type standard table of zemptab2 with HEADER LINE ,

int_tab3 type standard table of zemptab3 with header line.

select * from zemptab1 into corresponding fields of table int_tab1.

select id dcode desig exp into corresponding fields of table int_tab2 from zemptabtwo for all entries IN

int_tab1 where id = int_tab1-id.

select dcode bp da ta hra pa ea ma sal into corresponding fields of table int_tab3 from zemptab3 for all entries in

int_tab2 where dcode = int_tab2-dcode.

loop at int_tab1.

inttab-id = int_tab1-id.

inttab-name = int_tab1-name.

inttab-qualification = int_tab1-qualification.

inttab-city = int_tab1-city.

inttab-age = int_tab1-age.

append inttab.

endloop.

loop at inttab.

read table int_tab2 with key id = inttab-id.

if sy-subrc eq 0.

inttab-dcode = int_tab2-dcode.

inttab-desig = int_tab2-desig.

inttab-exp = int_tab2-exp.

modify inttab.

endif.

endloop.

loop at inttab.

read table int_tab3 with key dcode = inttab-dcode.

if sy-subrc eq 0.

inttab-bp = int_tab3-bp.

inttab-da = int_tab3-da.

inttab-ta = int_tab3-ta.

inttab-hra = int_tab3-hra.

inttab-pa = int_tab3-pa.

inttab-ea = int_tab3-ea.

inttab-ma = int_tab3-ma.

inttab-sal = int_tab3-sal.

modify inttab.

endif.

endloop.