Hola a todos, estoy realizando un alv que me permita añadir, borrar, modificar líneas, poner algún botón.
El avl se ejecuta y me muestra la información de los campos que necesito de la tabla z, asi como los botones para los mismo,pero al seleccionar un registro ya sea para modificar, borrar me genera el siguiente error:
An exception occurred that is explained in detail below.
The exception, which is assigned to class ‘CX_SY_REF_IS_INITIAL’, was not
caught in
procedure “MODIFICAR_INFORMACION” “(FORM)”, nor was it propagated by a RAISING
clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
You attempted to use a ‘NULL’ object reference (points to ‘nothing’)
access a component (variable: “GV_ALVGRID”).
En los distinto foros que he leido dice que el programa trabaja con un programa z y no reconoce
Si alguien me puede ayudar.
Codigo:
&---------------------------------------------------------------------
*& Report Z_ALVT510J
*&
&---------------------------------------------------------------------
*&
*&
&---------------------------------------------------------------------
REPORT Z_ALVT510J.
* Cargar la tabla de la base de datos
TABLES: T510J.
TABLES: T512T.
* Cargamos los datos tipo slis
TYPE-POOLS: SLIS.
* Definición de variables
*DATA: G_IT_T510J TYPE TABLE OF T510J,
* G_ST_T510J TYPE T510J.
*
*DATA: G_IT_T512T TYPE TABLE OF T512T,
* G_ST_T512T TYPE T512T.
*DATA:
* BEGIN OF IT_TABLA OCCURS 0,
* MANDT LIKE T510J-MANDT,
* MOLGA LIKE T510J-MOLGA,
* MODIF LIKE T510J-MODIF,
* LGART LIKE T510J-LGART,
* ENDDA LIKE T510J-ENDDA,
* BEGDA LIKE T510J-BEGDA,
* WERT1 LIKE T510J-WERT1,
* LGTXT LIKE T512T-LGTXT,
* END OF IT_TABLA.
* ---------------------------------------
* AREA DE TRABAJO
*-----------------------------------------
* DATA:T_IT_TABLA TYPE STANDARD TABLE OF IT_TABLA WITH HEADER LINE.
* DATA: ita_tabla TYPE T_IT_TABLA.
*DATA: wa1 LIKE LINE OF T_IT_TABLA.
DATA: G_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
G_ST_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: G_REPID TYPE SY-REPID.
DATA: INDICE.
*&---------------------------------------------------------------------*
*& Declaracion de las tablas internas *
*&---------------------------------------------------------------------*
DATA : IT_TABLA LIKE TABLE OF T510J WITH HEADER LINE,
T_INTAB2 LIKE TABLE OF T510J WITH HEADER LINE,
W_INTAB1 LIKE LINE OF IT_TABLA.
*&---------------------------------------------------------------------*
*& Declaration Section for the ALV Grid *
*&---------------------------------------------------------------------*
DATA : OK_CODE LIKE SY-UCOMM,
I_CONTAINER TYPE SCRFNAME VALUE 'CONTENEDOR',
gv_alvgrid TYPE REF TO CL_GUI_ALV_GRID,
gv_container TYPE REF TO cl_gui_custom_container,
i_layout TYPE lvc_s_layo,
i_fgroup TYPE lvc_t_sgrp,
i_fcat TYPE lvc_t_fcat,
I_INDEX_ROWS TYPE LVC_T_ROW,
I_SELECTED_ROW LIKE LVC_S_ROW,
i_variant TYPE disvariant,
x_save.
* Variable con el nombre del programa
G_REPID = SY-REPID.
*INDICE = 1.
* SQL para copiar la tabla T510J a la tabla interna
*SELECT IT_T510J~MANDT IT_T510J~MOLGA IT_T510J~MODIF IT_T510J~LGART
* IT_T510J~ENDDA IT_T510J~BEGDA IT_T510J~WERT1 IT_T512T~LGTXT
* INTO CORRESPONDING FIELDS OF TABLE IT_TABLA
*FROM T510J AS IT_T510J
*INNER JOIN T512T AS IT_T512T
*ON IT_T510J~LGART = IT_T512T~LGART
* WHERE IT_T510J~MOLGA = 17.
*SELECT T510J~MANDT T510J~MOLGA T510J~MODIF T510J~LGART
* T510J~ENDDA T510J~BEGDA T510J~WERT1
* INTO CORRESPONDING FIELDS OF TABLE IT_TABLA
*FROM T510J
* WHERE T510J~MOLGA = 17.
SELECT * FROM T510J INTO TABLE IT_TABLA
WHERE T510J~MOLGA = 17. .
*SELECT * from T510J INTO CORRESPONDING FIELDS OF TABLE IT_TABLA
* WHERE T510J~MOLGA = 17.
* Datos del fieldcat para el ALV
G_ST_FIELDCAT-FIELDNAME = 'MOLGA'.
G_ST_FIELDCAT-SELTEXT_M = 'Agr.de paises'.
G_ST_FIELDCAT-SELTEXT_S = 'Mol'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
G_ST_FIELDCAT-FIELDNAME = 'MODIF'.
G_ST_FIELDCAT-SELTEXT_M = 'Mod.Nomina'.
G_ST_FIELDCAT-SELTEXT_S = 'Mod'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
G_ST_FIELDCAT-FIELDNAME = 'ENDDA'.
G_ST_FIELDCAT-SELTEXT_M = 'Fin de Validez '.
G_ST_FIELDCAT-SELTEXT_S = 'Fin V'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
G_ST_FIELDCAT-FIELDNAME = 'BEGDA'.
G_ST_FIELDCAT-SELTEXT_M = 'Inicio de Validez '.
G_ST_FIELDCAT-SELTEXT_S = 'In V'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
G_ST_FIELDCAT-FIELDNAME = 'WERT1'.
G_ST_FIELDCAT-SELTEXT_M = 'Valor '.
G_ST_FIELDCAT-SELTEXT_S = 'V'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
G_ST_FIELDCAT-FIELDNAME = 'LGART'.
G_ST_FIELDCAT-SELTEXT_M = 'CC-Nomina'.
G_ST_FIELDCAT-SELTEXT_S = 'CC-N'.
G_ST_FIELDCAT-TABNAME = 'g_it_T512T'.
APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
*G_ST_FIELDCAT-FIELDNAME = 'LGTXT'.
*G_ST_FIELDCAT-SELTEXT_M = 'Descripcion'.
*G_ST_FIELDCAT-SELTEXT_S = 'CC-N'.
*G_ST_FIELDCAT-TABNAME = 'g_it_T512T'.
*APPEND G_ST_FIELDCAT TO G_IT_FIELDCAT.
* Función ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = 'MI_STANDARD'
I_CALLBACK_USER_COMMAND = 'MI_USER_COMMAND'
I_SAVE = 'X'
IT_FIELDCAT = G_IT_FIELDCAT[]
TABLES
T_OUTTAB = IT_TABLA[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
* COMANDO DE GUI
FORM MI_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&BT2'.
PERFORM eliminar_registro_seleccionado.
WHEN'ADD'.
PERFORM nuevo_registro.
WHEN'&MOD'.
PERFORM modificar_informacion.
ENDCASE.
ENDFORM. "mi_user_command
*&---------------------------------------------------------------------*
*& Form mi_standard
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM MI_STANDARD USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD'. "Nombre del Status GUI
ENDFORM. "mi_standard
**----------------------------------
** modificar la informacion
**----------------------------------
FORM modificar_informacion.
CALL METHOD gv_alvgrid->refresh_table_display
EXPORTING
i_soft_refresh = ''.
DATA : w_intab1 LIKE TABLE OF IT_TABLA WITH HEADER LINE.
UPDATE T510J FROM TABLE IT_TABLA.
* UPDATE T510J SET
* MOLGA = T_IT_TABLA-MOLGA
* MODIF = T_IT_TABLA-MODIF
* ENDDA = T_IT_TABLA-ENDDA
* BEGDA = T_IT_TABLA-BEGDA
* WERT1 = T_IT_TABLA-WERT1.
*
* UPDATE T512T SET
* LGTXT = T_IT_TABLA-LGTXT.
IF sy-subrc = 0.
MESSAGE 'Los Cambios se Guardaron...' TYPE 'I'.
ELSE.
MESSAGE 'Los Cambios NO se Guardaron...' TYPE 'I'.
ENDIF.
CALL METHOD gv_alvgrid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDFORM. " update_modified_information
*&---------------------------------------------------------------------*
*& nuevo registro
*&---------------------------------------------------------------------*
FORM nuevo_registro .
DATA : w_MOLGA LIKE T510j-MOLGA.
DATA : w_T512T LIKE T512T-mandt.
SELECT SINGLE MOLGA INTO w_MOLGA FROM T510j CLIENT SPECIFIED
WHERE mandt = sy-mandt
AND MOLGA = w_intab1-MOLGA
AND MODIF = w_intab1-MODIF
AND ENDDA = w_intab1-ENDDA
AND BEGDA = w_intab1-BEGDA
AND WERT1 = w_intab1-WERT1.
* SELECT SINGLE mandt INTO w_T512T FROM T512T CLIENT SPECIFIED
* WHERE mandt = sy-mandt
* AND LGTXT = w_intab1-LGTXT.
IF ( sy-subrc EQ 0 ).
MESSAGE 'Relacion de Bloqueo Ya Existe...' TYPE 'I'.
ELSE.
CLEAR : T510J,T512T .
MOVE-CORRESPONDING w_intab1 TO T510J.
* MOVE-CORRESPONDING w_intab1 TO T512T.
INSERT T510J.
* INSERT T512T.
COMMIT WORK.
CLEAR :IT_TABLA.
REFRESH : IT_TABLA.
SELECT * FROM T510J INTO TABLE IT_TABLA.
*SELECT * FROM T512T INTO TABLE t_intab1.
* CALL METHOD gv_alvgrid->refresh_table_display.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& eliminar registro
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM eliminar_registro_seleccionado.
DATA : i_lines TYPE i.
CLEAR : t_intab2.
REFRESH : t_intab2.
* Capturar Indice de Fila Marcada
CALL METHOD gv_alvgrid->get_selected_rows
IMPORTING
et_index_rows = i_index_rows.
DESCRIBE TABLE i_index_rows LINES i_lines.
IF i_lines = 0.
MESSAGE 'Para Eliminar...Debe Marcar un Registro.' TYPE 'I'.
EXIT.
ENDIF.
* Lee Filas Marcacadas en TBI para Borrado
LOOP AT i_index_rows INTO i_selected_row.
READ TABLE IT_TABLA INDEX i_selected_row-index INTO w_intab1.
APPEND w_intab1 TO t_intab2.
ENDLOOP.
* Borra Las Filas Marcadas en TBI de Borrado
LOOP AT t_intab2 INTO w_intab1.
DELETE IT_TABLA WHERE mandt = w_intab1-mandt
AND MOLGA = w_intab1-MOLGA
AND MODIF = w_intab1-MODIF
AND ENDDA = w_intab1-ENDDA
AND BEGDA = w_intab1-BEGDA
AND WERT1 = w_intab1-WERT1.
DELETE FROM T510J CLIENT SPECIFIED
WHERE mandt = sy-mandt
AND MOLGA = w_intab1-MOLGA
AND MODIF = w_intab1-MODIF
AND ENDDA = w_intab1-ENDDA
AND BEGDA = w_intab1-BEGDA
AND WERT1 = w_intab1-WERT1.
ENDLOOP.
COMMIT WORK.
* PERFORM refresh_table_information.
IF sy-subrc = 0.
MESSAGE 'Proceso de Borrado Ok.' TYPE 'I'.
ELSE.
MESSAGE 'Fallo el Proceso de Borrado' TYPE 'I'.
ENDIF.
ENDFORM. " eliminar_registro_seleccionado