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

Read Table

Former Member
0 Likes
1,329

HI

I have selected the objid, sobid from hrp1001 into one internal table itab where relat = '008'.

Now im looping another internal table .This table contains objid. Inside this table i want to read the table itab with key objid = itab1-objid. And

if sy-subrc = 0.

wa_users-sobid = wa_hrp1001-sobid.

APPEND wa_users to it_users.

Endif.

Here im facing one problem like inside itab i have the values like 5000314 Anirban

5000314 Fahad

In this case im getting only one user. I need both the users.

How can i write the read statement. Can i write read table statement with both index & with key.

Please help me.

11 REPLIES 11
Read only

Former Member
0 Likes
1,295

hiii

yes you can write READ statement with more then one keys like below

READ TABLE i_bom INTO wa_bom WITH KEY ebeln = wa_ekpo-ebeln
                                              matnr = wa_ekpo-matnr
                                              bmtnr = wa_quantity-idnrk
                                              BINARY SEARCH.

regards

twinkal

Read only

0 Likes
1,295

Hi

I have already written read statement inside the loop like this

loop at it_obj into wa_obj.

Read table it_hrp1001 into wa_hrp1001 with key objid = wa_obj-objid.

if sy-subrc eq 0.

wa_users-sobid = wa_hrp1001-sobid.

APPEND wa_users to it_users.

endif.

endloop.

My question is here inside it_hrp1001 table im having two records like

objid sobid

-


-


5000314 Jesmila

5000314 fahad

here after read statement im getting only one record..

how to read both the statement

Read only

Former Member
0 Likes
1,295

Hi,

Check this:

loop at itab into wa_user.
if wa_users-sobid = wa_hrp1001-sobid.
APPEND wa_users to it_users.
endif.
endloop.

Regards

Adil

Read only

Former Member
0 Likes
1,295

Instead of READ use loop statement as READ only fetches the 1st records that is matching the criteria at a time..

loop at itab1.

loop at itab where objid = itab1-objid.

wa_users-sobid = wa_hrp1001-sobid.

APPEND wa_users to it_users.

endloop.

endloop.

Regards,

Joy.

Read only

former_member787646
Contributor
0 Likes
1,295

Hi,

Try this...

Data: ITAB (Your own internal goes here with 2 fields),

ITAB2 LIKE ITAB1 OCCURS 0,

ITAB3 LIKE ITAB1 OCCURS 0.

ITAB2[] = ITAB[].

sort itab2 by objid.

Delete Adjacent duplicates from ITAB2 comparing objid.

Loop at ITAB2.

Refresh ITAB3.

Insert TABLE ITAB3 Where KEY EBELN = ITAB2-objid.

IF sy-subrc = 0.

Loop at ITAB3.

..........

..........

EndLoop.

EndIf.

EndLoop.

Hope this would help you.

Murthy

Read only

Former Member
0 Likes
1,295

Hima,

sort i_bom by matnr bmtnr."sorting is must
READ TABLE i_bom INTO wa_bom WITH KEY ebeln = wa_ekpo-ebeln
                                              matnr = wa_ekpo-matnr
                                              bmtnr = wa_quantity-idnrk
                                              BINARY SEARCH.

Amit.

Read only

Former Member
0 Likes
1,295

Hi Hima,

you can try sumthing like;

loop itab into wa1.

  loop itab into wa where objid = wa1-objid.

  wa_users-sobid = wa_hrp1001-sobid.

  APPEND wa_users to it_users.

  delete itab from wa.

  endloop.
endloop.

With luck,

Pritam

Read only

Former Member
0 Likes
1,295

try this

loop at itab into wa.

if wa-sobid = wa_hrp1001-sobid.

APPEND wa_ to it_users.

endif.

endloop.

Read only

Former Member
0 Likes
1,295

loop at itab1.

loop at itab2 where sobid = itab1-sobid..

final-... = itab2-...

final-....= itab1-....

APPEND final.

endloop.

Above code satisfies ur requirement.

rwrd points if helpful

Bhupal

Read only

Former Member
0 Likes
1,295

Hi Hima,

sort the internal table itab by key field.

Describe itab lines <var>

do <var> times.

read table itab with key objid = itab1-sobid.

enddo.

regards

padma

Read only

Former Member
0 Likes
1,295

Hello Hima,

you can use the loop.. endloop

Or if you want to use only the READ TABLE.. statement, try this..

describe table itab lines w_line.

loop at itab2

read table itab1 into wa_itab1 with key <condition>

append....

endloop.

Indu.