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

Regarding read statement

Former Member
0 Likes
965

Hi ,

this read is not working as expected any suggestions????

SELECT * FROM cdpos INTO TABLE t_cdpos

WHERE objectid = t_cdhdr1-objectid AND

objectclas = 'EINKBELEG' AND

changenr = t_cdhdr1-changenr and

tabname = 'EKPO' .

IF sy-subrc = 0.

read table t_cdpos with

key tabkey+16(2) = tbl_output-ebelp binary search.

if sy-subrc = 0 .

l_ponum = t_cdpos-tabkey+3(10).

l_poline = t_cdpos-tabkey+16(2).

endif.

ENDIF.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
942

hi,

You need to use the sort on table t_cdpos before using Binary search in the Read Statement.

And check value exists in tbl_output-ebelp .

Edited by: avinash kodarapu on Jan 7, 2009 8:22 AM

8 REPLIES 8
Read only

Former Member
0 Likes
943

hi,

You need to use the sort on table t_cdpos before using Binary search in the Read Statement.

And check value exists in tbl_output-ebelp .

Edited by: avinash kodarapu on Jan 7, 2009 8:22 AM

Read only

Former Member
0 Likes
942

Hi,

U need to sort the table before applying Read using binary search,

Chk this

http://help.sap.com/saphelp_nw04s/helpdata/en/fa/e8a9c30c1711d5b38a0050dadfafba/frameset.htm

Regards,

Manish

Read only

former_member156446
Active Contributor
0 Likes
942

> SELECT * FROM cdpos INTO TABLE t_cdpos

> WHERE objectid = t_cdhdr1-objectid AND

> objectclas = 'EINKBELEG' AND

> changenr = t_cdhdr1-changenr and

> tabname = 'EKPO' .

> sort table t_cdpos with key key tabkey. "<<<addition

> IF sy-subrc = 0.

> read table t_cdpos with

> key tabkey+16(2) = tbl_output-ebelp binary search.

> if sy-subrc = 0 .

> l_ponum = t_cdpos-tabkey+3(10).

> l_poline = t_cdpos-tabkey+16(2).

> endif.

> ENDIF.

> ENDIF.

Read only

Former Member
0 Likes
942

always sort the internal table with the filelds that you used in read statement key ....when u use binary search ...that's it .

Read only

Former Member
0 Likes
942

Hi Revanth,

One liner from my side i.e. Sort the table before deleting the adjacent duplicate records.

regards

Sachin Sharma

Read only

Former Member
0 Likes
942

hi,

SELECT * FROM cdpos

INTO TABLE t_cdpos

WHERE objectid = t_cdhdr1-objectid AND

objectclas = 'EINKBELEG' AND

changenr = t_cdhdr1-changenr and

tabname = 'EKPO' .

IF sy-subrc = 0.

read table t_cdpos with

key tabkey+16(2) = tbl_output-ebelp binary search.

if sy-subrc = 0 .

l_ponum = t_cdpos-tabkey+3(10).

l_poline = t_cdpos-tabkey+16(2).

endif.

ENDIF.

ENDIF.

after select sort the internal table with key.

Read only

Former Member
0 Likes
942

hi,

SELECT * FROM cdpos

INTO TABLE t_cdpos

WHERE objectid = t_cdhdr1-objectid AND

objectclas = 'EINKBELEG' AND

changenr = t_cdhdr1-changenr and

tabname = 'EKPO' .

sort t_cdpos by ebelp. "with ur key

IF sy-subrc = 0.

read table t_cdpos with key tabkey+16(2) = tbl_output-ebelp binary search.

if sy-subrc = 0 .

l_ponum = t_cdpos-tabkey+3(10).

l_poline = t_cdpos-tabkey+16(2).

endif.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
942

Hi,

When you are using binary search in the read statement you want to sort the table before itself.

Have you checked the SY-SUBRC = 0 after the select statement.

Regards,

Joan