hola soy nueva en el mundo sap, como primeraa incidencia me han pedido realizar un ALV; lo he hecho pero aunuqe me muestra la plantilla con el nro de registro que deberia mostrar no me aparece nigun valor.
me explico; al generar un alv realice un busqueda para que salga un solo registro, y efectivamente cuando me aparece el resultado o listado del alv, me sale la linea de cabecera y junto luego una linea en blanco;
he debugger y siempre me aparece en mi tabla interna el registro, asi q no se en que momento se pierde
![Mad](http://www.mundosap.com/foro/images/smilies/mad.gif)
ya llevo mas de un dia en esto y no se que hacerrrrrrrrrr; he hecho varias veces desde cero el alv usando diferentes plantillas y nada. alquien me ayuda....
codigo....
*&---------------------------------------------------------------------*
*& Report ZPS_LISTADO_VBRK *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT zps_listado_facturas .
*--Definición de las tablas
TABLES: kna1,vbrk.
*--Definición de las Tipos, datos y TI
TYPES: BEGIN OF t_vbrk,
date LIKE vbrk-fkdat_rl, "Fecha de la Factura
vbeln LIKE vbrk-vbeln, "Numero de la Factura
zuorn LIKE vbrk-zuonr, "Codigo Analitico
kunnr LIKE kna1-kunnr, "Cliente kna1-kunnr
opera LIKE vbrk-vbeln, "Operacion
waerk LIKE vbrk-waerk, "Moneda
END OF t_vbrk.
DATA: wa_factura TYPE STANDARD TABLE OF t_vbrk WITH HEADER LINE.
DATA: it_fact TYPE STANDARD TABLE OF t_vbrk WITH HEADER LINE.
*DATA: it_output TYPE STANDARD TABLE OF t_vbrk WITH HEADER LINE,
*p_tipo(10).
*
**--Selección de la pantalla principal
*SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*SELECT-OPTIONS: gjahr FOR vbrk-gjahr.
*SELECTION-SCREEN: END OF BLOCK b1.
*
*
*&---------------------------------------------------------------------*
*& Form seleccion_datos
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IT_ text
*----------------------------------------------------------------------*
FORM seleccion_datos TABLES it_vbrk STRUCTURE it_fact. "it_output.
*--Seleccionando los datos de la BD
SELECT *
FROM vbrk
INTO CORRESPONDING FIELDS OF TABLE wa_factura.
" where vbeln = '0000010000'.
* WHERE vbeln IN gjahr.
*--Si trae la información de la BD, clasificar la información
IF sy-subrc = 0.
*--Interactuando con la WA donde se guardo la información extraida de BD
LOOP AT wa_factura.
*--Moviendo la información de la WA a la TI que se mostrará en el ALV
MOVE-CORRESPONDING wa_factura TO it_fact.
*--Agregando la información a la TI
APPEND it_fact.
ENDLOOP.
ENDIF.
ENDFORM. "selección
*--Definiendo el primer evento del reporte
START-OF-SELECTION.
*-Llamando a las subrutinas y pasandole la TI que se mostraran en el ALV
PERFORM seleccion_datos TABLES it_fact. "it_output.
PERFORM alv_create TABLES it_fact. "it_output.
*Type Pool donde vienen definidas todas las estructuras y tablas
TYPE-POOLS: slis.
DATA:
* Catálogo de campos: contiene la descripción de los campos de salida
alv_git_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
alv_git_fieldcat_par TYPE slis_t_fieldcat_alv WITH HEADER LINE,
w_field TYPE slis_t_fieldcat_alv WITH HEADER LINE,
alv_sort TYPE slis_t_sortinfo_alv,
t_spec_groups TYPE slis_t_sp_group_alv,
* Descripción de la estructura de salida
alv_gwa_layout TYPE slis_layout_alv,
* alv_gwa_print type slis_print_alv,
* Cabecera del reporte
alv_git_heading TYPE slis_t_listheader WITH HEADER LINE,
* Eventos
alv_git_events TYPE slis_t_event WITH HEADER LINE,
alv_gc_save(1) TYPE c,
alv_gc_exit(1) TYPE c,
alv_gx_variant LIKE disvariant,
alv_gx_tmpvariant LIKE disvariant,
sp_group TYPE slis_sp_group_alv,
* Nombre de la Tabla con los datos para el ALV
alv_it_data TYPE slis_formname VALUE 'IT_ALV',
* Nombre del programa
alv_gx_repid LIKE sy-repid.
*-------------------------------------------------------------------*
* Declaración de constantes
*-------------------------------------------------------------------*
CONSTANTS:
* FORM para escribir el encabezado
alv_formname_top_of_page TYPE slis_formname VALUE 'ALV_TOP_OF_PAGE',
* * alv_formname_user_command TYPE slis_formname VALUE 'USER_COMMAND',
alv_formname_end_of_list TYPE slis_formname VALUE 'ALV_END_OF_LIST'.
INITIALIZATION.
* NOMBRE DEL PROGRAMA VARIABLE ALV
alv_gx_repid = sy-repid.
PERFORM initialize_variant.
* gs_print-no_print_listinfos = 'X'.
*Subrutinas del ALV
*---------------------------------------------------------------------*
* FORM alv_build_eventtab *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM alv_build_eventtab.
FREE alv_git_events.
*Llamada de la funcion
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = alv_git_events[].
*Llamada del Top_of_page
READ TABLE alv_git_events WITH KEY name = slis_ev_top_of_page.
IF sy-subrc = 0.
MOVE alv_formname_top_of_page TO alv_git_events-form.
APPEND alv_git_events.
ENDIF.
*Llamada del End_of_list
READ TABLE alv_git_events WITH KEY name = slis_ev_end_of_list.
IF sy-subrc = 0.
MOVE alv_formname_end_of_list TO alv_git_events-form.
APPEND alv_git_events.
ENDIF.
ENDFORM. "alv_build_eventtab
*&---------------------------------------------------------------------*
*& Form alv_ini_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_ini_layout.
* alv_gwa_layout-box_fieldname = 'SEL'.
* alv_gwa_layout-edit = 'X'.
*
*Indica como se vera la pantalla de salida.
* zebra = 'X' (Lista los registros con dos colores, uno por linea).
* zebra = ' ' (Lista los registro de un solo color).
alv_gwa_layout-zebra = 'X'.
*Detail_popup = ' ' (Al pulsar doble-click en un registro de la lista
*principal, se presenta otra lista con el detalle).
*Detail_popup = 'X' (Al pulsar doble-click en un registro de la lista
*principal, se presenta una ventana con el detalle).
*
alv_gwa_layout-detail_popup = ' '.
ENDFORM. "alv_ini_layout
*&---------------------------------------------------------------------*
*& Form alv_ini_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_ini_fieldcat.
* Mediante esta tabla vamos a definir los campos que se quiere mostrar
* en el listado de salida.
*COLUMNAS CLAVES
CLEAR alv_git_fieldcat.
REFRESH alv_git_fieldcat.
alv_git_fieldcat-tabname = alv_it_data.
alv_git_fieldcat-fix_column = space. "# Dejar campos Fijos
*--Fecha
alv_git_fieldcat-fieldname = 'date'.
alv_git_fieldcat-seltext_l = text-002.
alv_git_fieldcat-just = 'C'.
alv_git_fieldcat-col_pos = '0'.
alv_git_fieldcat-outputlen = '15'.
alv_git_fieldcat-hotspot = 'X'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
*--Numero de la Factura
alv_git_fieldcat-fieldname = 'vbeln'.
alv_git_fieldcat-seltext_l = text-003.
alv_git_fieldcat-just = 'C'.
alv_git_fieldcat-col_pos = '1'.
alv_git_fieldcat-outputlen = '20'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
*--Codigo Analitico
alv_git_fieldcat-fieldname = 'zuorn'.
alv_git_fieldcat-seltext_l = text-004.
alv_git_fieldcat-just = 'L'.
alv_git_fieldcat-col_pos = '2'.
alv_git_fieldcat-outputlen = '20'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
*--Cliente
alv_git_fieldcat-fieldname = 'kunnr'.
alv_git_fieldcat-seltext_l = text-005.
alv_git_fieldcat-just = 'L'.
alv_git_fieldcat-col_pos = '3'.
alv_git_fieldcat-outputlen = '40'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
*--Operacion
alv_git_fieldcat-fieldname = 'vbeln'.
alv_git_fieldcat-seltext_l = text-006.
alv_git_fieldcat-just = 'L'.
alv_git_fieldcat-col_pos = '4'.
alv_git_fieldcat-outputlen = '20'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
*--Moneda local
alv_git_fieldcat-fieldname = 'waerk'.
alv_git_fieldcat-seltext_l = text-007.
alv_git_fieldcat-just = 'L'.
alv_git_fieldcat-col_pos = '5'.
alv_git_fieldcat-outputlen = '7'.
APPEND alv_git_fieldcat. CLEAR alv_git_fieldcat.
ENDFORM. "alv_ini_fieldcat
*&---------------------------------------------------------------------*
*& Form alv_build_comment
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_build_comment.
*Definicion del contenido del top_of_page
DATA: aux_1(100) TYPE c,
aux_2(100) TYPE c,
empresa_nombre TYPE t001-butxt,
fch1(10) TYPE c,
fch2(10) TYPE c.
DATA: divi(100) TYPE c,
div_asignada TYPE c.
FREE alv_git_heading.
CLEAR aux_1.
aux_1 = ' '.
alv_git_heading-typ = 'H'.
alv_git_heading-key = aux_1.
alv_git_heading-info = aux_1.
APPEND alv_git_heading.
CLEAR aux_1.
aux_1 = 'Listado de Facturas'.
alv_git_heading-typ = 'H'.
* alv_git_heading-key = aux_1.
alv_git_heading-info = aux_1.
APPEND alv_git_heading.
* Fecha
alv_git_heading-typ = 'S'.
DATA fecha(10).
PERFORM format_date USING sy-datum CHANGING fecha.
alv_git_heading-key = 'Fecha: '.
alv_git_heading-info = fecha.
APPEND alv_git_heading.
ENDFORM. "alv_build_comment
*&---------------------------------------------------------------------*
*& Form format_date
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_DATUM text
* <--P_FECHA text
*----------------------------------------------------------------------*
FORM format_date USING fecha_entrada LIKE sy-datum
CHANGING fecha_salida TYPE c.
*Definicion formato de la fecha
CONCATENATE fecha_entrada+6(2) fecha_entrada+4(2) fecha_entrada+0(4)
INTO fecha_salida SEPARATED BY '/'.
ENDFORM. " format_date
*&---------------------------------------------------------------------*
*& Form alv_listado
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_ALV text
*----------------------------------------------------------------------*
FORM alv_listado TABLES it_fact. "p_it_alv.
DATA: lc_glay TYPE lvc_s_glay.
lc_glay-edt_cll_cb = 'X'.
*Llamado de la funcion del ALV
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
i_callback_program = alv_gx_repid
i_callback_pf_status_set = 'ALV_PF_STATUS_SET'
* i_callback_user_command = 'USER_COMMAND'
i_structure_name = alv_it_data
is_layout = alv_gwa_layout
it_fieldcat = alv_git_fieldcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
it_sort = alv_sort[]
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'A'
i_save = alv_gc_save
is_variant = alv_gx_variant
it_events = alv_git_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
* IR_SALV_LIST_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_fact "it_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. "alv_listado
*&---------------------------------------------------------------------*
*& Form alv_top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_top_of_page.
*Llamado de la funcion del top_of_page
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = alv_git_heading[].
* I_LOGO =
* I_END_OF_LIST_GRID =
ENDFORM. "alv_top_of_page
*&---------------------------------------------------------------------*
*& Form alv_create
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_create TABLES it_fact. "p_it_output.
*Llamados de las subrutinas del ALV
* PERFORM ordenar_por USING alv_sort[].
PERFORM alv_build_eventtab.
PERFORM alv_ini_layout.
PERFORM alv_ini_fieldcat.
PERFORM alv_build_comment.
PERFORM alv_listado TABLES it_fact. "p_it_output.
ENDFORM. "alv_create
*&---------------------------------------------------------------------*
*& Form initialize_variant
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM initialize_variant.
*Llamado de la variable de inicializacion del programa
alv_gc_save = 'A'.
CLEAR alv_gx_variant.
alv_gx_variant-report = alv_gx_repid.
alv_gx_variant = alv_gx_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = alv_gc_save
CHANGING
cs_variant = alv_gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
vari = alv_gx_variant-variant.
ENDIF.
ENDFORM. "initialize_variant
**&---------------------------------------------------------------------
*
**& Form ordenar_por
**&---------------------------------------------------------------------
*
** text
**----------------------------------------------------------------------
*
** -->P_SORT text
**----------------------------------------------------------------------
*
***FORM ordenar_por USING p_sort TYPE slis_t_sortinfo_alv.
***
*** DATA: wa_sort TYPE slis_sortinfo_alv.
***
*** CLEAR wa_sort.
*** wa_sort-fieldname = 'vbeln'.
*** wa_sort-spos = 1.
*** wa_sort-up = 'X'.
*** wa_sort-subtot = 'X'.
*** APPEND wa_sort TO p_sort.
***
***
***ENDFORM. " ordenar_por
*&---------------------------------------------------------------------*
*& Form alv_pf_status_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->EXTAB text
*----------------------------------------------------------------------*
*FORM alv_pf_status_set USING extab TYPE slis_t_extab."TABLES
*p_it_output
*
* SET PF-STATUS 'ESTANDAR_NEW_II'. " EXCLUDING p_it_output.
*
*ENDFORM. "alv_pf_status_set
***&-------------------------------------------------------------------*
***& Form user_command
***&-------------------------------------------------------------------*
*** text
***--------------------------------------------------------------------*
*** -->UCOMM text
*** -->SELFIELD text
***--------------------------------------------------------------------*
**FORM user_command USING ucomm LIKE sy-ucomm
** selfield TYPE slis_selfield.
**
** DATA: copy_syucomm LIKE sy-ucomm.
** MOVE ucomm TO copy_syucomm.
**
**** CHECK selfield-fieldname EQ 'CARRID'.
***
** CHECK ucomm EQ '&IC1' AND NOT selfield-tabindex IS INITIAL.
**
** READ TABLE it_output INDEX selfield-tabindex.
**
** CASE selfield-fieldname.
** WHEN 'vbeln'.
** IF it_output-vbeln NE space.
** SET PARAMETER ID 'CAR' FIELD it_output-carrid.
** SET PARAMETER ID 'CON' FIELD it_output-connid.
** CALL TRANSACTION 'ZCURSO_02_KP' AND SKIP FIRST SCREEN.
** ENDIF.
** ENDCASE.
**ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form refresca_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->U_SELFIELD text
*----------------------------------------------------------------------*
FORM refresca_alv USING u_selfield TYPE slis_selfield.
u_selfield-refresh = 'X'.
u_selfield-col_stable = 'X'.
u_selfield-row_stable = 'X'.
ENDFORM. "refresca_alv
*&---------------------------------------------------------------------*
*& Form ALV_END_OF_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*FORM alv_end_of_list.
*
**Seleccion del end_of_list
** DATA: aux_5(100) TYPE c.
**
** FREE alv_git_heading.
** aux_5 = 'Días'.
** alv_git_heading-typ = 'S'.
** alv_git_heading-key = aux_5.
*** alv_git_heading-info = suma.
** APPEND alv_git_heading.
**
** CLEAR aux_5.
*** FREE alv_git_heading.
** aux_5 = 'Promedio de días'.
** alv_git_heading-typ = 'S'.
** alv_git_heading-key = aux_5.
*** alv_git_heading-info = promedio.
** APPEND alv_git_heading.
**
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* it_list_commentary = alv_git_heading[]
* i_end_of_list_grid = 'end'.
**
**
**
*ENDFORM. "ALV_END_OF_LIST