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 with key

Former Member
0 Likes
1,162

hi all,

my question might seems to be abit silly, but i am really doubt with this,

wht the code

READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> BINARY SEARCH.

can i read a specify details from a table and display it using the code above?

let say i am having a loop passing internal table to work area, and display it, can i be done using the rad table command?

how am i going to write it?

i am facing problem with congestion of the data retrieve, and cause of long runtime error.

please help. thanks

1 ACCEPTED SOLUTION
Read only

former_member386202
Active Contributor
0 Likes
951

Hi,

Refer this code.

*--Sort table by referance document

SORT it_vbrp BY vgbel.

SORT it_mkpf BY xblnr.

IF NOT it_mkpf[] IS INITIAL.

LOOP AT it_mkpf INTO wa_mkpf.

lv_index = sy-tabix.

*--Clear

CLEAR : wa_vbrp.

READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel = wa_mkpf-xblnr

BINARY SEARCH.

IF sy-subrc EQ 0.

wa_mkpf-fkdat = wa_vbrp-fkdat.

wa_mkpf-kunnr = wa_vbrp-kunnr.

ENDIF.

MODIFY it_mkpf FROM wa_mkpf INDEX lv_index TRANSPORTING

fkdat kunnr.

*--Clear

CLEAR : wa_mkpf.

ENDLOOP.

ENDIF.

Regards,

Prashant

4 REPLIES 4
Read only

Former Member
0 Likes
951

sort internal table

READ TABLE <itab> WITH KEY <k1> = <f1>... <kn> = <fn> BINARY SEARCH.

before used binary search.

used sort internal table

Read only

former_member386202
Active Contributor
0 Likes
952

Hi,

Refer this code.

*--Sort table by referance document

SORT it_vbrp BY vgbel.

SORT it_mkpf BY xblnr.

IF NOT it_mkpf[] IS INITIAL.

LOOP AT it_mkpf INTO wa_mkpf.

lv_index = sy-tabix.

*--Clear

CLEAR : wa_vbrp.

READ TABLE it_vbrp INTO wa_vbrp WITH KEY vgbel = wa_mkpf-xblnr

BINARY SEARCH.

IF sy-subrc EQ 0.

wa_mkpf-fkdat = wa_vbrp-fkdat.

wa_mkpf-kunnr = wa_vbrp-kunnr.

ENDIF.

MODIFY it_mkpf FROM wa_mkpf INDEX lv_index TRANSPORTING

fkdat kunnr.

*--Clear

CLEAR : wa_mkpf.

ENDLOOP.

ENDIF.

Regards,

Prashant

Read only

0 Likes
951

hi,

so does this mean, read table can only return with one unit result only?

if there is more then one result, then will it loop?

let say i have a condition which, will need to fetch several data, so i cant use read table instead, have to use loop into work area?

Read only

0 Likes
951

yes ben when you need to fetch several records from the internal table

you have to use loop.

loop at itab.

read table itab with key ....binary search.

endloop.

thnkx

bhanu malik