01-05-2015 10:15 AM
Hello,
I am having a problem in getting headers by using cl_gui_frontend_services=>gui_download. I am getting headers as F1 F2 F3 F4.......and so on for headers. Can anybody provide me the code as to how to display the headers.
01-05-2015 10:20 AM
Hi Parita,
Hope you are passing the Header Value, while calling the Method.
Provide the code sample for better understanding your problem.
regards.
Praveer.
01-05-2015 11:01 AM
Hi,
Following is my code
DATA lv_montxt TYPE t247-ltx.
TYPES : BEGIN OF gs_itab1,
line TYPE char250,
end of gs_itab1.
DATA : gw_itab1 TYPE gs_itab1,
itab1 TYPE TABLE OF gs_itab1.
DATA: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
c_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
DATA : text1(250) TYPE c.
DATA : text2(250) TYPE c.
DATA : l_const(17) TYPE c VALUE '0107002268360010'.
break anukoran.
CONDENSE P_ICNUM NO-GAPS.
CONDENSE g_finamt NO-GAPS.
CONCATENATE '' 'H' 'ARNB' '2069' 'N' '' l_const 'SAR' '' g_finamt '' P_ICNUM '' INTO text1 SEPARATED BY c_tab. " by Parita
CONCATENATE text1 c_ret INTO text1.
CONCATENATE text-004 'D' text-017 text-007 text-005 text-016
g_payroll text-019 text-020 text-021 text-022 text-023 INTO text2 SEPARATED BY c_tab.
CONCATENATE text1 text2 INTO gw_itab1-line.
APPEND gw_itab1 to itab1.
CLEAR : gt_hsbc[].
*--and so on you have to add up the records in itab1.
LOOP AT gt_final INTO gs_final.
MOVE-CORRESPONDING gs_final TO wa_hsbc.
wa_hsbc-indc = 'D'.
************Start Changes by Parita on 29/12/2014
*FM to shift negative sign from right to left
DATA : gv_deduction(16) TYPE c.
gv_deduction = wa_hsbc-DED.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
VALUE = gv_deduction.
wa_hsbc-DED = gv_deduction.
* IF wa_hsbc-iban IS NOT INITIAL.
APPEND wa_hsbc TO gt_hsbc.
* ENDIF.
CLEAR :gs_final,wa_hsbc.
ENDLOOP.
* IF gt_hsbc[] IS NOT INITIAL.
DATA : lv_filename TYPE string.
DATA lv_dir(200) TYPE c.
DATA lv_file(100) TYPE c.
DATA lv_filetype TYPE Char10.
lv_filetype = 'DBF'.
SELECT SINGLE ltx FROM t247 INTO lv_montxt
WHERE spras = sy-langu
AND mnr = pnpdispp.
lv_dir = p_file.
CONCATENATE P_ICNUM '.XlS' INTO lv_file."pnpxabkr lv_montxt pnpdispj
CONCATENATE lv_dir '\' lv_file INTO lv_filename.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
* BIN_FILESIZE =
FILENAME = lv_filename
FILETYPE = lv_filetype
* APPEND = SPACE
WRITE_FIELD_SEPARATOR = '#'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
* DAT_MODE = SPACE
* CONFIRM_OVERWRITE = 'X'
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = SPACE
* WK1_N_SIZE = SPACE
* WK1_T_FORMAT = SPACE
* WK1_T_SIZE = SPACE
* SHOW_TRANSFER_STATUS = 'X'
FIELDNAMES = itab1
* WRITE_LF_AFTER_LAST_LINE = 'X'
* IMPORTING
* FILELENGTH =
CHANGING
DATA_TAB = gt_hsbc
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
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ENDIF.
refresh : gt_hsbc[].
01-05-2015 12:57 PM
01-06-2015 4:51 AM
01-06-2015 6:34 AM
Hi Parita,
If no values get populated in to titles(field name) table then we get out put as F1, F2 in field headings and also note that in field heading it allow only 10 characters.
Regards,
Manasa.
01-06-2015 6:51 AM
Hi Parita,
Found the solution.
Pass the Value in itab1 as below, it will give your the proper format of header.
1 Column
gw_tab1-line = text-004.
append gw_tab1 to itab1.
2 Column
gw_tab1-line = text-005.
append gw_tab1 to itab1.
...Like that you append your columns name into the itab1 table and then pass the same to FM.
You will get the Correct Header in file.
Regards.
Praveer.
01-05-2015 10:54 AM
you can call the same method twice, first call the internal table will have one record with the headers and the 2nd call will have values.
In the 2nd call pass the import parameter of the method append as 'X' .
01-05-2015 11:05 AM
01-05-2015 12:18 PM
Hi Parita,
Declare one itab with for header. suppose
BEGIN OF ty_header,
field1 TYPE char10,
field2 TYPE char12,
field3 TYPE char20,
field4 TYPE char30,
field5 TYPE bankn,
field6 TYPE char20,
field7 TYPE char15,
field8 TYPE char30,
field9 TYPE char30,
field10 TYPE char30,
field11 TYPE char30,
field12 TYPE char20,
field13 TYPE char20,
field14 TYPE char16,
END OF ty_header.
DATA: t_header TYPE TABLE OF ty_header.
Now put the header texts:
*--Appending header to the Text file.
CLEAR wa_header.
wa_header-field1 = text-008.
wa_header-field2 = text-009.
wa_header-field3 = text-010.
wa_header-field4 = text-011.
wa_header-field5 = text-012.
wa_header-field6 = text-013.
wa_header-field7 = text-014.
wa_header-field8 = text-015.
wa_header-field9 = text-016.
wa_header-field10 = text-017.
wa_header-field11 = text-018.
wa_header-field12 = text-019.
wa_header-field13 = text-020.
wa_header-field14 = text-021.
APPEND wa_header TO t_header.
Where the texts are the header texts.
Now call the method CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD and pass
CHANGING
DATA_TAB = t_header
It will download the header to the excel file.
Now again call the method CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD and pass
EXPORTING
APPEND = 'X'
CHANGING
DATA_TAB = the itab containing data ( in your case gt_hsbc)
pass the file name as same as above.
Passing append = 'X' will append the data records below the header record in the excel file.
Hope you are clear now!
01-06-2015 4:57 AM
Hi Tiki,
For filetype 'DBF', the headers come automatically as F1 F2 and so on inspite of not giving fieldnames. So the method you suggested is not working. Basically i am using 'DBF' to retain 0.00 in excel when internal table is downloaded since client wants it. So is there a way to keep 0.00 in excel other than using 'DBF'.
Please suggest.
01-06-2015 5:46 AM
Hi Parita,
In that case you have to pass the parameter FIELDNAMES also with the headers you want to set.
Please refer:
01-06-2015 5:46 AM