HTML/Javascript en Reporte ABAP

Colapsar
Este tema está cerrado
X
X
 
  • Tiempo
  • Mostrar
Limpiar Todo
nuevos mensajes
  • karinastolen
    Member
    • mar
    • 60

    #1

    HTML/Javascript en Reporte ABAP

    No se por que estoy obteniendo este error cuando ejecuto este reporte,
    ¿saben que esta mal?

    Código:
    REPORT  Z_JAVASCRIPT_IN_ABAP3.
    
    CLASS lcl_class DEFINITION.
      PUBLIC SECTION.
        METHODS: main, on_html_event FOR EVENT sapevent OF
    cl_gui_html_viewer
        IMPORTING action frame getdata.
      PROTECTED SECTION.
      PRIVATE SECTION.
      DATA ob_ref TYPE REF TO cl_gui_html_viewer.
    ENDCLASS.
    
    CLASS lcl_class IMPLEMENTATION.
      METHOD main.
        DATA ob_lcl TYPE REF TO lcl_class.
        DATA html TYPE w3htmltab.
        DATA url TYPE c LENGTH 255.
        CREATE OBJECT ob_ref
        EXPORTING
          parent = cl_gui_container=>screen0.
        DATA events TYPE cntl_simple_events.
        DATA event TYPE cntl_simple_event.
        event-eventid = ob_ref->m_id_sapevent.
        event-appl_event = 'X'.
        APPEND event TO events.
        CALL METHOD ob_ref->set_registered_events
          EXPORTING
            events = events.
    
        SET HANDLER me->on_html_event FOR ob_ref.
        APPEND '<html>'                                             TO html.
    
      APPEND '<html>'  TO html.
      APPEND '<head>'  TO html.
      APPEND '<script languaje="JavaScript">'  TO html.
      APPEND '<!--'  TO html.
      APPEND 'estados = new Array();'  TO html.
      APPEND 'estados[0] = new Array();'  TO html.
      APPEND 'estados[1] = new Array("Aguascalientes",'  TO html.
      APPEND '"Baja California", "Baja California","Campeche",'  TO html.
      APPEND '"Chiapas","Chihuahua",'  TO html.
      APPEND '"Coahuila","Colima","Distrito Federal",' TO html.
      APPEND '"Durango","Guanajuato","Guerrero","Hidalgo",'  TO html.
     	APPEND '"Jalisco","México","Michoacán","Morelos",' TO html.
      APPEND '"Nayarit","Nuevo León","Oaxaca","Puebla",'  TO html.
      APPEND '"Querétaro","Quintana Roo","San Luis Potosí",' TO html.
      APPEND '"Sinaloa","Sonora","Tabasco","Tamaulipas",'  TO html.
      APPEND '"Tlaxcala","Veracruz","Yucatán","Zacatecas");'  TO html.
      APPEND 'estados[2] = new Array("Ahuachapán",'  TO html.
      APPEND '"Cabañas","Chalatenango",'  TO html.
      APPEND '"Cuscatlán","La Libertad","La Paz","La Unión",'  TO html.
      APPEND '"Morazan","San Miguel","San Salvador","San Vicente"' TO html.
      APPEND ',"Santa Ana","Sonsonate","Usulutan");'  TO html.
      APPEND 'function cambiar(formulario){'  TO html.
      APPEND 'var i = 0;'  TO html.
      APPEND 'var select1 = formulario["D1"];'  TO html.
      APPEND 'var select2 = formulario["D2"];'  TO html.
      APPEND 'var vector = estados[select1.selectedIndex];'  TO html.
      APPEND 'if(vector.length)select2.length=vector.length;'  TO html.
      APPEND 'while(vector[i]){'  TO html.
      APPEND 'select2.options[i].value = vector[i];'  TO html.
      APPEND 'select2.options[i].text = vector[i];'  TO html.
      APPEND 'i++;'  TO html.
      APPEND '}'  TO html.
      APPEND 'select2.options[0].selected = 1;'  TO html.
      APPEND '}'  TO html.
      APPEND '-->'  TO html.
      APPEND '</script>'  TO html.
      APPEND '</head>'  TO html.
      APPEND '<body >'  TO html.
      APPEND '<form method="POST">'  TO html.
      APPEND '<select name="D1" onchange="cambiar(this.form)">'  TO html.
      APPEND '<option>-</option>'  TO html.
      APPEND '<option>México</option>'  TO html.
      APPEND '<option>Salvador</option>'  TO html.
      APPEND '</select>'  TO html.
      APPEND '<select name="D2">'  TO html.
      APPEND '<option>-</option>'  TO html.
      APPEND '</select></p>'  TO html.
      APPEND '</form>'  TO html.
      APPEND '</body>'  TO html.
      APPEND '</html>'  TO html.
    
        ob_ref->load_data( IMPORTING assigned_url = url
                           CHANGING data_table = html ).
        ob_ref->show_url( url = url ).
    ENDMETHOD.
    METHOD on_html_event.
      DATA: l_string TYPE string.
      l_string = getdata.
      MESSAGE i001(00) WITH l_string.
    ENDMETHOD.
    
    ENDCLASS.
    
    PARAMETERS: p_dummy TYPE c LENGTH 1.
    
    AT SELECTION-SCREEN OUTPUT.
      DATA: lcl_oref TYPE REF TO lcl_class.
      IF lcl_oref IS NOT BOUND.
        CREATE OBJECT lcl_oref.
        CALL METHOD lcl_oref->main.
      ENDIF.
    Archivos Adjuntos
    "Experience is what you get when you didn't get what you wanted." Randy Pausch
  • DCErick
    Moderator
    • mar
    • 1090

    #2
    Tienes 2 etiquetas <html>

    Código:
        APPEND '<html>'                                             TO html.
    
      APPEND '<html>'  TO html.
    -------------------
    ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

    Comentario

    • karinastolen
      Member
      • mar
      • 60

      #3
      He borrado una etiqueta, y ahora el error aparece antes, cuando selecciono algún pais
      "Experience is what you get when you didn't get what you wanted." Randy Pausch

      Comentario

      • DCErick
        Moderator
        • mar
        • 1090

        #4
        Originalmente publicado por karinastolen
        He borrado una etiqueta, y ahora el error aparece antes, cuando selecciono algún pais
        Ese HTML funciona en el explorer( MIE, Firefox, etc)?
        -------------------
        ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

        Comentario

        • karinastolen
          Member
          • mar
          • 60

          #5
          Si, lo he probado en IE, y en google chrome, funciona bien...
          "Experience is what you get when you didn't get what you wanted." Randy Pausch

          Comentario

          • DCErick
            Moderator
            • mar
            • 1090

            #6
            Originalmente publicado por karinastolen
            Si, lo he probado en IE, y en google chrome, funciona bien...
            mmm tienes varios errores que solo exploradores los aceptan... osea como que entienden lo que querias hacer y te lo dejan pasar jaja xD.

            Comenta
            * APPEND '<html>' TO html. "Son 2 aperturas de etiqueta un solo cierre.
            * APPEND '<!--' TO html. "Esto es lo que origina el problema
            * APPEND '-->' TO html. "Esto es lo que origina el problema
            -------------------
            ¿Dudas para descargar manuales? Ver este tema -> Cómo descargar manuales de la sección "Descargas" ?

            Comentario

            • karinastolen
              Member
              • mar
              • 60

              #7
              Listo, mil gracias!!
              "Experience is what you get when you didn't get what you wanted." Randy Pausch

              Comentario

              Trabajando...