0% found this document useful (0 votes)
15 views23 pages

Zdemo Test2

Twest 2 gbl demo

Uploaded by

arvinder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views23 pages

Zdemo Test2

Twest 2 gbl demo

Uploaded by

arvinder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 23

**&---------------------------------------------------------------------*

**& Report ZDEMO_TEST


**&---------------------------------------------------------------------*
**&
**&---------------------------------------------------------------------*
REPORT zdemo_test2.
*
***DATA: lr_mime_rep TYPE REF TO if_mr_api.
***
***DATA: lv_filename TYPE string.
***DATA: lv_path TYPE string.
***DATA: lv_fullpath TYPE string.
***DATA: lv_content TYPE xstring.
***DATA: lv_length TYPE i.
***DATA: lv_rc TYPE sy-subrc.
***
***DATA: lt_file TYPE filetable.
***DATA: ls_file LIKE LINE OF lt_file.
***
***
***DATA: lt_data TYPE STANDARD TABLE OF x255.
***
***PARAMETERS: p_path TYPE string
*** DEFAULT 'SAP/PUBLIC/Test.jpg'. "<<-- Mime path, save to path
***
***
***cl_gui_frontend_services=>file_open_dialog(
*** CHANGING
*** file_table = lt_file " Table Holding Selected Files
*** rc = lv_rc ). " Return Code, Number of Files or -1 If
Error Occurred
***READ TABLE lt_file INTO ls_file INDEX 1.
***IF sy-subrc = 0.
*** lv_filename = ls_file-filename.
***ENDIF.
***
***cl_gui_frontend_services=>gui_upload(
*** EXPORTING
*** filename = lv_filename " Name of file
*** filetype = 'BIN'
*** IMPORTING
*** filelength = lv_length " File length
*** CHANGING
*** data_tab = lt_data " Transfer table for file contents
*** EXCEPTIONS
*** OTHERS = 19 ).
***
***CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
*** EXPORTING
*** input_length = lv_length
**** first_line = 0
**** last_line = 0
*** IMPORTING
*** buffer = lv_content
*** TABLES
*** binary_tab = lt_data
*** EXCEPTIONS
*** failed = 1
*** OTHERS = 2.
***
***lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
***lr_mime_rep->put(
*** EXPORTING
*** i_url = p_path " Object URL
*** i_content = lv_content " Object Contents (if exists
-> overwrite contents)
**** i_language = SY-LANGU " Language of MIME Object
**** i_description = " For new object: Object short
description
**** i_check_authority = 'X' " X Check Authorization, '' No
Authorization Check
**** i_suppress_package_dialog = space " For New Object: X - Suppress
Package Query
**** i_dev_package = " Package (Initial -> Copy
Dialog / Parent Package)
**** i_language_version = '?'
**** i_genflag = abap_false
**** i_corr_number = " Request/Task
**** i_new_loio = " Only for creating: unique
object ID, if known
**** i_suppress_dialogs = " X no dialogs
**** i_virus_profile = c_virus_profile
*** EXCEPTIONS
*** parameter_missing = 1 " Parameter missing or is
initial
*** error_occured = 2 " Unspecified Error Occurred
*** cancelled = 3 " Action was canceled
*** permission_failure = 4 " Missing Authorization
*** data_inconsistency = 5 " Internal Data Inconsistency
*** new_loio_already_exists = 6 " Specified GUId for new LOIO
already assigned
*** is_folder = 7 " Specified URL is a folder
*** OTHERS = 8
***).
***IF sy-subrc <> 0.
**** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
***ENDIF.
*
**--------------------------------------------------------------------*
*
***DATA: lr_mime_rep TYPE REF TO if_mr_api.
***
***DATA: lv_url TYPE char255.
***DATA: lv_content TYPE xstring.
***DATA: lv_repid TYPE sy-repid.
***
***DATA: lt_data TYPE STANDARD TABLE OF x255.
***
***DATA: lo_docking TYPE REF TO cl_gui_docking_container.
***DATA: lo_picture TYPE REF TO cl_gui_picture.
***
***DATA: p_path TYPE string VALUE 'SAP/PUBLIC/Test1.jpg'.
***
***PARAMETERS: p_check.
***
***AT SELECTION-SCREEN OUTPUT.
***
**** Create controls
*** CREATE OBJECT lo_docking
*** EXPORTING
*** repid = lv_repid
*** dynnr = sy-dynnr
*** side = lo_docking->dock_at_left
*** extension = 200.
***
*** CREATE OBJECT lo_picture
*** EXPORTING
*** parent = lo_docking.
***
*** lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
***
*** lr_mime_rep->get(
*** EXPORTING
*** i_url = p_path
*** IMPORTING
*** e_content = lv_content
*** EXCEPTIONS
*** not_found = 3 ).
***
*** CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
*** EXPORTING
*** buffer = lv_content
*** TABLES
*** binary_tab = lt_data.
***
*** CALL FUNCTION 'DP_CREATE_URL'
*** EXPORTING
*** type = 'IMAGE'
*** subtype = 'JPG'
*** TABLES
*** data = lt_data
*** CHANGING
*** url = lv_url.
***
*** lo_picture->load_picture_from_url_async( lv_url ).
*
**--------------------------------------------------------------------*
*
***DATA: lr_mime_rep TYPE REF TO if_mr_api.
***
***DATA: lv_filename TYPE string.
***DATA: lv_path TYPE string.
***DATA: lv_fullpath TYPE string.
***DATA: lv_content TYPE xstring.
***DATA: lv_length TYPE i.
***DATA: lv_rc TYPE sy-subrc.
***
***DATA: lt_file TYPE filetable.
***DATA: ls_file LIKE LINE OF lt_file.
***
***
***DATA: lt_data TYPE STANDARD TABLE OF x255.
***DATA: lv_url TYPE char255.
***DATA: lv_repid TYPE sy-repid.
***
***DATA: lo_docking TYPE REF TO cl_gui_docking_container.
***DATA: lo_picture TYPE REF TO cl_gui_picture.
***
***
***PARAMETERS: p_check.
***
***AT SELECTION-SCREEN OUTPUT.
***
**** Create controls
*** CREATE OBJECT lo_docking
*** EXPORTING
*** repid = lv_repid
*** dynnr = sy-dynnr
*** side = lo_docking->dock_at_left
*** extension = 200.
***
*** CREATE OBJECT lo_picture
*** EXPORTING
*** parent = lo_docking.
***
***
*** cl_gui_frontend_services=>file_open_dialog(
*** CHANGING
*** file_table = lt_file " Table Holding Selected Files
*** rc = lv_rc ). " Return Code, Number of Files or -1
If Error Occurred
*** READ TABLE lt_file INTO ls_file INDEX 1.
*** IF sy-subrc = 0.
*** lv_filename = ls_file-filename.
*** ENDIF.
***
*** cl_gui_frontend_services=>gui_upload(
*** EXPORTING
*** filename = lv_filename " Name of file
*** filetype = 'BIN'
*** IMPORTING
*** filelength = lv_length " File length
*** CHANGING
*** data_tab = lt_data " Transfer table for file contents
*** EXCEPTIONS
*** OTHERS = 19 ).
***
*** CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
*** EXPORTING
*** input_length = lv_length
**** first_line = 0
**** last_line = 0
*** IMPORTING
*** buffer = lv_content
*** TABLES
*** binary_tab = lt_data
*** EXCEPTIONS
*** failed = 1
*** OTHERS = 2.
***
*** CLEAR : lt_data.
***
*** CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
*** EXPORTING
*** buffer = lv_content
*** TABLES
*** binary_tab = lt_data.
***
*** CALL FUNCTION 'DP_CREATE_URL'
*** EXPORTING
*** type = 'IMAGE'
*** subtype = 'JPG'
*** TABLES
*** data = lt_data
*** CHANGING
*** url = lv_url.
*****
*** lo_picture->load_picture_from_url_async( lv_url ).
*
**--------------------------------------------------------------------*
*
**--------------------------------------------------------------------*
*
DATA : gv_cursor TYPE char50.
PARAMETERS : rb1 RADIOBUTTON GROUP rbg DEFAULT 'X',
rb2 RADIOBUTTON GROUP rbg.

INITIALIZATION.

START-OF-SELECTION.

IF rb1 = 'X'.
* PERFORM upload_file.
PERFORM download_file_dms.
ELSE.
CALL SCREEN 9000.
LEAVE TO SCREEN 0.
ENDIF.
*
*
*
**&---------------------------------------------------------------------*
*
**& Module STATUS_9000 OUTPUT
*
**&---------------------------------------------------------------------*
*
** text
*
**----------------------------------------------------------------------*
*
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS9000'.
PERFORM show_pic.

ENDMODULE. " STATUS_9000 OUTPUT


*
**&-------------------------------------------------------------------
*
**& Form show_pic
*
**&-------------------------------------------------------------------
*
FORM show_pic.

DATA: obj_custom TYPE REF TO cl_gui_custom_container,


lv_url TYPE char255,
lv_content TYPE xstring,
obj_picture TYPE REF TO cl_gui_picture,
lt_data TYPE STANDARD TABLE OF sdokcntbin.

DATA : ls_documentdata TYPE bapi_doc_draw2,


ls_return TYPE bapiret2,
lt_doc_desc TYPE STANDARD TABLE OF bapi_doc_drat,
lt_doc_file TYPE STANDARD TABLE OF bapi_doc_files2,
lt_info TYPE STANDARD TABLE OF scms_acinf.
CREATE OBJECT obj_custom
EXPORTING
container_name = 'CUSTOM'
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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT obj_picture


EXPORTING
parent = obj_custom
EXCEPTIONS
error = 1
OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CHECK sy-subrc = 0.

CALL METHOD obj_picture->set_3d_border


EXPORTING
border = 5
EXCEPTIONS
error = 1
OTHERS = 2.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL METHOD obj_picture->set_display_mode


EXPORTING
display_mode = cl_gui_picture=>display_mode_stretch
EXCEPTIONS
error = 1
OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* SELECT SINGLE FROM zdemo_image


* FIELDS img_content
* INTO @DATA(lv_img_content).
* IF sy-subrc = 0.
* lv_content = lv_img_content .
* CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
* EXPORTING
* buffer = lv_content
* TABLES
* binary_tab = lt_data.

SELECT SINGLE FROM zge_dms_img


FIELDS doknr_wi
INTO @DATA(lv_doc_no).
IF sy-subrc = 0.
BREAK vw_arvinder.
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = 'ZG1'
documentnumber = lv_doc_no
documentpart = '000'
documentversion = '00'
* GETOBJECTLINKS = ' '
* GETCOMPONENTS = ' '
* GETSTATUSLOG = ' '
* GETLONGTEXTS = ' '
* GETACTIVEFILES = 'X'
* GETDOCDESCRIPTIONS = 'X'
* GETDOCFILES = 'X'
* GETCLASSIFICATION = ' '
* GETSTRUCTURE = ' '
* GETWHEREUSED = ' '
* HOSTNAME = ' '
* INHERITED = 'X'
* PF_BAPI_CALL =
IMPORTING
documentdata = ls_documentdata
return = ls_return
TABLES
* OBJECTLINKS =
documentdescriptions = lt_doc_desc
* LONGTEXTS =
* STATUSLOG =
documentfiles = lt_doc_file
* COMPONENTS =
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTSTRUCTURE =
* WHEREUSEDLIST =
.
IF sy-subrc = 0.
DATA(ls_doc_file) = VALUE #( lt_doc_file[ 1 ] OPTIONAL ).

CALL FUNCTION 'SCMS_DOC_READ'


EXPORTING
mandt = sy-mandt
stor_cat = ls_doc_file-storagecategory
* CREP_ID = ' '
doc_id = ls_doc_file-file_id
* PHIO_ID =
* SIGNATURE = 'X'
* SECURITY = ' '
* NO_CACHE = ' '
* RAW_MODE = ' '
* IMPORTING
* FROM_CACHE =
* CREA_TIME =
* CREA_DATE =
* CHNG_TIME =
* CHNG_DATE =
* STATUS =
* DOC_PROT =
TABLES
access_info = lt_info
* CONTENT_TXT =
content_bin = lt_data
EXCEPTIONS
bad_storage_type = 1
bad_request = 2
unauthorized = 3
comp_not_found = 4
not_found = 5
forbidden = 6
conflict = 7
internal_server_error = 8
error_http = 9
error_signature = 10
error_config = 11
error_format = 12
error_parameter = 13
error = 14
OTHERS = 15.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.

CALL FUNCTION 'DP_CREATE_URL'


EXPORTING
type = 'IMAGE'
subtype = 'JPG'
TABLES
data = lt_data
CHANGING
url = lv_url.
**
obj_picture->load_picture_from_url_async( lv_url ).

ENDIF.

ENDFORM. "show_pic
**&---------------------------------------------------------------------*
**& Form upload_file
**&---------------------------------------------------------------------*
**& text
**&---------------------------------------------------------------------*
**& --> p1 text
**& <-- p2 text
**&---------------------------------------------------------------------*
FORM upload_file .
DATA : ls_img TYPE zdemo_image,
lt_file TYPE filetable,
lv_rc TYPE sy-subrc,
lv_filename TYPE string,
lv_url TYPE char255,
lv_length TYPE i,
lt_data TYPE STANDARD TABLE OF x255,
lv_content TYPE xstring.

DATA : ls_documentdata TYPE bapi_doc_draw2,


lt_doc_desc TYPE STANDARD TABLE OF bapi_doc_drat,
lt_doc_file TYPE STANDARD TABLE OF bapi_doc_files2,
ls_return TYPE bapiret2,
lv_doc_no TYPE bapi_doc_aux-docnumber,
ls_img_f1 TYPE zge_dms_img.

cl_gui_frontend_services=>file_open_dialog(
CHANGING
file_table = lt_file " Table Holding Selected Files
rc = lv_rc ). " Return Code, Number of Files or -1 If
Error Occurred
READ TABLE lt_file INTO DATA(ls_file) INDEX 1.
IF sy-subrc = 0.
lv_filename = ls_file-filename.
ENDIF.

ls_documentdata = VALUE #( documenttype = 'ZG1' documentversion = '00'


documentpart = '00' statusintern = 'IA' ).

lt_doc_desc = VALUE #( ( language = 'E' language_iso = 'E' description =


'I000000001' ) ).
lt_doc_file = VALUE #( ( storagecategory = 'ZDMSNONPRD' wsapplication = 'ZIM'
docfile = lv_filename checkedin = 'X' ) ).

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'


EXPORTING
documentdata = ls_documentdata
* HOSTNAME =
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
* CAD_MODE = ' '
* PF_FTP_DEST = ' '
* PF_HTTP_DEST = ' '
* DEFAULTCLASS = 'X'
IMPORTING
* DOCUMENTTYPE =
documentnumber = lv_doc_no
* DOCUMENTPART =
* DOCUMENTVERSION =
return = ls_return
TABLES
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
documentdescriptions = lt_doc_desc
* OBJECTLINKS =
* DOCUMENTSTRUCTURE =
documentfiles = lt_doc_file
* LONGTEXTS =
* COMPONENTS =
.

IF ls_return-type CA 'EA'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'


EXPORTING
wait = 'X'.

ls_img_f1-mandt = sy-mandt.
ls_img_f1-gateid = 'I000000001'.
ls_img_f1-doknr_wi = lv_doc_no.

IF ls_img_f1 IS NOT INITIAL.


MODIFY zge_dms_img FROM ls_img_f1.
IF sy-subrc = 0.
MESSAGE : 'File Uploaded sucessfully' TYPE 'S'.
ENDIF.
ENDIF.

ENDIF.

* cl_gui_frontend_services=>gui_upload(
* EXPORTING
* filename = lv_filename " Name of file
* filetype = 'BIN'
* IMPORTING
* filelength = lv_length " File length
* CHANGING
* data_tab = lt_data " Transfer table for file contents
* EXCEPTIONS
* OTHERS = 19 ).
*
* CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
* EXPORTING
* input_length = lv_length
** first_line = 0
** last_line = 0
* IMPORTING
* buffer = lv_content
* TABLES
* binary_tab = lt_data
* EXCEPTIONS
* failed = 1
* OTHERS = 2.
* IF lv_content IS NOT INITIAL.
* ls_img-mandt = sy-mandt.
* ls_img-gate_id = 'W000000001'.
* ls_img-img_content = lv_content .
*
* MODIFY ZDEMO_IMAGE FROM ls_img.
* IF sy-subrc = 0.
* MESSAGE : 'File Uploaded sucessfully' TYPE 'S'.
* ENDIF.
* ENDIF.
ENDFORM.
*
**--------------------------------------------------------------------*
*
**CLASS demo DEFINITION.
** PUBLIC SECTION.
** TYPES _url TYPE c LENGTH 200.
** TYPES: BEGIN OF _graphic_row,
** line(255) TYPE x,
** END OF _graphic_row,
** _graphic_tab TYPE STANDARD TABLE OF _graphic_row WITH DEFAULT KEY.
** METHODS show.
** PRIVATE SECTION.
** METHODS get_image_url
** RETURNING
** VALUE(url) TYPE url.
** METHODS convert_xstring_to_table
** IMPORTING
** xstr TYPE xstring
** RETURNING
** VALUE(tab) TYPE _graphic_tab.
**
** DATA picture TYPE REF TO cl_gui_picture.
** DATA container TYPE REF TO cl_gui_docking_container.
**
**ENDCLASS.
**
**CLASS demo IMPLEMENTATION.
** METHOD show.
**
** DATA: graphic_size TYPE i.
**
** CREATE OBJECT container
** EXPORTING
** extension = 300
** no_autodef_progid_dynnr = 'X'.
**
** CREATE OBJECT picture
** EXPORTING
** parent = container.
**
** picture->load_picture_from_url( url = get_image_url( ) ).
** picture->set_display_mode( cl_gui_picture=>display_mode_fit ).
**
** ENDMETHOD.
*
** METHOD get_image_url.
** DEFINE a.
** CONCATENATE graphic_str &1 INTO graphic_str.
** END-OF-DEFINITION.
**
** DATA graphic_xstr TYPE xstring.
** DATA graphic_x TYPE x.
** DATA graphic_str TYPE string.
** DATA graphic_size TYPE i.
** DATA graphic_table TYPE _graphic_tab.
**
**
** TYPES ty_char160 TYPE c LENGTH 160.
** DATA local_pic TYPE STANDARD TABLE OF ty_char160.
**
** "GIF rennpony 16 colors
** a 'R0lGODlhFQATADMAACH5BAAAAAAALAAAAAAVABMAg////19qcHaP'.
** a 'jo6ij5XL/p3Mx6rR3qTS+LPUksPessjcysvl+ufbrvrclPfv1Or0'.
** a '+wSMEMg5F1mY6g0eztzmNA3TKEu4LYaptI2jShbBMIahlDNwXCwD'.
** a 'YcdQeQ6HwEDxOyiKmyNhKhj8pobYBjkl6K5TokZRKBe+3enhRnEg'.
** a '3u/EbwH2aiWJfB6hfjzAa3d6ewYHDzRpWQ0SCoMJBoc0gCYOMo15'.
** a 'hho1aiaLAAqgkRR/aYE9iKVQPZtppwCsXREAOw=='.
**
** CALL FUNCTION 'SSFC_BASE64_DECODE'
** EXPORTING
** b64data = graphic_str
** IMPORTING
** bindata = graphic_xstr
** EXCEPTIONS
** OTHERS = 8.
**
**
** graphic_table = convert_xstring_to_table( graphic_xstr ).
**
** CALL FUNCTION 'DP_CREATE_URL'
** EXPORTING
** type = 'image' "#EC NOTEXT
** subtype = 'gif'
** lifetime = cndp_lifetime_transaction "'T'
** TABLES
** data = graphic_table
** CHANGING
** url = url.
**
** ENDMETHOD.
**
** METHOD convert_xstring_to_table.
**
** DATA conv TYPE i.
**
** DATA offs TYPE i.
** DATA size TYPE i.
** DATA row TYPE _graphic_row.
**
** size = xstrlen( xstr ).
** CHECK size > 0.
**
** conv = size.
** offs = 0.
**
** WHILE conv > 255.
** row-line = xstr+offs(255).
** APPEND row TO tab.
** offs = offs + 255.
** conv = conv - 255.
** ENDWHILE.
**
** row-line = xstr+offs(conv).
** APPEND row TO tab.
**
** ENDMETHOD.
**ENDCLASS.
**
**
**PARAMETERS p_test.
**
**INITIALIZATION.
** NEW demo( )->show( ).

*--------------------------------------------------------------------*

****&---------------------------------------------------------------------*
****& Data Declaration
****&---------------------------------------------------------------------*
***DATA : lo_mime_helper TYPE REF TO cl_gbt_multirelated_service,
*** lo_bcs TYPE REF TO cl_bcs,
*** lo_doc_bcs TYPE REF TO cl_document_bcs,
*** lo_recipient TYPE REF TO if_recipient_bcs,
*** lt_soli TYPE TABLE OF soli,
*** ls_soli TYPE soli,
*** lv_status TYPE bcs_rqst.
***
****&---------------------------------------------------------------------*
****& Creation of the mail
****&---------------------------------------------------------------------*
***
***" Create the main object of the mail.
***CREATE OBJECT lo_mime_helper.
***
***" Create the mail content.-----"CLASSIC WAY"
****ls_soli-line = '<!DOCTYPE html PUBLIC �-//IETF//DTD HTML 5.0//EN">'.
****APPEND ls_soli TO lt_soli.
***
****ls_soli-line = '<HTML>'.
****APPEND ls_soli TO lt_soli.
***
****ls_soli-line = '<BODY>'.
****APPEND ls_soli TO lt_soli.
***
****ls_soli-line = 'Hi Dear,<P>Content Section!</P>'.
****APPEND ls_soli TO lt_soli.
***
****ls_soli-line = '</BODY>'.
****APPEND ls_soli TO lt_soli.
***
****ls_soli-line = '</HTML>'.
****APPEND ls_soli TO lt_soli.
***
***" Create the mail content.-----"NEW WAY"
***DATA(string) = '<!DOCTYPE html PUBLIC �-//IETF//DTD HTML 5.0//EN">'
*** && '<HTML><BODY>Hi Dear,<P>Content Section!</P></BODY></HTML>'.
***
***lt_soli = CL_DOCUMENT_BCS=>STRING_TO_SOLI( string ).
***
***" Set the HTML body of the mail
***CALL METHOD lo_mime_helper->set_main_html
*** EXPORTING
*** content = lt_soli
*** description = 'Test Email'.
***
**** Set the subject of the mail.
***lo_doc_bcs = cl_document_bcs=>create_from_multirelated(
*** i_subject = 'Subject of our email'
*** i_importance = '9' " 1~High Priority
5~Average priority 9~Low priority
*** i_multirel_service = lo_mime_helper ).
***
***lo_bcs = cl_bcs=>create_persistent( ).
***
***lo_bcs->set_document( i_document = lo_doc_bcs ).
***
**** Set the email address
***lo_recipient = cl_cam_address_bcs=>create_internet_address(
*** i_address_string = '[email protected]' ).
***
***lo_bcs->add_recipient( i_recipient = lo_recipient ).
***
**** Change the status.
***lv_status = 'N'.
***CALL METHOD lo_bcs->set_status_attributes
*** EXPORTING
*** i_requested_status = lv_status.
***
****&---------------------------------------------------------------------*
****& Send the email
****&---------------------------------------------------------------------*
***TRY.
*** lo_bcs->send( ).
*** COMMIT WORK.
***CATCH cx_bcs INTO DATA(lx_bcs).
*** ROLLBACK WORK.
***ENDTRY.
*--------------------------------------------------------------------*
**CONSTANTS:
** lc_subject TYPE so_obj_des VALUE 'Email using CL_BCS Class',
** lc_raw TYPE char03 VALUE 'RAW'.
**
**DATA:
** lv_mlrec TYPE so_obj_nam,
** lv_sent_to_all TYPE os_boolean,
** lv_email TYPE adr6-smtp_addr,
** lv_subject TYPE so_obj_des,
** lv_text TYPE bcsy_text,
** lr_send_request TYPE REF TO cl_bcs,
** lr_bcs_exception TYPE REF TO cx_bcs,
** lr_recipient TYPE REF TO if_recipient_bcs,
** lr_sender TYPE REF TO cl_sapuser_bcs,
** lr_document TYPE REF TO cl_document_bcs.
**
**
**
**TRY.
** "Create send request
** lr_send_request = cl_bcs=>create_persistent( ).
**
**
** "Email From
** lr_sender = cl_sapuser_bcs=>create( sy-uname ).
**
** "Add sender to send request
** CALL METHOD lr_send_request->set_sender
** EXPORTING
** i_sender = lr_sender.
**
**
** "Email To...
** lv_email = '[email protected]'.
** lr_recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
**
** "Add recipient to send request
** CALL METHOD lr_send_request->add_recipient
** EXPORTING
** i_recipient = lr_recipient
** i_express = 'X'.
**
**
** "Email BODY
** APPEND 'Hello world! My first ABAP email using Class CL_BCS!' TO lv_text.
** lr_document = cl_document_bcs=>create_document(
** i_type = lc_raw
** i_text = lv_text
** i_subject = lc_subject ).
**
** "Add document to send request
** CALL METHOD lr_send_request->set_document( lr_document ).
**
**
** "Send email
** CALL METHOD lr_send_request->send(
** EXPORTING
** i_with_error_screen = 'X'
** RECEIVING
** result = lv_sent_to_all ).
** IF lv_sent_to_all = 'X'.
** WRITE 'Email sent successully!'.
** ENDIF.
**
** "Commit to send email
** COMMIT WORK. "MANDATORY*
**
**
** "Exception handling
** CATCH cx_bcs INTO lr_bcs_exception.
** WRITE:
** 'Error!',
** 'Error type:',
** lr_bcs_exception->error_type.
**ENDTRY.

