Quantcast
Channel: SCN : Document List - ABAP Development
Viewing all articles
Browse latest Browse all 935

Inner html table optimization for SO_NEW_DOCUMENT_ATT_SEND_API1 function module

$
0
0

When you prepare HTML-data for ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ function module it could be convenient to make a new internal table line for each tag (or several tags). Like this:

 

1.png

But, this approach has certain drawback. In fact, the greater part of each table line would remain unoccupied. Accordingly, the internal table with HTML code would have been looking like this:

 

3.png

But, the line of HTML table has type ‘SOLISTI1’ (CHAR255), consequently, a very large amount of memory remains useless.

When program started, generated inner table has become inadmissibly spacious.

So, as there is a limitation that e-mail can’t be heavier than 20 megabytes, it is often impossible to send large e-mails via ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ FM.

 

To avoid this, it would be expedient to use following function module to optimize inner table with HTML code:

FUNCTION z_html_optimize.

*"----------------------------------------------------------------------

*"*"Локальный интерфейс:

*"  IMPORTING

*"     REFERENCE(WHOLE_WORDS) TYPE  FLAG DEFAULT ' '

*"     REFERENCE(LINE_LEN) TYPE  INT4 DEFAULT 255

*"  CHANGING

*"     REFERENCE(CT_TAB) TYPE  RSPC_T_TEXT

*"----------------------------------------------------------------------

  TYPE-POOLS abap.

 

  DATA:

    l_in_len   TYPE i,

    l_free_len TYPE i,

    l_diff     TYPE i,

    ls_out     TYPE solisti1,

    lt_out     TYPE rspc_t_text.

 

  FIELD-SYMBOLS:

    <s_in>LIKELINEOF ct_tab.

 

 

  LOOPAT ct_tab ASSIGNING<s_in>.

    l_in_len  = STRLEN(<s_in>-line ).

    l_free_len = line_len - STRLEN( ls_out-line ).

    IF l_in_len <= l_free_len.

      CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

      CONDENSE ls_out-line.

    ELSE.

      IF whole_words = abap_true.

        IF l_free_len >= l_in_len.

          CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

          CONDENSE ls_out-line.

          APPEND ls_out TO lt_out.

          CLEAR ls_out.

        ELSE.

          APPEND ls_out TO lt_out.

          CLEAR ls_out.

          CONCATENATE ls_out-line <s_in>-line INTO ls_out-line.

          CONDENSE ls_out-line.

        ENDIF.

      ELSE.

        IF l_free_len >0.

          CONCATENATE ls_out-line <s_in>-line(l_free_len)INTO ls_out-line.

          CONDENSE ls_out-line.

        ENDIF.

 

        APPEND ls_out TO lt_out.

        CLEAR ls_out.

        IF l_free_len <0.

          l_free_len = 0.

        ENDIF.

        l_diff = l_in_len - l_free_len.

        IF l_diff >0.

          CONCATENATE ls_out-line <s_in>-line+l_free_len(l_diff)INTO ls_out-line.

          CONDENSE ls_out-line.

        ENDIF.

      ENDIF.

    ENDIF.

    ATLAST.

      IF l_in_len <= l_free_len.

        APPEND ls_out TO lt_out.

      ELSE.

        IF whole_words = abap_true.

          APPEND ls_out TO lt_out.

        ELSE.

          IF l_diff >0.

            APPEND ls_out TO lt_out.

          ENDIF.

        ENDIF.

      ENDIF.

    ENDAT.

  ENDLOOP.

 

  ct_tab[] = lt_out[].

 

ENDFUNCTION.

If you use it like this:

2.png

The inner table would have no useless space:

4.png

And it would have allowable weight, so FM ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ would easily send derivable e-mail.


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>