Skip to Content
avatar image
Former Member

Data in to HTML

I have a requirment in my project where i should get the output in HTML format. Is there any way to do this?

Thanks in Advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 18, 2008 at 01:19 PM

    Hello,

    find the example below.

    REPORT ZTNEEL_HTML .

    TABLES:PAYR,BSAK.

    TYPES: BEGIN OF TY_BSAK,

    BUKRS LIKE BSAK-BUKRS,

    AUGBL LIKE BSAK-AUGBL,

    END OF TY_BSAK.

    TYPES:BEGIN OF TY_PAYR,

    ZBUKR LIKE PAYR-ZBUKR,

    CHECT LIKE PAYR-CHECT,

    VBLNR LIKE PAYR-VBLNR,

    END OF TY_PAYR.

    DATA:BEGIN OF WA,

    LINE(1000),

    END OF WA.

    .

    DATA: ITAB_BSAK TYPE STANDARD TABLE OF TY_BSAK,

    ITAB_PAYR TYPE STANDARD TABLE OF TY_PAYR,

    ITAB LIKE STANDARD TABLE OF WA,

    ITAB1 LIKE STANDARD TABLE OF WA,

    WA1 LIKE LINE OF itab,

    WA_PAYR LIKE LINE OF ITAB_PAYR,

    WA_BSAK LIKE LINE OF ITAB_BSAK.

    CONSTANTS : c_html_b(6) VALUE '<html>',

    c_html_e(7) VALUE '</html>',

    c_body_b(6) VALUE '<body>',

    c_body_e(7) VALUE '</body>',

    c_title_b(7) VALUE '<title>',

    c_title_e(8) VALUE '</title>',

    c_table_b(20) VALUE '<table border="1">',

    c_table_e(20) VALUE '</table>',

    c_caption_b(20) VALUE '<caption>',

    c_table_header(20) VALUE 'CLOSED CALLS',

    c_caption_e(20) VALUE '</caption>',

    c_trb(10) VALUE '<tr>',

    c_tre(10) VALUE '</tr>',

    c_tdb(10) VALUE '<td>',

    c_tde(10) VALUE '</td>',

    c_thb(10) VALUE '<th>',

    c_the(10) VALUE '</th>'.

    *PARAMETERS : P_FILE TYPE RLGRAP-FILENAME.

    DATA:V_FILE TYPE STRING,

    W_PATH(100) VALUE 'D:\new\test.htm',

    W_PATH1(100) VALUE 'D:\new\test1.htm'.

    SELECT-OPTIONS: S_AUGBL FOR BSAK-AUGBL.

    *

    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

    *

    *CALL FUNCTION 'F4_FILENAME'

    • EXPORTING

    • PROGRAM_NAME = SYST-CPROG

    • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • IMPORTING

  • FILE_NAME = P_FILE.

  • .

    START-OF-SELECTION.

    PERFORM FETCH_DATA.

    PERFORM FORMAT_HTML TABLES ITAB_BSAK.

    PERFORM DOWNLOAD_APPLI. "download data on application server.

    PERFORM DOWNLOAD_DATA.

    &----


    *& Form FETCH_DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM FETCH_DATA .

    SELECT BUKRS AUGBL INTO CORRESPONDING FIELDS OF TABLE

    ITAB_BSAK FROM BSAK WHERE AUGBL IN S_AUGBL.

    IF NOT ITAB_BSAK[] IS INITIAL.

    SELECT ZBUKR CHECT VBLNR INTO CORRESPONDING FIELDS OF TABLE

    ITAB_PAYR FROM PAYR FOR ALL ENTRIES IN ITAB_BSAK

    WHERE ZBUKR = ITAB_BSAK-BUKRS.

    ENDIF.

    ENDFORM. " FETCH_DATA

    &----


    *& Form FORMAT_HTML

    &----


    • text

    ----


    • -->P_ITAB_BSAK text

    ----


    FORM FORMAT_HTML TABLES P_ITAB_BSAK LIKE ITAB_BSAK.

    **********HTML FILE1

    CONCATENATE c_html_b

    c_body_b

    c_table_b

    c_caption_b

    '<b>'

    c_table_header

    '</b>'

    c_caption_e

    INTO wa.

    APPEND WA TO ITAB.

    CONCATENATE c_thb ' Company Code ' c_the

    c_thb ' Doc no for Clrng doc ' c_the

    into wa.

    APPEND WA TO ITAB.

    LOOP AT ITAB_BSAK INTO WA_BSAK.

    IF WA_BSAK-AUGBL IS INITIAL.

    WA_BSAK-AUGBL = '&nbsp'.

    ENDIF.

    CONCATENATE c_trb

    c_tdb wa_bsak-bukrs c_tde

    c_tdb wa_bsak-augbl c_tde

    c_tre

    INTO wa.

    APPEND WA TO ITAB.

    ENDLOOP.

    CONCATENATE c_table_e c_body_e c_html_e INTO wa.

    APPEND WA TO ITAB.

    CONCATENATE 'TEST1.htm"'

    'target="_BLANK">DETAIL LIST</a>'

    INTO WA.

    APPEND WA TO ITAB.

    *HTML FILE2

    CONCATENATE c_html_b

    c_body_b

    c_table_b

    c_caption_b

    '<b>'

    'DETAIL LIST'

    '</b>'

    c_caption_e

    INTO wa1.

    APPEND WA1 TO ITAB1.

    CONCATENATE c_thb ' Paying company code ' c_the

    c_thb ' Check Number ' c_the

    c_thb ' Document Number ' c_the

    into wa1.

    APPEND WA1 TO ITAB1.

    LOOP AT ITAB_payr INTO WA_payr.

    IF WA_PAYR-VBLNR IS INITIAL.

    WA_PAYR-VBLNR = '&nbsp'.

    ENDIF.

    CONCATENATE c_trb

    c_tdb wa_payr-zbukr c_tde

    c_tdb wa_payr-chect c_tde

    c_tdb wa_payr-vblnr c_tde

    c_tre

    INTO wa1.

    APPEND WA1 TO ITAB1.

    ENDLOOP.

    CONCATENATE c_table_e c_body_e c_html_e INTO wa1.

    APPEND WA1 TO ITAB1.

    ENDFORM. " FORMAT_HTML

    &----


    *& Form DOWNLOAD_DATA

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DOWNLOAD_DATA .

    V_FILE = W_PATH.

    • REPLACE FIRST OCCURRENCE OF '.htm' IN V_FILE WITH '.txt'.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    FILENAME = V_FILE

    TABLES

    DATA_TAB = ITAB.

    V_FILE = W_PATH1.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    FILENAME = V_FILE

    TABLES

    DATA_TAB = ITAB1.

    IF SY-SUBRC = 0.

    MESSAGE I005(ZTNEEL_M1).

    LEAVE TO SCREEN 0.

    ENDIF.

    ENDFORM. " DOWNLOAD_DATA

    &----


    *& Form DOWNLOAD_APPLI

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DOWNLOAD_APPLI .

    • REPLACE FIRST OCCURRENCE OF '.txt' IN w_path WITH '.htm'.

    OPEN DATASET W_PATH FOR OUTPUT in text mode encoding default.

    IF sy-subrc <> 0.

    EXIT.

    ENDIF.

    LOOP AT ITAB INTO WA.

    Transfer WA to W_PATH.

    ENDLOOP.

    Close dataset W_PATH.

    ENDFORM. " DOWNLOAD_APPLI

Add comment
10|10000 characters needed characters exceeded

  • Sep 18, 2008 at 01:20 PM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2008 at 01:20 PM

    from sap one can see the output in HTML format only when one sends an email...so, you need to send the data via email using email HTML format and you can view the same once the mail is opened..

    Add comment
    10|10000 characters needed characters exceeded