2008 Aug 06 1:26 PM
Hi all,
I have written a simple program to transfer contents to an excel sheet.
here is my code......
TYPES: BEGIN OF ty_pa0014,
pernr(8) TYPE c,
betrg TYPE pad_amt7s, " I have also tried betrg itself in type.
END OF ty_pa0014.
DATA: it_pa0014 TYPE STANDARD TABLE OF ty_pa0014 WITH HEADER LINE.
This is my select satement---
SELECT pernr
betrg
INTO (it_pa0014-pernr, it_pa0014-betrg)
FROM pa0014
WHERE uname = s_uname
AND aedtm = s_date.
COLLECT it_pa0014.
ENDSELECT.
SORT it_pa0014 BY pernr.
IF NOT it_pa0014 IS INITIAL.
" I have gone into debugging mode. The internal table is getting filled with contents. when I write a write statement, it displays the contents properly. I mean the PERNR and BETRG.
But when I transfer the contents using the below function module, the value for BETRG is coming as 0.00 or 0 in the excel sheet.
I do understand that there is some conversion problem.
Is there a better function module to handle amounts.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename = p_file
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = it_pa0014
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.
Regards,
Hari Kiran
2008 Aug 06 1:34 PM
WHERE uname in s_uname
AND aedtm in s_date.
here use in instead of = ......do it and let me know
WHERE uname in s_uname
AND aedtm in s_date.
here use in instead of = ......do it and let me know
2008 Aug 06 1:30 PM
2008 Aug 06 1:34 PM
WHERE uname in s_uname
AND aedtm in s_date.
here use in instead of = ......do it and let me know
2008 Aug 06 1:37 PM
Hi pandu,
I will make that change.
But, I dont think that's the problem
because I wrote a write statement after populationg the internal table.
And the values came out perfectly.
Thank you for replying.
2008 Aug 06 1:46 PM
Can u pl. check what value u r getting in I_TAB_CONVERTED_DATA parameter?
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename = p_file
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = it_pa0014
CHANGING
I_TAB_CONVERTED_DATA =
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
Also instead of using curr data type use char data type for betrg.
like:
tYPES: BEGIN OF ty_pa0014_1,
pernr(8) TYPE c,
betrg(25) TYPE c, " I have also tried betrg itself in type.
END OF ty_pa0014_1.
DATA: it_pa0014_1 TYPE STANDARD TABLE OF ty_pa0014_1 WITH HEADER LINE.
YPES: BEGIN OF ty_pa0014,
pernr(8) TYPE c,
betrg TYPE pad_amt7s, " I have also tried betrg itself in type.
END OF ty_pa0014.
DATA: it_pa0014 TYPE STANDARD TABLE OF ty_pa0014 WITH HEADER LINE.
SELECT pernr
betrg
INTO (it_pa0014-pernr, it_pa0014-betrg)
FROM pa0014
WHERE uname = s_uname
AND aedtm = s_date.
COLLECT it_pa0014.
ENDSELECT.
SORT it_pa0014 BY pernr.
loop at it_pa0014.
it_pa0014_1-pernr = t_pa0014-pernr.
it_pa0014_1-betrg = it_pa0014-betrg.
append it_pa0014_1.
endloop.
IF NOT it_pa0014_1 IS INITIAL.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER =
i_filename = p_file
I_APPL_KEEP = ' '
TABLES
i_tab_sap_data = it_pa0014_1
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.
endif.
Edited by: Joyjit Ghosh on Aug 6, 2008 2:47 PM
2008 Aug 06 1:59 PM
Hi all,
I used GUI_DOWNLOAD.
It has resolved the issue.
BETRG is getting populated properly in the excel sheet.
for example--
10007 162.16--> BETRG Value
I have taken the following for BETRG--
" betrg TYPE pad_amt7s, "
I will try out what Ghosh has said and get back.
Regards,
Hari
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |