SlideShare a Scribd company logo

Encrypting PDF Files Using ABAP Code

rlavi
rlavirlavi

Encrypting PDF Files using ABAP Code and Free License Library.

Encrypting PDF Files Using ABAP Code

rlavi
rlavirlavi

Encrypting PDF Files using ABAP Code and Free License Library.

Encrypting PDF Files Using ABAP Code

1 of 5
Encrypting PDF Files by ABAP Code
By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow.
Content
1. Prerequisite................................................................................................................................. 2
1.1. Download Java Encrypter File..................................................................................... 2
1.2. Upload the .jar file to the Server SAP.......................................................................... 2
2. Procedure.................................................................................................................................... 3
2.1. Funcionality............................................................................................................... 3
2.2. ABAP Code. ............................................................................................................... 3
Encrypting PDF Files by ABAP Code
By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow.
1. Prerequisite
1.1. Download Java Encrypter File.
Download the .jar file from URL:
https://pdfbox.apache.org/downloads.html#recent
1.2. Upload the .jar file to the Server SAP.
The .jar file must be uploaded to a directory from SAP server. To do this, use the
CG3Z TCode. We indicate the PC directory where the .jar file was downloaded and
the server directory where you will be uploaded the .jar file.
Encrypting PDF Files by ABAP Code
By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow.
2. Procedure
2.1. Funcionality
This report has the next premises:
 Require the URL of PDF file and the password to Encrypt It.
 Indicate the server’s URL where .jar file was uploaded.
 Define the PC URL where .jar file will be downloaded on runtime. Only if the .jar
file is not found in Local PC.
 Define the PC URL where .BAT file will be created on runtime. This executes the
command to encrypt the PDF File.
 This command has the next structure:
“java –jar <LocalURLpdfbox-app-1.8.6.jar> Encrypt –U <Password>
<LocalURLFile.PDF>”.
Example:
java -jar D:pdfbox-app-1.8.6.jar Encrypt -U 12345 D:TESTPDF.pdf
2.2. ABAP Code.
TYPES : BEGIN OF lty_content,
linecmd LIKE rlgrap-filename,
END OF lty_content.
DATA : ld_ftfront LIKE rcgfiletr-ftfront,
ld_ftappl LIKE rcgfiletr-ftappl,
ld_flgstay TYPE boolean,
ld_return TYPE c,
ld_filename TYPE string,
ld_fileDat TYPE rlgrap-filename VALUE 'D:FileCmd.BAT',
ld_flg_open_error TYPE boolean,
ld_os_message(100) TYPE c.
DATA : lt_content TYPE STANDARD TABLE OF lty_content,
ls_content LIKE LINE OF lt_content.
PARAMETERS : p_front TYPE rcgfiletr-ftfront DEFAULT 'D:pdfbox-app-
1.8.6.jar' NO-DISPLAY,
p_appl LIKE rcgfiletr-
ftappl DEFAULT '/usr/sap/trans/tmp/pdfbox-app-1.8.6.jar' NO-
DISPLAY,
p_Encryp TYPE rlgrap-
filename DEFAULT 'D:TESTPDF.pdf',
p_Pass TYPE rlgrap-filename DEFAULT '12345'.
ld_ftfront = p_front.
ld_ftappl = p_appl.
Encrypting PDF Files by ABAP Code
By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow.
ld_filename = ld_ftfront.
* Verify if it was downloaded previously
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = ld_filename
RECEIVING
result = ld_return
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF ld_return EQ abap_false.
* Change the sy-cprog else the next function module return error.
sy-cprog = 'SAPLC13G'.
CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
EXPORTING
i_file_front_end = ld_ftfront
i_file_appl = ld_ftappl
i_file_overwrite = 'X'
IMPORTING
e_flg_open_error = ld_flg_open_error
e_os_message = ld_os_message
EXCEPTIONS
fe_file_open_error = 1
fe_file_exists = 2
fe_file_write_error = 3
ap_no_authority = 4
ap_file_open_error = 5
ap_file_empty = 6
OTHERS = 7.
ENDIF.
* Build the Command
CONCATENATE 'java -jar'
p_front
'Encrypt -U'
p_Pass
p_Encryp
INTO ls_content-linecmd
SEPARATED BY space.
* Agregar el Comando al contenido del archivo BAT
APPEND ls_content TO lt_content.
* Download .BAT File on Local Directory
CALL FUNCTION 'WS_DOWNLOAD'
Encrypting PDF Files by ABAP Code
By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow.
EXPORTING
FILENAME = ld_fileDat
FILETYPE = 'DAT'
TABLES
DATA_TAB = lt_content
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
* Execute .BAT file
CALL FUNCTION 'GUI_EXEC'
EXPORTING
command = ld_fileDat.
Finally Verify the PDF File and use the seted password