*--------------------------------------------------------------------*

**DATA: lo_bcs TYPE REF TO cl_bcs,


** lo_doc_bcs TYPE REF TO cl_document_bcs,
** lo_recep TYPE REF TO if_recipient_bcs,
** lo_sapuser_bcs TYPE REF TO cl_sapuser_bcs,
** lr_sender TYPE REF TO cl_cam_address_bcs,
** lo_cx_bcx TYPE REF TO cx_bcs,
** lv_string_text TYPE string, "SO_TEXT255
** lt_text TYPE bcsy_text.
**
**
**
**TRY.
*** -------- create persistent send request ------------------------
** lo_bcs = cl_bcs=>create_persistent( ).
**
*** ----------Create Email Body ------------------------------------
**
** "First line
** lt_text = VALUE #( ( |Dear Customer, { cl_abap_char_utilities=>newline }
{ cl_abap_char_utilities=>newline }| )
** ( |PO Delivery date updation mail for your reference.
{ cl_abap_char_utilities=>newline }| )
** ( |Note: Kindly update the Delivery date and only reply
back to [email protected].{ cl_abap_char_utilities=>newline }| )
** ( |Login Name : { sy-uname }
{ cl_abap_char_utilities=>newline }| )
** ( |PO No :
{ cl_abap_char_utilities=>newline }| )
** ( |Supplier Name :
{ cl_abap_char_utilities=>newline }| )
** ( |Plant :
{ cl_abap_char_utilities=>newline }| )
** ( |Plant Name :
{ cl_abap_char_utilities=>newline }| )
** ( |Item Code :
{ cl_abap_char_utilities=>newline }| )
** ( |Item Name :
{ cl_abap_char_utilities=>newline }| )
** ( |PO Quantity :
{ cl_abap_char_utilities=>newline }| )
** ( |PO Rate :
{ cl_abap_char_utilities=>newline }| )
** ( |PO Pending Quantity :
{ cl_abap_char_utilities=>newline }| )
** ( |Thanking You{ cl_abap_char_utilities=>newline }| )
** ( |Globus IT Support{ cl_abap_char_utilities=>newline }| )
).
**
** lo_doc_bcs = cl_document_bcs=>create_document(
** i_type = 'RAW' " Code for Document
Class
** i_subject = 'PO Delivery date updation mail' " Short
Description of Contents
** i_length = '12' " Size of Document
Content
*** i_importance = '5' " Document priority
** i_text = lt_text " Content (Text-Like)
** ).
**
*** add document to send request
** lo_bcs->set_document( i_document = lo_doc_bcs ).
**
*** lo_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ).
** lr_sender = cl_cam_address_bcs=>create_internet_address( '[email protected]'
).
** CALL METHOD lo_bcs->set_sender
** EXPORTING
** i_sender = lr_sender ." lo_sapuser_bcs.
**
** lo_recep = cl_cam_address_bcs=>create_internet_address(
** '[email protected]' ).
**
** "Add recipient with its respective attributes to send request
** CALL METHOD lo_bcs->add_recipient
** EXPORTING
** i_recipient = lo_recep
** i_express = 'X'.
**
**
*** CALL METHOD lo_bcs->set_send_immediately
*** EXPORTING
*** i_send_immediately = 'X'.
**
** CALL METHOD lo_bcs->send(
** EXPORTING
** i_with_error_screen = 'X'
** RECEIVING
** result = DATA(lv_sent_to_all) ).
**
** IF lv_sent_to_all IS NOT INITIAL.
** COMMIT WORK.
** ENDIF.
**
** CATCH cx_bcs INTO DATA(lo_cx_bcs).
** DATA(lv_msg) = lo_cx_bcs->get_text( ).
** MESSAGE lv_msg TYPE 'E'.
**ENDTRY.
*--------------------------------------------------------------------*
*DATA : okcode_100 TYPE sy-ucomm.
*CALL SCREEN 100.
**&---------------------------------------------------------------------*
**& Module USER_COMMAND_0100 INPUT
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
*MODULE user_command_0100 INPUT.
*
* CASE okcode_100.
* WHEN 'FCT_SHIP'.
* CALL TRANSACTION 'ZMM_GATE_SI'.
* WHEN 'FCT_WEIGH'.
** CALL TRANSACTION 'ZMM_GATE_WT'.
* SUBMIT SAPMZMM_WEIGH_PROCESS.
* WHEN OTHERS.
* ENDCASE.
*ENDMODULE.

*--------------------------------------------------------------------*
*DATA : ls_pi_i_spr TYPE pispr,
* ls_komk TYPE komk,
* ls_komp TYPE komp,
* e_komk TYPE komk,
* e_komp TYPE komp,
* lt_komv TYPE STANDARD TABLE OF komv.
*
*ls_pi_i_spr-vkorg = '1000'.
*ls_pi_i_spr-vtweg = '10' .
*ls_pi_i_spr-spart = '10' .
*ls_pi_i_spr-matnr = '000000004510000037' .
*ls_pi_i_spr-werks = '1011' .
*ls_pi_i_spr-mgame = '4.000' .
*ls_pi_i_spr-vkals = 'ZCIMFL' .
*ls_pi_i_spr-kunnr = '0000300008'.
*ls_pi_i_spr-kwaer = 'INR' .
*
*
*CALL FUNCTION 'SPR_KOMK_KOMP_FILL'
* EXPORTING
* pi_i_spr = ls_pi_i_spr
* IMPORTING
* pe_i_komk = ls_komk
* pe_i_komp = ls_komp
* EXCEPTIONS
* org_structure_not_completed = 1
* OTHERS = 2.
*IF sy-subrc <> 0.
** Implement suitable error handling here
*
*ELSE.
* ls_komk-kunwe = '0000300010' .
* ls_komk-kunre = '0000300008' .
* ls_komk-kalsm = 'ZCIMFL' .
* ls_komk-kappl = 'V' .
* ls_komk-zterm = '0001' .
* ls_komk-prsdt = sy-datum.
* ls_komk-fbuda = sy-datum.
* ls_komk-fkdat = sy-datum.
* ls_komk-erdat = sy-datum.
* ls_komk-audat = sy-datum.
* ls_komk-land1_we = ls_komk-land1.
* ls_komk-aland_werk = ls_komk-land1.
* ls_komk-vbtyp = 'C'.
* ls_komk-kokrs = '1000'.
* ls_komk-vkorgau = '1000'.
* ls_komk-auart_sd = 'ZIMF'.
* ls_komk-trtyp = 'H'.
* ls_komk-auart = 'ZIMF'.
*
*
* ls_komp-kposn = '000010'.
* ls_komp-wkreg = '08'.
* ls_komp-mglme = '4.000'.
* ls_komp-mgame = '4.000'.
* ls_komp-kmein = 'CV'.
* ls_komp-pstyv = 'TAN'.
* ls_komp-taxps = '000010'.
*
* CALL FUNCTION 'PRICING'
* EXPORTING
* calculation_type = 'B'
* comm_head_i = ls_komk
* comm_item_i = ls_komp
** PRELIMINARY = ' '
** NO_CALCULATION = ' '
** IV_NO_MESSAGE_COLLECT_LORD = ' '
* IMPORTING
* comm_head_e = e_komk
* comm_item_e = e_komp
* TABLES
* tkomv = lt_komv
** SVBAP =
** CHANGING
** REBATE_DETERMINED = ' '
* .
*
* cl_demo_output=>new(
* )->begin_section( `Net Value`
* )->write_text( CONV string( e_komp-netwr )
* )->next_section( `Tax`
* )->write_text( CONV string( e_komp-mwsbp )
* )->display( ).
*
*
*
*ENDIF.

*--------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'PICK'.
GET CURSOR FIELD gv_cursor.
IF gv_cursor = 'TIMG'.
CALL SCREEN 9100 STARTING AT 1 1 ENDING AT 130 80.
ENDIF.
ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module STATUS_9100 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE status_9100 OUTPUT.

SET PF-STATUS 'STATUS9100'.


PERFORM show_pic.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
SET SCREEN 0.
ENDCASE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Form download_file_dms
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
FORM download_file_dms .
DATA: lt_data TYPE STANDARD TABLE OF sdokcntbin.

DATA : ls_documentdata TYPE bapi_doc_draw2,


ls_return TYPE bapiret2,
ls_return1 TYPE bapiret2,
lt_doc_desc TYPE STANDARD TABLE OF bapi_doc_drat,
lt_doc_file TYPE STANDARD TABLE OF bapi_doc_files2,
lt_doc_file1 TYPE STANDARD TABLE OF bapi_doc_files2,
lt_info TYPE STANDARD TABLE OF scms_acinf,
lv_path TYPE string,
lf_pathname TYPE bapi_doc_draw-docfile1,
lv_front(10) TYPE c VALUE '\Front.bmp',
lv_back(9) TYPE c VALUE '\Back.bmp'.

SELECT SINGLE FROM zge_dms_img


