Foro de programacion ABAP
Código abierto => Reports => Mensaje iniciado por: Carlos en 05 de Diciembre de 2012, 12:06:08 pm
-
Cuando nos pega un DUMP por duplicidad en la tabla EKKI... SAPSQL_ARRAY_INSERT_DUPREC
Se le puede pasar este programa 'Z' para eliminar esos registros. Se le indica el pedido que da problemas y listo.
*&---------------------------------------------------------------------*
*& Report ZZEKKI01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Title: Delete EKKI records for items before correction *
*&---------------------------------------------------------------------*
REPORT zzekki01.
TABLES: ekki, komk, ekko.
PARAMETERS: p_ebeln LIKE ekko-ebeln.
DATA: tekki LIKE ekki OCCURS 0 WITH HEADER LINE.
DATA: tkomv LIKE komv OCCURS 0 WITH HEADER LINE.
CHECK NOT p_ebeln IS INITIAL.
SELECT SINGLE * FROM ekko
WHERE ebeln = p_ebeln .
CHECK sy-subrc EQ 0.
CHECK ( ekko-bstyp EQ 'F' OR ekko-bstyp EQ 'L' ) AND
ekko-stako EQ space AND ekko-knumv NE space.
REFRESH tekki.
CLEAR komk.
komk-knumv = ekko-knumv.
CALL FUNCTION 'RV_KONV_SELECT'
EXPORTING
comm_head_i = komk
general_read = 'X'
TABLES
tkomv = tkomv.
LOOP AT tkomv WHERE kntyp EQ 'B'.
CLEAR tekki.
tekki-mandt = sy-mandt.
tekki-eknty = 'B'.
tekki-klief = tkomv-lifnr.
tekki-lifnr = ekko-lifnr.
tekki-reswk = ekko-reswk.
tekki-ebeln = ekko-ebeln.
tekki-ebelp = tkomv-kposn.
tekki-knumv = ekko-knumv.
READ TABLE tekki.
IF sy-subrc NE 0.
APPEND tekki.
ENDIF.
ENDLOOP.
DESCRIBE TABLE tekki LINES sy-tfill.
IF sy-tfill GT 0.
DELETE ekki FROM TABLE tekki.
ENDIF.
-
Otro programa similar pero mejorado...
*&---------------------------------------------------------------------*
*& Report ZEKKI_MEJORADO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZEKKI_MEJORADO.
INCLUDE: zalv.
DATA: gt_ekki LIKE ekki OCCURS 0 WITH HEADER LINE.
SELECT-OPTIONS: s_ebeln FOR gt_ekki-ebeln OBLIGATORY.
SELECT-OPTIONS: s_klief FOR gt_ekki-klief.
SELECT-OPTIONS: s_lifnr FOR gt_ekki-lifnr.
SELECTION-SCREEN SKIP 2.
PARAMETERS: p_real AS CHECKBOX.
START-OF-SELECTION.
SELECT * INTO TABLE gt_ekki
FROM ekki
WHERE ebeln IN s_ebeln.
SORT gt_ekki BY ebeln ASCENDING
klief ASCENDING
lifnr ASCENDING.
IF NOT p_real IS INITIAL.
LOOP AT gt_ekki.
DELETE ekki FROM gt_ekki.
ENDLOOP.
COMMIT WORK AND WAIT.
MESSAGE s836(sd) WITH 'Registros borrados'.
ELSE.
MESSAGE s836(sd) WITH 'Registros NO borrados'.
ENDIF.
PERFORM mostrar_alv.
*&---------------------------------------------------------------------*
*& Form mostrar_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM mostrar_alv .
DATA: lf_alv_repid LIKE sy-repid.
DATA: lt_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
DATA: lt_fieldtab TYPE slis_t_fieldcat_alv.
DATA: ls_fieldtab TYPE slis_fieldcat_alv.
lf_alv_repid = sy-repid.
PERFORM obt_descrip_campos_tabla USING lf_alv_repid
'GT_EKKI'.
PERFORM activar_hotspot USING: 'EBELN' 'X'.
PERFORM carac_gen_listado.
ls_fieldtab-ddictxt = 'M'.
MODIFY fieldtab FROM ls_fieldtab TRANSPORTING ddictxt
WHERE fieldname <> space.
DATA: lf_grid_title TYPE lvc_title.
IF NOT p_real IS INITIAL.
lf_grid_title = 'Registros borrados'.
ELSE.
lf_grid_title = 'Registros NO borrados'.
ENDIF.
* Mostramos el listado
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lf_alv_repid
is_layout = layout
it_fieldcat = fieldtab
it_sort = lt_sort
i_callback_user_command = 'USER_COMMAND'
i_grid_title = lf_grid_title
* i_default = ' '
* i_save = 'A'
* is_variant = variant
TABLES
t_outtab = gt_ekki
EXCEPTIONS
program_error = 1
OTHERS = 99.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " mostrar_alv
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM user_command USING pf_ucomm TYPE sy-ucomm
ps_selfield TYPE slis_selfield.
DATA: ls_venum TYPE hum_venum,
lt_venum TYPE hum_venum_t.
CASE pf_ucomm.
WHEN '&IC1'.
READ TABLE gt_ekki INDEX ps_selfield-tabindex.
CHECK NOT gt_ekki-ebeln IS INITIAL.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = gt_ekki-ebeln
i_enjoy = 'X'
i_display_only = 'X'
EXCEPTIONS
not_found = 1
no_authority = 2
invalid_call = 3
preview_not_possible = 4
OTHERS = 5.
ENDCASE.
ENDFORM. "USER_COMMAND