Recommended

More Related Content

Viewers also liked

2013 stamps-intro-assembly
2013 stamps-intro-assembly2013 stamps-intro-assembly
2013 stamps-intro-assemblyc.titus.brown
 
Ashleigh and Sarah's Killer Whale
Ashleigh and Sarah's Killer WhaleAshleigh and Sarah's Killer Whale
Ashleigh and Sarah's Killer WhaleTakahe One
 
Theoretical framework d1 2016 11-18
Theoretical framework d1 2016 11-18Theoretical framework d1 2016 11-18
Theoretical framework d1 2016 11-18Zafar Ahmad
 
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertising
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertisingMoMoTLV Israel March 2010 - innerActive - appstores & in-app advertising
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertisingMobileMonday Tel-Aviv
 
Kakapo slideshow
Kakapo slideshowKakapo slideshow
Kakapo slideshowTakahe One
 
19th annual professional responsibility seminar
19th annual professional responsibility seminar19th annual professional responsibility seminar
19th annual professional responsibility seminarKegler Brown Hill + Ritter
 
2014 whitney-public-talk
2014 whitney-public-talk2014 whitney-public-talk
2014 whitney-public-talkc.titus.brown
 
Anunturi De Pomina
Anunturi De PominaAnunturi De Pomina
Anunturi De Pominanbmro
 
From High Hopes to High Deficit and Back - EuroITV2009
From High Hopes to High Deficit and Back - EuroITV2009From High Hopes to High Deficit and Back - EuroITV2009
From High Hopes to High Deficit and Back - EuroITV2009Nils Walravens
 
E Syn Doc2032009112513
E Syn Doc2032009112513E Syn Doc2032009112513
E Syn Doc2032009112513Piet van Vugt
 
33 Lead Generation Tips in 33 Minutes
33 Lead Generation Tips in 33 Minutes33 Lead Generation Tips in 33 Minutes
33 Lead Generation Tips in 33 MinutesAlex Rascanu
 

Viewers also liked (16)

Ramifications of New USEPA
Ramifications of New USEPARamifications of New USEPA
Ramifications of New USEPA
 
2013 stamps-intro-assembly
2013 stamps-intro-assembly2013 stamps-intro-assembly
2013 stamps-intro-assembly
 
2014 villefranche
2014 villefranche2014 villefranche
2014 villefranche
 
Ashleigh and Sarah's Killer Whale
Ashleigh and Sarah's Killer WhaleAshleigh and Sarah's Killer Whale
Ashleigh and Sarah's Killer Whale
 
Theoretical framework d1 2016 11-18
Theoretical framework d1 2016 11-18Theoretical framework d1 2016 11-18
Theoretical framework d1 2016 11-18
 
SocialMediaMagic slides
SocialMediaMagic slidesSocialMediaMagic slides
SocialMediaMagic slides
 
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertising
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertisingMoMoTLV Israel March 2010 - innerActive - appstores & in-app advertising
MoMoTLV Israel March 2010 - innerActive - appstores & in-app advertising
 
2012 oslo-talk
2012 oslo-talk2012 oslo-talk
2012 oslo-talk
 
Kakapo slideshow
Kakapo slideshowKakapo slideshow
Kakapo slideshow
 
