2014 Aug 05 3:01 PM
Hi,
I want to calculate margin percentage based on line item wise & subtotal wise for a billing doc/sales doc.
I have already accomplish line item wise & working fine. Problem occurs when I want it to be print subtotal wise.
I have applied logic to calculate subtotals but loop is not working properly though not getting any errors but not getting desired output ,instead I am getting same output in as getting in percentage line item wise but ideally figure should be different in % if we are calculating it line item wise & subtotal wise.
2014 Aug 05 3:23 PM
Hi suruchi,
Please click on code image it would be clear.
Instead of calculating lv_totamt & lv_maramt for all line items it calculates percentage & modifying table for all line items .. I want it to be be done per billing document. so that I can get percentage based on totalamt (netwr) & margin amt ..
Hi suruchi,
Please click on code image it would be clear.
Instead of calculating lv_totamt & lv_maramt for all line items it calculates percentage & modifying table for all line items .. I want it to be be done per billing document. so that I can get percentage based on totalamt (netwr) & margin amt ..
2014 Aug 05 3:07 PM
can u share the code..
here it it unclear... let me understand the code where u r doing subtotals...
2014 Aug 05 3:20 PM
2014 Aug 05 3:23 PM
Hi suruchi,
Please click on code image it would be clear.
Instead of calculating lv_totamt & lv_maramt for all line items it calculates percentage & modifying table for all line items .. I want it to be be done per billing document. so that I can get percentage based on totalamt (netwr) & margin amt ..
2014 Aug 05 3:31 PM
Hi Drashti,
Both Header and Item table points same values here. But it should not be like that. Delete the duplicate values in header table and then please change the code as shown below.
"Sort the Header Table
SORT IT_DISPLAY BY VBELN.
"Delete the duplicate value
DELETE ADJACENT DUPLICATES IT_DISPLAY COMPARING VBELN.
LOOP AT IT_DISPLAY INTO WA_DISPLAY.
LOOP AT IT_TMP INTO WA_TMP.
"Use WA_TMP instead of WA_DISPLAY
LV_TOTAMT = LV_TOTAMT + WA_TMP-NETWR.
"Use WA_TMP instead of WA_DISPLAY
LV_MARAMT = LV_MARAMT+ WA_TMP-MRGAMT.
---
---
ENDLOOP.
ENDLOOP.
Regards
Rajkumar Narasimman
2014 Aug 05 4:19 PM
Hi rajkumar,
I am getting my value in column margin%subtotals , Now end user doesn't want to see duplicate records ..... can I print that percentage value just once per billing document and keep rest cells blank ???
2014 Aug 05 4:39 PM
Hi Drashti,
You can get the ouput using AT NEW Statement
Make vbeln as the first field in it_display.
sort it_display by vbeln.
loop at it_display.
at new of vbeln.
flag = 'X'.
endat.
if flag is not initial.
modify it_display from wa_display transporting mrgpctt.
endif.
clear flag.
endloop.
margin%subtotals will be modified at the starting of vbeln.
Regards,
Venkat.
2014 Aug 05 4:46 PM
Hi Venkat,
Thank you for help. That way it is working but rest cells are showing 0,00 Is it possible to make that blank ?
2014 Aug 05 5:53 PM
Hello Drashti,
Set No_out = 'X in field catalogue definition for that field to show 0.0 as space.
Thanks
2014 Aug 06 2:38 AM
Hi drashti,
if you are using alv,
wa_fcat-no_zero = 'X'.
for classical write: / per no-zero .
Regards,
Venkat.
2014 Aug 06 11:36 AM
Hi all,
I am using reuse alv grid display & need to print % sign along with value in both percentage columns.
I am using edit_mask but it is just displaying sign & no values... do I need to call a function or something like that or change to lvc_fcat_merge ??
2014 Aug 06 12:47 PM
Hi,
You May use Underscore for any Character and a period for decimal point like
wa_fcat-EDIT_MASK = '__.__%.
-----------------------
clear wa_fcat.
Regards'
2014 Aug 06 12:54 PM
Hi,
I already tried that but values are not printing proper ..
EX : If actual percentage to be printed is 4.4%
with edit_mask option it is showing 44.0% ( because of '__.__%' )
How to resolve that , I have kept my percentage field of type P decimal 2.
2014 Aug 06 1:02 PM
Hi Drashti,
if you never find any possibility, try this code.
Decalred one variable concatenate with Percentage symbol.
TYPE-POOLs: slis.
DATA: BEGIN of itab OCCURS 0,
lv_type TYPE string,
END OF itab.
data: lv_type TYPE string,
it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.
START-OF-SELECTION.
CONCATENATE '12.0' '%' INTO itab-lv_type.
APPEND itab.
wa_fcat-fieldname = 'LV_TYPE'.
wa_fcat-seltext_m = '%'.
APPEND wa_fcat to it_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IT_FIELDCAT = it_fcat
TABLES
T_OUTTAB = itab[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
Regards,
Venkat.
.
2014 Aug 06 1:32 PM
hi Venkat,
This code throws me error
concatenate wa_display-mrgpctt '%' into wa_display-lv_per.
As mrgpctt field is of type P decimal 2 and lv_per is of type string.
2014 Aug 06 1:38 PM
Hi Drashti,
Know Check,
if wa_display-mrgpctt is not initial.
move wa_display-mrgpctt to wa_display-lv_per.
concatenate wa_display-lv_per '%' into wa_display-lv_per.
endif.
Regards,
Venkat.
2014 Aug 06 1:59 PM
Hi Drasthi,
Sample code,
REPORT ZPRODUCT.
TYPE-POOLs: slis.
data: lv_p TYPE p DECIMALS 2,
it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat TYPE slis_fieldcat_alv.
data: BEGIN OF itab OCCURS 0,
lv_per TYPE string,
END OF itab.
START-OF-SELECTION.
lv_p = '12.0'.
if lv_p is not initial.
MOVE lv_p to itab-lv_per.
CONCATENATE itab-lv_per '%' INTO itab-lv_per.
APPEND itab.
endif.
wa_fcat-fieldname = 'LV_PER'.
APPEND wa_fcat to it_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IT_FIELDCAT = it_fcat
TABLES
T_OUTTAB = itab[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
Regards,
Venkat.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |