Print or download ALV report with sort options
Dear friends,
How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
Regards,
Praveen Lobo
Hi Praveen,
Use this code, its working:-
*FOR SORTING DATA
DATA : it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
* SORT W.R.T. CUSTOMER NAME
wa_sort-spos = 1.
wa_sort-fieldname = 'NAME1'. "field customer name
wa_sort-tabname = 'IT_KNA1'. "internal table with records
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
"this will sort the ALV o/p for customer with same name
"now the name will not be repeated
"records with same name will be grouped
* DISPLAY RECORDS IN ALV GRID
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid "report id
it_fieldcat = it_field "field catalog
it_sort = it_sort "sort info
TABLES
t_outtab = it_kna1 "internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM
Similar Messages
-
Download ALV report with layout to application server
Hi Gurus,
I have a problem as follows:
I have one ALV Grid report. This report is very time consuming.
That is why, user wants this to be run in background every night and in the morning when user comes to the office that ALV report should be on user's drive in excel format.
However, it should run with one specific variant and that variant should be dynamically populated. (I have handled this part)
It should also apply specific layout that has many filtering conditions.
As I can not download ALV to excel in background, I decided to download it to the Application server.
My problem is that when run in background, in spool ALV report shows o/p with proper filter conditions that is 5 out of 20 records.
But, when I write this report o/p to Application server, it writes all the records in there, i.e., all 20 records. It does not take into account all the filters. [:(]
I also tried downloading spool to excel, but o/p is not neatly formatted. All columns are fying here and there.
Any suggestion, how can I write ALV o/p to Application server with layout into consideration?
P.S. I have searched forum for this type of query, but no apt responses.
Thanksdid u downloaded the report with standard option provided in the alv and checked the data? that is populating all 20 records?. if so then use coding for achieving the standard one
at the end of selection do like this ..
SET USER-COMMAND ' %PC' .
and in the user-command use like this..
case sy-ucomm.
when ' %PC'.
give the file name ..
do processing ..
endcase. -
Download ALV report to PDF with Lights
Hi,
I have a requirement wherein, when i download ALV report to PDF which has Lights in the first column. My problem is these lights are not displayed instead i get the following in the PDF
PDF o/p:
XOO RED SIGNAL
OXO YELLOW SIGNAL
OOX GREEN SIGNAL
Please let me know how to get the lights in the PDF o/p
Thanks & Regards,
SandhyaHi Sandhya,
U can convert any type of display(SF,ALV) to PDF.....
User Program rstxpdft4 to convert it first the O/P need to be converted into spool.
cheers,
Naveen. -
Hi,
I've created an ALV report with a logo in the header.
But, when i'm taking the printout ,the logo is not printed.
How to solve this problem,..please help me .
Thanks and regards.
RajeshIt is not possible to Print the logo, which you are showing in ALV Grid.
But you have to work with Cl_DD_DOCUMENT class
Check this program DD_ADD_PICTURE, Here you can print the logo.the same you can try to implement if you want. -
Dump in prodcution server while downloading ALV report to excel sheet
HI ALL,
ALV report is working fine in bother DEV and PROD servers....but in production while downloading report to excel sheet it is going to dump.
"dump is below:
Short text
Field symbol has not yet been assigned.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLKKBL" had to be terminated because it has
come across a statement that unfortunately cannot be executed. "
But in development this problem is not there, iam able to download ALV report to EXCEL sheet.
Any help experts......
Thanks in advance
RamHi,
I had the same problem,
Run a consistency check for your ALV and you will find out. See if you havent passed any unnecessary parameter to FM.
/people/rainer.hbenthal/blog/2009/09/25/sos--my-alv-report-is-not-working
Dump while printing ALV (field symbol not assigned)
Sumit -
ALV Reporting with drill down capabillities
I'm creating a abap custom report using the ALV. I want to drill down to CJ03 which is projects. I know how to do it in regular custom reporting, but I don't seem to be able to get it to work using the ALV. Can anyone help?
Thanks.
LindaHi Linda,
Take a look at this sample program. The logic to handle any interaction with the user is in my "PORCESS_USER_COMMANDS" routine.
This is defined in the "I_CALLBACK_USER_COMMAND" parameter in the ALV FM.
Hope this helps.
Cheers,
Pat.
[code]
Modification History
Date | Author | Chg Req # | Description
15.08.2001| Pat Yee | $TMP | Program Creation
This program is an example of how the ALV Display works.
It will display Customer Data.
This report will also show how to display an ALV report with different
colored lines and icons
REPORT zpat.
Include Programs
INCLUDE <icon>.
Database Tables
TABLES: kna1. "Customer Master
Types
TYPE-POOLS: kkblo.
Structures
Structure to hold the Color Information
DATA: BEGIN OF st_color,
color(3) TYPE c,
END OF st_color.
Structure to hold the Icon Information
DATA: BEGIN OF st_icon,
icon(4) TYPE c,
END OF st_icon.
ALV Field Catalog Structure
DATA: st_fieldcat TYPE slis_fieldcat_alv.
ALV Layout Structure
DATA: st_layout TYPE slis_layout_alv.
Internal Tables
Output Table
DATA: BEGIN OF tbl_kna1 OCCURS 0.
INCLUDE STRUCTURE st_icon. "Icon Structure
INCLUDE STRUCTURE kna1. "Customer Master Structure
INCLUDE STRUCTURE st_color. "Color Structure
DATA: END OF tbl_kna1.
ALV Field Catalog Table
DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv.
Variables
DATA: fieldname(30) TYPE c,
g_repid LIKE sy-repid.
Start of Selection
START-OF-SELECTION.
g_repid = sy-repid.
PERFORM get_data.
End of Selection
END-OF-SELECTION.
PERFORM do_fancy_stuff.
PERFORM get_layout.
PERFORM get_fieldcat.
PERFORM create_report.
*& Form CREATE_REPORT
Learn to read the subroutine name!
FORM create_report.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
i_callback_program = g_repid
i_callback_user_command = 'PROCESS_USER_COMMANDS'
it_fieldcat = tbl_fieldcat
i_default = 'X'
i_save = ' '
is_layout = st_layout
TABLES
t_outtab = tbl_kna1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " CREATE_REPORT
*& Form GET_FIELDCAT
Build the Field Catalog
FORM get_fieldcat.
Here the field catalog is created. To display more fields simply
'uncomment' the additional lines and add the field name. Also note
that the field catalog is much more powerful than this. You can
intensify fields, change the colour, assign reference fields, etc.
Look at type slis_fieldcat_alv for more options.
PERFORM write_fieldcat USING 'ICON' 'TBL_KNA1' ' ' 'X' 1 '2' 'X'
PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '
PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '
'X'.
PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '
PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '
PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '
PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '
PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '
PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '
PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.
ENDFORM. " GET_FIELDCAT
*& Form WRITE_FIELDCAT
Write the Field Catalog data to the Field Catalog Table
-->name Field name
-->tab Table name
-->st Structure Name
-->key Is this field a Key?
-->pos Position Number
-->length Field Length
-->icon Display as Icon
-->hot Hotspot
FORM write_fieldcat USING name tab st key pos length icon hot.
st_fieldcat-fieldname = name.
st_fieldcat-tabname = tab.
st_fieldcat-ref_tabname = st.
st_fieldcat-key = key.
st_fieldcat-col_pos = pos.
st_fieldcat-outputlen = length.
st_fieldcat-icon = icon.
st_fieldcat-hotspot = hot.
APPEND st_fieldcat TO tbl_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " WRITE_FIELDCAT
*& Form PROCESS_USER_COMMANDS
Interactive Reporting Commands
FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
selfield TYPE slis_selfield.
This subroutine is called when there is user interaction in the output
In this case if the user double clicks the Customer Number then the
program will call transaction XD03 and display the Customer Master
Data
CASE syst-ucomm.
WHEN '&IC1'.
get cursor field fieldname.
READ TABLE tbl_kna1 INDEX selfield-tabindex.
SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. " PROCESS_USER_COMMANDS
*& Form GET_LAYOUT
set the layout of the ALV.
add color to the row?
FORM get_layout.
st_layout-info_fieldname = 'COLOR'.
st_layout-colwidth_optimize = 'X'.
st_layout-get_selinfos = 'X'.
ENDFORM. " GET_LAYOUT
*& Form get_data
Get some data to play with
FORM get_data.
SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
UP TO 30 ROWS.
ENDFORM. " get_data
*& Form do_fancy_stuff
Do some fancy pants stuff for example changing the color of
lines and adding icons
FORM do_fancy_stuff.
Here we will demonstrate changing the color of ALV Record lines as
well as displaying Icons
LOOP AT tbl_kna1.
All records where NAME1 begins with 'M', will be displayed in Bluish
Green
IF tbl_kna1-name1(1) EQ 'M'.
tbl_kna1-color = 'C41'. "Bluish Green
MODIFY tbl_kna1 TRANSPORTING color.
ENDIF.
All records with no TELF1 will be displayed in White and have a
Warning Icon
IF tbl_kna1-telf1 IS INITIAL.
tbl_kna1-color = 'C00'. "White
tbl_kna1-icon = '@AH@'. "Warning Icon
MODIFY tbl_kna1 TRANSPORTING icon color.
ENDIF.
ENDLOOP.
ENDFORM. " do_fancy_stuff[/code] -
How to download ALV report having more than 200 columns to Excel
Dear Experts,
I am facing the issue of line break during downloading ALV report into excel. I referred the lot of forums but i didn't get the proper solution to solve this issue..Please guide me to solve this issue....
My output in ALV
header1 header2..........header200
but when i download that to spreadsheet i am getting like this
header1 header2.....
header65 header66....
header199...
Regards,
Rathish
Edited by: joerathish on Jun 3, 2011 9:53 AMjoerathish wrote:
not working well.
Do you get a excel with empty sheet with excel in place ?
Then you need to enable macro in trust center of excel sheet settings. The way you do this depends on the version of excel you are using.
I am able to get 200+ columns perfectly this way.
Regards -
How can I print and email a report with a logo?
How can I print and email a report with a logo?
Is this possible??hi ravikant!
im talking about reports, not forms.
i bet se78 is for forms and oaer is for report.
because my logo is displayed on screen, using html-top-of-page.
but at the time of printing and email, internally, alv grid is converted into alv list, and alv list doesn't support having a logo.
That's my know-how of the situation.
Do you have a way with it???
Please advice.
Thanks a lot! -
In my MacBook Pro(10.7.5), finder is crashing after logging in. It is showing crash report with Relaunch option, when i click on Relaunch option finder is working properly but i am unable to see Top bar(Apple logo, Date and Wifi etc... bar). Even in safari address bar, TextEdit not accepting any text means when type something not showing up and also i am unable operate any thing from keyboard. Plz help me…..
One thing that you can try is installing a 'fresh' version of OS X Lion. Boot into your Recovery partition (holding down the command and R keys whilst booting) and elect to install OS X from the Recovery screen. You need not erase your hard drive and you should not lose any of your data.
Oh, and just as a precaution, I would use Disk Utility, once you're in Recovery mode, to verify your hard drive before trying to install the OS again.
Clinton -
Create a Procedural ALV Report with editable fields and save the changes
Hi,
I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
BCALV_TEST_GRID_EDIT_01
BCALV_TEST_GRID_EDIT_02
BCALV_TEST_GRID_EDIT_04_FORMS
BCALV_TEST_GRID_EDITABLE
BCALV_EDIT_01
BCALV_EDIT_02
BCALV_EDIT_03
BCALV_EDIT_04
BCALV_EDIT_05
BCALV_EDIT_06
BCALV_EDIT_07
BCALV_EDIT_08
BCALV_FULLSCREEN_GRID_EDIT
But all these are using OO Concepts.
Please help.
Regards,
SmruthiTABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-edit = 'X'
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_pf_status_set = 'STATUS'
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
LOOP AT it_ekko INTO wa_ekko.
ld_color = ld_color + 1.
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL
FORM top-of-page *
FORM top-of-page.
WRITE:/ 'This is First Line of the Page'.
ENDFORM.
FORM status *
FORM status USING rt_extab TYPE slis_t_extab. .
SET PF-STATUS 'ALV'.
ENDFORM.
FORM USER_COMMAND *
--> RF_UCOMM *
--> RS *
FORM user_command USING rf_ucomm LIKE sy-ucomm
rs TYPE slis_selfield.
DATA ref1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref1.
CALL METHOD ref1->check_changed_data.
CASE rf_ucomm.
when 'SAVE'.
get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
endcase.
endform.
ENDFORM.
here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
create a custom PF status and create push buttons and assign your ok codes in your PF status.
if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
Hope this will help you.
Regards,
phani. -
How many lines we can print using Non-alv report list ?
Hi Experts,
How many lines we can print using Non-alv report list ?
regards
vishnuHi,
It depends on the page size according to the page size we can set the no. of lines as follows,
REPORT program_name NO STANDARD PAGE HEADING
LINE-SIZE 290
LINE-COUNT 65.
Hope it helps you,
Regards,
Abhijit G. Borkar -
Download alv report output to excel format with out header line
Hi experts,
i want to download a alv report output into excel formatt with out the header line but it has to download including field description. as this output will fed into another transaction, the downloaded excel file should be with out header line.
fro eg:
Report : Zabc ABAP Development Page : 1
Run Date : 12/14/06 System: UD400
Run Time : 08:45:37
this header details should not be downloaded into the excel file.
could somebody help me please.
thanks
deepuhi jayanti,
thanks for your response.
i have delclared all the field types as character but still it is not downloading and it 's sy-subrc is 4... the code is as below.
*field names
lt_fieldnames-value = 'Material Number'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Plant'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Group'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Description'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'UOM'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Price Unit'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Material Type'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'X-Plant Status'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Valuation Class'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_avmng.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_avntp.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Latest PO Qty'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Latest PO Cost'.
APPEND lt_fieldnames.
lt_fieldnames-value = 'PO Creation Date'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_fcaqt.
APPEND lt_fieldnames.
lt_fieldnames-value = 'Prev. Yr. Std. Cost'.
APPEND lt_fieldnames.
lt_fieldnames-value = lw_stcst.
APPEND lt_fieldnames.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'XLSHEET'
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = t_output1
fieldnames = lt_fieldnames
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_pivot_fields = 6
download_problem = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE e001 WITH 'Data could not be downloaded'.
ENDIF.
ENDFORM. " z_dwn_xl
thanks
deepu -
ALV Report with Logo .. Print Out Problem
Hello Guys..
I am facing and differerent problem , I have created one Report in ALV contain logo of my company and some other details as per selection screen.
At the time of taking printoput the logo is not coming in print out only report data is coming.
How I take logo and ALV report in one print out .
Please do the needful.
Regards
Swati....We Can't take logo of ALV in print out.
-
ALV REPORT WITH MULTIPLE BLOCKS
To print two blocks in a single ALV report, I have taken the sample and modified to my requirement. I am having the following problems in this code.
1. Columnwise total not appearing.
2. Amount and numbers in all the columns are
left justified instead of right justified.
The code written is given below. Kindly check the same and suggest for corrections.
--- SAMPLE 1--
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'.
PERFORM list_append TABLES IT_CTV
USING '1'
'IT_CTV'.
PERFORM list_append TABLES IT_APP
USING '2'
'IT_APP'.
PERFORM f_list_display.
FORM USER_COMMAND *
FORM user_command USING i_ucomm LIKE sy-ucomm
is_selfield TYPE slis_selfield. "#EC CALLED
ENDFORM. " USER_COMMAND
Form list_append
FORM list_append TABLES ut_table
USING u_no TYPE char1
u_tabname TYPE slis_tabname.
DEFINE m_fieldcat.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA :
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv. " Sort table
DATA:
lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event,
ls_layout TYPE slis_layout_alv.
ls_layout-group_change_edit = 'X'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-zebra = 'X'.
ls_layout-cell_merge = 'X'.
ls_layout-detail_popup = 'X'.
ls_layout-get_selinfos = 'X'.
ls_layout-max_linesize = '300'.
CASE u_no.
WHEN '1'.
ls_fieldcat-SELTEXT_L = ' REGION'.
ls_fieldcat-DO_SUM = 'X'.
m_fieldcat 'BZIRK' 'IT_CTV'.
ls_fieldcat-SELTEXT_L = ' CTV STOCK'.
m_fieldcat 'CTVST' 'IT_CTV'.
ls_fieldcat-SELTEXT_L = ' CTV VALUE'.
m_fieldcat 'CTVVL' 'IT_CTV'.
m_sort 'BZIRK'.
ls_fieldcat-DO_SUM = 'X'.
WHEN '2'.
ls_fieldcat-SELTEXT_L = ' REGION'.
m_fieldcat 'BZIRK' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' RFG STK'.
m_fieldcat 'RFGST' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' RFG VAL'.
m_fieldcat 'RFGVL' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' WM STK'.
m_fieldcat 'WMCST' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' WM VAL'.
m_fieldcat 'WMCVL' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' MCCS STK'.
m_fieldcat 'MOVST' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' MCCS VAL'.
m_fieldcat 'MOVVL' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' APP STK'.
m_fieldcat 'APPST' 'IT_APP'.
ls_fieldcat-SELTEXT_L = ' APP VAL'.
m_fieldcat 'APPVL' 'IT_APP'.
m_sort 'BZIRK'.
ENDCASE.
ls_fieldcat-COL_POS = 1.
ls_fieldcat-FIELDNAME = 'BZIRK'.
ls_fieldcat-DO_SUM = 'X'.
ls_fieldcat-FIX_COLUMN = 'X'.
APPEND ls_fieldcat TO lT_fieldcat.
IF u_no CA '13'.
MOVE 'TOP_OF_PAGE' TO ls_event-name.
CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ELSE.
MOVE 'TOP_OF_LIST' TO ls_event-name.
CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
it_fieldcat = lt_fieldcat
is_layout = ls_layout
i_tabname = u_tabname
it_events = lt_events
it_sort = lt_sort
TABLES
t_outtab = ut_table
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " LIST_APPEND
Form f_list_display
FORM f_list_display.
DATA ls_print TYPE slis_print_alv.
ls_print-no_print_selinfos = 'X'. " Display no selection infos
ls_print-no_print_listinfos = 'X'. " Display no listinfos
ls_print-reserve_lines = 2. " Lines reserved for end of page
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
is_print = ls_print
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " F_LIST_DISPLAY
Thanks in advance.
A S VINCENTHai Vincent
Check the following Code
*& Report ZALV_BLOCK *
REPORT ZALV_BLOCK NO STANDARD PAGE HEADING
MESSAGE-ID ZZ.
*..Type Definitions for ALV Report
TYPE-POOLS SLIS.
Table Declarations. *
TABLES: MARA, "Material Master
MARC, "Plant Data for Material
MARD, "Storage Location Data for Material
VBAP, "Sales Document: Item Data
VBUP. "Sales Document: Item Status
Internal table to store sales orders.......
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "Sales Document
POSNR LIKE VBAP-POSNR, "Sales Document Item
KWMENG LIKE VBAP-KWMENG, "Cumulative order quantity in sales
" Units
END OF IT_VBAP.
internal table to store final data
DATA: BEGIN OF IT_FINAL OCCURS 0,
WERKS LIKE MARD-WERKS, "Plant
MATNR LIKE MARD-MATNR, "Material Number
LGORT LIKE MARD-LGORT, "Storage Location
LABST LIKE MARD-LABST, "Valuated stock with unrestricted use
INSME LIKE MARD-INSME, "Stock in quality inspection
RETME LIKE MARD-RETME, "Blocked Stock Returns
UMLME LIKE MARD-UMLME, "Stock in transfer
MAKTX LIKE MAKT-MAKTX, "Material description
VBELN LIKE VBAP-VBELN, "Sales Document
POSNR LIKE VBAP-POSNR, "Sales Document Item
KWMENG LIKE VBAP-KWMENG, "Cumulative order quantity in sales
" Units
END OF IT_FINAL.
ALV Type declaration *
*..Field Catalog for Basic List.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*..Events For Basic List.
DATA : IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT.
*..Layout For Basic List
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
*..Sort Table For Basic List
DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
DATA DECLARATIONS *
DATA: V_FLAG,
VINDEX TYPE SY-TABIX,
TOTAL TYPE VBAP-KWMENG. "Open order quantity
*..To Store Program Name
DATA: V_REPID TYPE SYREPID.
*..To know whether basic list contains any data
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_WERKS FOR MARC-WERKS,
S_LGORT FOR MARD-LGORT.
SELECTION-SCREEN END OF BLOCK B1.
Event:Initialization *
INITIALIZATION.
V_REPID = SY-REPID.
AT Selection Screen. *
AT SELECTION-SCREEN.
PERFORM VALIDATIONS.
Event: Start-of-Selection *
START-OF-SELECTION.
To get data from vbap into internal table IT_VBAP
PERFORM FETCH_OPEN_DATA.
To get data into final internal table IT_FINAL
IF V_FLAG = 'X'.
PERFORM FETCH_FINAL_DATA.
ENDIF.
IF V_FLAG = ''.
MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
EXIT.
ELSE.
--Setting the FIELD CATALOG for ALV
PERFORM FILL_FIELDCAT_HEADER.
*-----Setting the LAYOUT for ALV
PERFORM GET_LAYOUT.
*-----Getting the ALV Events
PERFORM GET_EVENT.
*---- To Sort the list
PERFORM DO_SORT.
ENDIF.
Event: End-of-Selection *
END-OF-SELECTION.
*--Generating the ALV LIST DISPLAY
PERFORM DISPLAY_LIST.
FORM DEFINITIONS *
*& Form VALIDATIONS
To validate data in selection screen
--> p1 text
<-- p2 text
FORM VALIDATIONS.
PERFORM VALIDATE_MATNR.
PERFORM VALIDATE_WERKS.
PERFORM VALIDATE_LGORT.
IF NOT ( ( MARA-MATNR IS INITIAL ) AND
( MARC-WERKS IS INITIAL ) AND
( MARD-LGORT IS INITIAL ) ).
SELECT SINGLE MATNR
WERKS
LGORT
FROM MARD
INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
WHERE MATNR = MARA-MATNR
AND WERKS = MARC-WERKS
AND LGORT = MARD-LGORT.
ENDIF.
ENDFORM. " VALIDATIONS
*& Form VALIDATE_MATNR
To validate MATNR
--> p1 text
<-- p2 text
FORM VALIDATE_MATNR.
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
UP TO 1 ROWS
INTO (MARD-MATNR)
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-001.
ENDIF.
ENDFORM. " VALIDATE_MATNR
*& Form VALIDATE_WERKS
To validate plant
--> p1 text
<-- p2 text
FORM VALIDATE_WERKS.
IF NOT S_WERKS[] IS INITIAL.
SELECT WERKS
UP TO 1 ROWS
INTO (MARD-WERKS)
FROM MARC
WHERE WERKS IN S_WERKS.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-002.
ENDIF.
ENDFORM. " VALIDATE_WERKS
*& Form VALIDATE_LGORT
To validate storage
--> p1 text
<-- p2 text
FORM VALIDATE_LGORT.
IF NOT S_LGORT[] IS INITIAL.
SELECT LGORT
UP TO 1 ROWS
INTO (MARD-LGORT)
FROM MARD
WHERE LGORT IN S_LGORT.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-003.
ENDIF.
ENDFORM. " VALIDATE_LGORT
*& Form FETCH_OPEN_DATA
To get data into internal table IT_VBAP
--> p1 text
<-- p2 text
FORM FETCH_OPEN_DATA.
IF NOT ( ( MARA-MATNR IS INITIAL ) AND
( MARC-WERKS IS INITIAL ) AND
( MARD-LGORT IS INITIAL ) ).
SELECT VBELN
POSNR
KWMENG
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP
WHERE MATNR IN S_MATNR
AND WERKS IN S_WERKS
AND LGORT IN S_LGORT.
ENDIF.
LOOP AT IT_VBAP.
SELECT * FROM VBUP
INTO VBUP
WHERE VBELN = IT_VBAP-VBELN
AND POSNR = IT_VBAP-POSNR
AND LFSTA NE 'C'.
ENDSELECT.
ENDLOOP.
IF SY-SUBRC NE 0.
REFRESH IT_VBAP.
MESSAGE E000 WITH TEXT-004.
EXIT.
ELSE.
V_FLAG = 'X'.
ENDIF.
To get sum of all quantities as open order quantity
LOOP AT IT_VBAP.
TOTAL = TOTAL + IT_VBAP-KWMENG.
ENDLOOP.
ENDFORM. " FETCH_OPEN_DATA
*& Form FETCH_FINAL_DATA
To get data into final internal table IT_FINAL
--> p1 text
<-- p2 text
FORM FETCH_FINAL_DATA.
SELECT A~MATNR
A~WERKS
A~LGORT
MAKTX
LABST
INSME
RETME
UMLME
VBELN
POSNR
KWMENG
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM MARD AS A
INNER JOIN MAKT AS B
ON AMATNR = BMATNR
AND SPRAS = 'E'
INNER JOIN VBAP AS C
ON AMATNR = CMATNR
FOR ALL ENTRIES IN IT_VBAP
WHERE VBELN = IT_VBAP-VBELN
AND POSNR = IT_VBAP-POSNR
AND KWMENG = IT_VBAP-KWMENG
AND A~MATNR IN S_MATNR
AND A~WERKS IN S_WERKS
AND A~LGORT IN S_LGORT.
IF SY-SUBRC NE 0.
V_FLAG = SPACE.
MESSAGE E001 WITH 'No data found IN the selection criteria'.
EXIT.
ELSE.
V_FLAG = 'X'.
ENDIF.
ENDFORM. " FETCH_FINAL_DATA
*& Form FILL_FIELDCAT_HEADER
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_HEADER .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_FINAL'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
CASE WA_FIELDCAT-FIELDNAME.
WHEN 'KWMENG'.
WA_FIELDCAT-COL_POS = '11'.
WA_FIELDCAT-OUTPUTLEN = '22'.
WA_FIELDCAT-SELTEXT_L = 'Net Value'.
WA_FIELDCAT-DO_SUM = 'X'.
ENDCASE.
MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_HEADER
*& Form GET_LAYOUT
text
--> p1 text
<-- p2 text
FORM GET_LAYOUT .
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM. " GET_LAYOUT
*& Form GET_EVENT
text
--> p1 text
<-- p2 text
FORM GET_EVENT .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_EVENTS INTO WA_EVENTS.
CASE WA_EVENTS-NAME.
WHEN 'TOP_OF_PAGE'.
WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
WHEN 'USER_COMMAND'.
WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
ENDCASE.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " GET_EVENT
FORM FILL_LIST_HEADER *
FORM FILL_LIST_HEADER.
WRITE:2'Report :' , SY-REPID,
: 85 ' Intelligroup Asia Pvt Ltd' CENTERED,
: 159 'Date :' ,SY-DATUM,
:/2'User :', SY-UNAME,
: 82 ' Hyderabad ' CENTERED ,
: 159 'Pg.No :' ,SY-PAGNO,
:/86 ' Stock Report ' CENTERED.
SKIP 2.
ENDFORM. "FILL_LIST_HEADER
*& Form DISPLAY_LIST
text
--> p1 text
<-- p2 text
FORM DISPLAY_LIST .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = IT_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_LIST
*& Form do_sort
text
--> p1 text
<-- p2 text
FORM DO_SORT .
*-- Populating the sort table
IT_SORT-FIELDNAME = 'MATNR'.
IT_SORT-TABNAME = 'IT_FINAL'.
IT_SORT-UP = 'X'.
it_sort-subtot = 'X'.
APPEND IT_SORT.
ENDFORM. " do_sort
Thanks & Regards
Sreenivasulu P -
Download alv report in excel format in Linux
Hi All,
I am working on SAP GUI for Java in Linux PC. I have installed
Open Office.
After executing an alv report there is no spreadsheet option
to download the report in excel format .
Also, when doing Save as Local File -> Spreadsheet ,
the report is not downloaded in proper format.
So, how to download the alv reports in excel format ?Hi Vinod ,
Save as Local File -> Spreadsheet
It will ask for Directory and file name with .xls format . Give proper name e.g. test.xls and save, and after saving file right click on the file and click on Open with "OpenOffice.org calc".
It will definetly work.
Abhijeet
Maybe you are looking for
-
Multiple installs on one computer (2013 and 2013 R2)
Is it possible to install both Biztalk 2013 and Biztalk 2013 R2 on the same computer? I realize it might not be prudent, but is it possible? Thanks Scott K Berger
-
A7-30TC tablet connection to external USB drive
Hi, bit of a rookie here! I have copied about 70GB of music from my PC to a 500GB external hard drive, which I now want to connect to my tablet so I can play the music. However, the tablet either doesnt recognise the external storage at all (it doesn
-
Are there any other Lower Thirds Titles like "Clouds"?
Are there any other "Lower Thirds" titles that are like "Clouds"? Is there a way to download them and pop them into your titles folder perhaps... Just the variety of Lower Thirds titles are non existent, so I assumed there would be a library of title
-
Any recommendations for a hosting site and photo album software?
I'm looking for a hosting site that doesn't cost too much. All I want is the ability for someone to upload images (perhaps sometimes large) to a site that I can download and edit, then re-upload. I'm looking at an open source software called Gallery.
-
Remote debug a Flash file running inside an application
Hello everyone. I'm an application developer, and my standard usage of Flash is as follows: I'm creating an executable application, which contains a ShockwaveFlash object instance, which in turn is displaying a Flash Movie Clip - also created by myse