Subtotal of the columns in the ALV
Hi,
I want to do the Subtotal of the columns in the ALV by using any of the FMs:
ALV_OPTIONS_FOR_SUBTOTALS
ALV_SUBTOTALS_GET
ALV_SUBTOTALS_GET_H
But since the functional documentation is not available.
I am not getting how to use.
Please provide me the code or reply me about how to go about.
Thanks & Regards,
Pooja
Hi,
Consider i have 3 fields
lifnr curr DMBTR
5600 GBP 1000
5600 GBP 1000
5600 USD 1000
5600 TND 1000
5601 GBP 1000
5602 GBP 1000
I want output to be :
lifnr curr DMBTR
5600 GBP 1000
5600 GBP 1000
5600 USD 1000
5600 TND 1000
5600 GBP 2000
USD 1000
TND 1000
5601 GBP 1000
5601 GBP 1000
5602 GBP 1000
5602 GBP 1000
Actually i tried using the using subtotal option here:
**Method 1:
lv_fieldname = lc_lifnr.
lw_sort-spos = 1.
lw_sort-fieldname = lv_fieldname.
lw_sort-up = c_mark.
lw_sort-subtot = 'X'.
APPEND lw_sort TO i_sort.
Next i tried using the modifying field catalog like this
**Method 2:
LOOP AT i_fieldcat INTO wa_fieldcat.
IF wa_fieldcat-fieldname EQ 'DMBTR'.
wa_fieldcat-do_sum = 'X'.
ENDIF.
IF wa_fieldcat-fieldname EQ 'WRBTR'.
wa_fieldcat-do_sum = 'X'.
ENDIF.
MODIFY i_fieldcat FROM wa_fieldcat
TRANSPORTING do_sum .
ENDLOOP.
But both the methods didnt work .
So kindly tel me how to go about?
Regards,
Pooja
Similar Messages
-
Short dump while doing subtotal in the ALV report
Hi All,
I am getting run time error while doing the sub total and total in the ALV .
error is "MESSAGE_TYPE_X" and
discription is "The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X)."
Can anyone help me regarding this.
My alv field catog is like below
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
ls_sort TYPE SLIS_SORTINFO_ALV.
CLEAR:ls_fieldcat,
ls_sort.
REFRESH ot_fieldcat.
ls_fieldcat-FIELDNAME = 'LEASE_NUMBER'.
ls_fieldcat-SELTEXT_M = 'Lease Number'(001).
ls_fieldcat-COL_POS = 0.
ls_fieldcat-OUTPUTLEN = 10.
ls_fieldcat-DO_SUM = 'X'.
ls_fieldcat-KEY = 'X'.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'LEASE_TYPE'.
ls_fieldcat-SELTEXT_M = 'Lease Type'(002).
ls_fieldcat-COL_POS = 1.
ls_fieldcat-OUTPUTLEN = 5.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'LEGACY_NUM'.
ls_fieldcat-SELTEXT_M = 'Legacy Contract No'(003).
ls_fieldcat-COL_POS = 2.
ls_fieldcat-OUTPUTLEN = 10.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'CUSTOMER'.
ls_fieldcat-SELTEXT_M = 'Customer'(004).
ls_fieldcat-COL_POS = 3.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'STATUS'.
ls_fieldcat-SELTEXT_M = 'Status'(017).
ls_fieldcat-COL_POS = 16.
ls_fieldcat-OUTPUTLEN = 10.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'GATEIN_DT'.
ls_fieldcat-SELTEXT_M = 'Gate In Date'(018).
ls_fieldcat-COL_POS = 17.
ls_fieldcat-OUTPUTLEN = 10.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-FIELDNAME = 'SVALUE'.
ls_fieldcat-COL_POS = 18.
ls_fieldcat-DO_SUM = 'X'.
ls_fieldcat-OUTPUTLEN = 12.
APPEND ls_fieldcat TO ot_fieldcat.
CLEAR ls_fieldcat.
DATA SORTING AND SUBTOTAL
CLEAR ls_sort.
ls_sort-FIELDNAME = 'LEASE_NUMBER'.
ls_sort-SPOS = 0.
ls_sort-UP = 'X'.
ls_sort-SUBTOT = 'X'.
APPEND ls_sort TO GT_SORT.
If i coment the code relate dto 'SVALUE' i am getting output without sub total and total.
if i uncomment the same then I am getting short dump.Hi,
Try this coding,
TYPE-POOLS: SLIS. " ALV GLOBAL TYPES
* FORM F_READ_DATA
FORM F_READ_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_VBAK
FROM VBAK
UP TO P_MAX ROWS
WHERE KUNNR IN S_KUNNR
AND VBELN IN S_VBELN
AND VKORG IN S_VKORG.
ENDFORM. " F_READ_DATA
* FORM F_DISPLAY_DATA
FORM F_DISPLAY_DATA.
DEFINE M_FIELDCAT.
ADD 1 TO LS_FIELDCAT-COL_POS.
LS_FIELDCAT-FIELDNAME = &1.
LS_FIELDCAT-REF_TABNAME = 'VBAK'.
LS_FIELDCAT-DO_SUM = &2.
LS_FIELDCAT-CFIELDNAME = &3.
APPEND LS_FIELDCAT TO LT_FIELDCAT.
END-OF-DEFINITION.
DEFINE M_SORT.
ADD 1 TO LS_SORT-SPOS.
LS_SORT-FIELDNAME = &1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = &2.
APPEND LS_SORT TO LT_SORT.
END-OF-DEFINITION.
DATA:
LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
LT_SORT TYPE SLIS_T_SORTINFO_ALV,
LS_SORT TYPE SLIS_SORTINFO_ALV,
LS_LAYOUT TYPE SLIS_LAYOUT_ALV.
M_FIELDCAT 'VKORG' '' ''.
M_FIELDCAT 'KUNNR' '' ''.
M_FIELDCAT 'VBELN' '' ''.
M_FIELDCAT 'NETWR' 'X' 'WAERK'.
M_FIELDCAT 'WAERK' '' ''.
M_SORT 'VKORG' 'X'. " SORT BY VKORG AND SUBTOTAL
M_SORT 'KUNNR' 'X'. " SORT BY KUNNR AND SUBTOTAL
M_SORT 'VBELN' ''. " SORT BY VBELN
LS_LAYOUT-CELL_MERGE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = LT_FIELDCAT
IT_SORT = LT_SORT
TABLES
T_OUTTAB = GT_VBAK.
ENDFORM. " F_DISPLAY_DATA
Regards,
Nikhil. -
How to print the subtotal in the alv
Hi all,
I got a requirement ..
i got matnr . quantity.
material1 1000kg
material1 2000kg
material1 3000kg .
material2 100kg
material2 200kg
materail2 300 kg
i need to print the subtotal based upon the material number in ALV . So my ouput should look like ....
material1 1000kg
material1 2000kg
material1 3000kg .
6000kg
material2 100kg
material2 200kg
materail2 300 kg
600kg
I am not able to do , i have gone through the forums , but i am able to print the Grand totals .
I need to print the sub totals . Please let me know ....
RegardsDear Raj
You can do it with your fieldcatalog, check my code properly.
REPORT ZTEST_ALV_TEXT .
type-pools : slis.
types : begin of itab_t,
ebeln like ekpo-ebeln,
lifnr like ekko-lifnr,
ekorg like ekko-ekorg,
ekgrp like ekko-ekgrp,
werks like ekpo-werks,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
netpr like ekpo-netpr,
d, "Dummy field to fire the Subtotal text event
end of itab_t.
data: itab type table of itab_t.
data: tab type itab_t.
data : itab1 like eket occurs 0 with header line.
data: t_fcat type slis_t_fieldcat_alv,
it_sort type slis_t_sortinfo_alv,
t_events type slis_t_event,
listhead type slis_t_listheader,
ls_layout type slis_layout_alv.
start-of-selection.
select a~ebeln
a~lifnr
a~ekorg
a~ekgrp
b~werks
b~ebelp
b~matnr
b~menge
b~netpr
up to 100 rows
into corresponding fields of table itab
from ekko as a inner join ekpo as b
on a~ebeln = b~ebeln.
end-of-selection.
perform fill_fcat using t_fcat.
perform fill_event using t_events.
perform fill_layout.
perform display.
form fill_fcat using p_t_fcat type slis_t_fieldcat_alv.
data : lfcat type slis_fieldcat_alv,
colpos type i value '0'.
data : ls_sort type slis_sortinfo_alv.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EBELN'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELN'.
lfcat-ref_tabname = 'EKKO'.
lfcat-hotspot = 'X'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'LIFNR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'LIFNR'.
lfcat-ref_tabname = 'EKKO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EKORG'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EKORG'.
lfcat-ref_tabname = 'EKKO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EKGRP'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EKGRP'.
lfcat-ref_tabname = 'EKKO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'WERKS'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'WERKS'.
lfcat-ref_tabname = 'EKPO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'EBELP'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELP'.
lfcat-ref_tabname = 'EKPO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'MATNR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'MATNR'.
lfcat-ref_tabname = 'EKPO'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'MENGE'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'MENGE'.
lfcat-ref_tabname = 'EKPO'.
lfcat-do_sum = 'X'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'NETPR'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'NETPR'.
lfcat-ref_tabname = 'EKPO'.
lfcat-do_sum = 'X'.
append lfcat to p_t_fcat.
clear lfcat.
colpos = colpos + 1.
lfcat-col_pos = colpos.
lfcat-fieldname = 'D'.
lfcat-tabname = 'ITAB'.
lfcat-ref_fieldname = 'EBELN'.
lfcat-ref_tabname = 'EKKO'.
lfcat-no_out = 'X'.
append lfcat to p_t_fcat.
clear lfcat.
ls_sort-spos = 1.
ls_sort-fieldname = 'EBELN'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
append ls_sort to it_sort.
clear ls_sort.
ls_sort-spos = 2.
ls_sort-fieldname = 'D'.
ls_sort-tabname = 'ITAB'.
ls_sort-up = 'X'.
ls_sort-group = 'UL'.
ls_sort-subtot = 'X'.
append ls_sort to it_sort.
endform. " fill_fcat
form fill_event using p_t_events type slis_t_event.
data : ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_t_events
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
if sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
read table p_t_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move 'TOP_OF_PAGE' to ls_event-form.
append ls_event to p_t_events.
endif.
read table p_t_events with key name = SLIS_EV_SUBTOTAL_TEXT
into ls_event.
if sy-subrc = 0.
move 'SUBTOTAL' to ls_event-form.
append ls_event to p_t_events.
endif.
endform. " FILL_EVENT
FORM SUBTOTAL USING I_LISTHEAD STRUCTURE tab
I_SUBTOTAL TYPE SLIS_SUBTOT_TEXT.
*criteria type slis_fieldname,
keyword like dd03p-reptext,
criteria_text(255) type c,
max_len like dd03p-outputlen,
display_text_for_subtotal(255) type c,
if I_SUBTOTAL-criteria = 'D'.
I_SUBTOTAL-display_text_for_subtotal = 'Sub total'.
"here you need to do some calculations and assing the data
"back to total line
endif.
ENDFORM.
form top_of_page.
data : s_listhead type slis_listheader.
clear s_listhead.
s_listhead-typ = 'H'.
s_listhead-info = 'SIMPLE REPORT'.
append s_listhead to listhead.
s_listhead-typ = 'S'.
s_listhead-key = 'EBELN'.
s_listhead-info = 'ALV'.
append s_listhead to listhead.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = listhead
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
endform. "TOP_OF_PAGE
form fill_layout .
ls_layout-zebra = 'X'.
ls_layout-detail_popup = 'X'.
ls_layout-key_hotspot = 'X'.
ls_layout-window_titlebar = 'Test Title'.
ls_layout-totals_text = 'GRAND TOTAL'.
ls_layout-subtotals_text = 'SUB'.
endform. " fill_layout
form display .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
it_sort = it_sort[]
it_events = t_events
tables
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
if sy-subrc ne 0.
MESSAGE ID SY-MSGI D TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " display
Hope this will help you to close your thrend -
Subtotal text in the 3rd column of the alv list
Hi Guru,
Can anyone know or have some codes on how to implement a subtotal text in the 3rd column of the ALV list. Im using FM REUSE_ALV_HIERSEQ_LIST_DISPLAY to display the report.
Please give some advise or help.
Thanks and rewards is given.Hi my friend,
Insted Using FM REUSE_ALV_HIERSEQ_LIST_DISPLAY
better use REUSE_ALV_GRID_DISPLAY.
in that
it_sort = i_sort[]
constants : c_x type char1 value 'X'.
l_rec_fieldcat_wa-do_sum = c_x.
endif. -
Hiding a column in the ALV in a webdynpro component(standrad one)
Hi,
i have an requirement of hiding a column inside a ALV output of a web dynpro component which is a standrad one. please help me finding the way to do the same.
thanks,
selvakumar M.data: l_ref_usage type ref to if_wd_component_usage.
l_ref_usage = wd_this->wd_CpUse_Alv( ).
if l_ref_usage->has_active_component( ) = abap_false.
l_ref_usage->create_component( ).
endif.
DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_Alv( ).
data:
l_VALUE type ref to Cl_Salv_Wd_Config_Table.
l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model(
data: lr_column type ref to CL_SALV_WD_COLUMN.
lr_column =
l_value->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'CARRID' ).
lr_column->set_visible( CL_WD_UIELEMENT=>E_VISIBLE-NONE ).
Abhi -
Problem with the order of the columns of a ALV
I have a problem with a ALV, variants we keep this ALV does not record the order of the columns
Thank youI suppose you want to change the sequence of columns of a ALV. If you can change it by clicking 'settings' of right-top corner of ALV. After done you can save the new settings into a new. If you find some abnormal behaviour, please check the settings by WDA component "wd_analyze_config_user".
FYI.
[http://help.sap.com/saphelp_nw70/helpdata/en/32/f26f73d81e11d1a26f0000e8a5a614/frameset.htm] -
How to get the Row and Column values in ALV (without using Objects)
Hi All,
I need to get the Row / Column when double click is used in ALV, I can use the double click event for this. However, I do not want to use the Object Oriented ALV. I want to implement the same functionality using general (using functions) ALV.
Is there any way to get the row / column values for a Generia (non-OOPs) ALV report.
Please help.
Thanks,
Vishal.Hello,
The only think you have to do is to get the index where the user clicked, and then read the internal table you sent to the alv
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'prg_name'
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND' " this is to the click event!!
i_callback_top_of_page = 'TOP_OF_PAGE'
is_layout = alv_layout
it_fieldcat = alv_fieldcat
i_save = 'A'
it_events = alv_events[]
TABLES
t_outtab = i_totmez. ---> TOUR IT.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" then....
FORM user_commandUSING r_ucomm TYPE sy-ucomm
ls_selfield TYPE slis_selfield.
" r_ucomm -> HAS THE STATUS
" ls_selfield-tabindex -> HAS THE SELECTED INDEX
" THEN READ THE INTERNAL TABLE
" HERE YOU WILL HAVE THE SELECTED ROW
READ TABLE i_totmez INDEX ls_selfield-tabindex.
ENDFORM.
cheers,
Gabriel P. -
Is it possible to create the ALV output with dropdown list for the columns
Hi forum experts,
Could the ALV output contain the dropdown list for the column names? if yes, then how we can acheive this to happen.
Thanks in advance,
Regards,
Samad.
Edited by: Samad arif on Aug 21, 2009 4:40 PMHi Arif,
Yes we can .FOr the codding check the article,
[dropdowns in ALV|https://wiki.sdn.sap.com/wiki/display/Snippets/DropdownsinALV]
regards,
Archana
Edited by: Archana Kumari on Aug 21, 2009 1:22 PM -
How to increase the column size of Alv tbale
Hi All,
I created an Alv table to display the content of my database table. In one of the column the entire data from my database are not displayed the last few characters are missing. The data type for that column in the database is char. Can any one help me how to increase the column size in my Alv table or any suggestions to resolve this issue.Hi Vadiv,
Try with this..
DATA: LR_IF_CONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,
LR_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE,
LR_CMDL TYPE REF TO CL_SALV_WD_CONFIG_TABLE,
LR_TABLE_SETTING TYPE REF TO IF_SALV_WD_TABLE_SETTINGS.
LR_CMP_USAGE = WD_THIS->WD_CPUSE_ALV( ).
IF LR_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
LR_CMP_USAGE->CREATE_COMPONENT( ).
ENDIF.
" get reference to the ALV model
LR_IF_CONTROLLER = WD_THIS->WD_CPIFC_ALV( ).
LR_CMDL = LR_IF_CONTROLLER->GET_MODEL( ).
LR_TABLE_SETTING ?= LR_CMDL.
" Set column width
DATA LR_COL TYPE REF TO CL_SALV_WD_COLUMN.
LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'PERNR' ).
LR_COL->SET_WIDTH( '70' ) .
LR_COL = LR_CMDL->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'ENAME' ).
LR_COL->SET_WIDTH( '100' ) .
LR_TABLE_SETTING->SET_FIXED_TABLE_LAYOUT( ABAP_TRUE ).
You can refer to webdynpro component SALV_WD_TEST_TABLE_PROPS. Go to the view TABLE and look inside the method SET_COLUMN_SETTINGS. I hope this will help you.
Cheers,
Kris. -
All the columns of an alv grid report are not downloading in excel in 1 lin
Hi All,
I have some 60 columns in my alv grid report and user can download the report using list->export->localfile->spreadsheet.
What the issue is that all the columns are not downloading in one line, instead they split in two rows.
Please help.
Regards,
Neha Patelhi,
just use this procedure it will solve your problem:
Firstly export the data to memory using the FM LIST_FROM_MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE e000(su) WITH text-001.
ENDIF.
then i converted it into ASCII using LIST_TO_ASCI,
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_xlstab
listobject = t_listobject
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE e003(yuksdbfzs).
ENDIF.
This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
cl_abap_char_utilities=>horizontal_tab.
Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
This will create an excel attachment.
Sample code for formatting the data for the attachment in excel format.
u2022 Format the data for excel file download
LOOP AT t_xlstab INTO wa_xlstab .
DESCRIBE TABLE t_xlstab LINES lw_cnt.
CLEAR lw_sytabix.
lw_sytabix = sy-tabix.
u2022 If not new line then replace '|' by tabs
IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
WITH cl_abap_char_utilities=>horizontal_tab.
MODIFY t_xlstab FROM wa_xlstab .
CLEAR wa_xlstab.
wa_xlstab = cl_abap_char_utilities=>newline.
IF lw_cnt NE 0 .
lw_sytabix = lw_sytabix + 1.
u2022 Insert new line for the excel data
INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
lw_cnt = lw_cnt - 1.
ENDIF.
CLEAR wa_xlstab.
ENDIF.
ENDLOOP.
Sample code for creating attachment and sending mail:
FORM send_mail .
u2022 Define the attachment format
lw_doc_type = 'XLS'.
u2022 Create the document which is to be sent
lwa_doc_chng-obj_name = 'List'.
lwa_doc_chng-obj_descr = w_subject. "Subject
lwa_doc_chng-obj_langu = sy-langu.
u2022 Fill the document data and get size of message
LOOP AT t_message.
lt_objtxt = t_message-line.
APPEND lt_objtxt.
ENDLOOP.
DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
IF lw_tab_lines GT 0.
READ TABLE lt_objtxt INDEX lw_tab_lines.
lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
lwa_doc_chng-obj_langu = sy-langu.
lwa_doc_chng-sensitivty = 'F'.
ELSE.
lwa_doc_chng-doc_size = 0.
ENDIF.
u2022 Fill Packing List For the body of e-mail
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = 'RAW'.
APPEND lt_packing_list.
u2022 Create the attachment (the list itself)
DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
u2022 Fill the fields of the packing_list for creating the attachment:
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = lw_doc_type.
lt_packing_list-obj_name = 'Attach'.
lt_packing_list-obj_descr = w_docdesc.
lt_packing_list-doc_size = lw_tab_lines * 255.
APPEND lt_packing_list.
u2022 Fill the mail recipient list
lt_reclist-rec_type = 'U'.
LOOP AT t_recipient_list.
lt_reclist-receiver = t_recipient_list-address.
APPEND lt_reclist.
ENDLOOP.
u2022 Finally send E-Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = lw_sent_to_all
TABLES
packing_list = lt_packing_list
object_header = lt_objhead
contents_bin = t_xlstab
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Hope it will help you
Regards
Rahul sharma -
New column in the ALV output of transaction phap_admin_pa
Hello All,
I want to display a new column in the ALV output of transaction phap_admin_pa. Is this possible? If so, could anyone please give some guidance how to proceed. The new column willl contain the elements from appraisal catalog. Do u think there will be any BADi's to achieve this or I am not sure if a custom program need to be created?
Thank you very much,
RushHi
I had same problem of adding felds from additional data into the ALV and when I asked SAP they told me to implement BADI HRHAP00_REPORTING.
I am still trying to get some info on how to implement it if you find any documentation of someone who has implemented appreciate you tell me.
regards
Pravin -
HI Experts,
im here with a problem , i want to know if its possible to add an extra column to the ALV display my problem is im using the dictionary table directly not using any structures and hence iv not declared any field catalog....the output of this one extra field has to be hard coded and added to the display so it appears with the displayed alv at all times.
is this possible can i get help pls?
Thanks & Regards,
Goldie.Hi,
Append one more field to the field catalog & populate the same in the output internal table of ALV.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog. -
Setting the ALV Hierarchy tree with grid line between the columns and rows
Hi Experts,
I would like to ask if there is any suggestion on setting the ALV hierarchy tree to be separated by grid line between the columns and rows just like how it is display the same way in normal ALV grid.
Thanks in advance.Hi Lin,
The requirement which you have stated is not possible.
Lin,
Also i have a query regarding BADI ZME_PROCESS_REQ_CUST, which you had raised on SDN. You have marked the question as solved/answered.
Changing the data of a customize field in purchase requisition
Could you please let me know, the steps you did to update the screen fields through the BADI.
I would really appreciate your reply, because i am facing exactly the same problem which you have mentioned.
Thanks,
Best regards,
Prashant -
How to make column tree the ALV
As in normal table we can make column tree by using 'TreeByNestingTableColumn' property, can any one tell me how to do the same in alv.
I have used set_hierarchy_column( abap_true ), but i was not able to map all the elements with in a node to other columns present in the alv table.
requirement:
Column 1 Column 2
P1 value 1
->C1 value 2
-> C11 value 3
-> C12 value 4
->C2 value 5
-> C21 value 6
-> C22 value 7
P2 value 8
Can some please tell me how to do it.
Thanks
AbhishekCan some one please help me!!
I need to implement column tree in web dynpro application using ALV -
Is it possible to adjust the size of the columnes when send alv by mail ?
is it possible to adjust the size of the columns when send alv by mail ?
i send alv ( list ) by mail , work fine but all the columns are small and in the
same size , can i adjust it in the mail ?
how to do it in regular alv i know it .
LS_FCAT-OUTPUTLEN = 29 .is it possible to adjust the size of the columns when send alv by mail ?
i send alv ( list ) by mail , work fine but all the columns are small and in the
same size , can i adjust it in the mail ?
how to do it in regular alv i know it .
LS_FCAT-OUTPUTLEN = 29 .
Maybe you are looking for
-
Restrict printing a report on physical paper
HI All I am generating online report from my Forms 10g application in the web browser in PDF format. Now I want to restrict the user to take print of that report on physical paper based some application restrictions. How do I achieve this? Thanking Y
-
We are in the process of upgrading from 4.6c to ERP2005. When running third-party posting we get the following error: No entry in table T52EK for key /401 F or Q Table T52EK contains the symbolic accounts and what type of account they are. /401 sho
-
Is there any way you could track your Ipod touch after it gets stolen??
nope not really:/
-
Reg:-Previous Year Quarter
Hi All, I need to build a new report on Balance Sheet Quarterly in Financials. My reqiurement is..Show the Quarterly Balance sheet comparing Curent Quarter and Previous year Quarter i.e Current Qtr vs Previous Year Qtr. In the report levl , I have us
-
Recommended installation option PO vs. AEX / adding usage type in future
Dear guys, at the moment some clients I am working with a thinking of migrate their existing PI dual stack landscape and setupt a new single stack landscape. Doing so there is the question either to go for PO or AEX. Often there is no need for BPM/BR