If you wish to retrieve the selection Parameters of a report and print them at the end of the report then you can use the following function Module.
To use this Function Module you need to create a variant for the the report. There can be multiple variants for a single report, but the selection screen will get printed fro the one that is used currently for running the report.
Please note that code related to this function module is marked in Brown.
* Tables declaration
TABLES:bsak, "Accounting: Secondary Index for Vendors (Cleared Items)
payr, "Payment Medium File
lfa1. "Vendor Master (General Section)
TYPE-POOLS : slis.
* Type Declaration
TYPES : BEGIN OF etab,
bukrs LIKE bsak-bukrs,
augdt LIKE bsak-augdt,
xblnr LIKE bsak-xblnr,
belnr LIKE bsak-belnr,
bldat LIKE bsak-bldat,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
augb1 LIKE bsak-augbl,
rwbtr LIKE payr-rwbtr,
waers LIKE payr-waers,
chect LIKE payr-chect,
zaldt LIKE payr-zaldt,
hbkid LIKE payr-hbkid,
END OF etab.
* Internal Tables
DATA : tab_etab TYPE STANDARD TABLE OF etab,
wa_etab TYPE etab,
d_prog like sy-repid.
Data: Begin of int_infotab occurs 0,
Field1(100),
End of int_infotab.
* Data Declaration
DATA: wa_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_event TYPE slis_alv_event,
it_events TYPE slis_t_event,
wa_line TYPE slis_listheader,
it_line TYPE slis_t_listheader,
wa_sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS s_ccode FOR bsak-bukrs ."OBLIGATORY.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS s_pdate FOR bsak-augdt.
SELECT-OPTIONS s_drence FOR bsak-xblnr.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM select.
PERFORM build_fcat.
PERFORM display.
PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'H:\TESTSAP.xls'.
move: sy-repid to d_prog.
CALL FUNCTION 'RS_COVERPAGE_SELECTIONS'
EXPORTING
REPORT = d_prog
VARIANT = sy-slset
* NO_IMPORT = ' '
TABLES
INFOTAB = int_infotab
EXCEPTIONS
ERROR_MESSAGE = 1
VARIANT_NOT_FOUND = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
i_filename = p_file
TABLES
i_tab_sap_data = tab_etab.
if sy-subrc = 0.
Endif.
loop at int_infotab.
write:/ int_infotab-field1.
endloop.
*---------------------------------------------------------------------*
* FORM build_fcat *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_fcat.
wa_fieldcat-fieldname = 'BELNR'.
wa_fieldcat-seltext_m = 'VENDOR INVOICE'.
APPEND wa_fieldcat TO it_fieldcat.
FREE wa_fieldcat.
wa_fieldcat-fieldname = 'AUGDT'.
wa_fieldcat-ref_tabname = 'BSAK'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'PAYMENT DATE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'BLDAT'.
wa_fieldcat-ref_tabname = 'BSAK'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'VENDOR INVOICE DATE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-ref_tabname = 'BSAK'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'VENDOR NUMBER'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-ref_tabname = 'LFA1'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'VENDOR NAME'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AUGBL'.
wa_fieldcat-ref_tabname = 'BSAK'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'PAYMENT DOCUMENT'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'RWBTR'.
wa_fieldcat-ref_tabname = 'PAYR'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'AMOUNT PAID'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WAERS'.
wa_fieldcat-ref_tabname = 'PAYR'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'CURRENCY'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'CHECT'.
wa_fieldcat-ref_tabname = 'PAYR'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'CHECK NUMBER'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ZALDT'.
wa_fieldcat-ref_tabname = 'PAYR'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'CHECK DATE'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'HBKID'.
wa_fieldcat-ref_tabname = 'PAYR'.
wa_fieldcat-tabname = 'TAB_ETAB'.
wa_fieldcat-seltext_m = 'BANK'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " build_fcat
*---------------------------------------------------------------------*
* FORM display *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM display.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
i_callback_program = 'ZEXPA'
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_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
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = tab_etab.
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
* FORM display.
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.
*---------------------------------------------------------------------*
* FORM select *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM select.
SELECT bsak~bukrs
bsak~augdt
bsak~xblnr
bsak~belnr
bsak~bldat
bsak~lifnr
bsak~bschl
bsak~xstov
payr~rwbtr
payr~waers
payr~chect
payr~zaldt
payr~hbkid
FROM bsak
INNER JOIN lfa1 ON bsak~lifnr = lfa1~lifnr
INNER JOIN payr ON bsak~augbl = payr~vblnr
AND bsak~gjahr = payr~gjahr
INTO TABLE tab_etab
WHERE bukrs IN s_ccode
AND
augdt IN s_pdate
AND
xblnr IN s_drence
AND
bsak~bschl = 31
AND
bsak~xstov = ''.
IF sy-subrc EQ 0.
WRITE:/ 'Rows found'.
WRITE:/ 'ROWS=',sy-dbcnt.
ELSE.
WRITE:/ 'no rows found'.
ENDIF.
ENDFORM. " select
No comments:
Post a Comment