FIELDS doknr_wi
WHERE doknr_wi = '0000000000000010000024441'
INTO @DATA(lv_doc_no).
IF sy-subrc = 0.
BREAK vw_arvinder.
CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
EXPORTING
documenttype = 'ZG1'
documentnumber = lv_doc_no
documentpart = '000'
documentversion = '00'
* GETOBJECTLINKS = ' '
* GETCOMPONENTS = ' '
* GETSTATUSLOG = ' '
* GETLONGTEXTS = ' '
* GETACTIVEFILES = 'X'
* GETDOCDESCRIPTIONS = 'X'
* GETDOCFILES = 'X'
* GETCLASSIFICATION = ' '
* GETSTRUCTURE = ' '
* GETWHEREUSED = ' '
* HOSTNAME = ' '
* INHERITED = 'X'
* PF_BAPI_CALL =
IMPORTING
documentdata = ls_documentdata
return = ls_return
TABLES
* OBJECTLINKS =
documentdescriptions = lt_doc_desc
* LONGTEXTS =
* STATUSLOG =
documentfiles = lt_doc_file
* COMPONENTS =
* CHARACTERISTICVALUES =
* CLASSALLOCATIONS =
* DOCUMENTSTRUCTURE =
* WHEREUSEDLIST =
.
IF sy-subrc = 0.

cl_gui_frontend_services=>directory_browse(
EXPORTING
window_title = 'Select path to download DMS img'
" Title of Browsing Window
* initial_folder = " Start Browsing Here
CHANGING
selected_folder = lv_path " Folder Selected By User
EXCEPTIONS
cntl_error = 1 " Control error
error_no_gui = 2 " No GUI available
not_supported_by_gui = 3 " GUI does not support this
OTHERS = 4
).
IF sy-subrc = 0.

CONCATENATE lv_path '\' INTO lf_pathname.


* LOOP AT lt_doc_file ASSIGNING FIELD-SYMBOL(<fs_doc_file>).
* IF <fs_doc_file> IS ASSIGNED.
* IF <fs_doc_file>-originaltype = '1'.
* lv_file_path = |{ lv_file_path }{ lv_front }|.
* <fs_doc_file>-docfile = lv_file_path.
* ELSE.
* lv_file_path = |{ lv_file_path }{ lv_back }|.
* <fs_doc_file>-docfile = lv_file_path.
* ENDIF.
* ENDIF.
* ENDLOOP.
DATA(ls_doc_file_tmp) = VALUE #( lt_doc_file[ 1 ] OPTIONAL ).
CLEAR : ls_doc_file_tmp,lt_doc_file.
ls_doc_file_tmp-wsapplication = 'ZIM'.
CALL FUNCTION 'BAPI_DOCUMENT_CHECKOUTVIEW2'
EXPORTING
documenttype = 'ZG1'
documentnumber = lv_doc_no
documentpart = '000'
documentversion = '00'
documentfile = ls_doc_file_tmp
* GETSTRUCTURE = '1'
* GETCOMPONENTS = 'X'
ORIGINALPATH = lf_pathname
* HOSTNAME = ' '
* GETHEADER = 'X'
* DOCBOMCHANGENUMBER =
* DOCBOMVALIDFROM =
* DOCBOMREVISIONLEVEL =
* PF_HTTP_DEST = ' '
* PF_FTP_DEST = ' '
IMPORTING
return = ls_return1
TABLES
* DOCUMENTSTRUCTURE =
documentfiles = lt_doc_file
* COMPONENTS =
.

ENDIF.

* DATA(ls_doc_file) = VALUE #( lt_doc_file[ 1 ] OPTIONAL ).


*
* CALL FUNCTION 'SCMS_DOC_READ'
* EXPORTING
* mandt = sy-mandt
* stor_cat = ls_doc_file-storagecategory
** CREP_ID = ' '
* doc_id = ls_doc_file-file_id
** PHIO_ID =
** SIGNATURE = 'X'
** SECURITY = ' '
** NO_CACHE = ' '
** RAW_MODE = ' '
** IMPORTING
** FROM_CACHE =
** CREA_TIME =
** CREA_DATE =
** CHNG_TIME =
** CHNG_DATE =
** STATUS =
** DOC_PROT =
* TABLES
* ACCESS_INFO = lt_info
** CONTENT_TXT =
* content_bin = lt_data
* exceptions
* bad_storage_type = 1
* bad_request = 2
* unauthorized = 3
* comp_not_found = 4
* not_found = 5
* forbidden = 6
* conflict = 7
* internal_server_error = 8
* error_http = 9
* error_signature = 10
* error_config = 11
* error_format = 12
* error_parameter = 13
* ERROR = 14
* OTHERS = 15.
* IF sy-subrc <> 0.
** Implement suitable error handling here
* ENDIF.

ENDIF.

ENDIF.
ENDFORM.

*Messages
*----------------------------------------------------------
*
* Message class: Hard coded
* File Uploaded sucessfully

----------------------------------------------------------------------------------
Extracted by Mass Download version 1.5.5 - E.G.Mellodew. 1998-2024. Sap Release 757

You might also like