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

Former Member
0 Likes
539

READ TABLE internal table with KEY matnr = <fs>-matnr

werks = <fs>-werks

erfme = <fs>-erfme

lgort <> SPACE.

This code does not compile because of the lgort negative condition. Is there aonther wa I can find the index of the internal table meeting all of the conditions above?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
509

You should sort the table in matnr, werks, erfme ascending and lgort descending, then:

READ TABLE internal table with KEY matnr = <fs>-matnr
werks = <fs>-werks
erfme = <fs>-erfme 
binary search.

If there is a record that has lgort NE SPACE, it will be picked, but if there is only a record with LGORT = SPACE, it will also be picked, so you have to check after the read the value of LGORT.

I am assuming that since you haven't stated otherwise, you are using a standard table.

Rob

Edited by: Rob Burbank on Feb 23, 2009 4:14 PM

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
509

May be this way


loop at  internal table where matnr = <fs>-matnr
                                    and werks = <fs>-werks
                                    and  erfme = <fs>-erfme
                                    and lgort SPACE..
v_tabix = sy-tabix.
exit
endloop.

a®

Read only

Former Member
0 Likes
510

You should sort the table in matnr, werks, erfme ascending and lgort descending, then:

READ TABLE internal table with KEY matnr = <fs>-matnr
werks = <fs>-werks
erfme = <fs>-erfme 
binary search.

If there is a record that has lgort NE SPACE, it will be picked, but if there is only a record with LGORT = SPACE, it will also be picked, so you have to check after the read the value of LGORT.

I am assuming that since you haven't stated otherwise, you are using a standard table.

Rob

Edited by: Rob Burbank on Feb 23, 2009 4:14 PM

Read only

faisalatsap
Active Contributor
0 Likes
509

Hi, Gregory.

Please try following

data: indx like sy-tabix.
Loop at it into it where matnr EQ <fs>-matnr and werks EQ <fs>-werks and erfme EQ <fs>-erfme and lgort NE ''.
indx = sy-tabix.
exit.
endloop.
write: indx.

Hope will Solve out your problem,

Please Reply if any issue,

Kind Regards,

Faisal