19th annual professional responsibility seminar
19th annual professional responsibility seminar19th annual professional responsibility seminar
19th annual professional responsibility seminar
 
2014 whitney-public-talk
2014 whitney-public-talk2014 whitney-public-talk
2014 whitney-public-talk
 
Anunturi De Pomina
Anunturi De PominaAnunturi De Pomina
Anunturi De Pomina
 
From High Hopes to High Deficit and Back - EuroITV2009
From High Hopes to High Deficit and Back - EuroITV2009From High Hopes to High Deficit and Back - EuroITV2009
From High Hopes to High Deficit and Back - EuroITV2009
 
E Syn Doc2032009112513
E Syn Doc2032009112513E Syn Doc2032009112513
E Syn Doc2032009112513
 
33 Lead Generation Tips in 33 Minutes
33 Lead Generation Tips in 33 Minutes33 Lead Generation Tips in 33 Minutes
33 Lead Generation Tips in 33 Minutes
 
VRay in RealTimeStudio
VRay in RealTimeStudioVRay in RealTimeStudio
VRay in RealTimeStudio
 

Recently uploaded

Preventing Downtime with Better IT Operations Management
Preventing Downtime with Better IT Operations ManagementPreventing Downtime with Better IT Operations Management
Preventing Downtime with Better IT Operations ManagementPrecisely
 
Employment of Virtual Reality Technology to Enhance Human Spaceflight Missions
Employment of Virtual Reality Technology to Enhance Human Spaceflight MissionsEmployment of Virtual Reality Technology to Enhance Human Spaceflight Missions
Employment of Virtual Reality Technology to Enhance Human Spaceflight MissionsVINOTHE9
 
WEEK 2 - Cradle of Early Science In STS.pptx
WEEK 2 - Cradle of Early Science In STS.pptxWEEK 2 - Cradle of Early Science In STS.pptx
WEEK 2 - Cradle of Early Science In STS.pptxJOEYJIMENEZ7
 
scale-model-slides.pptx
scale-model-slides.pptxscale-model-slides.pptx
scale-model-slides.pptxehclark63
 
FAIR Data-centric Information Architecture.pptx
FAIR Data-centric Information Architecture.pptxFAIR Data-centric Information Architecture.pptx
FAIR Data-centric Information Architecture.pptxBen Gardner
 
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and CostLLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and CostAggregage
 
Dolphin Latest Data Recovery Tools and Features 2024
Dolphin Latest Data Recovery Tools and Features 2024Dolphin Latest Data Recovery Tools and Features 2024
Dolphin Latest Data Recovery Tools and Features 2024Dolphin Data Lab
 
The Industrialist: Trends & Innovations - January 2024
The Industrialist: Trends & Innovations - January 2024The Industrialist: Trends & Innovations - January 2024
The Industrialist: Trends & Innovations - January 2024accenture
 
Wait Storyboard.pptx
Wait Storyboard.pptxWait Storyboard.pptx
Wait Storyboard.pptxehclark63
 
scale-model-slides-v1
scale-model-slides-v1scale-model-slides-v1
scale-model-slides-v1ehclark63
 
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdf
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdfVoxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdf
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdfIván López Martín
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataSafe Software
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBScyllaDB
 
IASW Storyboard (1).pptx
IASW Storyboard (1).pptxIASW Storyboard (1).pptx
IASW Storyboard (1).pptxehclark63
 
3D PRINTER technology by sultana.pptx
3D PRINTER technology by sultana.pptx3D PRINTER technology by sultana.pptx
3D PRINTER technology by sultana.pptxriyasathalikhan03
 
Lightning Network Integrations in Unity
Lightning Network Integrations in UnityLightning Network Integrations in Unity
Lightning Network Integrations in UnityLUCA VAJANI
 
OpenText Cybersecurity Tabletop Exercise
OpenText Cybersecurity Tabletop ExerciseOpenText Cybersecurity Tabletop Exercise
OpenText Cybersecurity Tabletop ExerciseMarc St-Pierre
 
Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)wesley chun
 
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...DianaGray10
 

Recently uploaded (20)

