‎2022 Sep 23 6:06 AM
Hi Team,
I have a requirement where i want to find the min value( combination of both date and time) based on a transaction number using sy-tabix variable. Any input will be greatly appreciated. Below is the pseudo code, i am using to get the max value.
current output

Expected output for Min value :

lv_tabix_temp = 1.
SORT RESULT_PACKAGE BY /bic/tnr ASCENDING
/bic/zerdat ASCENDING
/bic/zerzetims ASCENDING.
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
lv_tabix = sy-tabix.
LOOP AT RESULT_PACKAGE INTO wa_result_package FROM
lv_tabix_temp WHERE /bic/zrpa_tnr = <result_fields>-/bic/zrpa_tnr.
lv_tabix_temp = sy-tabix.
ENDLOOP.
IF lv_tabix = lv_tabix_temp.
<result_fields>-/bic/flag = 'X'.
ENDIF.
ENDLOOP.
‎2022 Sep 23 6:35 AM
If you make a Sort by TNR & ZERDAT & ZERZETIMS ascending, the first row of new TNR will be the lower values of ZERDAT & ZERZETIMS
So you don't need to play with SY-TABIX or do several LOOP on the same internal table.
‎2022 Sep 23 6:49 AM
Hi Girod,
Yes, we can do that with sort. But I want to achieve that with SY-TABIX because of some other dependency. Any input on SY-TABIX will be of great help.
‎2022 Sep 23 2:30 PM
You have proposed a code with a SORT
Otherwise you could also add a new sorted key on the internal table.
If it is a lesson exercise and you have to follow stupid rules, just say it