Ver Mensaje Individual
  #5  
Viejo 27/06/07, 16:14:42
Hectorlp Hectorlp is offline
Junior Member
 
Fecha de Ingreso: jun 2007
Localización: Venezuela
Mensajes: 5

Hola este es mi código completo, Muchas Gracias por tu ayuda.

**********************************************************
REPORT ZAC_TEMPORAL LINE-SIZE 100
NO STANDARD PAGE HEADING.

INCLUDE <ICON>.

**
DATA TYPES.
**

****************************Definición de tabla interna para alv***********************



DATA CONT(2) TYPE C.




TYPE-POOLS: SLIS.

TYPES: BEGIN OF TP_DATA,
POSC(2) TYPE C,
ACTECON TYPE C LENGTH 200,
ALICUO TYPE BETRW_KK,
IMPBASE TYPE BETRW_KK,
IMPTOTA TYPE BETRW_KK,
MARK,
END OF TP_DATA,

TP_TBL_DATA TYPE STANDARD TABLE OF TP_DATA.

DATA: WA_ALV TYPE TP_DATA.



DATA: IT_ALV LIKE TABLE OF WA_ALV.

***
* Constants
**


**
* Data objects (variable declarations and definitions)
**
*
*Report data to be shown.
*data: it_data type standard table of tp_data.

*Heading of the report.
DATA: T_HEADING TYPE SLIS_T_LISTHEADER.

START-OF-SELECTION.

CONT = 0.
DO 15 TIMES.
WA_ALV-POSC = CONT.
CONT = CONT + 1.
APPEND WA_ALV TO IT_ALV.
ENDDO.


*perform get_data using it_alv.
*
END-OF-SELECTION.
PERFORM BUILD_ALV USING IT_ALV T_HEADING.

**======================== Subroutines ==============================*
*
**&------------------------------------------------------------------*
**& Form get_data
**&------------------------------------------------------------------*
** Gets the information to be shown in the report.
**-------------------------------------------------------------------*
*
**&------------------------------------------------------------------*
**& Form build_alv
**&------------------------------------------------------------------*
** Builds and display the ALV Grid.
**-------------------------------------------------------------------*
FORM BUILD_ALV USING T_ALV TYPE TP_TBL_DATA
T_HEADING TYPE SLIS_T_LISTHEADER.

* ALV required data objects.
DATA: W_TITLE TYPE LVC_TITLE,
W_REPID TYPE SYREPID,
W_COMM TYPE SLIS_FORMNAME,
W_STATUS TYPE SLIS_FORMNAME,
X_LAYOUT TYPE SLIS_LAYOUT_ALV,
T_EVENT TYPE SLIS_T_EVENT,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
T_SORT TYPE SLIS_T_SORTINFO_ALV.

REFRESH T_FIELDCAT.
REFRESH T_EVENT.
REFRESH T_SORT.
CLEAR X_LAYOUT.
CLEAR W_TITLE.


* Field Catalog
PERFORM SET_FIELDCAT2 USING:
1 'POSC' 'POSC' SPACE 10 SPACE SPACE 'Posición' SPACE SPACE SPACE SPACE SPACE SPACE SPACE SPACE T_FIELDCAT ,
2 'ACTECON' 'ACTECON' SPACE 30 SPACE SPACE 'Act. Economica' SPACE SPACE SPACE SPACE SPACE SPACE 'X' SPACE T_FIELDCAT ,
3 'ALICUO' 'ALICUO' SPACE 20 SPACE SPACE 'Alicuota' SPACE SPACE SPACE SPACE SPACE SPACE 'X' SPACE T_FIELDCAT ,
4 'IMPBASE' 'IMPBASE' SPACE 20 SPACE SPACE 'Importe Base' SPACE SPACE SPACE SPACE SPACE SPACE 'X' SPACE T_FIELDCAT,
5 'IMPTOTA' 'IMPTOTA' SPACE 20 SPACE SPACE 'Importe total' SPACE SPACE SPACE 'X' SPACE SPACE 'X' 'X' T_FIELDCAT.

* Layout
X_LAYOUT-ZEBRA = 'X'.
X_LAYOUT-BOX_FIELDNAME = 'MARK'.
X_LAYOUT-BOX_TABNAME = 'IT_ALV'.

* Top of page heading
PERFORM SET_TOP_PAGE_HEADING USING T_HEADING T_EVENT.

* Events
PERFORM SET_EVENTS USING T_EVENT.

* GUI Status
W_STATUS = ''.
W_REPID = SY-REPID.

* Title
W_TITLE = 'Liquidaciones'.

