You are on page 1of 5

*Declaracin de variables

********** DATA ALV **************************************************


*****************************

*Type Pool donde vienen definidas todas las estructuras y tablas


TYPE-POOLS: slis.

*Estructura de parmetros
DATA: LF_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,"Manejar grupos de campos
LF_LAYOUT TYPE SLIS_LAYOUT_ALV, "Manejar diseo de layout
IT_TOPHEADER TYPE SLIS_T_LISTHEADER, "Manejar cabecera del rep
WA_TOP LIKE LINE OF IT_TOPHEADER. "Lnea para cabecera

*Tablas. Catlogo de campos


DATA: alv_git_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
"manejar catlogo de parmetros

menu entries and favorites. entries. You can adjust the favorites. area in particular to
your needs. The entries of the SAP menus and the user menus can only be changed by
system administrators.

*Llamado al ALV

*ALV Report
PERFORM alv_report USING itab[].

*PERFORMS del ALV

FORM alv_report USING pp_itab LIKE itab[].

PERFORM sp_group_build USING lf_sp_group[].


PERFORM alv_ini_fieldcat.
PERFORM layout_build USING lf_layout.
PERFORM alv_listado USING pp_itab[].

ENDFORM. " ALV_REPORT

*FORMS del ALV

* FORM SP_GROUP_BUILD para crear los grupos de campos.


FORM SP_GROUP_BUILD USING U_LF_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.

DATA: LS_SP_GROUP TYPE SLIS_SP_GROUP_ALV.


CLEAR LS_SP_GROUP.
LS_SP_GROUP-SP_GROUP = 'A'.
LS_SP_GROUP-TEXT = TEXT-010.
APPEND LS_SP_GROUP TO U_LF_SP_GROUP.

ENDFORM. " SP_GROUP_BUILD3

their user menus. If both menus are disallowed, then the user menu is still
displayed. The availability of the user or SAP menu does not affect a user.s
authorizations. This means that a user can always call authorized functions
using a transaction code, independent of the menu structure.
The role-based user menu is created on the basis of the role(s) assigned to the user
and transferred to the front end. This means that it makes sense to keep roles as small
as possible because large roles could take a long time to transfer
*FORM ALV_INI_FIELDCAT para crear el catlogo de campos con sus propiedades.
FORM ALV_INI_FIELDCAT .

*Documento Comercial
CLEAR alv_git_fieldcat.
alv_git_fieldcat-fieldname = 'PEDIDO'.
alv_git_fieldcat-key = 'X'.
alv_git_fieldcat-seltext_m = 'Doc. Comercial'.
alv_git_fieldcat-seltext_l = 'Doc. Comercial'.
alv_git_fieldcat-col_pos = 0.
alv_git_fieldcat-sp_group = 'A'.
alv_git_fieldcat-outputlen = '20'.
APPEND alv_git_fieldcat TO alv_git_fieldcat.

*Fecha del Documento


CLEAR alv_git_fieldcat.
alv_git_fieldcat-fieldname = 'FECHA'.
alv_git_fieldcat-seltext_m = 'Fecha'.
alv_git_fieldcat-seltext_l = 'Fecha'.
alv_git_fieldcat-col_pos = 0.
alv_git_fieldcat-sp_group = 'A'.
alv_git_fieldcat-outputlen = '10'.
APPEND alv_git_fieldcat TO alv_git_fieldcat.

CLEAR alv_git_fieldcat.
alv_git_fieldcat-SP_GROUP = 'A'.
MODIFY alv_git_fieldcat FROM alv_git_fieldcat
TRANSPORTING SP_GROUP WHERE FIELDNAME = 'VBTYP'
.

ENDFORM. " ALV_INI_FIELDCAT

Hint: As long as you have the appropriate authorization, you can also display
user menus other than the ones assigned to you in your user master record.
To do this, choose Other menu. Use Create role to start the role maintenance
transaction, PFCG.
The user and SAP menus can be structured in a pretty complex way. It is then difficult
to remember the exact path for the transaction you are looking for. As long as the
transaction has not been copied into the favorite area, you can find it more easily
with special search transactions. The transactions SEARCH_SAP_MENU and
SEARCH_USER_MENU search the corresponding menus for the predefined text
pattern. The search result is prepared in a list view from which you can take the
navigation path. The transactions found cannot be started directly with a double-click.
A further search option for SAP menu entries is the transaction SDMO, which also
allows you to search for a text pattern. A (technically out-of-date) dynamic menu is
generated, from which the transactions found can be started with a double-click.
Favorites Management
In addition to the area menu or SAP menu, the user is also provided with functions
in the favorites. area. Links to frequently used transactions, web links or files can
be stored in the favorites. area.
The users. favorites. entries are in the system tables SMEN_BUFFC and
SMEN_BUFFI. Administrators can access these table to make changes and thereby
change or delete the favorites of large user groups.
The favorites list thus contains references to SAP system functions or links to internet
content or to files on the end user.s front-end computer. The favorites list, which
is initially empty, can be edited by each end user in accordance with his or her
preferences; you can only view your own favorites list. Since data on the favorites is
stored within the SAP system, each user might have different collections of favorites
in different systems.
62
* FORM LAYOUT_BUILD para disear el Layout de salida del ALV
FORM LAYOUT_BUILD USING U_LF_LAYOUT TYPE SLIS_LAYOUT_ALV.

