‎2008 Sep 10 8:01 AM
Hello all,
i have one simple doubt plz help.
data:begin of itab1 occurs 0,
psnfh like plfh-psnfh,
end of itab1.
select psnfh into table itab1
from plfh
where plnty = 'N'
AND plnNR = group_number
AND plnfl = W_PRT_ASSIGN-SEQUENCE_NO
and loekz ne 'X'
and plnkn = t_plnkn.
this query is working fine.
now i have 3 psnfh entires(0010 0020 0030) ..my requirement is that i have choose maximum of these that is 0030 and wanna add 0010 to it everytime.....and may be it will be better if i can save it in a variable.......
plz help in this syntax......i know we can use MAX function but it will be better if u can give that exact 2-3 lines of code.
‎2008 Sep 10 8:11 AM
Hi Abhijeet,
Do you always want to add "0010" to the maximum value from that internal table?
If yes, then you can follow the steps mentioned below.
1. Declare temporary internal table and transfer al values from your main internal table to the temporary.
ITAB_TEMP[] = ITAB[].
2. Now Sort the temp table as follows.
SORT ITAB_TEMP BY fieldname DESCENDING.
3. Now if you READ this temp table with INDEX 1, you wil get the maximum value to which you can add the value.
READ TABLE ITAB_TEMP INTO W_ITAB INDEX 1.
IF SY-SUBRC EQ 0.
V_MAX = W_ITAB-field + 0010.
ENDIF.
Best Regards,
Ram.
‎2008 Sep 10 8:07 AM
Hi,
do it in this way.
in a loop first compare the values and assign max value to a variable.
then again in a loop increase the value as per your requirment.
hope it will help you.
Thanks
Rajesh Kumar
‎2008 Sep 10 8:09 AM
Hi Abhijeet.
Let all the entries come into your internal table first. After you got all the entries :
sort itab by psnfh descending.
read table itab from wa index 1.
if sy-subrc eq 0.
add 10 to wa_psnfh.
endif.
and delete rest of the records if unnecessary.Regards,
Swapna.
‎2008 Sep 10 8:11 AM
Hi,
Sort the internal table entries in descending order.
And delete all the remaining entries except the first entry,
‎2008 Sep 10 8:11 AM
Hi Abhijeet,
Do you always want to add "0010" to the maximum value from that internal table?
If yes, then you can follow the steps mentioned below.
1. Declare temporary internal table and transfer al values from your main internal table to the temporary.
ITAB_TEMP[] = ITAB[].
2. Now Sort the temp table as follows.
SORT ITAB_TEMP BY fieldname DESCENDING.
3. Now if you READ this temp table with INDEX 1, you wil get the maximum value to which you can add the value.
READ TABLE ITAB_TEMP INTO W_ITAB INDEX 1.
IF SY-SUBRC EQ 0.
V_MAX = W_ITAB-field + 0010.
ENDIF.
Best Regards,
Ram.
‎2009 Feb 10 10:28 AM