Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
"Pass table and header style to this method ,
"This method will return attachemtn binary data based on header data and table dynamically
"Want to make This method such that it can return both attachment and HTML table code and that can be used accordingly - done
"In LTFS ZFSBORCL_XLSX=>TABLE_ATTACHMENT_1"For XLS file If u want to display full numbers in attachment eg 123456789 is showing as 1.23E.. then use prefix(=") and suffix(") to show numbers in attachment as 123456789
"So need to use text type soli which can be appended in our html table and used as HTML table and the same soli lines can be concatenated in string for attachment
*IM_HEADER-HEADER_CONTENT:-Table Type With Header Details and content style Details
* -FIELDNAME Field Names / Techenical Name Of tables being passed
* -DESCRIPTION Description Of Fieldnames / Description To Be shown on Display of Table or Attachment
* -EDITMASK Flag For ALPHA = OUTPUT Of the Field
* -CHAR_CONVERT Flag For Amount/Numeric Fields
* -NOZERO Flag For Amount/Numeric Fields Show No Zeros
* -HEADER_CELL_STYL Pass HTML Code For Header Cell Style Of Single Header Eg Making One Header Of Table BOLD etc.
* -CONTENT_COLUMN_STYL Pass HTML Code For Content Cell Styling
*IM_HEADER-HEADER_ROW_STYL Pass HTML Code to Style Header Row
*IM_HEADER-TABLE_STYLE Pass HTML Code Table Style
*IM_HEADER-ROW_COLOR_COLUMN Pass Column Name of Internal table consisting of
* 1. HTML Row Style as content "Option 1
* 2. Column on which Conditon is to be applied "Option 2
"Additonal requirements for Option 2
*IM_HEADER-ROW_COLOR_STYLE Pass Style of Row
*Table with conditon of row color
*IM_HEADER-ROW_COLOR_COND_TABLE Pass table with below values , conditon will be applied in order , first condition satisfyed will be considered
* ROW_COLOR_STYLE HTML Style , for bold and other attributes
* ROW_COLOR_CONDITON_CS Pass Value of String based on which color is to be assigned
* ROW_BGCOLOR_ATTR Pass Color Name instead of colmplete style in td attribute ,
* since color in style causes complete row in excel attachment to get color , columns outside html table too
* MERGE_COLUMN - Consits of column containing table type , data of merging column .
"Cell merging logic
TYPES : BEGIN OF ty_merge_col ,
field TYPE text40,
value TYPE i,
read TYPE flag, "Indicating that merge attribute is passed for the cell
row_reset TYPE i, "Indicating if there are rows and columns both to be merged for the cell
END OF ty_merge_col .
DATA : gt_col_merge TYPE TABLE OF ty_merge_col,
gs_col_merge TYPE ty_merge_col,
lt_merg_table TYPE zfstrmtt_0025,
lv_cell_merge TYPE text255,
lv_row_skip TYPE i,
lv_col_skip TYPE i.
FIELD-SYMBOLS : <fs_merg> TYPE zfstrmtt_0025.
DATA: lv_skip TYPE flag.
"End of Cell merging logic
DATA : lv_flag TYPE c.
DATA: gt_vtb TYPE TABLE OF vtbfha,
gr_alv TYPE REF TO cl_salv_table,
gt_fcat TYPE lvc_t_fcat,
lv_str TYPE string,
gt_content TYPE ztrm_tt_email_01,
lv_line TYPE soli,
lv_data TYPE string,
* lv_write TYPE text255,
lv_decimal TYPE text255.
* lv_col_color TYPE string .
FIELD-SYMBOLS : <fs> TYPE any,
<ft_table> TYPE table.
"""
CLEAR: lv_str.
gt_content = im_header-header_content.
* -----HTML Table Start-----
* -----Attachment------
im_attachment = |<TABLE| && im_header-table_style && |>| .
im_attachment = im_attachment && |<TR| && im_header-header_row_styl && |>|.
* -----HTML Header Code-----
LOOP AT im_header-header_content ASSIGNING FIELD-SYMBOL(<im_head>). "Fill Header and Style Of HTML Table
im_attachment = im_attachment && |<TH| && <im_head>-header_cell_styl && |>| && <im_head>-description && |</TH>|.
ENDLOOP.
im_attachment = |{ im_attachment } </TR>| .
* -----HTML Contetn Binding-----
LOOP AT im_data ASSIGNING FIELD-SYMBOL(<fs_data>).
* "Cell merging logic
ASSIGN COMPONENT im_header-merge_column OF STRUCTURE <fs_data> TO <fs_merg>.
IF sy-subrc = 0.
""Column Merging Table Filled
LOOP AT <fs_merg> ASSIGNING FIELD-SYMBOL(<fs_colm>) WHERE col_cells IS NOT INITIAL .
gs_col_merge-field = <fs_colm>-field.
gs_col_merge-value = <fs_colm>-col_cells .
gs_col_merge-row_reset = COND #( WHEN <fs_colm>-col_cells IS NOT INITIAL AND <fs_colm>-row_cells IS NOT INITIAL THEN <fs_colm>-row_cells ELSE 0 ).
ASSIGN gt_col_merge[ field = <fs_colm>-field ] TO FIELD-SYMBOL(<fs_mergchk>).
IF sy-subrc = 0.
<fs_mergchk> = gs_col_merge.
UNASSIGN <fs_mergchk>.
ELSE.
APPEND gs_col_merge TO gt_col_merge.
ENDIF.
CLEAR gs_col_merge.
ENDLOOP.
ENDIF.
* ""end of cell merging logic
ASSIGN COMPONENT im_header-row_color_column OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_col_color>).
IF sy-subrc = 0.
IF NOT im_header-row_color_cond_table IS INITIAL.
LOOP AT im_header-row_color_cond_table ASSIGNING FIELD-SYMBOL(<fs_row_color>).
""Lv_row_color & lv_cell_color will be blank if cond is not satisfied
DATA(lv_row_color) = COND string( WHEN <fs_col_color> CS <fs_row_color>-row_color_conditon_cs AND <fs_row_color>-row_color_conditon_cs IS NOT INITIAL
THEN <fs_row_color>-row_color_style ) .
DATA(lv_cell_color) = COND string( WHEN <fs_col_color> CS <fs_row_color>-row_color_conditon_cs AND <fs_row_color>-row_color_conditon_cs IS NOT INITIAL
THEN <fs_row_color>-row_bgcolor_attr ) .
IF NOT lv_row_color IS INITIAL.
EXIT.
ENDIF.
ENDLOOP.
ELSE.
lv_row_color = <fs_col_color> .
ENDIF.
ENDIF.
im_attachment = im_attachment && |<TR| && lv_row_color && |>| .
LOOP AT im_header-header_content ASSIGNING FIELD-SYMBOL(<fs_content>). "Enter Columns as Put in Header
* -----Attachment-----
"""Cell merge logic
IF im_header-merge_column IS NOT INITIAL.
"Column Merging
CLEAR : lv_skip .
"Row Skipping
IF lv_row_skip IS NOT INITIAL AND lv_row_skip > 0.
lv_row_skip = lv_row_skip - 1 .
lv_skip = 'X'.
ELSE.
CLEAR lv_row_skip.
ENDIF.
"End row skipping
READ TABLE gt_col_merge ASSIGNING FIELD-SYMBOL(<fs_col>) WITH KEY field = <fs_content>-fieldname .
IF sy-subrc = 0.
IF <fs_col>-value > 0.
IF <fs_col>-read <> 'X'.
lv_cell_merge = | { lv_cell_merge } rowspan = "{ <fs_col>-value }" |.
<fs_col>-read = 'X'.
ELSE.
"prepair to Skip this line after checking row merging
lv_skip = 'X'.
lv_row_skip = COND #( WHEN <fs_col>-row_reset IS NOT INITIAL THEN <fs_col>-row_reset - 1 ELSE lv_row_skip ).
<fs_col>-row_reset = <fs_col>-row_reset - 1.
ENDIF.
""Reduce the counter of value
<fs_col>-value = <fs_col>-value - 1 .
ENDIF.
ENDIF.
IF <fs_merg> IS ASSIGNED .
READ TABLE <fs_merg> ASSIGNING FIELD-SYMBOL(<fs_row>) WITH KEY field = <fs_content>-fieldname .
IF sy-subrc = 0 AND lv_row_skip IS INITIAL.
IF <fs_row>-row_cells > 0 .
lv_row_skip = <fs_row>-row_cells - 1 .
lv_cell_merge = | { lv_cell_merge } colspan = "{ <fs_row>-row_cells }" |.
ENDIF.
ENDIF.
ENDIF.
IF lv_skip = 'X'.
CONTINUE.
ENDIF.
ENDIF.
"""end of cell merging logic
*
ASSIGN COMPONENT <fs_content>-fieldname OF STRUCTURE <fs_data> TO <fs>.
IF sy-subrc = 0.
IF <fs_content>-char_convert IS NOT INITIAL. "Converting Fields Into Char
MOVE <fs> TO lv_data.
CONDENSE lv_data.
ENDIF.
IF <fs_content>-decimals_out IS NOT INITIAL. "Limmiting Decimals For Rate Fields
TRY. DATA(lv_amt) = <fs> * 10 * <fs_content>-decimals_out . CATCH cx_sy_zerodivide . ENDTRY.
TRY. lv_data = abs( lv_amt ) / ( 10 * <fs_content>-decimals_out ). CATCH cx_sy_zerodivide . ENDTRY.
* TRY. lv_data = trunc( lv_amt ) / ( 10 * <fs_content>-decimals_out ). CATCH cx_sy_zerodivide . ENDTRY.
* WRITE lv_data DECIMALS <fs_content>-decimals_out to lv_decimal .
ENDIF.
IF <fs_content>-nozero IS NOT INITIAL AND ( <fs> = 0 OR <fs> IS INITIAL ). "Not Showing Zeros For Amt Fields
CLEAR lv_data.
ELSE.
MOVE <fs> TO lv_data.
CONDENSE lv_data.
ENDIF.
IF <fs_content>-time_flag IS NOT INITIAL.
IF <fs_content>-time_seperator IS INITIAL.
lv_data = <fs>+0(2) && ':' && <fs>+2(2) && ':' && <fs>+4(2) .
ELSE.
lv_data = <fs>+0(2) && <fs_content>-time_seperator && <fs>+2(2) && <fs_content>-time_seperator && <fs>+4(2) .
ENDIF.
ENDIF.
IF <fs_content>-editmask IS NOT INITIAL. "Edit Mask For removing Zeros
lv_data = |{ <fs> ALPHA = OUT }| .
CONDENSE lv_data.
ENDIF.
IF <fs_content>-date_flag IS NOT INITIAL AND <fs> <> '00000000'. "Date Logic From SAP to Output
IF <fs_content>-date_seperator IS INITIAL .
lv_data = <fs>+6(2) && |.| && <fs>+4(2) && |.| && <fs>+0(4).
ELSE.
lv_data = <fs>+6(2) && <fs_content>-date_seperator && <fs>+4(2) && <fs_content>-date_seperator && <fs>+0(4).
ENDIF.
ENDIF.
im_attachment = im_attachment && |<TD| && <fs_content>-content_column_styl && lv_cell_merge && lv_cell_color && |>| && lv_data && |</TD>| .
ENDIF.
* "Start of Addition By Tejas K on 28.05.24
* IF lv_data = 'Total' .
* lv_flag = abap_true.
* ENDIF .
* IF lv_flag = abap_true.
* im_attachment = im_attachment && |<TD| && <fs_content>-content_column_styl && |>| && |<B>| && lv_data && |</B>| && |</TD>| .
* ELSE.
* ENDIF.
* "End of addition
CLEAR : lv_data, lv_cell_merge .
ENDLOOP.
* CLEAR : lv_flag. "Added By Tejas K on 28.05.24
* -----Attachment-----
im_attachment = im_attachment && |</TR>| .
IF <fs_merg> IS ASSIGNED.
UNASSIGN <fs_merg>.
ENDIF.
"""cell merging logic
CLEAR : lv_row_skip.
"""end of cell merging logic
ENDLOOP.
im_attachment = im_attachment && |</TABLE>| .
IF im_htmlflag IS NOT INITIAL . "Converting Attachment String to HTML table which is compactable with HTML CODE
CALL FUNCTION 'SO_STRING_TO_TAB'
EXPORTING
content_str = im_attachment
TABLES
content_tab = im_html_table.
ENDIF.
ENDMETHOD.
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team