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: 

Read Internal Table

Former Member
0 Kudos

Hi,

I have an Internal Table with 6 records, I have done sort with key field.

How can I read that Internal table in the Loop by using Binary search and Transporting keys.

Internal Table Itab.

lifnr name1

1 A

2 B

3 C

4 D

5 E

6 F

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Test the following Code hope will help you,

TYPES: BEGIN OF t_test,
  s_no TYPE i,
  name(15),
  END OF t_test.

DATA: it_test TYPE STANDARD TABLE OF t_test WITH HEADER LINE.

DO 6 TIMES.
  it_test-s_no = sy-index.
  it_test-name = 'SDN'.
  APPEND it_test to it_test.
ENDDO.
SORT it_test by s_no.

READ TABLE it_test into it_test BINARY SEARCH WITH key s_no = 1.
IF sy-subrc = 0.
  WRITE: 1 it_test-s_no, 15 it_test-name.
ENDIF.

Kind Regards,

Faisal

7 REPLIES 7

Former Member
0 Kudos

READ TABLE itab INTO wa

WITH KEY <key> = "ur key".

BINARY SEARCH.

hit an F1 on read table

кu03B1ятu03B9к

0 Kudos

In F1 Help I din't see any examples with the combination of both the Keys

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Test the following Code hope will help you,

TYPES: BEGIN OF t_test,
  s_no TYPE i,
  name(15),
  END OF t_test.

DATA: it_test TYPE STANDARD TABLE OF t_test WITH HEADER LINE.

DO 6 TIMES.
  it_test-s_no = sy-index.
  it_test-name = 'SDN'.
  APPEND it_test to it_test.
ENDDO.
SORT it_test by s_no.

READ TABLE it_test into it_test BINARY SEARCH WITH key s_no = 1.
IF sy-subrc = 0.
  WRITE: 1 it_test-s_no, 15 it_test-name.
ENDIF.

Kind Regards,

Faisal

0 Kudos

You have Read the Internal with only 1 Key Binary search,

My question is is it possible to Read an internal intoi work area with with both the Keys Binary search and Transporting.

0 Kudos

sort itab_mara by matnr ernam.

READ TABLE itab_mara into wa with key matnr = '502233 T"

ernam = value

BINARY SEARCH

TRANSPORTING matnr ernam.

U need to sort the itab by specifying both key1 and key2 in sort sequesnce.

кu03B1ятu03B9к

Edited by: kartik tarla on Feb 7, 2009 7:32 PM

former_member226203
Active Contributor
0 Kudos

sort itab by key.

READ TABLE ITAB WITH KEY = 'key u need to enter'

TRANSPORTING NO FIELDS.