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 17/05/11, 15:13:22
HRU HRU is offline
Member
 
Fecha de Ingreso: ago 2006
Mensajes: 41
Erro al subir attachments en Background

Hola, tengo un problema. Tengo un programa que sube attachments de candidatos (PB30) en background. El programa funciona correctamente (adjunto el código) pero me da error en archivos .docx o .xlsx, la verdad es que no se sino se pueden subir este tipo de archivos o he de cambiar algo....
La parte en negrita del código son modificaciones que he hecho para intentar cargar los .docx pero no funciona.......
En teoría la variable p_msgtyp que recoge la extensión del achivo era de 3 dígitos->p_msgtyp LIKE sofm-doctp
p_botype LIKE obl_s_pbor-typeid VALUE 'APPLICANT',
p_bo_id LIKE obl_s_pbor-instid,
pc_file(128),
pc_file2(128),
* Object_b
p_docty LIKE borident-objtype VALUE 'MESSAGE',
p_reltyp LIKE breltyp-reltype VALUE 'ATTA',
p_msgtyp(4) TYPE c VALUE 'EXT'.
TYPES: BEGIN OF ty_message_key,
foltp TYPE so_fol_tp,
folyr TYPE so_fol_yr,
folno TYPE so_fol_no,
doctp TYPE so_doc_tp,
docyr TYPE so_doc_yr,
docno TYPE so_doc_no,
fortp TYPE so_for_tp,
foryr TYPE so_for_yr,
forno TYPE so_for_no,
END OF ty_message_key.
TYPES : BEGIN OF ty_binary,
binary_field(255) TYPE c,
END OF ty_binary.
DATA : lt_binary TYPE TABLE OF ty_binary WITH HEADER LINE,
wa_binary TYPE ty_binary.
DATA : lv_message_key TYPE ty_message_key.
DATA : lo_message TYPE swc_object.
DATA : lt_doc_content TYPE STANDARD TABLE OF soli-line WITH HEADER LINE.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
DATA: lv_doc_size TYPE i.
DATA: filesize TYPE so_doc_len.
DATA: l_file_lines TYPE i.
DATA help_objcont LIKE soli OCCURS 0 WITH HEADER LINE.
DATA file_type LIKE rlgrap-filetype.
DATA act_filetype LIKE rlgrap-filetype.
DATA act_filename LIKE rlgrap-filename.
DATA h_filename LIKE rlgrap-filename.
DATA doc_length LIKE soxwd-doc_length.
DATA def_filename(12).
DATA:filestring TYPE xstring.
DATA: object_hd_display LIKE sood2,
l_filename TYPE string,
l_title(60) TYPE c.
DATA: l_next TYPE i.
DATA: l_ext(4) TYPE c,
l_ruta(128) TYPE c,
l_extension(4) TYPE c.




CONCATENATE 'Curriculum' g_aplno INTO l_title.

pc_file = gt_ruta-path_cv.
p_bo_id = g_aplno.
DO 2 TIMES.
SPLIT pc_file AT '.' INTO l_ruta l_extension.
IF l_extension = 'docx'.
l_next = strlen( pc_file ) - 4.
l_ext = pc_file+l_next.
ELSE.
l_next = strlen( pc_file ) - 3.
l_ext = pc_file+l_next.
ENDIF.
p_msgtyp = l_ext.
*copiamos archivo en otra ruta y borramos antiguo
CONCATENATE 'H:\usr\sap\msp\sys\webcvhst\CV_y_cartas\' pc_file+37 INTO pc_file2.
CALL FUNCTION 'SCMS_FILE_COPY'
EXPORTING
src_filename = pc_file
* SRC_FRONTEND =
dst_filename = pc_file2
* DST_FRONTEND = ' '
EXCEPTIONS
READ_FAILED = 1
WRITE_FAILED = 2
OTHERS = 3.

CALL FUNCTION 'SCMS_FILE_DELETE'
EXPORTING
filename = pc_file
FRONTEND = ' '
EXCEPTIONS
NOT_FOUND = 1
NAME_TOO_LONG = 2
OTHERS = 3.
************************************************** ********************************
* Create an initial instance of BO 'MESSAGE' - to call the
* instance-independent method 'Create'.
swc_create_object lo_message 'MESSAGE' lv_message_key.
* define container to pass the parameter values to the method call
* in next step.
swc_container lt_message_container.
* Populate container with parameters for method
swc_set_element lt_message_container 'DOCUMENTTITLE' l_title.
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
swc_set_element lt_message_container 'NO_DIALOG' 'X'.
swc_set_element lt_message_container 'DOCUMENTNAME' p_docty.
swc_set_element lt_message_container 'DOCUMENTTYPE' p_msgtyp.
IF l_extension = 'docx'.
swc_set_element lt_message_container 'FILEEXTENSION' 'DOCX'.
ELSE.
swc_set_element lt_message_container 'FILEEXTENSION' 'DOC'.
ENDIF.
* 'DocumentContent' is a multi-line element ( itab ).


* In case of URLs..it should be concatenated with &KEY& in the begining.
CASE p_msgtyp.
WHEN 'URL'.
* In case of Notes or Private Notes, get the data from files on appl
* server or from wherever(? - remember background).
WHEN 'RAW'.

* In case of File attachments
WHEN 'OTHERS'.
*************************
ENDCASE.

CALL FUNCTION 'SCMS_UPLOAD'
EXPORTING
filename = pc_file2
binary = 'X'
frontend = space
TABLES
data = lt_doc_content
EXCEPTIONS
error = 1
OTHERS = 2.

DESCRIBE TABLE lt_doc_content LINES l_file_lines.

READ TABLE lt_doc_content INDEX l_file_lines.

lv_doc_size = ( 255 * ( l_file_lines - 1 ) ) +
STRLEN( lt_doc_content ).

swc_set_table lt_message_container 'DocumentContent' lt_doc_content.
swc_set_element lt_message_container 'DOCUMENTSIZE' lv_doc_size.
swc_refresh_object lo_message.
swc_call_method lo_message 'CREATE' lt_message_container.
* Refresh to get the reference of create 'MESSAGE' object for attachment
* swc_refresh_object lo_message.
* Get Key of new object
swc_get_object_key lo_message lv_message_key.


* Now we have attachment as a business object instance. We can now
* attach it to our main business object instance.
* Create main BO object_a
DATA: lo_is_object_a TYPE borident.
lo_is_object_a-objkey = p_bo_id.
lo_is_object_a-objtype = p_botype.
* Create attachment BO object_b
DATA: lo_is_object_b TYPE borident.
lo_is_object_b-objkey = lv_message_key.
lo_is_object_b-objtype = p_docty.

CALL FUNCTION 'BINARY_RELATION_CREATE'
EXPORTING
obj_rolea = lo_is_object_a
obj_roleb = lo_is_object_b
relationtype = p_reltyp
EXCEPTIONS
OTHERS = 1.

COMMIT WORK AND WAIT.

Si alguiense le ocurre algo......

Saludos y gracias
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 23:26:43.


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