02-07-2009 1:44 PM
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
02-07-2009 1:50 PM
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
02-07-2009 1:47 PM
READ TABLE itab INTO wa
WITH KEY <key> = "ur key".
BINARY SEARCH.
hit an F1 on read table
кu03B1ятu03B9к
02-07-2009 1:49 PM
In F1 Help I din't see any examples with the combination of both the Keys
02-07-2009 1:52 PM
see this sap help
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/frameset.htm
кu03B1ятu03B9к
02-07-2009 1:50 PM
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
02-07-2009 1:53 PM
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.
02-07-2009 1:57 PM
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
02-07-2009 1:55 PM
sort itab by key.
READ TABLE ITAB WITH KEY = 'key u need to enter'
TRANSPORTING NO FIELDS.