Code: Alles auswählen.
REPORT zzke24.
TABLES: ce11000.
SELECT-OPTIONS: paledger FOR ce11000-paledger,
s_perio FOR ce11000-perio,
s_bukrs FOR ce11000-bukrs.
PARAMETERS: filename(100).
PARAMETERS: P_FILEN LIKE RLGRAP-FILENAME.
SELECTION-SCREEN BEGIN OF BLOCK blok1 WITH FRAME TITLE TEXT-002.
PARAMETERS: p_ausw1 RADIOBUTTON GROUP sort,
p_ausw2 RADIOBUTTON GROUP sort,
p_ausw3 RADIOBUTTON GROUP sort.
SELECTION-SCREEN END OF BLOCK blok1.
DATA: BEGIN OF itab1 OCCURS 100,
paledger LIKE zzke24-paledger,
vrgar LIKE zzke24-vrgar,
perio LIKE zzke24-perio,
belnr LIKE zzke24-belnr,
hzdat LIKE zzke24-hzdat,
kndnr LIKE zzke24-kndnr,
rbeln LIKE zzke24-rbeln,
rposn LIKE zzke24-rposn,
usnam LIKE zzke24-usnam,
bukrs LIKE zzke24-bukrs,
frwae LIKE zzke24-frwae,
prctr LIKE zzke24-prctr,
vv126 LIKE zzke24-vv126,
vv125 LIKE zzke24-vv125,
absmg_me LIKE zzke24-absmg_me,
vv121 LIKE zzke24-vv121,
vv122 LIKE zzke24-vv122,
vv010 LIKE zzke24-vv010,
vv030 LIKE zzke24-vv030,
vv020 LIKE zzke24-vv020,
vv050 LIKE zzke24-vv050,
vv040 LIKE zzke24-vv040,
prodh LIKE zzke24-prodh,
absmg LIKE zzke24-absmg,
budat LIKE zzke24-budat,
summe LIKE zzke24-vv126.
DATA : END OF itab1.
DATA: BEGIN OF itab2 OCCURS 100,
paledger LIKE zzke24-paledger,
vrgar LIKE zzke24-vrgar,
perio LIKE zzke24-perio,
belnr LIKE zzke24-belnr,
hzdat LIKE zzke24-hzdat,
kndnr LIKE zzke24-kndnr,
rbeln LIKE zzke24-rbeln,
rposn LIKE zzke24-rposn,
usnam LIKE zzke24-usnam,
bukrs LIKE zzke24-bukrs,
frwae LIKE zzke24-frwae,
prctr LIKE zzke24-prctr,
vv126 LIKE zzke24-vv126,
vv125 LIKE zzke24-vv125,
absmg_me LIKE zzke24-absmg_me,
vv121 LIKE zzke24-vv121,
vv122 LIKE zzke24-vv122,
vv010 LIKE zzke24-vv010,
vv030 LIKE zzke24-vv030,
vv020 LIKE zzke24-vv020,
vv050 LIKE zzke24-vv050,
vv040 LIKE zzke24-vv040,
prodh LIKE zzke24-prodh,
absmg LIKE zzke24-absmg,
budat LIKE zzke24-budat,
summe LIKE zzke24-vv126,
c_vv126(15),
c_vv125(15),
c_vv121(15),
c_vv122(15),
c_vv010(15),
c_vv030(15),
c_vv020(15),
c_vv050(15),
c_vv040(15),
c_absmg(15),
c_budat(10).
DATA : END OF itab2.
DATA: v_transfer(1000).
DATA:V_Filen TYPE String.
data: begin of i_hold occurs 0,
data(450),
end of i_hold.
TYPE-POOLS: slis.
*--- Types ------------------------------------------------------------*
TYPES: t_output LIKE zzke24.
*--- ALV Definitions --------------------------------------------------*
DATA g_save TYPE c VALUE 'A'. " save option
DATA g_variant LIKE disvariant. " Daten für die Variante
DATA g_fieldcat TYPE slis_t_fieldcat_alv. " Feldkatalog
DATA: g_events TYPE slis_t_event,
g_sp_group TYPE slis_t_sp_group_alv,
g_layout TYPE slis_layout_alv,
g_list_top_of_page TYPE slis_t_listheader.
DATA: e_status TYPE slis_formname VALUE 'STANDARD_ER01',
e_user_command TYPE slis_formname VALUE 'USER_COMMAND',
er_list_top_of_page TYPE slis_t_listheader,
er_layout TYPE slis_layout_alv,
er_sp_group TYPE slis_t_sp_group_alv,
er_events TYPE slis_t_event.
*--- Constants --------------------------------------------------------*
CONSTANTS:
er_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
*--- Internal Tables --------------------------------------------------*
DATA: i_output TYPE t_output OCCURS 100,
wa_output LIKE LINE OF i_output.
START-OF-SELECTION.
PERFORM get_data.
DESCRIBE TABLE i_output.
IF sy-tfill = 0.
MESSAGE s000(z4) WITH TEXT-900.
ELSE.
IF p_ausw1 = 'X'.
PERFORM output_data.
ENDIF.
IF p_ausw2 = 'X'.
PERFORM download.
ENDIF.
IF p_ausw3 = 'X'.
PERFORM gui_download.
ENDIF.
ENDIF.
FORM get_data.
SELECT *
INTO CORRESPONDING FIELDS OF itab1
FROM ce11000
WHERE paledger IN paledger
AND perio IN s_perio
AND bukrs IN s_bukrs.
itab1-budat = sy-datum.
itab1-summe = itab1-vv126 + itab1-vv125 + itab1-vv121 + itab1-vv122 + itab1-vv010 + itab1-vv030 + itab1-vv020 + itab1-vv050 + itab1-vv040 + itab1-absmg.
If itab1-summe <> 0.
APPEND itab1.
ENDIF.
ENDSELECT.
LOOP at itab1.
itab2 = itab1.
WRITE itab1-vv126 to itab2-c_vv126.
WRITE itab1-vv125 to itab2-c_vv125.
WRITE itab1-vv121 to itab2-c_vv121.
WRITE itab1-vv122 to itab2-c_vv122.
WRITE itab1-vv010 to itab2-c_vv010.
WRITE itab1-vv030 to itab2-c_vv030.
WRITE itab1-vv020 to itab2-c_vv020.
WRITE itab1-vv050 to itab2-c_vv050.
WRITE itab1-vv040 to itab2-c_vv040.
WRITE itab1-absmg to itab2-c_absmg.
CONCATENATE
itab1-budat+6(2) '.' itab1-budat+4(2) '.' itab1-budat+0(4) INTO itab2-c_budat.
APPEND itab2.
ENDLOOP.
LOOP AT itab1.
wa_output = itab1.
APPEND wa_output TO i_output.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form output_data
*&---------------------------------------------------------------------*
FORM output_data.
*--- Variantedaten fuellen
CLEAR g_variant.
g_variant-report = 'ZZKE24'.
g_variant-username = sy-uname.
*--- Events, Sp.-Gruppen, Layout fuellen
PERFORM eventtab_build USING er_events[].
PERFORM sp_group_build USING er_sp_group[].
PERFORM layout_build USING er_layout.
*--- Feldkatalog fuellen
CALL FUNCTION 'SD_GET_FIELDCATALOG_OF_TABLE'
EXPORTING
i_table_name = 'ZZKE24'
TABLES
t_input_fieldcat = g_fieldcat.
*--- List-Viewer aufrufen
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_interface_check = ' '
i_bypassing_buffer = 'X'
i_buffer_active = ' '
i_callback_program = 'ZZKE24'
i_callback_pf_status_set = e_status
i_callback_user_command = e_user_command
i_callback_top_of_page = ' '
i_callback_html_top_of_page = ' '
i_callback_html_end_of_list = ' '
i_structure_name = 'ZZKE24'
i_background_id = 'ALV_BACKGROUND'
* i_grid_title = 'Titel 1'
* I_GRID_SETTINGS =
is_layout = er_layout
it_fieldcat = g_fieldcat[]
* it_excluding =
it_special_groups = er_sp_group[]
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
i_save = g_save
is_variant = g_variant
it_events = er_events[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_ADD_FIELDCAT =
* IT_HYPERLINK =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_output
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.
ENDFORM. " output_data
*&---------------------------------------------------------------------*
*& Form eventtab_build
*&---------------------------------------------------------------------*
FORM eventtab_build USING u_er_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = u_er_events.
READ TABLE u_er_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE er_formname_top_of_page TO ls_event-form.
APPEND ls_event TO u_er_events.
ENDIF.
READ TABLE u_er_events WITH KEY name = slis_ev_user_command
INTO ls_event.
IF sy-subrc = 0.
MOVE e_user_command TO ls_event-form.
APPEND ls_event TO u_er_events.
ENDIF.
READ TABLE u_er_events WITH KEY name = slis_ev_pf_status_set
INTO ls_event.
IF sy-subrc = 0.
MOVE e_status TO ls_event-form.
APPEND ls_event TO u_er_events.
ENDIF.
ENDFORM. " eventtab_build
*&---------------------------------------------------------------------*
*& Form sp_group_build
*&---------------------------------------------------------------------*
FORM sp_group_build USING u_er_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
CLEAR: ls_sp_group, u_er_sp_group.
REFRESH: u_er_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = TEXT-s06.
APPEND ls_sp_group TO u_er_sp_group.
ENDFORM. " sp_group_build
*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
FORM layout_build USING u_er_layout TYPE slis_layout_alv.
CLEAR: u_er_layout.
* u_er_layout-box_fieldname = 'SELK'. " Checkbox
u_er_layout-get_selinfos = 'X'.
* U_ER_LAYOUT-F2CODE = 'FEHL' . " Doppelklickfunktion
u_er_layout-confirmation_prompt = 'X'. "Sicherheitsabfrage
u_er_layout-key_hotspot = 'X'. "Schlüssel als Hotspot
u_er_layout-info_fieldname = 'COL'. "Zeilenfarbe
ENDFORM. " layout_build
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CHECK r_ucomm = '&IC1'. "nur bei PICK
*---
CLEAR: wa_output.
READ TABLE i_output INTO wa_output INDEX rs_selfield-tabindex.
CHECK sy-subrc = 0.
ENDFORM. "user_command
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* Ereigniss TOP_OF_PAGE *
* event TOP_OF_PAGE
*---------------------------------------------------------------------*
FORM top_of_page.
*
DATA: ls_line TYPE slis_listheader.
* report-header: Typ H
CLEAR: ls_line, er_list_top_of_page.
REFRESH: er_list_top_of_page.
ls_line-typ = 'H'.
ls_line-info = TEXT-001.
APPEND ls_line TO er_list_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = er_list_top_of_page.
ENDFORM. "top_of_page
*---------------------------------------------------------------------*
* FORM STANDARD_ER01 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM standard_er01 USING extab TYPE slis_t_extab.
DELETE extab WHERE fcode = '&RNT_PREV'.
DELETE extab WHERE fcode = '&LFO'.
DELETE extab WHERE fcode = '&NFO'.
SET PF-STATUS 'ALVLIST' EXCLUDING extab.
ENDFORM.
"standard_er01
FORM download.
OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
WRITE: 'File cannot be opened'.
EXIT.
ENDIF.
LOOP AT itab2.
CONCATENATE
itab2-paledger
itab2-vrgar
itab2-perio
itab2-belnr
itab2-hzdat
itab2-kndnr
itab2-rbeln
itab2-rposn
itab2-usnam
itab2-bukrs
itab2-frwae
itab2-prctr
itab2-c_vv126
itab2-c_vv125
itab2-absmg_me
itab2-c_vv121
itab2-c_vv122
itab2-c_vv010
itab2-c_vv030
itab2-c_vv020
itab2-c_vv050
itab2-c_vv040
itab2-prodh
itab2-c_absmg
itab2-c_budat
INTO v_transfer SEPARATED BY ';'.
TRANSFER v_transfer TO filename.
ENDLOOP.
WRITE: /001 'download Completed'.
CLOSE DATASET filename.
ENDFORM.
FORM gui_download.
loop at itab2.
CONCATENATE
itab2-paledger
itab2-vrgar
itab2-perio
itab2-belnr
itab2-hzdat
itab2-kndnr
itab2-rbeln
itab2-rposn
itab2-usnam
itab2-bukrs
itab2-frwae
itab2-prctr
itab2-c_vv126
itab2-c_vv125
itab2-absmg_me
itab2-c_vv121
itab2-c_vv122
itab2-c_vv010
itab2-c_vv030
itab2-c_vv020
itab2-c_vv050
itab2-c_vv040
itab2-prodh
itab2-c_absmg
itab2-c_budat
INTO i_hold SEPARATED BY ';'.
append i_hold.
endloop.
move p_filen to v_filen.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE = ' '
* CODEPAGE = 'IBM'
FILENAME = v_FILEN
FILETYPE = 'ASC'
* MODE = ' '
* wk1_n_format = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* COL_SELECT = ' '
* COL_SELECTMASK = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
TABLES
DATA_TAB = i_hold
* FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
ENDIF.
write:/ 'Download completed'.
ENDFORM.
Code: Alles auswählen.
CASE 'X'.
when P_ausw_1. do something.
when P_ausw_2. do something else.
when P_ausw_3. and something completly different.
ENDCASE.
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
Armin93
Du müsstest für den Background-Job "p_auswahl2" nehmen, da der GUI_DOWNLOAD Baustein nur im Dialogmodus funktioniert.Armin93 hat geschrieben: ↑15.10.2019 08:21Hallo black_adept,
bei der Variante verwende ich p_auswahl3 .....
Das komische ist ja manuell lässt sich das Dokument ja in das gewünschte Netzlaufwerk speichern.
Nur eben bei der ausführung vom Job leider nicht.
Der Job wird ganz normal ausgeführt und wird dann beendet.
aber tun tut sich nichts =(
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
Armin93
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag (Insgesamt 2):
Armin93 • tm987456