proceso de recepcion para factura electrónica en méxico
TRANSCRIPT
Proceso de Recepcion para Factura electrónica en México.
Posibles soluciones para recibir el XML:
1.- convertir el xml a una tabla SDIXML_XML_TO_DOM y SDIXML_DOM_TO_DATA.
2.-es convertirlo en tabla usando un programa:
Crea tu archivo con extensión XML.
<?xml version="1.0" encoding="iso-8859-1" ?> - <CUSTOMERS>- <PERSON><customer_id>1</customer_id> <first_name>Jan</first_name> <last_name>Krohn</last_name> </PERSON>- <PERSON><customer_id>2</customer_id> <first_name>James</first_name> <last_name>Kirk</last_name> </PERSON></CUSTOMERS>
Este es el Codigo ABAP que se necesita.
REPORT ZTT.
TYPE-POOLS abap.
CONSTANTS gs_file TYPE string VALUE 'C:\customers.xml'.
* This is the structure for the data from the XML file
TYPES: BEGIN OF ts_person,cust_id(4) TYPE n,firstname(20) TYPE c,lastname(20) TYPE c,END OF ts_person.
* Table for the XML content
DATA: gt_itab TYPE STANDARD TABLE OF char2048.
* Table and work ares for the data from the XML file
DATA: gt_person TYPE STANDARD TABLE OF ts_person,gs_person TYPE ts_person.
* Result table that contains references* of the internal tables to be filled
DATA: gt_result_xml TYPE abap_trans_resbind_tab,gs_result_xml TYPE abap_trans_resbind.
* For error handling
DATA: gs_rif_ex TYPE REF TO cx_root,gs_var_text TYPE string.
* Get the XML file from your client
CALL METHOD cl_gui_frontend_services=>gui_uploadEXPORTINGfilename = gs_fileCHANGINGdata_tab = gt_itabEXCEPTIONSfile_open_error = 1file_read_error = 2no_batch = 3gui_refuse_filetransfer = 4invalid_type = 5no_authority = 6unknown_error = 7bad_data_format = 8header_not_allowed = 9separator_not_allowed = 10header_too_long = 11unknown_dp_error = 12access_denied = 13dp_out_of_memory = 14disk_full = 15
dp_timeout = 16not_supported_by_gui = 17error_no_gui = 18OTHERS = 19.
IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.
* Fill the result table with a reference to the data table.* Within the XSLT stylesheet, the data table can be accessed with* "IPERSON".
GET REFERENCE OF gt_person INTO gs_result_xml-value.gs_result_xml-name = 'IPERSON'.APPEND gs_result_xml TO gt_result_xml.
* Perform the XSLT stylesheet
TRY.
CALL TRANSFORMATION z_xml_to_abapSOURCE XML gt_itabRESULT (gt_result_xml).
CATCH cx_root INTO gs_rif_ex.
gs_var_text = gs_rif_ex->get_text( ).MESSAGE gs_var_text TYPE 'E'.
ENDTRY.
* Now let's see what we got from the file
LOOP AT gt_person INTO gs_person.WRITE: / 'Customer ID:', gs_person-cust_id.WRITE: / 'First name :', gs_person-firstname.WRITE: / 'Last name :', gs_person-lastname.WRITE : /.ENDLOOP. "gt_person.
Ten presente de que antes de que actives el programa deberas crear el XSLT y eso lo haras haciendo doble clic en la linea del "CALL TRANSFORMATION z_xml_to_abap", seleccionas XSLT y luego pegas el XSLT debajo.
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/><xsl:strip-space elements="*"/>
<xsl:template match="/"><asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><IPERSON><xsl:apply-templates select="//PERSON"/></IPERSON></asx:values></asx:abap></xsl:template>
<xsl:template match="PERSON"><item><CUST_ID><xsl:value-of select="customer_id"/></CUST_ID><FIRSTNAME><xsl:value-of select="first_name"/></FIRSTNAME><LASTNAME><xsl:value-of select="last_name"/></LASTNAME></item></xsl:template>
</xsl:transform>
Activas el programa y debe funcionar.
3.- pensar usar un idoc del tipo invoic02 o fdicc02 para recibirlo tomando en cuenta que la estructura no va a ser la misma puesto que en java hugo cambiaba la estructura que recibia para que saliera como el quería.
En el proceso de recepción se va a tomar encuentra multiprocesos.