Download ALV output to excel with formatting
Hi All,
i want to download ALV output to excel sheet and the uneditable fields in ALV oputput should be locked (uneditable) in excel also.
Can you please tell me approach to achieve this functionality?
Thanks in advance.
Thanks Vamsi. Your Suggestion was helpful.
I have used excel integration and used SET PROPERTY OF (COLUMN) 'LOCKED' = 1.
For more details refer below mentioned link.
http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B(Password%2Bprotected)%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in (http://webcache.googleusercontent.com/search?q=cache:SoY6hFC17PoJ:wiki.sdn.sap.com/wiki/display/Snippets/Download%2BData%2Binto%2BMultiple%2BSheet%2BExcel%2BDocument%2Bwith%2BNon%2BEditable%2BColumns%2B%28Password%2Bprotected%29%2BUsing%2BABAP%2BOLESetPropertynoteditableexcelsapABAP&cd=1&hl=en&ct=clnk&gl=in&source=www.google.co.in
Similar Messages
-
Displaying alv output into excel with delimeter
Hai,
am downloading alv output to excel :
1. in that output one field is long text field with # delimeter at the end of sting .
while exporting this outout to excel it is not showing # and one empty column is adding after that field.Hi Satya,
Can you try out this piece of code below. It creates a demo Internal table to store some string with '#' as the final delimiter.
TYPES : BEGIN OF l_ty_demo,
data TYPE string,
END OF l_ty_demo.
DATA : l_i_demo TYPE STANDARD TABLE OF l_ty_demo.
DATA : l_wa_demo TYPE l_ty_demo.
DATA : l_v_i TYPE sy-tabix.
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.
WHILE l_v_i < 10.
l_wa_demo-data = 'Welcome to the world of computers#'.
APPEND l_wa_demo TO l_i_demo.
l_v_i = l_v_i + 1.
ENDWHILE.
* start Excel
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
PERFORM err_hdl.
SET PROPERTY OF h_excel 'Visible' = 1.
PERFORM err_hdl.
* 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.
LOOP AT l_i_demo INTO l_wa_demo.
h = sy-tabix + 1.
PERFORM fill_cell USING h 1 0 l_wa_demo-data.
ENDLOOP.
*& Form FILL_CELL
* text
* -->I text
* -->J text
* -->BOLD text
* -->VAL text
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. "FILL_CELL
*& Form ERR_HDL
* text
FORM err_hdl.
IF sy-subrc <> 0.
WRITE: / 'Fehler bei OLE-Automation:'(010), sy-subrc.
STOP.
ENDIF.
ENDFORM. "ERR_HDL
Please refer to the following Demo ABAP Code for a complete reference.
RSDEMO01.
Hope this helps.
Thanks,
Samantak. -
Hi gurus,
Cany anybody explain what is the procedure to download the alv output to EXCEL sheet?
Marks will be awarded
Thanks in Advance
RaviHi
when display the ALV . select from PF-STATUS menu bar select download option then SPEADSHEET. Thats all.
Reward all the helpful answers..
With Regards
Navin Khedikar -
Getting ERROR when downloading alv output to Excel
Hello All,
I get a error message when I try to use the standard funtionality to download the alv output to excel.
The current statement only supports character-type data objects.
What happened?
The current ABAP/4 program "SAPLKKBL " had to be terminated because
one of the statements could not be executed.
This is probably due to an error in the ABAP/4 program.
Error analysis
In statement
"STRLEN( obj )..."
the argument "obj" can only take a character-type data object.
Source code extract
038620 * ansonsten entspricht sich min. Ausgabelänge und Ausprägungslänge
038630 else.
038640 if gs_fc-tech_form ne 99.
> gs_out-hlplen = strlen( ).
038660 endif.
038670 endif.
In this case, the operand "obj" has the non-character type "I".
Please can anyone put some light on this. It is veru difficult to go through the whole std functionality to download.
Thanks for all support guys!
Sri.Hi srikanth,
This error comes because the values present in any one of the displayed coloums containing special character like * present before or after the number.... i.e instead of 4 ...**4.
While displaying in the screen it is of no problem. since both *4 are converted into char format (internally) and gets displayed.
But while you download the same throu the EXCEL functionality SAP will intenally convert the same into NUMERIC format. Since 4 is number.
So in that case *4 will cause dump.
*So find out the place in which the value appearing like this *4 and try to correct it.
*Surely it is of Field LENGTH problem. Try to increase the length of the field 4.
It Should WORK.!!!.. else post ur query here.
REWARD POINTS IF USEFUL
~Lakshmiraj~ -
Alv output to Excel with numeric fields as numeric fields only and not char
Hi,
When we download the alv output to excel format in the locat file using the toolbar button provided in the ALV, the numeric fields get converted to character format. Is there any other way or settings in ALV so that the numeric fields will be get saved as numeric fields only and not character?
Rgds,
MAdhuriany idea for above problem is welcome
-
Problem in downloading ALV output in excel
Dear Abapers,
I am facing a problem while downloading alv output in spreadsheet. Report headers and data headings are coming in excle but contents are missing instead of that No Data is displaying on excel sheet. I have debug that and observed the deep structure name T_OUTTAB using by the FM ALV_DATA_EXPORT is empty, It should contain the contents of my output data.
Below I am giving my code.
***********************************************declaration****************
BEGIN OF d_file_out,
index TYPE i, "Index no
msg TYPE string, "Message
msgtyp(1) TYPE c, "Message type
END OF d_file_out,
DATA:t_file_out TYPE TABLE OF d_file_out.
DATA:wa_file_out TYPE d_file_out.
Display Error Logs
PERFORM display_logs USING text-006.
FORM display_logs USING p_text TYPE string.
CONSTANTS: c_count TYPE char5 VALUE 'INDEX',
c_mestyp TYPE char6 VALUE 'MSG',
c_message TYPE char7 VALUE 'MSGTYP'.
*Field catalog
PERFORM: z_field_catalog USING c_count text-010, "Record number
z_field_catalog USING c_mestyp text-011, "Message type
z_field_catalog USING c_message text-012. "Message
*Top of page event
PERFORM z_event USING t_events.
wa_layout-colwidth_optimize = c_x.
ALV grid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_buffer_active = 'X'
i_callback_program = sy-repid
is_layout = wa_layout
I_STRUCTURE_NAME = wa_file_out
it_fieldcat = t_field
it_events = t_events
TABLES
t_outtab = t_file_out
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.
***********************************Fieldcatalog**********************************************
FORM z_field_catalog USING p_field TYPE any
p_name TYPE any.
wa_field-fieldname = p_field.
wa_field-seltext_l = p_name.
IF p_field = 'INDEX'.
wa_field-outputlen = '14'.
wa_field-col_pos = 1.
ELSEIF p_field = 'MSG'.
wa_field-outputlen = '120'.
wa_field-col_pos = 2.
ELSEIF p_field = 'MSGTYP'.
wa_field-outputlen = '08'.
wa_field-col_pos = 3.
ENDIF.
APPEND wa_field TO t_field.
CLEAR wa_field.
ENDFORM.
Here I have given my code, which contain the building of field catalog and Calling ALV Grid. I have already checked the excel micros settings. Other programs are working fine on my system and downloading in excel is also working.
Hope to get reply soon.
Regards,
HimanshuHi ,
use this to down load to xcel
v_file = lv_file.
DATA: BEGIN OF s_head OCCURS 0,
head(40) TYPE c ,
END OF s_head.
s_head-head = text-015."'Sales price'. * for header
APPEND s_head.
s_head-head = text-016."'Purchase price'. * for header
APPEND s_head.
s_head-head = text-017."'Listing Procedure'. * for header
APPEND s_head.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
write_field_separator = '#'
TABLES
data_tab = it_output1[]
fieldnames = s_head[]
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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. -
Problem in Download ALV Output to Excel
Hi All,
When iam going to Download the ALV ( Grid ) Output to Excel, all columns are not coming in Output.
But the ALV Output Contains 140 Columns.
How to solve this issue.
Points Rewarded.
Thanks & Regards,
Kiran . IHi,
You can download the report by going to menu option
List->export->local file.. in this select spreadsheet and give the name for this to download.
You can view all the columns here in xls sheet.
Regards,
Ram Mohan
Pls reward poins if useful... -
Problem in downloading ALV output to Excel
Here are the details of short dump.
Run time Error OBJECTS_NOT_CHARLIKE
The current statement only supports character-type data objects.
What happened?
Error in ABAP application program.
The current ABAP program "SAPLKKBL" had to be terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
What can you do?
Print out the error message (using the "Print" function)
and make a note of the actions and input that caused the
error.
To resolve the problem, contact your SAP system administrator.
You can use transaction ST22 (ABAP Dump Analysis) to view and administer
termination messages, especially those beyond their normal deletion
date.
Error analysis
In statement
"STRLEN( obj )..."
the argument "obj" can only take a character-type data object.
In this case, the operand "obj" has the non-character type "P".Declare another variable of same length as 'obj' let us say its obj1 , then move 'obj' to 'obj1', now findout the length of 'obj1', which wil be the same value.
MOVE obj TO obj1.
STRLEN(obj1).
Hope ur dump wil not trigger again.
Regards,
Sujatha. -
To download alv output to two excel sheets because of large data
Hi all,
I want to download alv output to excel sheet,I know how to do,but the no of record is very large and can not be accomodated in one sheet.
can anyone please tell how to download it into two sheets or some other way.
I want excel format only.
Regards,
sudhahi sudha yadav,
right now i am working on the same issue.
what right i am doing is that,
i want to download an internal table it is containing more than 2 lakhs records but excel can accomidate 60000 records, so
before call gui download i am sending first 60000 records into another internal table with same time, by using append statemen and indexs,
that new internal table i am downloading
again i am repeating the same thing by using sy-tabix,
finally i am creating more than one excel file
by using oops concepts we can also create in one excel file no of work sheets
but its lengthy process so i am right now creating no of excel files only
if it is useful , pls rewards points to this answer -
Procedure/sample code to download alv output in HTM format & mail to user.
Hello Experts,
I've a requirement to run the Alv report at background. But i need to download the alv output in HTM fomat because it has subtotal values & look wise downloaded HTM format will be same as that of ALV output. Then send the attachment through mail to users. I'm not intersted in downloading internal table dierctly to HTM format.
Will the code for alv display & downloading in HTM format & forwarding via email is all done in one single program or in 2 differnt programs . pls guide me on this.
I'm using FM REUSE_ALV_GRID_DISPLAY to display output with subtotals.
Pls anyone there suggest me the steps to download ALV output in HTM format & the forward the same to user ID through Lotus notes.
Regards
Devika.SHi,
This can be achieved without coding .
Fore ground Scenario:
1. Downloading as HTM . In foreground you can do this by using Export---> Local file
option in ALV grid.
Background Scenario:
2. In background while sending mail , You have to achieve the same through customisation settings as wexplained below.
In SM36 -- > Spool List Recipient, give the reciepient id and click on copy. Now when the Background job will be finished,
the reciepient mentioned above will recieve the mail , but in ALI format.
To convert the same to HTM format, you need to do customisation changes in SCOT
goto SCOT>Expant the node INT>Double click on Email-->Beside Internet we have SET tab , click on that -->
select the radio button " all formats except the following ">In the near by box type ALI>then click on the tick Mark.
Then go to SCOT>Settings>Conversion Rules-->there
create a new row with, Format->ALI , To Format->HTM , Ranking 1, FM -> SX_OBJECT_CONVERT_ALI_HTM.
Now when the mail will be sent, it will not go in ALI, but in HTM format.
Hope this helps you out. -
Downloading of ALV output to excel by asking the password
Hi all,
I need to down load the ALV output into the excel sheet. But the thing is that before going to download the output into excel sheet, the system has to prompt for password.once it happens then the user will enter the password and it should validate. if the validation is successful then the output should download to the excel sheet. This is the requirement, can anybody help me out regarding this.Please provide the function module names and sample code.
Thanks & Regards.
Laxman.P
B'lore.Hi,
Check this thread,
Make excel sheet password protected through ABAP codeu0085
Regards,
Omkar. -
I appreciate if anyone can let me know how to get the ALV output to an EXCEL file.I have done it thru list->export. Is there any other way?
Hi Deepti,
1) Once you have alv report displayed in the screen.
2) Click button 'View' ( next to print button) on application toolbar
3) Select Excel in Place
4) This will download the same format as of Report
I hope your ALV have all the Standard functions in Toolbar. If not copy the status from and get the function as mentioned above.
Program - SAPLSALV
Status - STANDARD
OR For downloading into Excel sheet use EXPORT->LOCAL FILE->Spread sheet
If you want to do programatically then:
Refer the link:
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
Please use the following FM
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename =
I_APPL_KEEP = ' '
tables
i_tab_sap_data =
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 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.
Another FM
MS_EXCEL_OLE_STANDARD_DAT
A simple option:
a) form download_file .
call function 'WS_EXCEL'
importing
filename = excel_name
tables
data = itab.
Reward points if this Helps.
Manish -
Download the output into Excel...(List- export- spreadsheet)
Dear friends,
I want to download the output into Excel...
I am using all SAP standards and using the ALV Block list
Ex: List->export->local file.. is anable from here i can download to excell .....but the same there is anothere option : List->export->spreadsheet...( this one inactive.)
I want to activate the List->export->spreadsheet option.
how to do this???
Thanks,
Sridhar.Hi
Use the Function Module:
EXCEL_OLE_STANDARD_DAT
For your purpose.
But by default you can get the option to download into several formats including your desired one.
Regards,
Sreeram -
ALV output converted into PDF format and send that PDF to user through mail
Hi Experts,
I have report earlier its output was in alv grid.
Now i want that ALV output converted into PDF format.And that PDF output send to user through mail.
Can u please tell how to do?
My code is here(output is displaying in ALV grid).
INCLUDE <icon>.
TYPE-POOLS: slis, kkblo.
TABLES : zmsd_freight_hdr, zmsd_freight_det, zmsd_blinfo, zmsd_diheader.
TABLES : lfa1.
DATA : t_hdr LIKE zmsd_freight_hdr OCCURS 0 WITH HEADER LINE,
T_DET LIKE ZMSD_FREIGHT_DET OCCURS 0 WITH HEADER LINE,
t_bl LIKE zmsd_blinfo OCCURS 0 WITH HEADER LINE,
t_di LIKE zmsd_diheader OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_det OCCURS 0.
INCLUDE STRUCTURE zmsd_freight_det.
DATA type(30).
DATA: END OF t_det.
DATA: v_target2(30),
v_zsammg LIKE t_det-zsammg,
v_gsttotal LIKE t_det-zamount.
DATA : BEGIN OF t_data OCCURS 0,
zsammg LIKE zmsd_freight_hdr-zsammg,
zdidbl LIKE zmsd_freight_hdr-zdidbl,
zvkorg LIKE zmsd_freight_hdr-zvkorg,
zinvno LIKE zmsd_freight_hdr-zinvno,
zttlamt LIKE zmsd_freight_hdr-zttlamt,
zstatus LIKE zmsd_freight_hdr-zstatus,
ztype LIKE zmsd_freight_hdr-ztype,
zconfirm LIKE zmsd_freight_hdr-zconfirm,
zconfirmdate LIKE zmsd_freight_hdr-zconfirmdate,
erdat LIKE zmsd_freight_hdr-erdat,
ernam LIKE zmsd_freight_hdr-ernam,
erzet LIKE zmsd_freight_hdr-erzet,
aedat(10),
aenam LIKE zmsd_freight_hdr-aenam,
aezet LIKE zmsd_freight_hdr-aezet,
zline LIKE zmsd_freight_det-zline,
zfptype LIKE zmsd_freight_det-zfptype,
zchrcode LIKE zmsd_freight_det-zchrcode,
zcurcode LIKE zmsd_freight_det-zcurcode,
zqty LIKE zmsd_freight_det-zqty,
zuom LIKE zmsd_freight_det-zuom,
zrate LIKE zmsd_freight_det-zrate,
zamount LIKE zmsd_freight_det-zamount,
zexrate LIKE zmsd_freight_det-zexrate,
zccode LIKE zmsd_blinfo-zccode, "MADK991565
zccode like ZMSD_FREIGHT_HDR-zfcode, "MADK991565
zbldate(10),
zbl LIKE zmsd_blinfo-zbl,
type(3),
waerk LIKE zmsd_freight_det-zcurcode,
zamountl LIKE zmsd_freight_det-zamount,
END OF t_data.
DATA : w_layout TYPE slis_layout_alv,
w_catalog TYPE slis_fieldcat_alv,
t_catalog TYPE slis_t_fieldcat_alv,
w_sort TYPE slis_sortinfo_alv,
t_sort TYPE slis_t_sortinfo_alv.
DATA V_ZINVNO like T_HDR-ZINVNO. "MADK991565
DATA : v_count TYPE i.
SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE text-001.
PARAMETERS : p_zvkorg LIKE zmsd_freight_hdr-zvkorg OBLIGATORY .
SELECT-OPTIONS : s_zdidbl FOR zmsd_freight_hdr-zdidbl ,
s_zccode FOR lfa1-lifnr ,
s_status FOR zmsd_freight_hdr-zstatus ,
s_ztype FOR zmsd_freight_hdr-ztype ,
s_erdat FOR zmsd_freight_hdr-erdat ,
s_ernam FOR zmsd_freight_hdr-ernam ,
s_zconfd FOR zmsd_freight_hdr-zconfirmdate .
PARAMETERS : p_zconf AS CHECKBOX .
SELECTION-SCREEN END OF BLOCK a0.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-002.
PARAMETERS : p_hdr RADIOBUTTON GROUP rad DEFAULT 'X' ,
p_det RADIOBUTTON GROUP rad .
SELECTION-SCREEN END OF BLOCK a1.
INITIALIZATION.
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM get_data.
PERFORM process.
PERFORM display.
END-OF-SELECTION.
PERFORM fm_get_num_pages.
AT USER-COMMAND.
AT LINE-SELECTION.
TOP-OF-PAGE.
PERFORM fm_top_of_page USING '7010' sy-title space.
FORM get_data.
SELECT *
FROM zmsd_freight_hdr
INTO TABLE t_hdr
WHERE zvkorg EQ p_zvkorg
AND zdidbl IN s_zdidbl
AND zstatus IN s_status
AND ztype IN s_ztype
AND erdat IN s_erdat
AND ernam IN s_ernam
AND zconfirmdate IN s_zconfd
AND ZFCODE IN S_ZCCODE. "MADK991565
IF p_zconf = 'X'.
DELETE t_hdr WHERE zconfirm NE 'C'.
ENDIF.
CHECK NOT t_hdr[] IS INITIAL.
SELECT *
FROM zmsd_blinfo
INTO TABLE t_bl
FOR ALL ENTRIES IN t_hdr
WHERE zsammg = t_hdr-zsammg.
SORT t_bl BY zsammg.
SELECT *
FROM zmsd_diheader
INTO TABLE t_di
FOR ALL ENTRIES IN t_hdr
WHERE zsammg = t_hdr-zsammg.
SORT t_di BY zsammg.
IF P_DET = 'X'. "MADK933361
SELECT *
FROM zmsd_freight_det
INTO TABLE t_det
FOR ALL ENTRIES IN t_hdr
WHERE zsammg = t_hdr-zsammg
AND ZINVNO = T_HDR-ZINVNO . "MADK991565
SORT t_det BY zsammg zline. "MADK991565
SORT T_DET BY ZSAMMG ZINVNO ZLINE. "MADK991565
ENDIF. "MADK933361
ENDFORM.
FORM process.
REFRESH t_data.
CLEAR v_gsttotal. "MADK933361
LOOP AT t_hdr.
Start of MADK933361
CLEAR: v_target2.
v_zsammg = t_hdr-zsammg.
V_ZINVNO = T_HDR-ZINVNO. "MADK991565
AT NEW zsammg. "MADK991565
AT NEW ZINVNO. "MADK991565
PERFORM get_gst_value.
ENDAT.
End of MADK933361
PERFORM move_header.
CHECK t_data-zccode IN s_zccode.
IF p_det = 'X'.
CSF Project Changes Starts DEV34 MADK985782
LOOP AT T_DET WHERE ZSAMMG = T_HDR-ZSAMMG..
LOOP AT t_det WHERE zsammg = t_hdr-zsammg AND
zinvno = t_hdr-zinvno.
CSF Project Changes Ends DEV34 MADK985782
PERFORM move_header.
CHECK t_data-zccode IN s_zccode.
MOVE-CORRESPONDING t_det TO t_data.
t_data-zamountl = t_data-zamount * t_data-zexrate.
APPEND t_data.
CLEAR t_data.
ENDLOOP.
ELSE.
APPEND t_data.
CLEAR t_data.
ENDIF.
AT END OF zsammg.
CLEAR v_gsttotal.
ENDAT.
*Start of changes for IS090901289-PIA MADK991565
AT END OF ZINVNO.
CLEAR V_GSTTOTAL.
ENDAT.
*End of changes for IS090901289-PIA MADK991565
ENDLOOP.
ENDFORM.
FORM move_header.
MOVE-CORRESPONDING t_hdr TO t_data.
t_data-zttlamt = t_data-zttlamt + v_gsttotal. "MADK933361
t_data-waerk = 'SGD'.
IF NOT t_hdr-aedat IS INITIAL.
WRITE: t_hdr-aedat TO t_data-aedat.
ELSE.
CLEAR : t_data-aedat.
ENDIF.
READ TABLE t_bl WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
IF sy-subrc EQ 0.
t_data-zccode = t_bl-zccode. "MADK991565
T_DATA-ZCCODE = T_HDR-ZFCODE. "MADK991565
IF NOT t_bl-zbldate IS INITIAL.
WRITE: t_bl-zbldate TO t_data-zbldate.
ENDIF.
t_data-zbl = t_bl-zbl.
t_data-type = 'DBL'.
ELSE.
READ TABLE t_di WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
IF sy-subrc EQ 0.
t_data-zccode = t_di-zdiforcode. "MADK991565
T_DATA-ZCCODE = T_HDR-ZFCODE. "MADK991565
t_data-type = 'DI'.
ENDIF.
ENDIF.
ENDFORM.
FORM display.
IF t_data[] IS INITIAL.
MESSAGE s398(00) WITH 'No Data Selected'.
EXIT.
ENDIF.
DATA : l_repid LIKE sy-repid.
l_repid = sy-repid.
REFRESH t_catalog.
CLEAR t_catalog.
w_layout-cell_merge = 'X'.
PERFORM map_fields.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_user_command = 'ALV_USER_COMMAND'
is_layout = w_layout
it_fieldcat = t_catalog[]
i_grid_title = sy-title
i_save = 'A'
it_sort = t_sort[]
TABLES
t_outtab = t_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
FORM map_fields.
Sort Order
CLEAR v_count.
PERFORM sf USING 'ZDIDBL' 'X' 'X'.
Fields to be displayed
CLEAR v_count.
IF p_hdr = 'X'.
PERFORM af USING :
DESCRIPTION FIELD LEN RTABLE RFIELD
'DI/DBL ' 'ZDIDBL' '14' ' ' ' ',
'Type ' 'TYPE' '04' ' ' ' ',
'Forwarder Code ' 'ZCCODE' '14' ' ' ' ',
'BL Number ' 'ZBL' '14' ' ' ' ',
'BL Date ' 'ZBLDATE' '10' ' ' ' ',
'Invoice Number ' 'ZINVNO' '15' ' ' ' ',
'Extraction ' 'ZSTATUS' '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
'Freight Type ' 'ZTYPE' '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE ',
'Confirmation ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
'Confirm Date ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
'ZCONFIRMDATE',
'Total Amount ' 'ZTTLAMT' '18' ' ' ' ',
'Created On ' 'ERDAT' '10' ' ' ' ',
'Created By ' 'ERNAM' '10' ' ' ' ',
'Changed On ' 'AEDAT' '10' ' ' ' ',
'Changed By ' 'AENAM' '10' ' ' ' '.
ELSE.
PERFORM af USING :
DESCRIPTION FIELD LEN RTABLE RFIELD
'DI/DBL ' 'ZDIDBL' '14' ' ' ' ',
'Type ' 'TYPE' '04' ' ' ' ',
'Forwarder Code ' 'ZCCODE' '14' ' ' ' ',
'BL Number ' 'ZBL' '14' ' ' ' ',
'BL Date ' 'ZBLDATE' '10' ' ' ' ',
'Invoice Number ' 'ZINVNO' '15' ' ' ' ',
'Extraction ' 'ZSTATUS' '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
'Freight Type ' 'ZTYPE' '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE ',
'Confirmation ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
'Confirm Date ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
'ZCONFIRMDATE',
'Total Amount ' 'ZTTLAMT' '18' ' ' ' ',
'Freight Payment ' 'ZFPTYPE' '14' ' ' ' ',
'Charge Code ' 'ZCHRCODE' '10' ' ' ' ',
'Currency ' 'ZCURCODE' '08' ' ' ' ',
'Quantity ' 'ZQTY' '13' ' ' ' ',
'UoM ' 'ZUOM' '04' ' ' ' ',
'Rate ' 'ZRATE' '15' ' ' ' ',
'Amt(Foreign Curr)' 'ZAMOUNT' '16' ' ' ' ',
'Exchange Rate ' 'ZEXRATE' '13' ' ' ' ',
'Amt(Local Curr) ' 'ZAMOUNTL' '16' ' ' ' ',
'Created On ' 'ERDAT' '10' ' ' ' ',
'Created By ' 'ERNAM' '10' ' ' ' ',
'Changed On ' 'AEDAT' '10' ' ' ' ',
'Changed By ' 'AENAM' '10' ' ' ' '.
ENDIF.
ENDFORM.
FORM af USING text
field
len
table
reffield.
v_count = v_count + 1.
w_catalog-col_pos = v_count.
w_catalog-fieldname = field.
w_catalog-ref_tabname = table.
w_catalog-ref_fieldname = reffield.
w_catalog-seltext_s = text.
w_catalog-seltext_m = text.
w_catalog-seltext_l = text.
w_catalog-outputlen = len.
IF field = 'ZTTLAMT' OR field = 'ZAMOUNTL'.
w_catalog-no_zero = 'X'.
w_catalog-cfieldname = 'WAERK'.
w_catalog-datatype = 'CURR'.
ENDIF.
IF FIELD = 'ZRATE' OR FIELD = 'ZAMOUNT'.
IF field = 'ZAMOUNT'.
w_catalog-no_zero = 'X'.
w_catalog-cfieldname = 'ZCURCODE'.
w_catalog-datatype = 'CURR'.
ENDIF.
IF field = 'ZQTY' OR field = 'ZRATE'.
w_catalog-no_zero = 'X'.
w_catalog-datatype = 'DEC'.
ENDIF.
APPEND w_catalog TO t_catalog.
CLEAR w_catalog.
ENDFORM.
FORM sf USING fieldname sortup group.
v_count = v_count + 1.
CLEAR w_sort.
w_sort-fieldname = fieldname.
w_sort-spos = v_count.
w_sort-up = sortup.
w_sort-group = group.
APPEND w_sort TO t_sort.
ENDFORM.
FORM alv_user_command USING in_ucomm LIKE sy-ucomm
in_selfield TYPE slis_selfield.
DATA: lfs_data LIKE t_data.
IF in_ucomm = '&IC1'.
READ TABLE t_data INDEX in_selfield-tabindex INTO lfs_data.
CHECK NOT lfs_data-zdidbl IS INITIAL.
IF lfs_data-type = 'DBL'.
DATA: l_zdbl LIKE zmsd_diheader-zdinum.
l_zdbl = in_selfield-value.
EXPORT l_zdbl TO MEMORY ID 'VBL'.
CALL TRANSACTION 'ZMSD_BL01'.
ENDIF.
IF lfs_data-type = 'DI'.
DATA: v_dinum LIKE zmsd_diheader-zdinum.
v_dinum = in_selfield-value.
EXPORT v_dinum TO MEMORY ID 'VDI'.
CALL TRANSACTION 'ZMSD_DI01'.
ENDIF.
ENDIF.
ENDFORM.
FORM get_gst_value.
LOOP AT t_det WHERE zsammg = v_zsammg
AND ZINVNO = V_ZINVNO. "MADK991565
CHECK t_data-zccode IN s_zccode.
t_det-zamount = t_det-zamount * t_det-zexrate.
SELECT SINGLE y0mmtarget2
INTO v_target2
FROM y0mmipstranslate
WHERE y0mmdatatype = '70' AND
y0mmsource = t_det-zchrcode.
SELECT SINGLE y0mmtarget1
INTO t_det-type
FROM y0mmipstranslate
WHERE y0mmdatatype = '76' AND
y0mmsource = v_target2.
IF t_det-type NE '3Z'.
v_gsttotal = v_gsttotal +
( t_det-zamount * 5 / 100 ).
ENDIF.
ENDLOOP.
Regards,
Raj.Hello,
Following is the procedure to convert alv output to spool and then it to PDF Format.
After we display the ALV, we can check whether it is running in the background using system field u2018sy-batchu2018. Then,we call an function module named u2018GET_JOB_RUNTIME_INFOu2019 to get the current job information. Then go to spool request table tbtcp to get the spool id.
Get current job details
CALL FUNCTION u2018GET_JOB_RUNTIME_INFOu2019
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> u20180000000000u2032
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
Finally, we can call function module u2018CONVERT_ABAPSPOOLJOB_2_PDFu2018 to convert spool reqeust(which is stored in OTF format) to PDF format. Then we can call either function module u2018SO_DOCUMENT_SEND_API1u2032 or SAP BCS (Business Communication Service) to send the pdf as an email attachment.
CALL FUNCTION u2018CONVERT_ABAPSPOOLJOB_2_PDFu2019
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
Regards,
Sayali
Edited by: Sayali Paradkar on Apr 20, 2010 12:51 PM -
How to Download displayed output to Excel Using Bsp Application
Hi Experts,
please give me some idea because I am New In BSP.
How to Download displayed output to Excel Using Bsp Application.
If any sample code please do send me.
In my condition I am getting data in 2-3 table view formats on one page and i want download that in Excel.
please help me.
Regards & Thanks,
YogeshHi,
This is more a question for the BSP forum.
Anyway, as such it's realy easy since you can use HTML in order to import to Excel. All you need to do is add
runtime->server->response->set_header_field( name = 'Contnet-Type'
value = 'application/vnd.ms-excel' ).
runtime->server->response->delete_header_field( name = 'Cache-Control' ).
runtime->server->response->delete_header_field( name = 'Expires' ).
runtime->server->response->delete_header_field( name = 'Pragma' ).
Also check threads like
Download BSP data into Excel
export bsp-table to excel
Export BSP Table to Excel
Eddy
PS. Reward useful answers and earn points yourself
Maybe you are looking for
-
I launch and relaunch and the same message appears over and over. Should I uninstall and then re-install Lightroom? Would this fix the problem?
-
How to load data from a flat file which is there in the application server
HI All, how to load data from a flat file which is there in the application server..
-
I got this error message when verifying the disk
The electricity in my apartment was abruptly shut down while I was using my imac. After I'd got all the electricity back on, I turn on my mac and found that when I verified the disk in disk utility I got this error message. Verifying volume "Macintos
-
My podcast wont download to IPOD
My podcast are gone after upgrading. Same thing happened to my music but I was able to find the fix to restore. Now I'm re-subscribing but the podcast wont download to my IPOD. Has anyone else had this issue
-
How to manage transactions in pl/sql instead of java
Hi, I have created a pl/sql package with a number of procedures and functions. In one of the functions I'd like to manage the transaction, instead of the jdbc driver. The function is something like: update <table> set <column>=<value> update <table>