MUNDOSAP

Regresar   MUNDOSAP > DESARROLLO > Programación ABAP IV
Nombre de Usuario
Contraseña
Home Descargas Registrar FAQ Miembros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




 
Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Viejo 02/11/10, 15:06:25
zhibys zhibys is offline
Junior Member
 
Fecha de Ingreso: may 2010
Mensajes: 5
Pasar xtring a tabla

Hola a todos,

tengo un problema que no soy capaz a solucionar.

El caso es que tengo un línea xtring y necesito pasarla a una tabla.

con la función SCMS_XSTRING_TO_BINARY consigo pasarlo a texto, pero no se el ancho que tiene en el fichero original.

Y no se leer ni lo intros ni la anchura del fichero.

no sé, igual no se puede. pero no hay ninguna forma, de pasar una cadena xtring y que corte por intros en una tabla interna.

Gracias de antemano.

saludos.
Responder Con Cita
  #2  
Viejo 02/11/10, 15:13:27
zhibys zhibys is offline
Junior Member
 
Fecha de Ingreso: may 2010
Mensajes: 5
no me acabe de explicar todo . . .

realmente lo que estoy haciendo es una lectura unix de un fichero que no se su anchura, también me serviría hacer la lectura ya separada por líneas, cosa que tampoco consigo.
Responder Con Cita
  #3  
Viejo 02/11/10, 15:18:43
agv1976 agv1976 is offline
Member
 
Fecha de Ingreso: jun 2006
Mensajes: 66
Mira el codigo espero te sirva

*&---------------------------------------------------------------------*
*& Report ZARAMOS03 *
*& *
*&---------------------------------------------------------------------*
*& Carga de fichero XML para posterior conversión mediante el XSLT *
*& *
*&---------------------------------------------------------------------*

REPORT ZARAMOS03 .
*
parameters: p_file(100)
* default '/sapinterfaces/sd/SIT/historia/'
lower case
* obligatory
.
parameters: p_visu as checkbox.

data: d_path type string.
data: l_string type string.
data: lv_xml type xstring.
data: it_file(1024) type x occurs 0 with header line .
DATA: lt_orders TYPE zsdbl_salesorder_table. " Para XSLT



d_path = p_file.

*

if p_file is not initial.

***************************
* Abre y carga el fichero
OPEN DATASET d_path FOR INPUT IN BINARY MODE.

IF sy-subrc <> 0.
WRITE: / 'ERROR: No se pudo abrir el fichero de datos ',
d_path.
EXIT.
ENDIF.

* Lectura del fichero
READ DATASET d_path INTO lv_xml.
*
CLOSE DATASET d_path.

else.

CALL FUNCTION 'UPLOAD'
TABLES
DATA_TAB = it_file
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

* Mover al String.
clear lv_xml.
loop at it_file.
**
** concatenate l_string it_file into l_string.
CONCATENATE lv_xml it_file INTO lv_xml IN BYTE MODE.
endloop.
***
** CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
** EXPORTING
** TEXT = l_string
*** MIMETYPE = ' '
*** ENCODING =
** IMPORTING
** BUFFER = lv_xml
** EXCEPTIONS
** FAILED = 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.


endif.



************************************
* TRANSFORMACION
************************************
TRY.

if p_file is not initial.

CALL TRANSFORMATION zxslt_admisiones_abap
SOURCE XML lv_xml
RESULT order_list = lt_orders.
else.
CALL TRANSFORMATION zxslt_admisiones_abap
SOURCE XML lv_xml
RESULT order_list = lt_orders.

endif.

CATCH cx_xslt_exception.
WRITE: / 'ERROR: No se pudo hacer la transformación'.

ENDTRY.

Break e001127.

if p_visu = 'X'.

DATA: lo_document TYPE REF TO if_ixml_document.


CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = lv_xml
IMPORTING
document = lo_document
EXCEPTIONS
invalid_input.

IF sy-subrc EQ 0.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
document = lo_document
EXCEPTIONS
no_document = 1
OTHERS = 2.
endif.
endif.
Responder Con Cita
  #4  
Viejo 03/11/10, 06:23:44
zhibys zhibys is offline
Junior Member
 
Fecha de Ingreso: may 2010
Mensajes: 5
Buenos días,

Muchas gracias por la respuesta. Pero me falta el programa:

CALL TRANSFORMATION zxslt_admisiones_abap
SOURCE XML lv_xml
RESULT order_list = lt_orders.

Esto sirve para cualquier tipo de fichero o solo para xml??

Gracias y saludos.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Reglas de Mensajes
no puedes crear nuevos temas
no puedes responder temas
no puedes adjuntar archivos
no puedes editar tus mensajes

El código vB está On
Las caritas están On
Código [IMG] está On
Código HTML está Off
Saltar a Foro


Husos Horarios son GMT. La hora en este momento es 05:29:03.


www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web