U_LF_LAYOUT-BOX_FIELDNAME = 'CHECK'. " Checkbox


U_LF_LAYOUT-ZEBRA = 'X'. " Streifenmuster
U_LF_LAYOUT-GET_SELINFOS = 'X'.
U_LF_LAYOUT-F2CODE = 'BEAN' . " Doppelklickfunktion
U_LF_LAYOUT-CONFIRMATION_PROMPT = 'X'. "Sicherheitsabfrage
U_LF_LAYOUT-KEY_HOTSPOT = 'X'. "Schlssel als Hotspot
U_LF_LAYOUT-INFO_FIELDNAME = 'COL'. "Zeilenfarbe

ENDFORM. " LAYOUT_BUILD

*FORM ALV_LISTADO para invocar al ALV


FORM alv_listado USING ppp_itab LIKE itab[].

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_BUFFER_ACTIVE = 'X'
I_BACKGROUND_ID = 'ALV_BACKGROUND'
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LF_LAYOUT
IT_FIELDCAT = alv_git_fieldcat[]
IT_SPECIAL_GROUPS = LF_SP_GROUP
I_SAVE = 'X'
TABLES
T_OUTTAB = ppp_itab.

ENDFORM. " ALV_LISTADO

extent. If you have highlighted a menu entry using the mouse, you can copy
the selected node in the favorites. area by right-hand mouse click.
Alternatively, you can also drag the elements from the menu area using the mouse and
store them in the favorites. area (Drag&Drop). You can add URLs or links to files to
your list of favorites by choosing FavoritesAdd other objects. Click on the triangle
symbol to the left of the file symbol to expand or collapse the list of favorites.
Hint: To change the name of a transaction in Favorites, highlight the
corresponding favorites entry and select the menu path Favorites Change.
You can change and save the text in the dialog box that opens.
You can delete favorites. entries that you no longer need. In doing so, the link to the
corresponding function is deleted from your favorites. list. If you want to delete the
entire Favorites menu, highlight the entry Favorites and right-click to call up the
available context menu. Choose Delete all favorites.
2008
*EVENTOS
*El FORM TOP_OF_PAGE nos permite configurar la cabecera del reporte
FORM top_of_page.

REFRESH it_topheader.

* Ttulo del reporte


MOVE: 'H' TO wa_top-typ,
'Contratos de Ventas bloqueados por Gestin de Crdito.' TO wa
_top-info.
APPEND wa_top TO it_topheader.

* Clientes
MOVE: 'S' TO wa_top-typ,
l_cli TO wa_top-info,
'Clientes:' TO wa_top-key.
APPEND wa_top TO it_topheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'


EXPORTING
it_list_commentary = it_topheader
i_logo = 'ZLOGO_LGT256'.

ENDFORM. "top_of_page

* EL FORM PF_STATUS nos permite asignar el Status GUI que queremos para el reporte.

FORM pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM.
You can reach the menus in the menu bar by simply using the key combination
Alt+<#> (# corresponds to the underlined letter of the selected menu item) or Alt
and cursor navigation using the arrow keys on the keyboard.
You can use the keyboard to get to the SAP Easy Access screen or the OK Code field
and call system functions from there.
Hint: Use the following keys to navigate using the keyboard:
. TAB moves from one field element to the next within a field group.
. Ctrl + TAB goes from one field group to the first element of the next
field group.
. Ctrl + / goes directly to the OK Code field.
You can find further shortcuts using Customizing of local layout (Alt+F12)
SAP GUI Help.
64
* El FORM USER_COMMAND nos permite controlar los eventos dentro del reporte

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM


RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.
WHEN 'BEAN'.
*** CUANDO EL USUARIO DA CLIC EN UNA COLUMNA DEL REPORTE
READ TABLE itab INDEX RS_SELFIELD-TABINDEX.
PERFORM bath.
rs_selfield-refresh = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.
CALL TRANSACTION 'VA43' USING bdc_tabla[] MODE 'E'.

MODIFY itab INDEX RS_SELFIELD-TABINDEX.

WHEN '&NFO'.
LOOP AT itab INTO linea WHERE check = 'X'.
*** CUANDO EL USUARIO DA CLIC EN UN BOTON/PULSADOR CREADO POR NOSOTROS
CALL FUNCTION 'SD_ORDER_CREDIT_RELEASE'
EXPORTING
VBELN = linea-pedido.

IF sy-subrc EQ 0.
MESSAGE i398(00) WITH 'Documento' linea-pedido 'desbloquead
o y liberado'.
MODIFY itab FROM linea INDEX index TRANSPORTING check.
ELSE.
MESSAGE i398(00) WITH 'Documento' linea-pedido 'no liberado
'.
ENDIF.

ENDCASE.
ENDFORM.

to cancel the current transaction


. /nXXXX to call transaction XXXX directly from another transaction. Without
the prefix you can only call XXXX from the SAP Easy Access screen.
. /o to display an overview of sessions
. /oXXXX to call transaction XXXX in a new session directly from another
transaction
. /nend to end the logon session with a confirmation dialog box
. /nex to end the logon session without a confirmation dialog box
. /i to delete the session you are currently using
Note: The OK Code field is an exception in that choosing the F4 key does
not display the input help. The F4 key in the OK Code field lists the last
15 different entries in the OK Code field. This list is stored in the registry
on the front end and is valid for all sessions on the front end (regardless
of the system used).
Help