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: 

find maximum number of OBKNR (Object list number)

former_member212786
Participant
0 Kudos

Hi All,

In  table SER01, it has fields LIEF_NR and POSNR

For a any given combination of LIEF_NR and POSNR ( I mean for any doc and item combination), what is the maximum number of OBKNR.

I want to know how to find maximum number of OBKNR.

rgds,

Rathinakumar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

RK,

If you are looking for to do this within a program:

SELECT lief_nr posnr obknr FROM ser01 INTO TABLE lt_res FOR ALL ENTRIES IN lt_xyz WHERE lief_nr = lt_xyz-lief_nr AND posnr = lt_xyz-posnr.

IF sy_subrc IS INITIAL.

SORT lt_res BY lief_nr posnr ASCENDING obknr DESCENDING.

ENDIF.

When you read you table the first entry should have the highest value.

Other option would be to use 'MAX' in your select.

Thanks,

Vikram.M

1 REPLY 1

Former Member
0 Kudos

RK,

If you are looking for to do this within a program:

SELECT lief_nr posnr obknr FROM ser01 INTO TABLE lt_res FOR ALL ENTRIES IN lt_xyz WHERE lief_nr = lt_xyz-lief_nr AND posnr = lt_xyz-posnr.

IF sy_subrc IS INITIAL.

SORT lt_res BY lief_nr posnr ASCENDING obknr DESCENDING.

ENDIF.

When you read you table the first entry should have the highest value.

Other option would be to use 'MAX' in your select.

Thanks,

Vikram.M