* User commands
W_COMM = 'USER_COMMAND'.

* Order
* Example
* PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.


* Displays the ALV grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
IT_FIELDCAT = T_FIELDCAT
IS_LAYOUT = X_LAYOUT
IT_SORT = T_SORT
I_CALLBACK_PF_STATUS_SET = W_STATUS
I_CALLBACK_USER_COMMAND = W_COMM
I_SAVE = 'X'
IT_EVENTS = T_EVENT
I_GRID_TITLE = W_TITLE
TABLES
T_OUTTAB = T_ALV
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. " build_alv.


*&------------------------------------------------------------------*
*& Form set_top_page_heading
*&------------------------------------------------------------------*
* Creates the report headings.
*-------------------------------------------------------------------*
FORM SET_TOP_PAGE_HEADING USING T_HEADING TYPE SLIS_T_LISTHEADER
T_EVENTS TYPE SLIS_T_EVENT.

DATA: X_HEADING TYPE SLIS_LISTHEADER,
X_EVENT TYPE LINE OF SLIS_T_EVENT.

* Report title
CLEAR T_HEADING[].
CLEAR X_HEADING.
X_HEADING-TYP = 'H'.
X_HEADING-INFO = 'Liquidaciones'(001).
APPEND X_HEADING TO T_HEADING.

* Program name
CLEAR X_HEADING.
X_HEADING-TYP = 'S'.
X_HEADING-KEY = 'Program: '.
X_HEADING-INFO = SY-REPID.
APPEND X_HEADING TO T_HEADING.

* User who is running the report
* clear x_heading.
* x_heading-typ = 'S'.
* x_heading-key = 'User: '.
* x_heading-info = sy-uname.
* append x_heading to t_heading.

* Date of execution
CLEAR X_HEADING.
X_HEADING-TYP = 'S'.
X_HEADING-KEY = 'Date: '.
WRITE SY-DATUM TO X_HEADING-INFO.
APPEND X_HEADING TO T_HEADING.

* Time of execution
CLEAR X_HEADING.
X_HEADING-TYP = 'S'.
X_HEADING-KEY = 'Time: '.
WRITE SY-UZEIT TO X_HEADING-INFO.
APPEND X_HEADING TO T_HEADING.

* Top of page event
X_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
X_EVENT-FORM = 'TOP_OF_PAGE'.
APPEND X_EVENT TO T_EVENTS.

ENDFORM. "set_top_page_heading

*&------------------------------------------------------------------*
*& Form set_events
*&------------------------------------------------------------------*
* Sets the events for ALV.
* The TOP_OF_PAGE event is alredy being registered in
* the set_top_page_heading subroutine.
*-------------------------------------------------------------------*
FORM SET_EVENTS USING T_EVENTS TYPE SLIS_T_EVENT.

DATA: X_EVENT TYPE LINE OF SLIS_T_EVENT.

FREE T_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = T_EVENTS.

READ TABLE T_EVENTS WITH KEY NAME = 'PF_STATUS_SET' INTO X_EVENT.
IF SY-SUBRC EQ 0.
X_EVENT-FORM = 'PF_STATUS_SET'.
ENDIF.
MODIFY T_EVENTS INDEX SY-TABIX FROM X_EVENT.


**

ENDFORM. "set_events

*&------------------------------------------------------------------*
*& Form set_fieldcat2
*&------------------------------------------------------------------*
* Adds an entry to the field catalog.
* p_colpos: Column position.
* p_fieldname: Field of internal table which is being described by
* this record of the field catalog.
* p_ref_fieldname: (Optional) Table field / data element which
* describes the properties of the field.
* If this field is not given, it is copied from
* the fieldname.
* p_ref_tabname: (Optional) Table which holds the field referenced
* by <<p_ref_fieldname>>.
* If this is not given, the parameter
* <<p_ref_fieldname>> references a data element.
* p_outputlen: (Optional) Column width.
* p_noout: (Optional) If set to 'X', states that the field is not
* showed initially. If so, the field has to be
* included in the report at runtime using the display
* options.
* p_seltext_m: (Optional) Medium label to be used as column header.
* p_seltext_l: (Optional) Long label to be used as column header.
* p_seltext_s: (Optional) Small label to be used as column header.
* p_reptext_ddic: (Optional) Extra small (heading) label to be
* used as column header.
* p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
* whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
* or REPTEXT_DDIC as text for column header.
* p_hotspot: (Optional) If set to 'X', this field will be used
* as a hotspot area for cursor, alolowing the user
* to click on the field.
* p_showasicon: (Optional) If set to 'X', this field will be shown
* as an icon and the contents of the field will set
* which icon to show.
* p_checkbox: (Optional) If set to 'X', this field will be shown
* as a checkbox.
* p_edit: (Optional) If set to 'X', this field will be editable.
* p_dosum: (Optional) If set to 'X', this field will be summed
* (aggregation function) according to the grouping set
* by the order functions.
* t_fieldcat: Table which contains the whole fieldcat.
*-------------------------------------------------------------------*
FORM SET_FIELDCAT2 USING
P_COLPOS P_FIELDNAME P_REF_FIELDNAME P_REF_TABNAME
P_OUTPUTLEN P_NOOUT
P_SELTEXT_M P_SELTEXT_L P_SELTEXT_S P_REPTEXT_DDIC P_DDICTXT
P_HOTSPOT P_SHOWASICON P_CHECKBOX P_EDIT
P_DOSUM
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR WA_FIELDCAT.

