2007 Jul 06 7:07 AM
hi,
i HAVE TO TAKE O/P IN EXCEL FILE. HERE IS SOME CODE WHICH I HAVE WRITTEN FOR DOWNLOADING IN EXCEL FILE.
BUT IT IS NOT DOWNLOADING.SO PLS HELP ME WHWT MISTAKE I AM DOING.
SELECT-OPTIONS: s_ekorg FOR ekko-ekorg,
WHEN 'EXCEL'.
PERFORM excel_exportieren_xxl
START-OF-SELECTION.
SET PF-STATUS 'D01'.
********SOME SELECT QUERRIES ARE WRITTEN
********eND OF SOME SELECT QUERRIES
FORM excel_exportieren_xxl.
Tabelle Online-Texte
DATA BEGIN OF xmplt_o OCCURS 1.
INCLUDE STRUCTURE gxxlt_o.
DATA END OF xmplt_o.
Tabelle Print-Texte
DATA BEGIN OF xmplt_p OCCURS 1.
INCLUDE STRUCTURE gxxlt_p.
DATA END OF xmplt_p.
Tabelle HKEY - horizontale Merkmale
DATA BEGIN OF xmplt_h OCCURS 1.
INCLUDE STRUCTURE gxxlt_h.
DATA END OF xmplt_h.
Tabelle VKEY - vertikale Merkmale
DATA BEGIN OF xmplt_v OCCURS 1.
INCLUDE STRUCTURE gxxlt_v.
DATA END OF xmplt_v.
Tabelle SEMA - semantische Informationen
DATA BEGIN OF xmplt_s OCCURS 1.
INCLUDE STRUCTURE gxxlt_s.
DATA END OF xmplt_s.
Spaltenüberschriften in Übergabetabelle einfügen
xmplt_h-col_no = 1.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkOrg'.
APPEND xmplt_h.
xmplt_h-col_no = 2.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpB'.
APPEND xmplt_h.
xmplt_h-col_no = 3.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefNr'.
APPEND xmplt_h.
xmplt_h-col_no = 4.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefName'.
APPEND xmplt_h.
xmplt_h-col_no = 5.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestellNr'.
APPEND xmplt_h.
xmplt_h-col_no = 6.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'Pos'.
APPEND xmplt_h.
xmplt_h-col_no = 7.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestDat'.
APPEND xmplt_h.
xmplt_h-col_no = 8.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'MatNr'.
APPEND xmplt_h.
xmplt_h-col_no = 9.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'MatKurztext'.
APPEND xmplt_h.
xmplt_h-col_no = 10.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BGS'.
APPEND xmplt_h.
xmplt_h-col_no = 11.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpM'.
APPEND xmplt_h.
xmplt_h-col_no = 12. "do060327
xmplt_h-row_no = 1. "do060327
xmplt_h-col_name = 'Dis'. "do060327
APPEND xmplt_h.
xmplt_h-col_no = 13.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZeichNr'.
APPEND xmplt_h.
xmplt_h-col_no = 14.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpE'.
APPEND xmplt_h.
xmplt_h-col_no = 15.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EtNr'.
APPEND xmplt_h.
xmplt_h-col_no = 16.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefDat'.
APPEND xmplt_h.
xmplt_h-col_no = 17.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'StatLiefDat'.
APPEND xmplt_h.
xmplt_h-col_no = 18.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'AuftragsbestNr'.
APPEND xmplt_h.
xmplt_h-col_no = 19. "do060118
xmplt_h-row_no = 1. "do060118
xmplt_h-col_name = 'K'. "do060118
APPEND xmplt_h. "do060118
xmplt_h-col_no = 20.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZBed'.
APPEND xmplt_h.
xmplt_h-col_no = 21.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg1'.
APPEND xmplt_h.
xmplt_h-col_no = 22.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg2'.
APPEND xmplt_h.
xmplt_h-col_no = 23.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg3'.
APPEND xmplt_h.
xmplt_h-col_no = 24.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZPr1'.
APPEND xmplt_h.
xmplt_h-col_no = 25.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZPr2'.
APPEND xmplt_h.
xmplt_h-col_no = 26.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'NTg'.
APPEND xmplt_h.
xmplt_h-col_no = 27.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 28.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffBestMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 29.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffReMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 30.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BME'.
APPEND xmplt_h.
xmplt_h-col_no = 31.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestWert'.
APPEND xmplt_h.
xmplt_h-col_no = 32.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffBestWert'.
APPEND xmplt_h.
xmplt_h-col_no = 33.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffReWert'.
APPEND xmplt_h.
xmplt_h-col_no = 34.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'Waer'.
APPEND xmplt_h.
Semantische Informationen in Übergabetabelle einfügen
xmplt_s-col_no = 1.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_ops = 'DFT'.
xmplt_s-col_src = 1. "EkOrg
APPEND xmplt_s.
xmplt_s-col_no = 2.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 2. "EkGrpB
APPEND xmplt_s.
xmplt_s-col_no = 3.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 3. "LiefNr
APPEND xmplt_s.
xmplt_s-col_no = 4.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 4. "LiefName
APPEND xmplt_s.
xmplt_s-col_no = 5.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 5. "BestellNr
APPEND xmplt_s.
xmplt_s-col_no = 6.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 6. "Pos
APPEND xmplt_s.
xmplt_s-col_no = 7.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 7. "BestDat
APPEND xmplt_s.
xmplt_s-col_no = 8.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 8. "MatNr
APPEND xmplt_s.
xmplt_s-col_no = 9.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 9. "MatKurztext
APPEND xmplt_s.
xmplt_s-col_no = 10.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 10. "BGS
APPEND xmplt_s.
xmplt_s-col_no = 11.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 11. "EkGrpM
APPEND xmplt_s.
xmplt_s-col_no = 12. "do060227
xmplt_s-col_typ = 'STR'. "do060327
xmplt_s-col_src = 12. "Dis "do060327
APPEND xmplt_s.
xmplt_s-col_no = 13.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 13. "ZeichNr
APPEND xmplt_s.
xmplt_s-col_no = 14.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 14. "EkGrpE
APPEND xmplt_s.
xmplt_s-col_no = 15.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 15. "EtNr
APPEND xmplt_s.
xmplt_s-col_no = 16.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 16. "LiefDat
APPEND xmplt_s.
xmplt_s-col_no = 17.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 17. "StatLiefDat
APPEND xmplt_s.
xmplt_s-col_no = 18.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 18. "AuftragsbestNr
APPEND xmplt_s.
xmplt_s-col_no = 19. "do060118
xmplt_s-col_typ = 'STR'. "do060118
xmplt_s-col_src = 19. "K "do060118
APPEND xmplt_s. "do060118
xmplt_s-col_no = 20.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 20. "ZBed
APPEND xmplt_s.
xmplt_s-col_no = 21.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 21. "ZTg1
APPEND xmplt_s.
xmplt_s-col_no = 22.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 22. "ZTg2
APPEND xmplt_s.
xmplt_s-col_no = 23.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 23. "ZTg3
APPEND xmplt_s.
xmplt_s-col_no = 24.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 24. "ZPr1
APPEND xmplt_s.
xmplt_s-col_no = 25.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 25. "ZPr2
APPEND xmplt_s.
xmplt_s-col_no = 26.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 26. "NTg
APPEND xmplt_s.
xmplt_s-col_no = 27.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 27. "BestMenge
APPEND xmplt_s.
xmplt_s-col_no = 28.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 28. "OffBestMenge
APPEND xmplt_s.
xmplt_s-col_no = 29.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 29. "OffReMenge
APPEND xmplt_s.
xmplt_s-col_no = 30.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 30. "BME
APPEND xmplt_s.
xmplt_s-col_no = 31.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 31. "BestWert
APPEND xmplt_s.
xmplt_s-col_no = 32.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 32. "OffBestWert
APPEND xmplt_s.
xmplt_s-col_no = 33.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 33. "OffReWert
APPEND xmplt_s.
xmplt_s-col_no = 34.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 34. "Waer
APPEND xmplt_s.
Export in Excel
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
n_vrt_keys = 0
n_att_cols = 34
n_hrz_keys = 1
sema_type = 'X'
no_dialog = space
TABLES
vkey = xmplt_v
hkey = xmplt_h
data = itab
sema = xmplt_s
online_text = xmplt_o
print_text = xmplt_p
EXCEPTIONS
file_open_error = 71
file_write_error = 72
inv_winsys = 73
inv_xxl = 74
cancelled_by_user = 75
OTHERS = 99.
CASE sy-subrc.
WHEN 0. "WRITE /'in Ordnung'.
WHEN OTHERS. WRITE: /'Fehler', sy-subrc.
ENDCASE.
ENDFORM.
FORM excel_exportieren_ole.
Feld-Symbol,
FIELD-SYMBOLS: <fn>. "z.Zt. nur Doku
Tabelle der Feldnamen entsprechend der Listüberschriften
DATA: BEGIN OF li_fname OCCURS 0,
fname(60) TYPE c,
END OF li_fname.
Felder zum Ermitteln des Dateinamens
DATA:
lw_file LIKE rlgrap-filename,
lw_type TYPE c, "z.Zt. nur Doku
lw_ind1 LIKE sy-tabix, "z.Zt. nur Doku
lw_ind2 LIKE sy-tabix, "z.Zt. nur Doku
lw_kname LIKE help_info-dynprofld. "z.Zt. nur Doku
xyz . "Dummy
Tabelle der Spalteninhalte entsprechend der Liste
DATA: BEGIN OF li_data OCCURS 0,
col01 LIKE cdpos-value_new,
col02 LIKE cdpos-value_new,
col03 LIKE cdpos-value_new,
col04 LIKE cdpos-value_new,
col05 LIKE cdpos-value_new,
col06 LIKE cdpos-value_new,
col07 LIKE cdpos-value_new,
col08 LIKE cdpos-value_new,
col09 LIKE cdpos-value_new,
col10 LIKE cdpos-value_new,
col11 LIKE cdpos-value_new,
col12 LIKE cdpos-value_new,
col13 LIKE cdpos-value_new,
col14 LIKE cdpos-value_new,
col15 LIKE cdpos-value_new,
col16 LIKE cdpos-value_new,
col17 LIKE cdpos-value_new,
col18 LIKE cdpos-value_new,
col19 LIKE cdpos-value_new,
col20 LIKE cdpos-value_new,
col21 LIKE cdpos-value_new,
col22 LIKE cdpos-value_new,
col23 LIKE cdpos-value_new,
col24 LIKE cdpos-value_new,
col25 LIKE cdpos-value_new,
col26 LIKE cdpos-value_new,
col27 LIKE cdpos-value_new,
col28 LIKE cdpos-value_new,
col29 LIKE cdpos-value_new,
col30 LIKE cdpos-value_new,
col31 LIKE cdpos-value_new,
col32 LIKE cdpos-value_new,
col33 LIKE cdpos-value_new,
col34 LIKE cdpos-value_new,
col35 LIKE cdpos-value_new,
col36 LIKE cdpos-value_new,
col37 LIKE cdpos-value_new,
col38 LIKE cdpos-value_new,
col39 LIKE cdpos-value_new,
col40 LIKE cdpos-value_new,
END OF li_data.
temporäres Verzeichnis auf Präsentationsserver ermitteln
PERFORM temp_bestimmen CHANGING lw_file.
Dateiname anhängen
CONCATENATE lw_file 'ZAMM28_' sy-datum sy-uzeit INTO lw_file.
Spaltenüberschriften in Übergabetabelle einfügen
li_fname-fname = 'EkOrg'.
APPEND li_fname.
li_fname-fname = 'EkGrpB'.
APPEND li_fname.
li_fname-fname = 'LiefNr'.
APPEND li_fname.
li_fname-fname = 'LiefName'.
APPEND li_fname.
li_fname-fname = 'BestellNr'.
APPEND li_fname.
li_fname-fname = 'Pos'.
APPEND li_fname.
li_fname-fname = 'BestDat'.
APPEND li_fname.
li_fname-fname = 'MatNr'.
APPEND li_fname.
li_fname-fname = 'MatKurztext'.
APPEND li_fname.
li_fname-fname = 'BGS'.
APPEND li_fname.
li_fname-fname = 'EkGrpM'.
APPEND li_fname.
li_fname-fname = 'Dis'. "do060327
APPEND li_fname. "do060327
li_fname-fname = 'ZeichNr'.
APPEND li_fname.
li_fname-fname = 'EkGrpE'.
APPEND li_fname.
li_fname-fname = 'EtNr'.
APPEND li_fname.
li_fname-fname = 'LiefDat'.
APPEND li_fname.
li_fname-fname = 'StatLiefDat'.
APPEND li_fname.
li_fname-fname = 'AuftragsbestNr'.
APPEND li_fname.
li_fname-fname = 'K'. "do060118
APPEND li_fname. "do060118
li_fname-fname = 'ZBed'.
APPEND li_fname.
li_fname-fname = 'ZTg1'.
APPEND li_fname.
li_fname-fname = 'ZTg2'.
APPEND li_fname.
li_fname-fname = 'ZTg3'.
APPEND li_fname.
li_fname-fname = 'ZPr1'.
APPEND li_fname.
li_fname-fname = 'ZPr2'.
APPEND li_fname.
li_fname-fname = 'NTg'.
APPEND li_fname.
li_fname-fname = 'BestMenge'.
APPEND li_fname.
li_fname-fname = 'OffBestMenge'.
APPEND li_fname.
li_fname-fname = 'OffReMenge'.
APPEND li_fname.
li_fname-fname = 'BME'.
APPEND li_fname.
li_fname-fname = 'BestWert'.
APPEND li_fname.
li_fname-fname = 'OffBestWert'.
APPEND li_fname.
li_fname-fname = 'OffReWert'.
APPEND li_fname.
li_fname-fname = 'Waer'.
APPEND li_fname.
Daten in Übergabetabelle einfügen
LOOP AT itab.
WRITE: itab-ekorg TO li_data-col01,
itab-ekgrp_ekko TO li_data-col02,
itab-lifnr TO li_data-col03,
itab-name1 TO li_data-col04,
itab-ebeln TO li_data-col05,
itab-ebelp TO li_data-col06,
itab-bedat TO li_data-col07,
itab-ematn TO li_data-col08,
itab-txz01 TO li_data-col09,
itab-matkl TO li_data-col10,
itab-ekgrp_marc TO li_data-col11,
itab-ekgrp_marc TO li_data-col12, "do060327
itab-zeinr(12) TO li_data-col13,
itab-ekgrp_eine TO li_data-col14,
itab-etenr TO li_data-col15,
itab-eindt TO li_data-col16,
itab-slfdt TO li_data-col17,
itab-labnr TO li_data-col18,
itab-knttp TO li_data-col19, "do060118
itab-zterm TO li_data-col20,
itab-zbd1t TO li_data-col21,
itab-zbd2t TO li_data-col22,
itab-zbd3t TO li_data-col23,
itab-zbd1p TO li_data-col24,
itab-zbd2p TO li_data-col25,
itab-zbd4t TO li_data-col26,
itab-menge_eket TO li_data-col27,
itab-menge_offen TO li_data-col28,
itab-rmenge_offen TO li_data-col29,
itab-meins TO li_data-col30,
itab-netwr_eket TO li_data-col31,
itab-netwr_offen TO li_data-col32,
itab-rwert_offen TO li_data-col33,
itab-waers TO li_data-col34.
APPEND li_data.
ENDLOOP.
Export in Excel
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = lw_file
data_sheet_name = 'ZAMM28'
TABLES
data_tab = li_data
fieldnames = li_fname
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 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.
ENDFORM.
temporäres Verzeichnis auf Präsentationsserver ermitteln
FORM temp_bestimmen CHANGING fc_file LIKE rlgrap-filename.
DATA:
lw_len LIKE sy-tabix,
lw_zeich TYPE c.
nach 'TEMP' bzw. 'TMP' suchen
CALL FUNCTION 'WS_QUERY'
EXPORTING
environment = 'TEMP'
query = 'EN' " Umgebungsvariable abfragen
IMPORTING
return = fc_file
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'WS_QUERY'
EXPORTING
environment = 'TMP'
query = 'EN' " Umgebungsvariable abfragen
IMPORTING
return = fc_file
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
fc_file = 'C:/'.
ENDIF.
ENDIF.
ggf. '/' anhängen
lw_len = strlen( fc_file ) - 1.
lw_zeich = fc_file+lw_len(1).
IF lw_zeich <> ''.
CONCATENATE fc_file '' INTO fc_file.
ENDIF.
ENDFORM.
hi,
i HAVE TO TAKE O/P IN EXCEL FILE. HERE IS SOME CODE WHICH I HAVE WRITTEN FOR DOWNLOADING IN EXCEL FILE.
BUT IT IS NOT DOWNLOADING.SO PLS HELP ME WHWT MISTAKE I AM DOING.
SELECT-OPTIONS: s_ekorg FOR ekko-ekorg,
WHEN 'EXCEL'.
PERFORM excel_exportieren_xxl
START-OF-SELECTION.
SET PF-STATUS 'D01'.
********SOME SELECT QUERRIES ARE WRITTEN
********eND OF SOME SELECT QUERRIES
FORM excel_exportieren_xxl.
Tabelle Online-Texte
DATA BEGIN OF xmplt_o OCCURS 1.
INCLUDE STRUCTURE gxxlt_o.
DATA END OF xmplt_o.
Tabelle Print-Texte
DATA BEGIN OF xmplt_p OCCURS 1.
INCLUDE STRUCTURE gxxlt_p.
DATA END OF xmplt_p.
Tabelle HKEY - horizontale Merkmale
DATA BEGIN OF xmplt_h OCCURS 1.
INCLUDE STRUCTURE gxxlt_h.
DATA END OF xmplt_h.
Tabelle VKEY - vertikale Merkmale
DATA BEGIN OF xmplt_v OCCURS 1.
INCLUDE STRUCTURE gxxlt_v.
DATA END OF xmplt_v.
Tabelle SEMA - semantische Informationen
DATA BEGIN OF xmplt_s OCCURS 1.
INCLUDE STRUCTURE gxxlt_s.
DATA END OF xmplt_s.
Spaltenüberschriften in Übergabetabelle einfügen
xmplt_h-col_no = 1.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkOrg'.
APPEND xmplt_h.
xmplt_h-col_no = 2.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpB'.
APPEND xmplt_h.
xmplt_h-col_no = 3.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefNr'.
APPEND xmplt_h.
xmplt_h-col_no = 4.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefName'.
APPEND xmplt_h.
xmplt_h-col_no = 5.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestellNr'.
APPEND xmplt_h.
xmplt_h-col_no = 6.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'Pos'.
APPEND xmplt_h.
xmplt_h-col_no = 7.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestDat'.
APPEND xmplt_h.
xmplt_h-col_no = 8.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'MatNr'.
APPEND xmplt_h.
xmplt_h-col_no = 9.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'MatKurztext'.
APPEND xmplt_h.
xmplt_h-col_no = 10.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BGS'.
APPEND xmplt_h.
xmplt_h-col_no = 11.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpM'.
APPEND xmplt_h.
xmplt_h-col_no = 12. "do060327
xmplt_h-row_no = 1. "do060327
xmplt_h-col_name = 'Dis'. "do060327
APPEND xmplt_h.
xmplt_h-col_no = 13.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZeichNr'.
APPEND xmplt_h.
xmplt_h-col_no = 14.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EkGrpE'.
APPEND xmplt_h.
xmplt_h-col_no = 15.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'EtNr'.
APPEND xmplt_h.
xmplt_h-col_no = 16.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'LiefDat'.
APPEND xmplt_h.
xmplt_h-col_no = 17.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'StatLiefDat'.
APPEND xmplt_h.
xmplt_h-col_no = 18.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'AuftragsbestNr'.
APPEND xmplt_h.
xmplt_h-col_no = 19. "do060118
xmplt_h-row_no = 1. "do060118
xmplt_h-col_name = 'K'. "do060118
APPEND xmplt_h. "do060118
xmplt_h-col_no = 20.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZBed'.
APPEND xmplt_h.
xmplt_h-col_no = 21.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg1'.
APPEND xmplt_h.
xmplt_h-col_no = 22.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg2'.
APPEND xmplt_h.
xmplt_h-col_no = 23.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZTg3'.
APPEND xmplt_h.
xmplt_h-col_no = 24.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZPr1'.
APPEND xmplt_h.
xmplt_h-col_no = 25.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'ZPr2'.
APPEND xmplt_h.
xmplt_h-col_no = 26.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'NTg'.
APPEND xmplt_h.
xmplt_h-col_no = 27.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 28.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffBestMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 29.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffReMenge'.
APPEND xmplt_h.
xmplt_h-col_no = 30.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BME'.
APPEND xmplt_h.
xmplt_h-col_no = 31.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'BestWert'.
APPEND xmplt_h.
xmplt_h-col_no = 32.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffBestWert'.
APPEND xmplt_h.
xmplt_h-col_no = 33.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'OffReWert'.
APPEND xmplt_h.
xmplt_h-col_no = 34.
xmplt_h-row_no = 1.
xmplt_h-col_name = 'Waer'.
APPEND xmplt_h.
Semantische Informationen in Übergabetabelle einfügen
xmplt_s-col_no = 1.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_ops = 'DFT'.
xmplt_s-col_src = 1. "EkOrg
APPEND xmplt_s.
xmplt_s-col_no = 2.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 2. "EkGrpB
APPEND xmplt_s.
xmplt_s-col_no = 3.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 3. "LiefNr
APPEND xmplt_s.
xmplt_s-col_no = 4.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 4. "LiefName
APPEND xmplt_s.
xmplt_s-col_no = 5.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 5. "BestellNr
APPEND xmplt_s.
xmplt_s-col_no = 6.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 6. "Pos
APPEND xmplt_s.
xmplt_s-col_no = 7.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 7. "BestDat
APPEND xmplt_s.
xmplt_s-col_no = 8.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 8. "MatNr
APPEND xmplt_s.
xmplt_s-col_no = 9.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 9. "MatKurztext
APPEND xmplt_s.
xmplt_s-col_no = 10.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 10. "BGS
APPEND xmplt_s.
xmplt_s-col_no = 11.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 11. "EkGrpM
APPEND xmplt_s.
xmplt_s-col_no = 12. "do060227
xmplt_s-col_typ = 'STR'. "do060327
xmplt_s-col_src = 12. "Dis "do060327
APPEND xmplt_s.
xmplt_s-col_no = 13.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 13. "ZeichNr
APPEND xmplt_s.
xmplt_s-col_no = 14.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 14. "EkGrpE
APPEND xmplt_s.
xmplt_s-col_no = 15.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 15. "EtNr
APPEND xmplt_s.
xmplt_s-col_no = 16.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 16. "LiefDat
APPEND xmplt_s.
xmplt_s-col_no = 17.
xmplt_s-col_typ = 'DAT'.
xmplt_s-col_src = 17. "StatLiefDat
APPEND xmplt_s.
xmplt_s-col_no = 18.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 18. "AuftragsbestNr
APPEND xmplt_s.
xmplt_s-col_no = 19. "do060118
xmplt_s-col_typ = 'STR'. "do060118
xmplt_s-col_src = 19. "K "do060118
APPEND xmplt_s. "do060118
xmplt_s-col_no = 20.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 20. "ZBed
APPEND xmplt_s.
xmplt_s-col_no = 21.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 21. "ZTg1
APPEND xmplt_s.
xmplt_s-col_no = 22.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 22. "ZTg2
APPEND xmplt_s.
xmplt_s-col_no = 23.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 23. "ZTg3
APPEND xmplt_s.
xmplt_s-col_no = 24.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 24. "ZPr1
APPEND xmplt_s.
xmplt_s-col_no = 25.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 25. "ZPr2
APPEND xmplt_s.
xmplt_s-col_no = 26.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 26. "NTg
APPEND xmplt_s.
xmplt_s-col_no = 27.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 27. "BestMenge
APPEND xmplt_s.
xmplt_s-col_no = 28.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 28. "OffBestMenge
APPEND xmplt_s.
xmplt_s-col_no = 29.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 29. "OffReMenge
APPEND xmplt_s.
xmplt_s-col_no = 30.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 30. "BME
APPEND xmplt_s.
xmplt_s-col_no = 31.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 31. "BestWert
APPEND xmplt_s.
xmplt_s-col_no = 32.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 32. "OffBestWert
APPEND xmplt_s.
xmplt_s-col_no = 33.
xmplt_s-col_typ = 'NUM'.
xmplt_s-col_src = 33. "OffReWert
APPEND xmplt_s.
xmplt_s-col_no = 34.
xmplt_s-col_typ = 'STR'.
xmplt_s-col_src = 34. "Waer
APPEND xmplt_s.
Export in Excel
CALL FUNCTION 'XXL_FULL_API'
EXPORTING
n_vrt_keys = 0
n_att_cols = 34
n_hrz_keys = 1
sema_type = 'X'
no_dialog = space
TABLES
vkey = xmplt_v
hkey = xmplt_h
data = itab
sema = xmplt_s
online_text = xmplt_o
print_text = xmplt_p
EXCEPTIONS
file_open_error = 71
file_write_error = 72
inv_winsys = 73
inv_xxl = 74
cancelled_by_user = 75
OTHERS = 99.
CASE sy-subrc.
WHEN 0. "WRITE /'in Ordnung'.
WHEN OTHERS. WRITE: /'Fehler', sy-subrc.
ENDCASE.
ENDFORM.
FORM excel_exportieren_ole.
Feld-Symbol,
FIELD-SYMBOLS: <fn>. "z.Zt. nur Doku
Tabelle der Feldnamen entsprechend der Listüberschriften
DATA: BEGIN OF li_fname OCCURS 0,
fname(60) TYPE c,
END OF li_fname.
Felder zum Ermitteln des Dateinamens
DATA:
lw_file LIKE rlgrap-filename,
lw_type TYPE c, "z.Zt. nur Doku
lw_ind1 LIKE sy-tabix, "z.Zt. nur Doku
lw_ind2 LIKE sy-tabix, "z.Zt. nur Doku
lw_kname LIKE help_info-dynprofld. "z.Zt. nur Doku
xyz . "Dummy
Tabelle der Spalteninhalte entsprechend der Liste
DATA: BEGIN OF li_data OCCURS 0,
col01 LIKE cdpos-value_new,
col02 LIKE cdpos-value_new,
col03 LIKE cdpos-value_new,
col04 LIKE cdpos-value_new,
col05 LIKE cdpos-value_new,
col06 LIKE cdpos-value_new,
col07 LIKE cdpos-value_new,
col08 LIKE cdpos-value_new,
col09 LIKE cdpos-value_new,
col10 LIKE cdpos-value_new,
col11 LIKE cdpos-value_new,
col12 LIKE cdpos-value_new,
col13 LIKE cdpos-value_new,
col14 LIKE cdpos-value_new,
col15 LIKE cdpos-value_new,
col16 LIKE cdpos-value_new,
col17 LIKE cdpos-value_new,
col18 LIKE cdpos-value_new,
col19 LIKE cdpos-value_new,
col20 LIKE cdpos-value_new,
col21 LIKE cdpos-value_new,
col22 LIKE cdpos-value_new,
col23 LIKE cdpos-value_new,
col24 LIKE cdpos-value_new,
col25 LIKE cdpos-value_new,
col26 LIKE cdpos-value_new,
col27 LIKE cdpos-value_new,
col28 LIKE cdpos-value_new,
col29 LIKE cdpos-value_new,
col30 LIKE cdpos-value_new,
col31 LIKE cdpos-value_new,
col32 LIKE cdpos-value_new,
col33 LIKE cdpos-value_new,
col34 LIKE cdpos-value_new,
col35 LIKE cdpos-value_new,
col36 LIKE cdpos-value_new,
col37 LIKE cdpos-value_new,
col38 LIKE cdpos-value_new,
col39 LIKE cdpos-value_new,
col40 LIKE cdpos-value_new,
END OF li_data.
temporäres Verzeichnis auf Präsentationsserver ermitteln
PERFORM temp_bestimmen CHANGING lw_file.
Dateiname anhängen
CONCATENATE lw_file 'ZAMM28_' sy-datum sy-uzeit INTO lw_file.
Spaltenüberschriften in Übergabetabelle einfügen
li_fname-fname = 'EkOrg'.
APPEND li_fname.
li_fname-fname = 'EkGrpB'.
APPEND li_fname.
li_fname-fname = 'LiefNr'.
APPEND li_fname.
li_fname-fname = 'LiefName'.
APPEND li_fname.
li_fname-fname = 'BestellNr'.
APPEND li_fname.
li_fname-fname = 'Pos'.
APPEND li_fname.
li_fname-fname = 'BestDat'.
APPEND li_fname.
li_fname-fname = 'MatNr'.
APPEND li_fname.
li_fname-fname = 'MatKurztext'.
APPEND li_fname.
li_fname-fname = 'BGS'.
APPEND li_fname.
li_fname-fname = 'EkGrpM'.
APPEND li_fname.
li_fname-fname = 'Dis'. "do060327
APPEND li_fname. "do060327
li_fname-fname = 'ZeichNr'.
APPEND li_fname.
li_fname-fname = 'EkGrpE'.
APPEND li_fname.
li_fname-fname = 'EtNr'.
APPEND li_fname.
li_fname-fname = 'LiefDat'.
APPEND li_fname.
li_fname-fname = 'StatLiefDat'.
APPEND li_fname.
li_fname-fname = 'AuftragsbestNr'.
APPEND li_fname.
li_fname-fname = 'K'. "do060118
APPEND li_fname. "do060118
li_fname-fname = 'ZBed'.
APPEND li_fname.
li_fname-fname = 'ZTg1'.
APPEND li_fname.
li_fname-fname = 'ZTg2'.
APPEND li_fname.
li_fname-fname = 'ZTg3'.
APPEND li_fname.
li_fname-fname = 'ZPr1'.
APPEND li_fname.
li_fname-fname = 'ZPr2'.
APPEND li_fname.
li_fname-fname = 'NTg'.
APPEND li_fname.
li_fname-fname = 'BestMenge'.
APPEND li_fname.
li_fname-fname = 'OffBestMenge'.
APPEND li_fname.
li_fname-fname = 'OffReMenge'.
APPEND li_fname.
li_fname-fname = 'BME'.
APPEND li_fname.
li_fname-fname = 'BestWert'.
APPEND li_fname.
li_fname-fname = 'OffBestWert'.
APPEND li_fname.
li_fname-fname = 'OffReWert'.
APPEND li_fname.
li_fname-fname = 'Waer'.
APPEND li_fname.
Daten in Übergabetabelle einfügen
LOOP AT itab.
WRITE: itab-ekorg TO li_data-col01,
itab-ekgrp_ekko TO li_data-col02,
itab-lifnr TO li_data-col03,
itab-name1 TO li_data-col04,
itab-ebeln TO li_data-col05,
itab-ebelp TO li_data-col06,
itab-bedat TO li_data-col07,
itab-ematn TO li_data-col08,
itab-txz01 TO li_data-col09,
itab-matkl TO li_data-col10,
itab-ekgrp_marc TO li_data-col11,
itab-ekgrp_marc TO li_data-col12, "do060327
itab-zeinr(12) TO li_data-col13,
itab-ekgrp_eine TO li_data-col14,
itab-etenr TO li_data-col15,
itab-eindt TO li_data-col16,
itab-slfdt TO li_data-col17,
itab-labnr TO li_data-col18,
itab-knttp TO li_data-col19, "do060118
itab-zterm TO li_data-col20,
itab-zbd1t TO li_data-col21,
itab-zbd2t TO li_data-col22,
itab-zbd3t TO li_data-col23,
itab-zbd1p TO li_data-col24,
itab-zbd2p TO li_data-col25,
itab-zbd4t TO li_data-col26,
itab-menge_eket TO li_data-col27,
itab-menge_offen TO li_data-col28,
itab-rmenge_offen TO li_data-col29,
itab-meins TO li_data-col30,
itab-netwr_eket TO li_data-col31,
itab-netwr_offen TO li_data-col32,
itab-rwert_offen TO li_data-col33,
itab-waers TO li_data-col34.
APPEND li_data.
ENDLOOP.
Export in Excel
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = lw_file
data_sheet_name = 'ZAMM28'
TABLES
data_tab = li_data
fieldnames = li_fname
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 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.
ENDFORM.
temporäres Verzeichnis auf Präsentationsserver ermitteln
FORM temp_bestimmen CHANGING fc_file LIKE rlgrap-filename.
DATA:
lw_len LIKE sy-tabix,
lw_zeich TYPE c.
nach 'TEMP' bzw. 'TMP' suchen
CALL FUNCTION 'WS_QUERY'
EXPORTING
environment = 'TEMP'
query = 'EN' " Umgebungsvariable abfragen
IMPORTING
return = fc_file
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
CALL FUNCTION 'WS_QUERY'
EXPORTING
environment = 'TMP'
query = 'EN' " Umgebungsvariable abfragen
IMPORTING
return = fc_file
EXCEPTIONS
inv_query = 1
no_batch = 2
frontend_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
fc_file = 'C:/'.
ENDIF.
ENDIF.
ggf. '/' anhängen
lw_len = strlen( fc_file ) - 1.
lw_zeich = fc_file+lw_len(1).
IF lw_zeich <> ''.
CONCATENATE fc_file '' INTO fc_file.
ENDIF.
ENDFORM.
2007 Jul 06 7:19 AM
try this FM
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_ftemp
filetype = 'DAT'
wk1_n_size = 'X'
wk1_n_format = 'X'
wk1_t_format = 'X'
wk1_t_size = 'X'
TABLES
data_tab = lt_headers
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.
please reward points if useful
2007 Jul 06 7:22 AM
Hi
Use the fun module
EXCEL_OLE_STANDARD_GET
or GUI_DOWNLOAD
declare an internal table (with final data) with all char fields and pass to above fun modules
Reward points for useful Answers
Regards
Anji
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |