07-02-2015 1:09 PM
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
07-02-2015 1:54 PM
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
07-02-2015 1:54 PM
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