SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

HTML viewer in ABAP

...Previous

Code :

*&---------------------------------------------------------------------*
*& Report  YCF_HTMLVIEWER
*&
*&---------------------------------------------------------------------*

REPORT  ycf_htmlviewer.

TYPES : BEGIN OF y_html,
        dataset(255) TYPE c,
        END OF y_html.

DATA: e_data  TYPE y_html,
      ts_data TYPE STANDARD TABLE OF y_html,
      e_user  TYPE usr03,
      ok_code TYPE sy-ucomm,
      w_uname TYPE char20,
      w_url   TYPE char255.

DATA : ref_cont TYPE REF TO cl_gui_custom_container,
       ref_html TYPE REF TO cl_gui_html_viewer.

PARAMETERS user_id TYPE usr01-bname.

START-OF-SELECTION.

  PERFORM f_get_username.

  PERFORM f_genearte_html.

  CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       PBO for 9000
*----------------------------------------------------------------------*
MODULE status_9000 OUTPUT.
  SET PF-STATUS 'STATUS'.

  CREATE OBJECT ref_cont
    EXPORTING
      container_name              = 'CONT'
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      OTHERS                      = 6.

  IF sy-subrc <> 0.

  ENDIF.

  CREATE OBJECT ref_html
    EXPORTING
      parent             = ref_cont
    EXCEPTIONS
      cntl_error         = 1
      cntl_install_error = 2
      dp_install_error   = 3
      dp_error           = 4
      OTHERS             = 5.
  IF sy-subrc <> 0.

  ENDIF.


  CALL METHOD ref_html->load_data
    EXPORTING
      type                 = 'text'
      subtype              = 'html'
    IMPORTING
      assigned_url         = w_url
    CHANGING
      data_table           = ts_data
    EXCEPTIONS
      dp_invalid_parameter = 1
      dp_error_general     = 2
      cntl_error           = 3
      OTHERS               = 4.
  IF sy-subrc <> 0.

  ENDIF.

  CALL METHOD ref_html->show_url
    EXPORTING
      url                    = w_url
    EXCEPTIONS
      cntl_error             = 1
      cnht_error_not_allowed = 2
      cnht_error_parameter   = 3
      dp_error_general       = 4
      OTHERS                 = 5.
  IF sy-subrc <> 0.

  ENDIF.

ENDMODULE.                 " STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*       PAI for screen 9000
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  CASE ok_code.
    WHEN 'BACK'.

      LEAVE TO SCREEN 0.

    WHEN OTHERS.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_9000  INPUT
*&---------------------------------------------------------------------*
*&      Form  F_GENEARTE_HTML
*&---------------------------------------------------------------------*
*       HTML code
*----------------------------------------------------------------------*

FORM f_genearte_html .

  CLEAR e_data.

  FREE ts_data.

  CONCATENATE '<html><body>Dear'
              w_uname
         INTO e_data-dataset
  SEPARATED BY space.
  APPEND e_data TO ts_data.

  e_data-dataset = '<br><h3>What you need to know:</h3><br>'.
  APPEND e_data TO ts_data.
  e_data-dataset =
  'Below is the invoice query ticket number and invoice information that you submitted.'.
  APPEND e_data TO ts_data.
  e_data-dataset =
  '<h5>Ticket and Invoice Information:</h5><table border = "1" bgcolor = "skyblue">'.
  APPEND e_data TO ts_data.
  e_data-dataset = '<tr><td>Invoice Query Ticket #</td><td>0000000522</td></tr>'.
  APPEND e_data TO ts_data.
  e_data-dataset = '<tr><td>Invoice #</td><td>INVOICE 12</td></tr>'.
  APPEND e_data TO ts_data.
  e_data-dataset = '<tr><td>Invoice Date</td><td>20110425</td></tr>'.
  APPEND e_data TO ts_data.
  e_data-dataset = '<tr><td>Value</td><td>2011</td></tr></table>'.
  APPEND e_data TO ts_data.
  e_data-dataset = '<h3>What you need to do:</h3>'.
  APPEND e_data TO ts_data.
  e_data-dataset = 'To track status of your invoice query ticket, please log onto the abc.com'.
  APPEND e_data TO ts_data.
  e_data-dataset = '</body></html>'.
  APPEND e_data TO ts_data.

ENDFORM.                    " F_GENEARTE_HTML
*&---------------------------------------------------------------------*
*&      Form  F_GET_USERNAME
*&---------------------------------------------------------------------*
*       To get User name from Tcode
*----------------------------------------------------------------------*
FORM f_get_username .

  CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
    EXPORTING
      user_name              = user_id
    IMPORTING
      user_usr03             = e_user
    EXCEPTIONS
      user_address_not_found = 1
      OTHERS                 = 2.

  IF sy-subrc = 0.

    CONCATENATE e_user-name1
                e_user-name2
           INTO w_uname
           SEPARATED BY space.

  ENDIF.

ENDFORM.                    " F_GET_USERNAME

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image