Ver Mensaje Individual
  #1  
Viejo 12/08/17, 02:55:08
jlholguins jlholguins is offline
Member
 
Fecha de Ingreso: feb 2008
Localización: Bogotá, Colombia
Mensajes: 67
Thumbs up Consulta BD SQL Server Externa desde SAP

Buenas noches a todos, tengo el siguiente codigo para hacer la conexion a una BD Sql Server externa a SAP.


DATA: wa_zpp_banda_ent TYPE zpp_banda_ent,
ti_zpp_banda_ent type zpp_banda_ent OCCURS 0 WITH HEADER LINE.
** Parametros de conexion a tabla intermedia.
DATA: c1 TYPE cursor.
DATA: exc_ref TYPE REF TO cx_sy_native_sql_error,
error_text TYPE string.

TRY.
** Apertura Conexion
EXEC SQL.
CONNECT TO 'ELVAR' AS 'V2'
ENDEXEC.

EXEC SQL.
SET CONNECTION 'V2'
ENDEXEC.
*** Consulta.
EXEC SQL.
OPEN C1 FOR
SELECT MANDT,
NUM_ORDEN,
MATERIAL,
FECHA,
HORA,
CANTIDAD,
UNIDAD,
NUM_NOTIF,
CONT_NOTIF,
ESTADO,
IDCAJA,
FPC
FROM ZPP_BANDA_ENT
WHERE ESTADO IS NULL
ENDEXEC.
*3. Operar con el cursor:
DO.
EXEC SQL.
FETCH NEXT C1
into:wa_zpp_banda_ent
ENDEXEC.
IF sy-subrc NE 0.
EXIT.
ENDIF.
APPEND wa_zpp_banda_ent TO ti_zpp_banda_ent.
ENDDO.
* 4. desconexión.
EXEC SQL.
CLOSE C1
ENDEXEC.
TRY.
** Conexion a BD
EXEC SQL.
DISCONNECT 'V2'
ENDEXEC.
CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
ENDTRY.
CATCH cx_sy_native_sql_error INTO exc_ref.
error_text = exc_ref->get_text( ).
ENDTRY.

Hago debug y la conexion a la BD la hace correctamente y la consulta con la instruccion Select tambien, al recorrer el cursor sale del debug y al momento sale la siguiente ventana con el siguiente mensaje "Mensaje de Sistema SAP: El proceso de trabajo se ha reactivado(modo cancelado)" y me saca del programa y de SAP.

Si a alguien le ha sucedido lo mismo como pudo solucionarlo, es posible saber que datos me arroja De antemano agradezco si alguien puede ayudarme.
Responder Con Cita