Preventing Downtime with Better IT Operations Management
Preventing Downtime with Better IT Operations ManagementPreventing Downtime with Better IT Operations Management
Preventing Downtime with Better IT Operations Management
 
Employment of Virtual Reality Technology to Enhance Human Spaceflight Missions
Employment of Virtual Reality Technology to Enhance Human Spaceflight MissionsEmployment of Virtual Reality Technology to Enhance Human Spaceflight Missions
Employment of Virtual Reality Technology to Enhance Human Spaceflight Missions
 
WEEK 2 - Cradle of Early Science In STS.pptx
WEEK 2 - Cradle of Early Science In STS.pptxWEEK 2 - Cradle of Early Science In STS.pptx
WEEK 2 - Cradle of Early Science In STS.pptx
 
scale-model-slides.pptx
scale-model-slides.pptxscale-model-slides.pptx
scale-model-slides.pptx
 
FAIR Data-centric Information Architecture.pptx
FAIR Data-centric Information Architecture.pptxFAIR Data-centric Information Architecture.pptx
FAIR Data-centric Information Architecture.pptx
 
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and CostLLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
 
Dolphin Latest Data Recovery Tools and Features 2024
Dolphin Latest Data Recovery Tools and Features 2024Dolphin Latest Data Recovery Tools and Features 2024
Dolphin Latest Data Recovery Tools and Features 2024
 
The Industrialist: Trends & Innovations - January 2024
The Industrialist: Trends & Innovations - January 2024The Industrialist: Trends & Innovations - January 2024
The Industrialist: Trends & Innovations - January 2024
 
Wait Storyboard.pptx
Wait Storyboard.pptxWait Storyboard.pptx
Wait Storyboard.pptx
 
scale-model-slides-v1
scale-model-slides-v1scale-model-slides-v1
scale-model-slides-v1
 
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdf
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdfVoxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdf
Voxxed Days CERN 2024 - Spring Boot <3 Testcontainers.pdf
 
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial DataCloud Revolution: Exploring the New Wave of Serverless Spatial Data
Cloud Revolution: Exploring the New Wave of Serverless Spatial Data
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
 
IASW Storyboard (1).pptx
IASW Storyboard (1).pptxIASW Storyboard (1).pptx
IASW Storyboard (1).pptx
 
3D PRINTER technology by sultana.pptx
3D PRINTER technology by sultana.pptx3D PRINTER technology by sultana.pptx
3D PRINTER technology by sultana.pptx
 
Lightning Network Integrations in Unity
Lightning Network Integrations in UnityLightning Network Integrations in Unity
Lightning Network Integrations in Unity
 
TRP-369.pdf
TRP-369.pdfTRP-369.pdf
TRP-369.pdf
 
OpenText Cybersecurity Tabletop Exercise
OpenText Cybersecurity Tabletop ExerciseOpenText Cybersecurity Tabletop Exercise
OpenText Cybersecurity Tabletop Exercise
 
Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)
 
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...
Career Talk Series: Session 2- Unlock career opportunities in intelligent aut...
 

