Download to excel problem
Hi Friends,
DATA lo_nd_hr_update TYPE REF TO if_wd_context_node.
DATA lt_hr_update TYPE wd_this->elements_hr_update.
DATA ls_hr_update TYPE wd_this->element_hr_update.
navigate from <CONTEXT> to <HR_UPDATE> via lead selection
lo_nd_hr_update = wd_context->get_child_node( name = wd_this->wdctx_hr_update ).
@TODO handle non existant child
IF lo_nd_hr_update IS INITIAL.
ENDIF.
lo_nd_hr_update->get_static_attributes_table( IMPORTING table = lt_hr_update ).
DATA text TYPE string.
DATA xtext TYPE xstring.
LOOP AT lt_hr_update INTO ls_hr_update.
CONCATENATE text ls_hr_update-mandt
ls_hr_update-pernr
ls_hr_update-effdt
ls_hr_update-upddt
ls_hr_update-ename
ls_hr_update-aedat
ls_hr_update-aenam
ls_hr_update-sigempno
ls_hr_update-signame
ls_hr_update-emailid
ls_hr_update-rejuvem
ls_hr_update-rejuvey
ls_hr_update-enrich1
ls_hr_update-enrich2
ls_hr_update-offdt
ls_hr_update-status
ls_hr_update-accdt
ls_hr_update-tedempno
ls_hr_update-tedname
ls_hr_update-skill1
ls_hr_update-skill2
ls_hr_update-skill3
ls_hr_update-skill4
ls_hr_update-comments
ls_hr_update-letter_rel
ls_hr_update-reldt
ls_hr_update-practice
ls_hr_update-practext
ls_hr_update-location
ls_hr_update-email
ls_hr_update-bill_date
cl_abap_char_utilities=>newline INTO text SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text
IMPORTING
buffer = xtext.
wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
i_filename = 'WDP.xls'
String Variable
i_content = xtext
File Type
i_mime_type = 'EXCEL' ).
The problem is i'm facing is i'm unable to download all the contents.
Is there any restriction on string size.....whether i need to increase string size....
Is it the problem with table size it has more than 25 fields & around 150 reocrds but every time when i use above code getting arnd 11 rows of data.
Kindly reply.
Thanks.
Hi,
I did as folllow changes in my code .....
DATA text TYPE string.
DATA text_s TYPE string_table.
DATA xtext TYPE xstring.
LOOP AT lt_hr_update INTO ls_hr_update.
CONCATENATE text ls_hr_update-mandt
ls_hr_update-pernr
ls_hr_update-effdt
ls_hr_update-upddt
ls_hr_update-ename
ls_hr_update-aedat
ls_hr_update-aenam
ls_hr_update-sigempno
ls_hr_update-signame
ls_hr_update-emailid
ls_hr_update-rejuvem
ls_hr_update-rejuvey
ls_hr_update-enrich1
ls_hr_update-enrich2
ls_hr_update-offdt
ls_hr_update-status
ls_hr_update-accdt
ls_hr_update-tedempno
ls_hr_update-tedname
ls_hr_update-skill1
ls_hr_update-skill2
ls_hr_update-skill3
ls_hr_update-skill4
ls_hr_update-comments
ls_hr_update-letter_rel
ls_hr_update-reldt
ls_hr_update-practice
ls_hr_update-practext
ls_hr_update-location
ls_hr_update-email
ls_hr_update-bill_date
cl_abap_char_utilities=>newline INTO text SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
APPEND text TO text_s.
CLEAR text.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = text_s
IMPORTING
buffer = xtext.
wdr_task=>client_window->client->attach_file_to_response(
**path to the word file
i_filename = 'WDP.xls'
String Variable
i_content = xtext
File Type
i_mime_type = 'EXCEL' ).
but it wil through type conflict error in fm 'SCMS_STRING_TO_XSTRING'
pls suggest.......
Similar Messages
-
Dear Gurus a problem in alv report downloading to excel:
on executing the report works fine but when downloading to excel there last digit of bpvno is getting truncated.
ex: actual bpvno:'4000010' but excel o/p shows as '400001'
I have declared a field in final internal table as:
data: bpvno as bseg-belnr,
(in field catalog)
fieldcatalog-fieldname = 'BPVNO'.
fieldcatalog-seltext_m = 'BPV No.'.
fieldcatalog-seltext_L = 'BPV No.'.
fieldcatalog-col_pos = I1.
fieldcatalog-emphasize = 'X'.
append fieldcatalog .
clear fieldcatalog.
I1 = I1 + 1.
but after specifying the REF_TABLENAME & REF_FIELDNAME the downloaded excel o/p is correct.
My questions is:
1) i want to know what all are mandatory fields to be specified in fieldcatalog & is it compulsory to specify REF_TABLENAME & REF_FIELDNAME .
if not complusory why the downloaded excel value is being truncated ???
plz dont send materilas on alv and answer specific to the question....Hi,
I wrote a small program, and for me it worked. My assumption about the seltext was wrong. And I also didn't use output lenght.
Here is the code.
REPORT ZALVTOEXCEL .
type-pools slis.
data : gt_fcat type slis_t_fieldcat_alv.
data fieldcatalog like line of gt_fcat.
types : begin of t_belnr,
bpvno like bseg-belnr.
types end of t_belnr.
data gt_belnr type table of t_belnr.
data gwa_belnr type t_belnr.
gwa_belnr-bpvno = '4000010'.
append gwa_belnr to gt_belnr.
fieldcatalog-fieldname = 'BPVNO'.
fieldcatalog-seltext_m = 'BPV No.'.
fieldcatalog-seltext_L = 'BPV No.'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to gt_fcat.
clear fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = gt_fcat
I_SAVE = 'A'
TABLES
t_outtab = gt_belnr
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.
regards,
Advait. -
ALV download to Excel--Problem with Column Headers
Hi,
I have created a dynamic internal table and displaying it as ALV using SALV classes. Problem is that when I download this ALV to Excel I'm not getting Column headings same as they are in ALV display.
I mean in Excel it is showing Column headings taken from domain or data element.
While creating dynamic table i'm passing short/ Medium & Long text too. Still it is not working.
Any kinda help is appreciated.
Thanks & Regards,
Vivek Gaur
Edited by: Vivek Gaur on Nov 4, 2009 2:04 PMLook I cant actually post the code as it is divided in some global classes and main program. But i can elaborate the steps little further:
1: I have created a field catalog for Dynamic internal table. In it i have passed every necessary field along with short/medium/Long texts.
2: I fill up this dynamic table with data.
3: I assign a field symbol to this dynamic internal table.
4: I pass this field symbol to the factory method of CL_SALV_TABLE Class.
Thats it buddy..Hope u have understood my problem. -
Download to EXCEL - Problem with truncating leading zeros
Hello Experts
I have Reqs-
When i download data into EXCEL some of the fields like PERNR lets say if the valus of the PERNR is 01000032 then in the excel it is displaying it as 1000032 or esle if a DATE field with value 02/03/2007 (obtained by concatenating MM / DD / YYYY) it is displaying in the excel as 2/3/2007.
I dont want the truncating of zeros to happen.
Any INPUT will be rewarded with points.
Thanks
VjHi,
Try to use this FM.
There are two very important functional modules ,which are used to add zeroes(0) & Remove zeroes(0) from numeric string input respectively.
The functional module CONVERSION_EXIT_ALPHA_INPUT comes handy in this situation.
Another functional module CONVERSION_EXIT_ALPHA_OUTPUT is used to reverse the Operations performed by the above FM.
Let us look up the first case.
Function Module: CONVERSION_EXIT_ALPHA_INPUT
PARAMETER:
Importing Parameter: Input of type C
Exporting Parameter: Output of type C.
This function module is use to add zeroes (0), to the left of the numeric string input ,after making the input numeric string right justified .
If the input string is non-numeric (including alphanumeric) , string is stored as left justified ,with blanks towards the right.
If the string is numeric say vehicle number , vlcvehicle-vhcle( 10 char)
INPUT : 123456
OUTPUT : 0000123456
Whereas if string is non-numeric
INPUT : ABCD
OUTPUT: ABCD.
Hope this will solve your problem.
Regards
Balaji -
Script for the SAP report - download to excel - problem
Hi all
I know that similar problem had already been discussed but going through the solution presented in
any of that topic I was not able to be successful (I am beginner in terms of VBA and SAP scripting)
What I would like to do is simply create the SAP script which based on the parameters filled
in in the excel sheet (user form created) will connect to SAP and make the report which I would like to have saved on my local drive as an excel file.
Everything is ok till the moment I would like to save it. As you know SAP records the macro only till the moment some window pops up (where and under what name you would like to have your report saved)
Could you please advise ?
As a screen I attached also point where macro stops (maybe this makes difference)
Thank you in advance for any suggestions.
Below my code.
Private Sub CommandButton1_Click()
Dim MojaData
MojaData = ComboBox2.Value
Dim Companycode
Companycode = ComboBox1.Value
Dim Depreciation_area
Depreciation_area = ComboBox3.Value
If Not IsObject(Application1) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Application1 = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Application1.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application1, "on"
End If
Dim sbar As String
sbar = session.findById("wnd[0]/sbar").Text
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/n s_alr_87011990"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtBUKRS-LOW").Text = Companycode
session.findById("wnd[0]/usr/ctxtSO_ANLKL-LOW").Text = ""
session.findById("wnd[0]/usr/ctxtBERDATUM").Text = MojaData
session.findById("wnd[0]/usr/ctxtBEREICH1").Text = Depreciation_area
session.findById("wnd[0]/usr/ctxtSRTVR").Text = "0003"
session.findById("wnd[0]/usr/radSUMMB").SetFocus
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[1]/menu[1]").SelectMJ MJ - I cannot replicate a screen like you have to test it but here's what I would suggest:
Immediately above the command that brings up the SAVE AS dialog, insert these lines:
... your code up to here.....
FileName = "C:\Apps\Notifications.txt" '<----- enter your save file path/name
Wshell.run "C:\Apps\DataLoad.vbs " & FileName,1,False '<-- call up the loader program
... then continue with your code....
Then build a program "dataload.vbs" as follows:
Dim FileNam2
Set Wshell = CreateObject("WScript.Shell")
Do
bWindowFound = Wshell.AppActivate("Save As")
WScript.Sleep 1000
Loop Until bWindowFound
bWindowFound = Wshell.AppActivate("Save As")
if (bWindowFound) Then
Wshell.appActivate "Save As"
WScript.Sleep 100
Wshell.sendkeys "{TAB}"
Wshell.sendkeys "{TAB}"
Wshell.sendkeys "{TAB}"
Wshell.sendkeys "{TAB}"
Wshell.sendkeys "{TAB}" 'make 4 or 5 depending on the platform 4:XP, 5:Win7
WScript.Sleep 100
FileNam2 = WScript.Arguments.Item(0)
Wshell.sendkeys FileNam2
WScript.Sleep 100
Wshell.sendkeys "{ENTER}"
WScript.Sleep 100
end if
This should do the trick of copying your filename into the filename box in the SAVE AS dialog.As I said, I did not get to test it but that is the theory.
Trial-and-error is the only way in many cases.
Good luck
Regards
Umur -
ALV Downloading to Excel problem
Dear All,
I have a Zreport. When i execute it - i will get the required values in ALV.
I have a header in the report (which is above the ALV)
and a footer below the ALV.
Example
USER : Vishal
Date Executed : 07/07/2008
MATNR MAKTX QTY MEINS PRICE
123 abc 4 pc 400
343 fgh 4 pc 500
567 hje 5 pc 600
754 wer 7 pc 700
367 qsa 2 pc 800
Error Log:
When i try downloading the data in excel - the header and footer is coming opposite.
Example - like this
Error Log:
MATNR MAKTX QTY MEINS PRICE
123 abc 4 pc 400
343 fgh 4 pc 500
567 hje 5 pc 600
754 wer 7 pc 700
367 qsa 2 pc 800
USER : Vishal
Date Executed : 07/07/2008
please give me a solution
Senthildont use that.
there are other functionalities available like local file->spread sheet.
menu item list->export->spread sheet.
hope this works for you -
Hi,
im trying to output my internal table contents to an excel spreadsheet. i used set pf-status so that an icon shows up on the application tool bar and its working fine and triggers the xxl_simple_api FM TOO. however, im not getting any output on the excel spread sheet.please help me out. i attached the code below.
regards,
ravi.
DATA :
it_online LIKE gxxlt_o OCCURS 0 WITH HEADER LINE,
it_print LIKE gxxlt_p OCCURS 0 WITH HEADER LINE.
header-col_no = 1.
header-col_name = 'FIELD1'.
APPEND header.
header-col_no = 2.
header-col_name = 'FIELD2'.
APPEND header.
header-col_no = 3.
CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
header = 'test'
filename = 'ZPROGRAM'
N_KEY_COLS = 0
TABLES
col_text = header[]
data = itab_excel[] "data itab
online_text = it_online
print_text = it_print
EXCEPTIONS
dim_mismatch_data = 1
file_open_error = 2
file_write_error = 3
inv_winsys = 4
inv_xxl = 5
OTHERS = 6.
IF sy-subrc <> 0.
EXIT.
ENDIF.Hi,
Check this example..This is working fine for me..
DATA: COL_TEXT LIKE GXXLT_V OCCURS 0 WITH HEADER LINE.
DATA: ONLINE_TEXT like GXXLT_O occurs 0 with header line.
DATA: PRINT_TEXT like GXXLT_P occurs 0 with header line.
col_text-col_no = '1'.
col_text-col_name = 'ID'.
APPEND COL_TEXT.
col_text-col_no = '2'.
col_text-col_name = 'NAME'.
APPEND COL_TEXT.
data: begin of data occurs 0,
id type int4,
name type char20,
end of data.
data-id = 1.
data-name = 'Naren'.
append data.
data-id = 2.
data-name = 'Test'.
append data.
CALL FUNCTION 'XXL_SIMPLE_API'
EXPORTING
N_KEY_COLS = 1
TABLES
col_text = col_text
data = data
online_text = online_text
print_text = print_text
EXCEPTIONS
DIM_MISMATCH_DATA = 1
FILE_OPEN_ERROR = 2
FILE_WRITE_ERROR = 3
INV_WINSYS = 4
INV_XXL = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran -
Download file from UNIX to EXCEL problem
Hi,
I am trying to download file from UNIX server to excel file, there is one column which is messing up and that is number 100000000000000002 (18 in length) it is writing as 1E+17, funny thing is when I click on that cell it is showing as
100000000000000000.
I am using GUI_DOWNLOAD to download to excel, below is the output excel format, I am talking about 4th value from left
GUID leg_reg lic_type lic_num ex_lic_num vali_from valid_to created_by
3E633B85C05E6F28E100 EAR ENC 1E+17 ENC 20030305 20930305 VANRIJ
below is the program I am using to download the output from UNIX to excel
FORM get_data_file.
OPEN DATASET p_unxfil FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET p_unxfil INTO input_file_tab-line_string.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND input_file_tab.
CLEAR input_file_tab.
ENDDO.
ELSE.
PERFORM write_message USING 'ZZ' 'E' '000'
'Unable to find file' p_unxfil
' Press Enter key to exit.' ''.
ENDIF.
CLOSE DATASET p_unxfil.
DESCRIBE TABLE input_file_tab LINES record_cnt.
ENDFORM. " get_data_file
FORM create_pc_file.
DATA: l_file TYPE string.
MOVE p_pcfile TO l_file.
Save the file
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file
TABLES
data_tab = input_file_tab
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.
IF sy-subrc NE 0.
WRITE: / 'Error creating pc file', p_pcfile.
EXIT.
endif.
I will assure of points.
Thanks for your help
SarathIt is not the problem of your program. This happens becuase of the "nature" of the excel. You need to retain the text property of that column.
Try like this:
1. Download the file in .txt
2. Open Excel .. blank sheet
3. Now, click on Open. Select your .txt file
4. One pop up will come ..."Text Import Wizard"
5. Select the fixed width or Delimited ... Press Next ...
6. Select appropriate delimitors or fixed length .. press Next
7. Select your coulumn (which has the problem), Select the "Text" radiobutton on the upper-right corner and finish.
Regards,
Naimesh Patel -
Problem in downloading to excel sheet
hi,
i have a file in the application server which needs to be downloaded into excel sheet and send it via attachment to outlook id's..
file is getting downloaded into excel sheet ( Via custom function module) and the attachment is being sent to the mail box, but the problem is everything appears in the first column..how to set the delimiters in excel sheet, i mean each field should appear in a separate coloumn...
format of the file in the application server
data: begin of dt_string occurs 0,
data(150) type c,
end of dt_string.
ex: dt_string+0(4) = 'name'.
dt_string+4(5) = 'place'. .....
append dt_string
clear dt_string.
same way, each record is inserted into the dt_string and the table was transferred to the app server.
thanksHi Mahesh,
Assuming that you are using 'GUI_DOWNLOAD'.
Add the thing in bold <b>WRITE_FIELD_SEPARATOR</b>.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename =
* FILETYPE = 'ASC'
* APPEND = ' '
<b> WRITE_FIELD_SEPARATOR = '#' "Tab Delimiter between fields</b>
Regards,
AS -
ALV - problem in downloading to excel - HIGH
In our ALV report , we are facing problem with downloading to excel. It is intact downloading but in an irregular manner.
LIST-> EXPORT-> Local File(excel)
How to overcome this..try to load like this
spreadsheet>press enter>pivot table-->microsoft excel -
Hi friends, Problems with Special Characters in Table download to Excel.
Hi friends,
I am using Binary Cache method to download to excel. The problem is that there are certain fields in the back end R/3 that has special characters in it eg : & * £ # etc.
As a result, the download is not working for these rows. Please can any of you tell me how to get rid of this. As an example let's say I wan to replace the "&" with "and".
Please help.
Thank You.
Avikhi,
Hope you find tgis of some help !!
public void ReplaceMethod( )
//@@begin ReplaceMethod()
// get the string value of the cell (for you from the table cell, for eg, Pinki & Rakesh)
test = wdContext.currentTestStringConversionElement().getInput();
// calculate the total length of the String
n=test.length ();
if(n!=0)
for(i=1;i<=n;i++)
// catching each character from the String
c = test.charAt (i-1);
// checking if any character within the String (eg, Pinki & Rakesh) is &
if (c=='&')
wdContext.currentTestStringConversionElement().setOutput(Character.toString(c));
no=i;
break;
String val = Integer.toString(no);
//wdContext.currentTestStringConversionElement().setNo(val);
// breaking the String and adding and in place of &
sub1= test.substring(0,i-1);
sub2= " and ";
sub3= test.substring(i,n);
//Concatenating the String
test1 = sub1sub2sub3;
//Printing the String
wdContext.currentTestStringConversionElement().setOutput(test1); -
Problem with CITY field when downloading to excel
Hi Gurus,
I have CITY field which is of 30 char length.Now Iam downloading the record having other fields also along with city field....Now my requirement is that in the Excel the city field should be right justified and the remaining characters should be space....How can we do that...
Generally I know that when We download to excel the fields adjust according to the data it has rather then with thier field size in SAP.
Regards,
Rohan.Hi,
In case of standard objects, it would be better if you can share the details like report name, the way you tried downloading(From menu, tool bar etc). Also search if there is any OSS notes for that program.
Thanks,
Vinod. -
Hi,
I have a problem with regards to the ALV download to excel. I have an ALV grid with 40 columns and i need to download the output to an excel file. But after downloading the ALV output, i noticed that some columns are already on the next line. i need to have all columns to be in the same line. Does anyone have an idea how to prevent columns to be printed in the next line?
Thanks in advance!
Kind regards,
MerriamLooks like Note 855314 has a workaround ... my be more.
Of course (yuk!), write you own download.
Best!
Jim -
ALV grid toolbar - standard download to excel error
Hi Experts,
In my ALV grid report, when i click on the standard ALV toolbar to download the output to excel file, the data gets downloaded fine execpt for one field called serial number. It is of size 18 chars.
The last number on this field is getting truncated when it is downloaded to excel. Only 17 characters is being shown. There is no output lenght specification in the field catalog. The column width optimize property is also not set. Any ideas on what might be the problem?
CheersHi,
Check this link:
Re: Digit missing in the alv export
Hope this helps.
Regards,
Satish Kanteti -
Download to excel from alv display
Hi,
How to download to excel from alv display.I am using object oriented abap for using alv.If i click export->spreadsheet i am getting fatal error and if i export->local file->spreadsheet i am getting only the column names and heading but no contents.Can anyone tell me how to overcome this problem.
Regards,
Sowmya.Hi Sowmya,
Just put break point near FM reuse_alv_grid_display and check if internal table which is used to display output is popullated or not.
Regards Sachin.
Maybe you are looking for
-
Could not get connections for 2 databases at the same time
Hi, I have a session bean which calls 2 entity beans in one method. The 2 entity beans are located in different databases (different datasources and different pools). When running, I got the following error: Couldn't get connection: java.sql.SQLExcep
-
PDF button Saveas Javascript not workning on other computers
Hi I created a pdf with a save button that executes a javascript with the saveas function. Problem is that it only seems to work on my PC and no other as the script does not appear to run. Kind regards Andy
-
Anyone using a HDMI to component cable?
Using an Apple TV 2 My TV doesn't have HDMI - I see cables for sale, but not at the Apple store. Anyone use one so I know it will work? Thanks
-
Solaris 01/06 Kernel panic at ipf
The system has three ethernet interfaces (Broadcom 5703, using bge driver). I added a line to ipf.conf to block an ip address and restarted ipfilter. 5-10 minutes later system rebooted and then freezed. I had to power down the system manually and the
-
Define dateline category during maintenance of billing plan type
Hi, I am in the midst of setting up the SD configuration in my current system from scratch and this is the error message that I have encountered, "Define dateline category during maintenance of billing plan type". Basically, what I have done is to c