* General settings
WA_FIELDCAT-FIELDNAME = P_FIELDNAME.
WA_FIELDCAT-COL_POS = P_COLPOS.
WA_FIELDCAT-NO_OUT = P_NOOUT.
WA_FIELDCAT-HOTSPOT = P_HOTSPOT.
WA_FIELDCAT-CHECKBOX = P_CHECKBOX.
WA_FIELDCAT-ICON = P_SHOWASICON.
WA_FIELDCAT-DO_SUM = P_DOSUM.

* Set reference fieldname, tablenam and rollname.
* If p_ref_tabname is not given, the ref_fieldname given
* is a data element.
* If p_ref_tabname is given, the ref_fieldname given is a
* field of a table.
* In case ref_fieldname is not given,
* it is copied from the fieldname.
IF P_REF_TABNAME IS INITIAL.
WA_FIELDCAT-ROLLNAME = P_REF_FIELDNAME.
ELSE.
WA_FIELDCAT-REF_TABNAME = P_REF_TABNAME.
IF P_REF_FIELDNAME EQ SPACE.
WA_FIELDCAT-REF_FIELDNAME = WA_FIELDCAT-FIELDNAME.
ELSE.
WA_FIELDCAT-REF_FIELDNAME = P_REF_FIELDNAME.
ENDIF.
ENDIF.

* Set output length.
IF NOT P_OUTPUTLEN IS INITIAL.
WA_FIELDCAT-OUTPUTLEN = P_OUTPUTLEN.
ENDIF.

* Set text headers.
IF NOT P_SELTEXT_M IS INITIAL.
WA_FIELDCAT-SELTEXT_M = P_SELTEXT_M.
ENDIF.

IF NOT P_SELTEXT_L IS INITIAL.
WA_FIELDCAT-SELTEXT_L = P_SELTEXT_L.
ENDIF.

IF NOT P_SELTEXT_S IS INITIAL.
WA_FIELDCAT-SELTEXT_S = P_SELTEXT_S.
ENDIF.

IF NOT P_REPTEXT_DDIC IS INITIAL.
WA_FIELDCAT-REPTEXT_DDIC = P_REPTEXT_DDIC.
ENDIF.

IF NOT P_DDICTXT IS INITIAL.
WA_FIELDCAT-DDICTXT = P_DDICTXT.
ENDIF.

* Set as editable or not.
IF NOT P_EDIT IS INITIAL.
WA_FIELDCAT-INPUT = 'X'.
WA_FIELDCAT-EDIT = 'X'.
ENDIF.

APPEND WA_FIELDCAT TO T_FIELDCAT.

ENDFORM. "set_fieldcat2

*======================== Subroutines called by ALV ================*

*&------------------------------------------------------------------*
*& Form top_of_page
*&------------------------------------------------------------------*
* Called on top_of_page ALV event.
* Prints the heading.
*-------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = <<If you want to set a logo, please,
* uncomment and edit this line>>
IT_LIST_COMMENTARY = T_HEADING.
ENDFORM. " alv_top_of_page

*&------------------------------------------------------------------*
*& Form user_command
*&------------------------------------------------------------------*
* Called on user_command ALV event.
* Executes custom commands.
*-------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.

CASE r_ucomm.
WHEN '&CONT'.
LOOP AT IT_ALV INTO WA_ALV.
WA_ALV-IMPTOTA = WA_ALV-ALICUO * WA_ALV-IMPBASE.
MODIFY TABLE IT_ALV FROM WA_ALV.
ENDLOOP.
ENDCASE.




ENDFORM. "user_command
*********** función para traer status**********************

FORM PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .

SET PF-STATUS 'STANDARD'.
ENDFORM. "PF_STATUS_SET
Responder Con Cita