Pto+how to Upload a Document for Client to View

About ->This document will provide the stride past step process from uploading a pdf document from presentation server to application server and save the document from application server to presentation server.

Contents

  1. Target Users
  2. Business Requirement
  3. Screen Details
  4. Process to Upload the document in webdynpro pop up screen.
  5. Display the data from the POP up if required
  6. Download the PDF document from Application Server
  7. Conclusion

1: Target Users :The target users of this document is those ABAPers working primarily in Hour ABAP expanse and for them who were facing a situation of storing  the document in application server and think it rather than storing the data in a table .

two: Concern Requirement

          The business requirement is involved in two parts.

  Part1–>This part is for the employees who accept been allocated sure courses where they will finish the courses and upload the documents related to the courses completed by them.

  Part2–>This office is for the Team who will validate those document and could able to download and view the documents attached by the employee, verify them and put their comments appropriately.

Part 1 Steps–>

Screen Details–>

Upload_Display Screen.png

The above screen show a highlighted push which volition assistance the user to upload the document as he/she has already completed the course.

AttachDoc.png

This screen will assistance the user to upload the certificate and once he/she hitting the adhere button it will save in the Application server.

Hither I am non providing the details how to trigger the pop-up screen.

  1. Below code is about saving the document in application server

CONSTANTS path_name TYPE localfile VALUE '/usr/sap/HRD/Learning/' .

"==========================================================
"Loop over zipper list for only new attachments
"==========================================================
LOOP AT lt_attachment_list ASSIGNING <fs_attachment_list> .
*    WHERE status = abap_false." new attachment

MOVE-CORRESPONDING <fs_attachment_list> TO ls_data.
Append ls_data TO lt_data.
ENDLOOP .
"get message manager
lo_api_controller ?= wd_this->wd_get_api( ).
" get message manager reference
CALL METHOD lo_api_controller->get_message_manager
RECEIVING
message_manager = lo_msg_manager.
IF lt_data[] IS INITIAL .
" Attachement listing is already saved
lo_msg_manager->report_error_message(
message_text = 'Attachement list is already saved' ).
Return .
ENDIF .

*—————————————————————-*
* Save the data in application server
*—————————————————————-*
CONCATENATE path_name ls_datafile_name into file.
lv_filedata = ls_datafile_data.
OPEN DATASET file FOR OUTPUT IN BINARY Manner MESSAGE msg.
TRANSFER ls_datafile_data TO file.
IF sysubrc = 0 .
Close DATASET file.
ENDIF .

*—————————————————————-*
" Bear witness success message
lo_msg_manager->report_success(
message_text = 'Attachement list saved successfully !!!' ).

/wp-content/uploads/2016/08/mapfile_1019747.png

Document Mapped

DocAttach.png

Striking the attach button and the document saved successfully in the Awarding Server.

SaveinAppserver.png

View the PDF File–>

To view the PDF certificate which user attached he has to click on the file name hyper link.

ViewPDF.JPG

Code to View the PDF document–>

*———————————————————————————–*
* For Upload Context Node
*———————————————————————————–*
lo_nd_file_upload
= wd_context -> get_child_node ( name = wd_this -> wdctx_file_upload ).
* go element via lead selection
lo_el_file_upload
= lo_nd_file_upload -> get_element ( ).
lo_el_file_upload
-> get_static_attributes (
IMPORTING
static_attributes
= ls_input ).

if ls_input IS NOT INITIAL .
wd_comp_controller
-> GV_PDF = ls_input file_contents .
else .
*———————————————————————————–
*     Select the data from the database table to view as the PDF     *
*———————————————————————————–
LOOP AT lt_elements INTO lo_element .
lo_element
-> get_static_attributes (
IMPORTING
static_attributes
= ls_attach_list
).
"Check if record exists in table
Movement-Corresponding ls_attach_list TO ls_data .
Suspend ls_data TO lt_data .
ENDLOOP .
wd_comp_controller
-> GV_PDF = ls_data file_data .
endif .
wd_this
-> fire_out_from_popup_plg ( ).
endmethod .

Part 2 Steps–>

Screen Details–>

DownloadOption.png

In this screen squad tin approve the asking and can able to download the document.

  1. Below code is nearly downloading the data from Application Server

Call Office 'EPS2_GET_DIRECTORY_LISTING'
EXPORTING
IV_DIR_NAME = dir_name
TABLES
DIR_LIST = dir_list
EXCEPTIONS
INVALID_EPS_SUBDIR = 1
SAPGPARAM_FAILED = 2
BUILD_DIRECTORY_FAILED = 3
NO_AUTHORIZATION = 4
READ_DIRECTORY_FAILED = 5
TOO_MANY_READ_ERRORS = vi
EMPTY_DIRECTORY_LIST = 7
OTHERS = viii
.
IF SYSUBRC <> 0 .
* MESSAGE ID SY-MSGID Blazon SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
LOOP AT lt_data INTO ls_data.
READ Tabular array DIR_LIST INTO wa_list with key name = ls_datafile_name.
lv_filename = ls_datafile_name.
Telephone call METHOD cl_wd_runtime_services=>attach_file_to_response
EXPORTING
i_filename = lv_filename
i_content = ls_datafile_data
i_mime_type = 'pdf' .
ENDLOOP .

Saving.png

In one case hitting the download push the certificate will download with download option.

Conclusion

Though I have not shared the whole code I believe this would helpful for those working in this kind of scenario.

Proffer and comments is always welcome.

Jay Tripathy

pantojaspont1950.blogspot.com

Source: https://blogs.sap.com/2016/08/20/step-by-step-process-to-upload-and-download-document-in-webdynpro-abap/

0 Response to "Pto+how to Upload a Document for Client to View"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel