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

Problem in read statement

Former Member
0 Likes
648

Hello Expert,

I am geting problem in read statement.

I am looping internal table Gt-ZSD0122t with vbeln and ponr and inside i am reading the one more internal table

GT_LIPS with GT_ZSD0122t-VBELN and GT_ZSD0122t-POSNR.

I have same value for vbeln and posnr in the 2 internal table than also sy-subrc i am getting 8.

So can u please tell me what is problem.

LOOP AT GT_ZSD0122T.

READ TABLE GT_LIPS INTO WA_LIPS WITH KEY VBELV = GT_ZSD0122T-VBELN

POSNV = GT_ZSD0122T-POSNR

BINARY SEARCH.

IF SY-SUBRC EQ 0.

MOVE WA_LIPS-VBELN TO GT_ZSD0122T-VBELN_D.

CLEAR:WA_LIPS-VBELN.

MODIFY GT_ZSD0122T.

ENDIF.

ENDLOOP.

what is the problem if sy-subrc equal to 8?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
617

Hello,

Before the loop sort the internal table and check


sort gt_lips by vbelv posnv.   "add this

LOOP AT GT_ZSD0122T.
READ TABLE GT_LIPS INTO WA_LIPS WITH KEY VBELV = GT_ZSD0122T-VBELN
POSNV = GT_ZSD0122T-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE WA_LIPS-VBELN TO GT_ZSD0122T-VBELN_D.
CLEAR:WA_LIPS-VBELN.
MODIFY GT_ZSD0122T.
ENDIF.
ENDLOOP.

Vikranth

5 REPLIES 5
Read only

Former Member
0 Likes
618

Hello,

Before the loop sort the internal table and check


sort gt_lips by vbelv posnv.   "add this

LOOP AT GT_ZSD0122T.
READ TABLE GT_LIPS INTO WA_LIPS WITH KEY VBELV = GT_ZSD0122T-VBELN
POSNV = GT_ZSD0122T-POSNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE WA_LIPS-VBELN TO GT_ZSD0122T-VBELN_D.
CLEAR:WA_LIPS-VBELN.
MODIFY GT_ZSD0122T.
ENDIF.
ENDLOOP.

Vikranth

Read only

Former Member
0 Likes
617

Hi ,

First u sort the internal table GT_LIPS based on vbelv and posnv .

then u can perform the binary search. because for binary serch , u should sort the table based on key field (ie u r using in read statement)

Read only

Former Member
0 Likes
617

Hi shridarudupi ,

Before using the BINARY SEARCH option in read statement you should sort the internal.

This is the primary requirement for using Binary Search.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
617

Always sort the internal table before using Binary search

SOR GT_ZSD0122T VBELV POSNV ASCENDING.

Read only

Former Member
0 Likes
617

thanks...problem solved