Field value is truncated while downloading to excel sheet from ALV report
Hi All,
I developed ALV report and displaying output.
In that output i had a filed VBRP-PRODH filed.
In the output it is coming correctly but while i click downlaod to excel the valus is truncted.
for Example the value for VBRP-PRODH is 03322764170100201
while downlaoding this one to excel it is showing 3322764170100200
Any inputs please..
Regards
Jai
Wrong forum..post in ABAP
Similar Messages
-
Downloading to Excel Sheet from ALV display
Hi Friends,
Here i am displaying data in ALV grid. i want to download data to excel file . My data is stored in a field symbol.Could you please tell me how to download this? Currently i am trying with
CALL FUNCTION 'OLE_SERVER_CHECK'
CALL FUNCTION 'XXL_SIMPLE_API'
But i am not getting the result.
Thanks.Download a report to excel with format (border, color cell, etc)
Try this program...
Code:
REPORT ZTEST NO STANDARD PAGE HEADING.
this report demonstrates how to send some ABAP data to an
EXCEL sheet using OLE automation.
INCLUDE OLE2INCL.
handles for OLE objects
DATA: H_EXCEL TYPE OLE2_OBJECT, " Excel object
H_MAPL TYPE OLE2_OBJECT, " list of workbooks
H_MAP TYPE OLE2_OBJECT, " workbook
H_ZL TYPE OLE2_OBJECT, " cell
H_F TYPE OLE2_OBJECT. " font
TABLES: SPFLI.
DATA H TYPE I.
table of flights
DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
*& Event START-OF-SELECTION
START-OF-SELECTION.
read flights
SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
display header
ULINE (61).
WRITE: / SY-VLINE NO-GAP,
(3) 'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(4) 'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
(8) 'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
ULINE /(61).
display flights
LOOP AT IT_SPFLI.
WRITE: / SY-VLINE NO-GAP,
IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
ENDLOOP.
ULINE /(61).
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-007
EXCEPTIONS
OTHERS = 1.
start Excel
CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
PERFORM ERR_HDL.
SET PROPERTY OF H_EXCEL 'Visible' = 1.
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
PERFORM ERR_HDL.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-008
EXCEPTIONS
OTHERS = 1.
get list of workbooks, initially empty
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP.
PERFORM ERR_HDL.
tell user what is going on
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
changes by Kishore - start
CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
PERFORM ERR_HDL.
add a new workbook
CALL METHOD OF H_MAPL 'Add' = H_MAP EXPORTING #1 = 2.
PERFORM ERR_HDL.
tell user what is going on
SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = 0
TEXT = TEXT-009
EXCEPTIONS
OTHERS = 1.
output column headings to active Excel sheet
PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
PERFORM FILL_CELL USING 1 3 1 'Von'(003).
PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
LOOP AT IT_SPFLI.
copy flights to active EXCEL sheet
H = SY-TABIX + 1.
PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
ENDLOOP.
changes by Kishore - end
disconnect from Excel
CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'C:\SKV.XLS'.
FREE OBJECT H_EXCEL.
PERFORM ERR_HDL.
FORM FILL_CELL *
sets cell at coordinates i,j to value val boldtype bold *
FORM FILL_CELL USING I J BOLD VAL.
CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
PERFORM ERR_HDL.
SET PROPERTY OF H_ZL 'Value' = VAL .
PERFORM ERR_HDL.
GET PROPERTY OF H_ZL 'Font' = H_F.
PERFORM ERR_HDL.
SET PROPERTY OF H_F 'Bold' = BOLD .
PERFORM ERR_HDL.
ENDFORM.
*& Form ERR_HDL
outputs OLE error if any *
--> p1 text
<-- p2 text
FORM ERR_HDL.
IF SY-SUBRC <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
STOP.
ENDIF.
ENDFORM. " ERR_HDL
Regards,
Pavan -
Download to excel sheet from ALV Grid report
Hi,
I need to download 3 lakhs of data to excel sheet but the constraint is that excel is having max limit of 65000 line items.
So i need to know the way in which i can create more than one sheet in excel while downloading so that each sheet can hold upto 65000 line items.
i need to create atleast 6 sheets in excel while downloading from report.
please help.Hi,
While downloading the data, it will prompt you save the list in file - Uncoverted, Spreadsheet, Rich text format, HTML format, Copy to Clipboard.
Why don't you try using Uncoverted format and give extension as .txt file.
So that you can download all 3 lacs of records.
Even if you use any FM, it will indirectly use excel for downloading and it will have restriction of having 65000 records only.
Thanks,
Sriram Ponna. -
Error while opening the EXCEL Sheet from a Report Program
Hi All,
I am getting an error saying 'SYLK: File Format is not valid' when my program is trying to open an excel sheet. I am using the function module WS_EXCEL to download it to excel sheet.
Following is the code:
Excel download
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
concatenate 'C:\' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
Download to Excel failed.
endif.
a00_excel contains the data that is to be downloaded into the excel sheet. I used the same code in the other program it is working fine. If you see in the type declaration for C5 its 70 characters, i tried putting it as same as others to 20... still it doesnt work.
Thank You,
SureshNot sure man, your code works ok for me.
report zrich_0001.
types: begin of t_excel,
c01(20),
c02(20),
c03(20),
c04(20),
c05(70),
c06(20),
c07(20),
c08(20),
c09(20),
c10(20),
end of t_excel.
data: a00_excel type standard table of t_excel.
data: x00_excel like line of a00_excel.
data: z_fname type string.
x00_excel-c01 = 'A'.
x00_excel-c02 = 'B'.
x00_excel-c03 = 'C'.
x00_excel-c04 = 'D'.
x00_excel-c05 = 'E'.
x00_excel-c06 = 'F'.
x00_excel-c07 = 'G'.
x00_excel-c08 = 'H'.
x00_excel-c09 = 'I'.
x00_excel-c10 = 'J'.
append x00_excel to a00_excel.
x00_excel-c01 = 'K'.
x00_excel-c02 = 'L'.
x00_excel-c03 = 'M'.
x00_excel-c04 = 'N'.
x00_excel-c05 = 'O'.
x00_excel-c06 = 'P'.
x00_excel-c07 = 'Q'.
x00_excel-c08 = 'R'.
x00_excel-c09 = 'S'.
x00_excel-c10 = 'T'.
append x00_excel to a00_excel.
concatenate 'C:' sy-repid sy-uzeit 'FILE01' '.xls' into z_fname.
condense z_fname no-gaps.
call function 'WS_EXCEL'
exporting
filename = z_fname
tables
data = a00_excel
exceptions
others = 1.
if sy-subrc ne 0.
message e019(zsd).
* download to excel failed.
endif.
Regards,
Rich Heilman -
Problem in down loading to excel sheet from ALV report
Hi Experts,
I have used the funtion module REUSE_ALV_GRID_DISPLAY, and for field catalog I have individually written the field catalog as there are not many fields instead of using the funtion module REUSE_ALV_FIELDCATALOG_MERGE.
Report is getting displayed well but while getting down load to xls only numeric fields are appearing and character fields are not appearing.
Have I selected the function module formats correctly.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = 'ZHR_DETAILS'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Active ETA Details'
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = RT_FCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
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
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
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.
Please advice me.
Thanks in advance.
Regards,
Irfan HussainHi Irfan,
This looks strange !!1
Try to use the layout option also and checkout if it works -
Leading zeros deleted while downloading to excel sheet
Hi ,
i am downloading data to excel sheet from internal table, iam using gui_download but its deletin leading zeros can any one tell me as to how i go about this
for ex i ahve a mterial no : 00123
i see 123 i want it to be 00123
Thanks
kajolHi,
try to explain to excel, that this field is character field (I think that it will be done by adding single quote as first character of string).
Pointing to my previous answer try:
Constants: c_single_quote(1) type c value ''''. " I _hope_ it works
loop at itab.
concatenate c_single_quote itab-matnr to texttab-c_matnr.
endloop. -
Warning while downloading an Excel file from WD ABAP
Hi folks,
In one of requirements, Client wants to download all the data that is appearing on the screen ( WD ABAP Application ) to an Excel with a layout in different manner.
We achieved this with Simple Transformations.
Now the question is while downloading the excel file, the framework/other is throwing an Warning like
" The file you are trying to open, 'info.xls', is in a different format than specified by the extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now? "
Note: All the users of my client are using MS Office 2002 / 2003.
I am using the following code........!
*------ Call Transformation for Excel OUTPUT
CALL TRANSFORMATION ZEXCEL_OUTPUT
SOURCE
t_dates = t_dates
t_info = t_info
RESULT XML l_xml_string.
REPLACE ALL OCCURRENCES OF '<?xml version="1.0" encoding="utf-16"?>' l_xml_string WITH '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'.
**-- Call Function Module for converting string data to XSTRING
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = l_xml_string
mimetype = 'application/xml'
IMPORTING
buffer = l_xml_xstring
EXCEPTIONS
failed = 1
OTHERS = 2.
CALL METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = 'info.xml'
i_content = l_xml_xstring
i_mime_type = 'application/vnd.ms-excel'.
With this code I am generating a file of type XML SPREADSHEET 2003. While opening this file I am getting the above message which the user unwanted......
Can any one help me on this -
> How to avoid this warning?
Thanks and Regards,
Aneel Danda
Edited by: danda aneel on Jul 13, 2010 1:43 PMFirstly, Thanks for Your quick Response, Thomas.
Even though what ever may be the file name I am passing either info.xml or Info.xls , In error info.xls is coming.
Kindly provide me an alternative on this XML doesn't seem like it would match the 'application/vnd.ms-excel'.
what is the supported format.?
Similarly, It is not considering the UTF-8 / UTF-16 for xml.........same result is appearing in the output.
Edited by: danda aneel on Jul 14, 2010 7:52 AM -
Hi Gurus,
is der any way to download data from ALV report to excel sheet depending on layout set dyanmically.
I mean to say that if I choose a layout then data has to transfer to excel sheet according to layout fields automaticaly.I think this can be done by oops ALV , are u using reusealv F.M to call output in ALV ?
Try the below kind of ALV
IN PBO -
>
SET PF-STATUS 'PROJREP'.
SET TITLEBAR text-046.
DATA: g_container TYPE scrfname VALUE 'ALV',
g_grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container. (Name of the container )
CREATE OBJECT g_grid1
EXPORTING i_parent = g_custom_container.
PERFORM create_field_catalog_ce
CALL METHOD g_grid1->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = t_fcat_ce.
ALL METHOD g_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'ST_DISPLAY'
CHANGING
it_outtab = t_display_io
it_fieldcatalog = t_fcat_ce.
->Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_double_click FOR g_grid1.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = g_grid1.
IN PAI -->
CALL METHOD cl_gui_cfw=>dispatch. -
Few records are missing while downloading to a Spreadsheet from a Report
Dear Gurus,
few records are missing while downloading to a Spread sheet from a Z report. There are around 300 records, out of which 11 records are not appearing in Spreadsheet file after saving. But, the funny thing is when i try to save in other format like, HTML or to a clip board all records are coming.
When asked, the ABAPer said -
your report is coming correctly. if the report is wrong then we can try checking some code in the Z report. Saving it into Spread sheet is the standard program provided by SAP.
He is also facing this problem for the first time.
Can anybody help.
Thanks in advance and u will get points if useful.
RegardsHi,
Few days back we got this kind of error, when i tried to down load the asset balances in excel format.
It was observed that, for one of the asset description ends with cama",". Due to this reason all other details has been stored in single cell. Once we changed the master data of that asset, then we able to get the report properly.
2) Some other time, when we tried to download material master details, for one of the material ... description not maintained. this is another issue. After maintain the description problem got resolved.
Hope this information will be helpful to u. -
Downloading records in in excel sheet from ALV.
Hi,
I am downloading Records from ALV GRID DIsplay to Excel sheet but i am unable to get all records that are displayed in ALV report.
I am getting only 73 records if i have only 180
Any inputs please for correctine the error
Regards
Rasheed.hi
you can follow these stapes and get ur work done
go to List > select Export > Spreadsheet or just click the excel icon from the tool bar.This would download the data to excel.
hope this helps
regards
Aakash Banga -
Excel sheets from Oracle reports
Is there any way to save the ouput of Oracle reports as an excel sheet?
I know it is possible to take the output as a text file and open the file from the Excel sheet. but the file is text, with no layout format, fonts,...
I tried to save it as HTML but when it is open from Excel each character is put on a distinctI have the same problem. Please let me know if you found a solution. Like you said it is possible to create a comma delimited file from Reports which can then be opened from Excel. Is there an easier way?
Thanks
Tertius -
Last digit truncates while downloading to Excel from ALV Grid
Hi All,
I have been using REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY in my report program.
While i use REUSE_ALV_GRID_DISPLAY and downloading the data to a local file(Excel) the last digit of the Vendor code is truncated. But in REUSE_ALV_LIST_DISPLAY the datas are downloaded correctly as displayed in the ALV.
I have copied the code for the reference.
REPORT zfirp001 .
TYPE-POOLS: slis.
TABLES: bsak.
SELECT-OPTIONS: s_bukrs FOR bsak-bukrs,
s_lifnr FOR bsak-lifnr,
s_blart FOR bsak-blart,
s_augdt FOR bsak-augdt,
s_zterm FOR bsak-zterm.
PARAMETERS: s_list AS CHECKBOX,
s_vari LIKE disvariant-variant.
DATA: g_ext_num(24) TYPE c.
DATA: BEGIN OF gt_bsak OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
END OF gt_bsak.
DATA: BEGIN OF gt_bseg OCCURS 0,
bukrs LIKE bseg-bukrs,
belnr LIKE bseg-belnr,
gjahr LIKE bseg-gjahr,
wrbtr LIKE bseg-wrbtr,
projk LIKE bseg-projk,
shkzg LIKE bseg-shkzg,
hkont LIKE bseg-hkont,
END OF gt_bseg.
ALV
DATA: gt_fieldtab TYPE slis_t_fieldcat_alv,
g_save(1) TYPE c,
g_variant LIKE disvariant.
DATA: BEGIN OF gt_result OCCURS 0,
bukrs LIKE bsak-bukrs,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
augdt LIKE bsak-augdt,
gjahr LIKE bsak-gjahr,
belnr LIKE bsak-belnr,
blart LIKE bsak-blart,
zterm LIKE bsak-zterm,
wrbtr LIKE bseg-wrbtr,
waers LIKE bkpf-waers,
ext_num(24) TYPE c,
txt20 LIKE skat-txt20,
usr00 LIKE prps-usr00,
usr01 LIKE prps-usr01,
usr02 LIKE prps-usr02,
usr03 LIKE prps-usr03,
END OF gt_result.
CONSTANTS: c_credit(1) TYPE c VALUE 'H',
c_x(1) TYPE c VALUE 'X',
c_en(2) TYPE c VALUE 'EN',
c_mrc(4) TYPE c VALUE 'CA01'.
*====================================================
INITIALIZATION.
PERFORM initialize_variant.
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
*====================================================
START-OF-SELECTION.
REFRESH gt_result.
find clearing documents
SELECT bukrs
lifnr
augdt
gjahr
belnr
blart
zterm
INTO TABLE gt_bsak
FROM bsak
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr
AND augdt IN s_augdt
AND blart IN s_blart
AND zterm IN s_zterm.
CHECK NOT gt_bsak[] IS INITIAL.
LOOP AT gt_bsak.
read WBS items
SELECT bukrs
belnr
gjahr
dmbtr
projk
shkzg
hkont
INTO TABLE gt_bseg
FROM bseg
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr
AND projk > space.
gt_result-bukrs = gt_bsak-bukrs.
gt_result-lifnr = gt_bsak-lifnr.
gt_result-augdt = gt_bsak-augdt.
gt_result-belnr = gt_bsak-belnr.
gt_result-gjahr = gt_bsak-gjahr.
gt_result-blart = gt_bsak-blart.
gt_result-zterm = gt_bsak-zterm.
document currency
SELECT SINGLE waers
INTO gt_result-waers
FROM bkpf
WHERE bukrs = gt_bsak-bukrs
AND belnr = gt_bsak-belnr
AND gjahr = gt_bsak-gjahr.
vendor name
SELECT SINGLE name1
INTO gt_result-name1
FROM lfa1
WHERE lifnr = gt_result-lifnr.
for each accounting document
LOOP AT gt_bseg.
convert to external WBS
CALL FUNCTION 'PSPNUM_INTERN_TO_EXTERN_CONV'
EXPORTING
edit_imp = c_x
int_num = gt_bseg-projk
IMPORTING
ext_num = gt_result-ext_num
EXCEPTIONS
not_found = 1
OTHERS = 2.
debit or credit
IF gt_bseg-shkzg = c_credit.
gt_result-wrbtr = gt_bseg-wrbtr.
ELSE.
gt_result-wrbtr = gt_bseg-wrbtr * -1.
ENDIF.
GL short Text
SELECT SINGLE txt20
INTO gt_result-txt20
FROM skat
WHERE spras = c_en
AND ktopl = 'CA01'
AND saknr = gt_bseg-hkont.
user fields
SELECT SINGLE usr00
usr01
usr02
usr03
INTO (gt_result-usr00,
gt_result-usr01,
gt_result-usr02,
gt_result-usr03)
FROM prps
WHERE pspnr = gt_bseg-projk.
append to result table
APPEND gt_result.
ENDLOOP.
ENDLOOP.
*====================================================
END-OF-SELECTION.
PERFORM initialize_fieldcat USING gt_fieldtab[].
g_variant-report = sy-repid.
g_save = 'A'.
IF s_list = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.
ELSE.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldtab
i_default = 'A'
i_save = g_save
is_variant = g_variant
TABLES
t_outtab = gt_result.
ENDIF.
*& Form initialize_variant
FORM initialize_variant.
g_save = 'A'.
CLEAR g_variant.
g_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
s_vari = g_variant-variant.
ENDIF.
ENDFORM. " INITIALIZE_VARIANT
*& Form pai_of_selection_screen
FORM pai_of_selection_screen.
IF NOT s_vari IS INITIAL.
MOVE s_vari TO g_variant-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = g_save
CHANGING
cs_variant = g_variant.
ELSE.
PERFORM initialize_variant.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form initialize_fieldcat
FORM initialize_fieldcat USING p_fieldtab TYPE slis_t_fieldcat_alv.
DATA: l_fieldcat TYPE slis_fieldcat_alv.
CLEAR l_fieldcat.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BUKRS'.
l_fieldcat-seltext_L = 'Company'.
l_fieldcat-outputlen = '8'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'LIFNR'.
l_fieldcat-seltext_L = 'Vendor'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'NAME1'.
l_fieldcat-seltext_L = 'Name'.
l_fieldcat-outputlen = '35'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'AUGDT'.
l_fieldcat-seltext_L = 'Cleared'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'GJAHR'.
l_fieldcat-seltext_L = 'Year'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BELNR'.
l_fieldcat-seltext_L = 'Document'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'BLART'.
l_fieldcat-seltext_L = 'Type'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'ZTERM'.
l_fieldcat-seltext_L = 'Pay Terms'.
l_fieldcat-outputlen = '4'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WRBTR'.
l_fieldcat-seltext_L = 'Amount'.
l_fieldcat-outputlen = '13'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'WAERS'.
l_fieldcat-seltext_L = 'CURR'.
l_fieldcat-outputlen = '5'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'EXT_NUM'.
l_fieldcat-seltext_L = 'WBS'.
l_fieldcat-outputlen = '24'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'TXT20'.
l_fieldcat-seltext_L = 'Short Text'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR00'.
l_fieldcat-seltext_L = 'H/O File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR01'.
l_fieldcat-seltext_L = 'Local File Ref'.
l_fieldcat-outputlen = '20'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR02'.
l_fieldcat-seltext_L = 'INFORM Agree ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
l_fieldcat-tabname = 'GT_RESULT'.
l_fieldcat-fieldname = 'USR03'.
l_fieldcat-seltext_L = 'INFM Prim Ag ID'.
l_fieldcat-outputlen = '10'.
APPEND l_fieldcat TO p_fieldtab.
ENDFORM. " INITIALIZE_FIELDCAT
Could the experts do help to overcome the probs.
Thanks in Advance.
Regards,
Anbalagan.VHi Anbalagan,
i've tested your program - but it works fine (Rel. 4.6C,SAPKB46C30)
download is ok and direct transfer (excel inplace) is ok.
but i've a question to the selection of waers in your program -
why do you select waers from bkpf and not from bsak ?
i think sel. of bkpf is'nt necessary !
regards Andreas -
Download to Excel file from ALV Grid
Hi,
I'm having a problem in downloading ALV Grid to excel file. The problem are the numbers are not in float format. I want them all in float format. Numbers in thousands are formatted with comma and decimals but numbers less than thousands are not in decimals.
Ex:
5 should be 5.00.
In ALV, this number is being displayed as 5.00 but when downloaded it displayed as 5 only.Did you mention the INTTYPE and Decimals in the fieldcatalog for those fields.
INTTYPE = 'P'.
DECIMALS_OUT = '3'.
try this..
also
use the Option
short cut CTRLSHFTF9 option
Local File->Spreadsheet-> and save it to excel file. -
Not able to download all the rows to excel sheet from alv grid display
Hi experts,
I am not able to download all the rows which are displayed in alv grid display for some material numbers.
for some materials i am able to download, i used two ways to download 1) from icon(local file) on grid 2) menu list->export.
i checked in debugging till selecting the spread sheet pop up window, i am able to see all the data in internal table.
Can you suggest me what will be the problem....
thanks in advance,hi sandeep,
sorry for didnt specify clearly.
note: EX: "asaasdada in this sentence i said " this symbol is special character not the text.
building final internal table code
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = p_capid
datuv = sy-datum
ehndl = '1'
mktls = 'X'
mehrs = 'X'
mmory = '1'
mtnrv = p_matnr
stlal = '1'
stpst = 0
svwvo = 'X'
werks = p_werks
vrsvo = 'X'
TABLES
stb = i_stb
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
conversion_error = 8
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
i_stb1[] = i_stb[].
IF NOT i_stb1[] IS INITIAL.
SORT i_stb1 BY idnrk.
DELETE ADJACENT DUPLICATES FROM i_stb1 COMPARING idnrk.
SELECT bmatn ematn FROM ampl INTO TABLE i_ampl
FOR ALL ENTRIES IN i_stb1
WHERE bmatn = i_stb1-idnrk AND
datuv LE sy-datum AND
datub GE sy-datum.
SELECT
matnr
bwkey
verpr
stprs
bwprh
FROM mbew
INTO TABLE i_mbew
FOR ALL ENTRIES IN i_stb1
WHERE
matnr EQ i_stb1-idnrk AND
bwkey EQ i_stb1-werks.
IF NOT i_stb1[] IS INITIAL.
SELECT matnr werks beskz
dzeit webaz plifz
ekgrp
INTO TABLE i_marc
FROM marc
FOR ALL ENTRIES IN i_stb1
WHERE matnr = i_stb1-idnrk
AND werks = i_stb1-werks.
SORT i_marc BY matnr werks.
ENDIF.
CLEAR i_ekpo.
CLEAR i_vend.
IF NOT i_stb1[] IS INITIAL.
SELECT ebeln ebelp matnr werks loekz aedat
netpr peinh
INTO TABLE i_ekpo
FROM ekpo
FOR ALL ENTRIES IN i_stb1
WHERE matnr = i_stb1-idnrk
AND werks = i_stb1-werks.
SORT i_ekpo BY matnr ASCENDING
aedat DESCENDING
ebeln DESCENDING
ebelp DESCENDING.
IF NOT i_ekpo IS INITIAL.
SELECT k~ebeln k~lifnr l~name1
INTO TABLE i_vend
FROM ekko AS k INNER JOIN lfa1 AS l
ON k~lifnr EQ l~lifnr
FOR ALL ENTRIES IN i_ekpo
WHERE ebeln = i_ekpo-ebeln.
SORT i_vend BY ebeln.
ENDIF.
ENDIF.
ENDIF.
i_ampl1[] = i_ampl[].
IF NOT i_ampl1[] IS INITIAL.
SORT i_ampl1 BY ematn.
DELETE ADJACENT DUPLICATES FROM i_ampl1 COMPARING ematn.
SELECT matnr mfrpn mfrnr FROM mara INTO TABLE i_mara
FOR ALL ENTRIES IN i_ampl1
WHERE matnr = i_ampl1-ematn.
ENDIF.
SORT i_ampl BY bmatn.
IF NOT i_stb[] IS INITIAL.
SELECT stlty stlnr stlkn stpoz idnrk potx1 potx2
INTO TABLE i_stpo
FROM stpo
FOR ALL ENTRIES IN i_stb
WHERE stlty = i_stb-stlty
AND stlnr = i_stb-stlnr
AND stlkn = i_stb-stlkn
AND stpoz = i_stb-stpoz
AND idnrk = i_stb-idnrk.
SORT i_stpo BY stlty stlnr stlkn stpoz idnrk.
ENDIF.
LOOP AT i_stb INTO wa_stb.
READ TABLE i_marc INTO wa_marc
WITH KEY matnr = wa_stb-idnrk
werks = wa_stb-werks
BINARY SEARCH.
IF sy-subrc = 0.
wa_outtab-beskz = wa_marc-beskz.
wa_outtab-dzeit = wa_marc-dzeit.
wa_outtab-webaz = wa_marc-webaz.
wa_outtab-plifz = wa_marc-plifz.
wa_outtab-ekgrp = wa_marc-ekgrp.
ENDIF.
READ TABLE i_ekpo INTO wa_ekpo
WITH KEY matnr = wa_stb-idnrk.
IF sy-subrc = 0.
wa_outtab-netpr = wa_ekpo-netpr.
wa_outtab-peinh = wa_ekpo-peinh.
READ TABLE i_vend INTO wa_vend
WITH KEY ebeln = wa_ekpo-ebeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_outtab-lifnr = wa_vend-lifnr.
wa_outtab-name_sup = wa_vend-name1.
ENDIF.
ENDIF.
READ TABLE i_stpo INTO wa_stpo
WITH KEY stlty = wa_stb-stlty
stlnr = wa_stb-stlnr
stlkn = wa_stb-stlkn
stpoz = wa_stb-stpoz
idnrk = wa_stb-idnrk
BINARY SEARCH.
IF sy-subrc = 0.
wa_outtab-potx1 = wa_stpo-potx1.
wa_outtab-potx2 = wa_stpo-potx2.
ENDIF.
READ TABLE i_mbew INTO wa_mbew
WITH KEY
matnr = wa_stb-idnrk
bwkey = wa_stb-werks.
IF sy-subrc IS INITIAL.
MOVE:
wa_mbew-verpr TO wa_outtab-verpr,
wa_mbew-stprs TO wa_outtab-stprs,
wa_mbew-bwprh TO wa_outtab-bwprh.
ENDIF.
wa_outtab-matnr = p_matnr.
wa_outtab-posnr = wa_stb-posnr.
wa_outtab-stufe = wa_stb-stufe.
wa_outtab-idnrk = wa_stb-idnrk.
wa_outtab-ojtxb = wa_stb-ojtxp.
wa_outtab-menge = wa_stb-menge.
wa_outtab-meins = wa_stb-meins.
MOVE: wa_stb-zzitem_draw_no TO wa_outtab-zzitem_draw_no.
IF wa_stb-upskz = 'X'.
SELECT * FROM stpu INTO TABLE i_stpu
WHERE stlty = wa_stb-stlty AND
stlnr = wa_stb-stlnr AND
stlkn = wa_stb-stlkn AND
stpoz = wa_stb-stpoz.
ENDIF.
LOOP AT i_stpu INTO wa_stpu.
wa_outtab-upmng = wa_stpu-upmng.
wa_outtab-ebort = wa_stpu-ebort.
wa_outtab-uposz = wa_stpu-uposz.
CONCATENATE v_ebort wa_stpu-ebort INTO v_ebort
SEPARATED BY space.
ENDLOOP.
MOVE strlen( v_ebort ) TO v_len.
MOVE: 0 TO x,
128 TO y.
DATA : lt_tab TYPE TABLE OF swastrtab.
DATA : ls_tab LIKE LINE OF lt_tab.
DATA : lv_ebort TYPE string.
CLEAR lv_ebort. CLEAR lt_tab.
MOVE v_ebort TO lv_ebort.
CALL FUNCTION 'SWA_STRING_SPLIT'
EXPORTING
input_string = lv_ebort
max_component_length = 128
TABLES
string_components = lt_tab
EXCEPTIONS
max_component_length_invalid = 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.
IF lt_tab[] IS NOT INITIAL.
LOOP AT lt_tab INTO ls_tab.
CLEAR lv_ebort.
MOVE: ls_tab-str TO lv_ebort.
CONDENSE lv_ebort.
MOVE lv_ebort TO wa_outtab-ebort.
APPEND wa_outtab TO i_outtab.
CLEAR:
wa_outtab-matnr,
wa_outtab-posnr,
wa_outtab-zzitem_draw_no,
wa_outtab-ojtxb,
wa_outtab-menge,
wa_outtab-meins,
wa_outtab-uposz,
wa_outtab-upmng,
wa_outtab-verpr,
wa_outtab-stprs,
wa_outtab-bwprh,
wa_outtab-lifnr,
wa_outtab-name_sup,
wa_outtab-potx1,
wa_outtab-potx2,
wa_outtab-netpr,
wa_outtab-peinh.
* wa_outtab-idnrk.
ENDLOOP.
ELSE.
APPEND wa_outtab TO i_outtab.
ENDIF.
CLEAR v_ebort.
CLEAR: wa_stpu.
REFRESH: i_stpu.
LOOP AT i_ampl INTO wa_ampl WHERE bmatn = wa_stb-idnrk.
READ TABLE i_mara INTO wa_mara WITH TABLE KEY matnr = wa_ampl-ematn.
IF sy-subrc = 0.
LOOP AT i_outtab INTO wa_outtab
WHERE
idnrk = wa_stb-idnrk AND
flag NE 'X'.
wa_outtab-mfrpn = wa_mara-mfrpn.
wa_outtab-mfrnr = wa_mara-mfrnr.
SELECT SINGLE name1 FROM lfa1 INTO wa_outtab-name1 WHERE lifnr = wa_mara-mfrnr.
MOVE 'X' TO wa_outtab-flag.
MODIFY i_outtab FROM wa_outtab
TRANSPORTING mfrpn mfrnr name1 flag.
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
CLEAR:
wa_outtab-matnr,
wa_outtab-posnr,
wa_outtab-zzitem_draw_no,
wa_outtab-ojtxb,
wa_outtab-ebort,
* wa_outtab-idnrk,
wa_outtab-menge,
wa_outtab-meins,
wa_outtab-uposz,
wa_outtab-upmng,
wa_outtab-verpr,
wa_outtab-stprs,
wa_outtab-bwprh,
wa_outtab-lifnr,
wa_outtab-name_sup,
wa_outtab-potx1,
wa_outtab-potx2,
wa_outtab-netpr,
wa_outtab-peinh.
wa_outtab-mfrpn = wa_mara-mfrpn.
wa_outtab-mfrnr = wa_mara-mfrnr.
SELECT SINGLE name1 FROM lfa1 INTO wa_outtab-name1 WHERE lifnr = wa_mara-mfrnr.
APPEND wa_outtab TO i_outtab.
ENDIF.
ENDIF.
REFRESH i_stpu.
CLEAR i_stpu.
ENDLOOP. CLEAR: wa_matnr1, wa_mfrnr, wa_outtab.
ENDLOOP.
Edited by: srinivasareddy j on Mar 9, 2011 7:16 AM
Edited by: srinivasareddy j on Mar 9, 2011 7:20 AM -
Download to Excel Function in ALV
Hai Friends,
I am using the following methods to download the report to an Excel Sheet from ALV.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
CALL FUNCTION 'GUI_DOWNLOAD'
The report is downloaded to Excel but the Column names are not displayed. It is displaying as F1, F2, F3..................
How can i solve this?.Hi,
Please check with the sample code below:
*"Excel sheet header
CLEAR e_excel.
MOVE text-001 TO e_excel-var1.
MOVE text-002 TO e_excel-var2.
APPEND e_excel TO t_excel.
CLEAR e_excel.
UNASSIGN <fs_t_final>.
REFRESH t_excel.
LOOP AT t_final
ASSIGNING <fs_t_final>.
CHECK <fs_t_final> IS ASSIGNED.
*"Data continued after the header part
MOVE <fs_t_final>-var1 TO e_excel-var1.
MOVE <fs_t_final>-var2 TO e_excel-var2.
APPEND e_excel TO t_excel.
CLEAR e_excel.
data: w_savetitle TYPE string,
w_filname TYPE string,
w_filename TYPE string,
w_path TYPE string,
w_fpath TYPE string.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = w_savetitle
CHANGING
filename = w_filname
path = w_path
fullpath = w_fpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = w_filename
filetype = ASC
write_field_separator =
codepage =
TABLES
data_tab = t_excel
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
Maybe you are looking for
-
hi, i want to change the width of a jTable's columnborder. do i have to write a own border class or can i manipulate the default border in some way? thanx for help, mischa
-
HT204088 how can i make complain about purchasing an item in app store
i have a problemi purchase an item for one time but every month they take from my accounts money to renewal and i dont want that i need to stop it
-
HP LaserJet P2015DN and HP 2550 Error: MSG 0x0073c35f [CAT 7/3 STD 50015 ]
Hello, We've installed printer 2015DN in our network with drivers 2015 PCL or 2015 PS. all works fine except when printing from Peregrine Service Center V5. then we get the errormessage Error: MSG 0x0073c35f [CAT 7/3 STD 50015 ] Category: Underlying
-
Extending 27" Cinema Display A Great Distance
Hey all, I have purchased 2 cinema displays and I have my computer located about 100 feet away in a separate machine room. Normally i would buy a KVM extender to extend the display over Cat6. However since the LED cinema displays i have only have a M
-
AUTO-CREATE LONG LIST BY USING CRITERIAS FOR APPLICANTS
Hi, By defining criterias, is it possible to automatically create the long list on the system for suited applicants? Thanks in advance