Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
*&-------------------------------------------------------------*
*& Report ZAG_BSP_GETDATA
*&-------------------------------------------------------------*
*&
*
*&------------------------------------------------------------*
*&
*
*& Example of a simple data retrieval *
*& ................................... *
*&
*
*& Used to demonstrate executing a report via a BSP application*
*& and using the data retrieved as the basis for the BSP app. *
*&
*
*& If report is executed via a BSP then data is extracted to *
*& memory and then retrievd by the BSP.... *
*&-------------------------------------------------------------*
REPORT ZAG_BSP_GETDATA.
TABLES: tstc.
type-pools: slis. "ALV Declarations
parameters: p_bsp(1) type c no-display.
*Data Declaration
*----------------
TYPES: BEGIN OF t_tstc,
TCODE type tstc-tcode,
PGMNA type tstc-pgmna,
END OF t_tstc.
DATA: it_tstc TYPE STANDARD TABLE OF t_tstc INITIAL SIZE 0,
wa_tstc TYPE t_tstc.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
**********************************************************************
**Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*&--------------------------------------------------------------------
-*
*& Form BUILD_FIELDCATALOG
*&--------------------------------------------------------------------
-*
* Build Fieldcatalog for ALV Report
*---------------------------------------------------------------------
-*
form build_fieldcatalog.
fieldcatalog-fieldname = 'TCODE'.
fieldcatalog-seltext_m = 'Trans code'.
fieldcatalog-col_pos = 0.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PGMNA'.
fieldcatalog-seltext_m = 'Program'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*&--------------------------------------------------------------------
-*
*& Form BUILD_LAYOUT
*&--------------------------------------------------------------------
-*
* Build layout for ALV grid report
*---------------------------------------------------------------------
-*
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
endform. " BUILD_LAYOUT
*&--------------------------------------------------------------------
-*
*& Form DISPLAY_ALV_REPORT
*&--------------------------------------------------------------------
-*
* Display report using ALV grid
*---------------------------------------------------------------------
-*
form display_alv_report.
if p_bsp EQ 'X'. "If report run from BSP application
export it_tstc to memory id sy-uname.
else.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_tstc
exceptions
program_error = 1
others = 2.
endif.
endform. " DISPLAY_ALV_REPORT
*&--------------------------------------------------------------------
-*
*& Form DATA_RETRIEVAL
*&--------------------------------------------------------------------
-*
* Retrieve data form EKPO table and populate itab it_ekko
*---------------------------------------------------------------------
-*
form data_retrieval.
data: r_tcode type range of tstc-tcode with header line.
r_tcode-sign = 'I'.
r_tcode-option = 'CP'.
r_tcode-low = 'SE*'.
append r_tcode.
select tcode pgmna
up to 10 rows
from tstc
into table it_tstc
where tcode in r_tcode.
endform. " DATA_RETRIEVAL
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<html>
<head>
<link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp
.css">
<title> Intial page of BSP application </title>
</head>
<body class="bspBody1">
<h1><img src="sap_logo.gif"> Transaction Display(TSTC)</h1>
<% submit ZBSP_GETDATA and return with p_bsp = 'X'.%>
<% import it_tstc to it_tstc from memory id sy-uname.%>
<table width="80%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><b>T Code </b></td>
<td><b>Program</b></td>
</tr>
<% data wa_tsts2 like line of it_tstc.
Loop at it_tstc into wa_tstc. %>
<tr>
<td><%=wa_tstc-tcode%></td>
<td><%=wa_tstc-PGMNA%></td>
</tr>
<% Endloop. %>
</table>
</body>
</html>
7 – Activar y probar
Guardar todo y presionar el botón de activar, se todo esta bien presionar el botón ejecutar el
cual abrirá una ventana de navegador y desplegará la recién creada BSP.