)(\w.*)` IN html_code WITH `$1 $2`.
- ENDIF.
- CATCH cx_root INTO DATA(error).
- cs->error = abap_true.
+ DATA(conv_xstring) = cl_abap_conv_codepage=>create_out( codepage = `UTF-8` )->convert( cs->markdown ).
+ CATCH cx_sy_conversion_codepage.
ENDTRY.
- "Preparing the title for expandable sections
- DATA(title) = cs->file_name.
- REPLACE ALL OCCURRENCES OF `_` IN title WITH ` `.
- REPLACE PCRE `^..` IN title WITH ``.
- REPLACE `.md` IN title WITH ``.
- "Assembling expandable sections
- html = html &&
- `
` &&
- ` ` && title && `
` &&
- COND #( WHEN cs->error = abap_false THEN html_code ELSE COND #( WHEN error IS INITIAL THEN status_error ELSE error->get_text( ) ) ) &&
- ``.
+
+ "Adding the xstring content as file content to zip
+ zip->add( name = cs->file_name
+ content = conv_xstring ).
+
ENDLOOP.
- "Providing the html skeleton and inserting the assembled expandable sections from above
- DATA(final_html) =
- `` &&
- `` &&
- `` &&
- `ABAP Cheat Sheet Code Snippets ` &&
- `` &&
- `` &&
- `` &&
- `ABAP Cheat Sheet Code Snippets
` &&
- `https://github.com/SAP-samples/abap-cheat-sheets
` &&
- html &&
- `` &&
- `` &&
- ``.
- "Displaying the html result in the ADT console
- "Note: Before running the class, clear the ADT console.
- "When the html code is displayed in the ADT console, you can, for example,
- "create a file named ABAP_cheat_sheet_code.html on your local machine.
- "Open the file in an editor, copy & paste the entire ADT console content and
- "save the local file. In doing so, you have various code snippets at your
- "disposal offline.
- out->write( final_html ).
+
+ "Saving the zip file
+ DATA(zipped_file) = zip->save( ).
+
+ "----------- Creating a ZIP file containing all ABAP cheat sheet Markdown documents -----------
+
+ "Sending email
+ TRY.
+ "Creating a new mail instance
+ DATA(mail) = cl_bcs_mail_message=>create_instance( ).
+ "Settings
+ mail->set_sender( sender_addr ).
+ mail->add_recipient( recipient_addr ).
+ mail->set_subject( 'Test Mail' ).
+ "Main document
+ mail->set_main( cl_bcs_mail_textpart=>create_instance(
+ iv_content = 'Test Mail
Please find ABAP cheat sheet markdown files attached.
Cheers
'
+ iv_content_type = 'text/html' ) ).
+ "Adding an attachment
+ mail->add_attachment( cl_bcs_mail_binarypart=>create_instance(
+ iv_content = zipped_file
+ iv_content_type = 'application/x-zip-compressed'
+ iv_filename = 'abap_cheat_sheets.zip' ) ).
+
+ "Sending mail synchronously, displaying the status for each recipient
+ mail->send( IMPORTING et_status = DATA(status_table) ).
+ out->write( status_table ).
+ CATCH cx_bcs_mail INTO DATA(error_mail).
+ out->write( |Mail sending error: { error_mail->get_text( ) }| ).
+ ENDTRY.
ENDIF.
ENDMETHOD.
ENDCLASS.
@@ -3293,7 +3233,7 @@ ENDCLASS.
CL_ABAP_ZIP
-The following example creates a zip file and adds three txt files with sample content.
+The following example creates a zip file and adds three txt files with sample content.
```abap
"Create zip file