Encrypting PDF Files Using ABAP Code

  • 1. Encrypting PDF Files by ABAP Code By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow. Content 1. Prerequisite................................................................................................................................. 2 1.1. Download Java Encrypter File..................................................................................... 2 1.2. Upload the .jar file to the Server SAP.......................................................................... 2 2. Procedure.................................................................................................................................... 3 2.1. Funcionality............................................................................................................... 3 2.2. ABAP Code. ............................................................................................................... 3
  • 2. Encrypting PDF Files by ABAP Code By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow. 1. Prerequisite 1.1. Download Java Encrypter File. Download the .jar file from URL: https://pdfbox.apache.org/downloads.html#recent 1.2. Upload the .jar file to the Server SAP. The .jar file must be uploaded to a directory from SAP server. To do this, use the CG3Z TCode. We indicate the PC directory where the .jar file was downloaded and the server directory where you will be uploaded the .jar file.
  • 3. Encrypting PDF Files by ABAP Code By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow. 2. Procedure 2.1. Funcionality This report has the next premises:  Require the URL of PDF file and the password to Encrypt It.  Indicate the server’s URL where .jar file was uploaded.  Define the PC URL where .jar file will be downloaded on runtime. Only if the .jar file is not found in Local PC.  Define the PC URL where .BAT file will be created on runtime. This executes the command to encrypt the PDF File.  This command has the next structure: “java –jar <LocalURLpdfbox-app-1.8.6.jar> Encrypt –U <Password> <LocalURLFile.PDF>”. Example: java -jar D:pdfbox-app-1.8.6.jar Encrypt -U 12345 D:TESTPDF.pdf 2.2. ABAP Code. TYPES : BEGIN OF lty_content, linecmd LIKE rlgrap-filename, END OF lty_content. DATA : ld_ftfront LIKE rcgfiletr-ftfront, ld_ftappl LIKE rcgfiletr-ftappl, ld_flgstay TYPE boolean, ld_return TYPE c, ld_filename TYPE string, ld_fileDat TYPE rlgrap-filename VALUE 'D:FileCmd.BAT', ld_flg_open_error TYPE boolean, ld_os_message(100) TYPE c. DATA : lt_content TYPE STANDARD TABLE OF lty_content, ls_content LIKE LINE OF lt_content. PARAMETERS : p_front TYPE rcgfiletr-ftfront DEFAULT 'D:pdfbox-app- 1.8.6.jar' NO-DISPLAY, p_appl LIKE rcgfiletr- ftappl DEFAULT '/usr/sap/trans/tmp/pdfbox-app-1.8.6.jar' NO- DISPLAY, p_Encryp TYPE rlgrap- filename DEFAULT 'D:TESTPDF.pdf', p_Pass TYPE rlgrap-filename DEFAULT '12345'. ld_ftfront = p_front. ld_ftappl = p_appl.
  • 4. Encrypting PDF Files by ABAP Code By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow. ld_filename = ld_ftfront. * Verify if it was downloaded previously CALL METHOD cl_gui_frontend_services=>file_exist EXPORTING file = ld_filename RECEIVING result = ld_return EXCEPTIONS cntl_error = 1 error_no_gui = 2 wrong_parameter = 3 not_supported_by_gui = 4 OTHERS = 5. IF ld_return EQ abap_false. * Change the sy-cprog else the next function module return error. sy-cprog = 'SAPLC13G'. CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY' EXPORTING i_file_front_end = ld_ftfront i_file_appl = ld_ftappl i_file_overwrite = 'X' IMPORTING e_flg_open_error = ld_flg_open_error e_os_message = ld_os_message EXCEPTIONS fe_file_open_error = 1 fe_file_exists = 2 fe_file_write_error = 3 ap_no_authority = 4 ap_file_open_error = 5 ap_file_empty = 6 OTHERS = 7. ENDIF. * Build the Command CONCATENATE 'java -jar' p_front 'Encrypt -U' p_Pass p_Encryp INTO ls_content-linecmd SEPARATED BY space. * Agregar el Comando al contenido del archivo BAT APPEND ls_content TO lt_content. * Download .BAT File on Local Directory CALL FUNCTION 'WS_DOWNLOAD'
  • 5. Encrypting PDF Files by ABAP Code By: Roger Lavi Chávez – Consultor SAP HCM/ABAP/WorFlow. EXPORTING FILENAME = ld_fileDat FILETYPE = 'DAT' TABLES DATA_TAB = lt_content EXCEPTIONS FILE_OPEN_ERROR = 1 FILE_WRITE_ERROR = 2 INVALID_FILESIZE = 3 INVALID_TYPE = 4 NO_BATCH = 5 UNKNOWN_ERROR = 6 INVALID_TABLE_WIDTH = 7 GUI_REFUSE_FILETRANSFER = 8 CUSTOMER_ERROR = 9 OTHERS = 10. * Execute .BAT file CALL FUNCTION 'GUI_EXEC' EXPORTING command = ld_fileDat. Finally Verify the PDF File and use the seted password