‎2014 Aug 21 6:51 AM
Hello SAP Guru,
I have developed a ZREPORT in material price list. my report is working fine..!!
i want to show only max. Rate per kg. in my report
Like that: i have enter a input parameter material code, invoice date 01.04.2014 to 21.08.2014 And sales organization then shows only one highest rate per kg. How to do .
Please check my code and give me idea or correct my code..!! Please find a attached screenshot and code also..!!
Thanks in Advance
Richa
‎2014 Aug 21 7:40 AM
Hi,
FORM DISPLAY_DATA .
SORT ITAB BY MATNR KBETR DESCENDING. " You may add other columns if required like
customer sales organisation etc.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATNR.
SORT ITAB BY VBELN MATNR.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPNAME
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDTAB[]
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = EVENTS[]
IS_PRINT = ALV_PRINT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Regards
‎2014 Aug 21 7:06 AM
Hello Richa,
Sort internal table by materal and rate per kg.
delete adjacent duplicates
FORM DISPLAY_DATA .
*sort itab by material
sort itab by matnr kbetr descending.
delete adjacent duplicates from itab comparing matnr .
*
SORT ITAB BY VBELN MATNR.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPNAME
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDTAB[]
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = EVENTS[]
IS_PRINT = ALV_PRINT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
* loop at itab.
* select SINGLE name1 into itab-name1
* from kna1
* WHERE kunnr = itab-kunag.
*
* write:/ itab-vbeln, itab-kunag, itab-name1, itab-fkdat, itab-fkart, itab-kbetr,itab-kwert, ITAB-ZJEXP,itab-ZJECS,itab-ZJHSC,
* itab-mwsbk, itab-netwr.
* endloop.
ENDFORM.
Thanks
‎2014 Aug 21 7:29 AM
Dear Learner,
Thanks for the reply.!!
Please Correct my code and reply if its' possible..!!
Because i wil try max. time but i am not success..!
‎2014 Aug 21 7:08 AM
Hi,
If yo are fetching rate from table you can use MAX statement in your query or els you can manage inside loop.
Please provide some more details and let us know where exactly you need help.
Regards,
Lingaraj
‎2014 Aug 21 7:25 AM
Dear Lingaraj,
Thank for the reply..!!
I have already attached a code and screen shot .!!
As per my requirement i want to show only Max. Rate per kg.in Billing Level.
EXP.
DATE Material Rate
15.07.2014 12345 155
19.08,2014 12345 160
19.08.2014 12345 135
20.08.2014 12345 150
I want to output only
19.08,2014 12345 160
Thanks in Advance
Richa
‎2014 Aug 21 7:11 AM
Hi Richa,
SORT output_table DESCENDING BY rate.
Read output_table index 1.
Thanks,
Anil
‎2014 Aug 21 7:16 AM
Dear Anil,
Thanks for the Reply..!!
Please check my code and give me correct code if it's possible..!!
Richa
‎2014 Aug 21 7:29 AM
Hi Richa,
DATA : Itab1 type table of ITAB,
lwa_tab type itab.
SORT itab DESCENDING BY netwr.
Read itab into lwa_tab index 1.
append lwa_tab to itab1.
In CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' ,
Instead of ITAB, pass ITAB1.
Thanks,
Anil
‎2014 Aug 21 7:40 AM
Hi Richa,
Just sorting the internal table and deleting the adjacent duplicates will solve your problem. You need to do this just before you display your ALV.
But, the reply suggested by Anil will fetch you only one entry.For multiple material selection, it will not work.
Refer to the code given by Always Learner in his reply. That will give you the required solution.
‎2014 Aug 21 7:19 AM
Hi Richa,
Since you are summing up the rate values for some other calculation, fetching data using MAX function in the SELECT statement may not get you the desired results.
The best way is to sort and delete the adjacent duplicates.
SORT itab BY matnr ASCENDING kbetr DESCENDING.
DELETE ADJACENT DUPLICATES FROM itab COMPARING matnr.
‎2014 Aug 21 7:35 AM
Hi Richa,
Try,
Sort itab by vbeln posnr kbetr descending.
Delete Adjacent duplicates from itab comparing vbeln posnr kbetr.
Regards,
Venkat.
‎2014 Aug 21 7:40 AM
Hi,
FORM DISPLAY_DATA .
SORT ITAB BY MATNR KBETR DESCENDING. " You may add other columns if required like
customer sales organisation etc.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATNR.
SORT ITAB BY VBELN MATNR.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = REPNAME
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDTAB[]
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = EVENTS[]
IS_PRINT = ALV_PRINT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Regards
‎2014 Aug 21 7:54 AM
Hi,
Sort ITAB by matnr kbetr DESCENDING.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATNR.
Rgds,
Vaikunt
‎2014 Aug 21 8:09 AM
Dear Somendra,
This condition is working fine.!
If i am try to Material Number Low to Material Number High then Price condition is not working
Exp.
Material no. Low Material no. High
‎2014 Aug 21 8:57 AM
Hi,
????
In abap code where you are giving these low and high values,Not getting correctly,
Although price is getting by knumv and kposnr.
‎2014 Aug 21 9:06 AM
Dear Somendra
Enter a input parameter
Material Number 12345 to 12347
date 19.08.2014 to 21.08.2014
then i want to show 12345 Max. Rate and 12347 Max Rate
Now Enter this input showing all material Max. Rate
‎2014 Aug 21 10:05 AM
Hi,
If I Understand then you want only the values for material-low and material-high and skip all the values for material lies in between low and high.
So Add a clause no interval in selection screen
SELECTION-SCREEN BEGIN OF BLOCK DOCDATA WITH FRAME TITLE TEXT-DOC.
SELECT-OPTIONS: MATNR FOR VBRP-MATNR no INTERVALS,
Regards
‎2014 Aug 21 10:09 AM
Dear Somendra,
As per my requirement i want to insert one other field and insert Current Bill Rate
Please check my screen shot..!!
Rate per KG. is Max. Rate but As per my requirement Current Rate is Latest Bill Rate
Richa