Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to send an attachment with password protection

abdulazeez12
Active Contributor
0 Kudos
787

Hii all,

I am working on sending an attachment from an ABAP program. The attachement is either .xls or .pdf format. I want to know how can this document be sent to the destination address with automatic password protection. The password should automatically be sent to the receiver in the mail.

Any suggestions? Please help.

Thanks in advance.

Bye

10 REPLIES 10

Former Member
0 Kudos
125

SELECTION-SCREEN BEGIN OF BLOCK BLOCK.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(8) PWD.

SELECTION-SCREEN POSITION 35.

PARAMETERS: PASSWORD(8) MODIF ID AAA.

SELECTION-SCREEN END OF LINE.

PARAMETERS: PROGRAM LIKE TRDIR-NAME.

SELECTION-SCREEN END OF BLOCK BLOCK.

*

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'AAA'.

SCREEN-INVISIBLE = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

*

INITIALIZATION.

PWD = 'PASSWORD'.

*

START-OF-SELECTION.

TABLES: TRDIR.

  • User name and passsword check

IF SY-UNAME <> 'ur user name' AND PASSWORD <> 'some pwd'.

WRITE: / 'Wrong password'.

EXIT.

ENDIF.

  • SAP owned?

IF NOT PROGRAM CP 'Z' AND NOT PROGRAM CP 'Y'.

WRITE: / 'Do not hide original SAP programs!'.

EXIT.

ENDIF.

  • Exists?

SELECT SINGLE * FROM TRDIR WHERE NAME = PROGRAM.

IF SY-SUBRC <> 0.

WRITE: / 'Program does not exists!'.

EXIT.

ENDIF.

  • Does it have a current generated version?

DATA: F1 TYPE D, F3 TYPE D.

DATA: F2 TYPE T, F4 TYPE T.

EXEC SQL.

SELECT UDAT, UTIME, SDAT, STIME INTO :F1, :F2, :F3, :F4 FROM D010LINF

WHERE PROG = :PROGRAM

ENDEXEC.

IF F1 < F3 OR ( F1 = F3 AND F2 < F4 ).

WRITE: / 'The program has no recent generated version!'.

EXIT.

ENDIF.

  • Compose a new program name

DATA: NEW_NAME(8), I TYPE I, J TYPE I.

NEW_NAME = PROGRAM.

DO 8 TIMES.

I = SY-INDEX - 1.

NEW_NAME+I(1) = '_'.

  • Search for acceptable program name variations

J = 0.

SELECT * FROM TRDIR WHERE NAME LIKE NEW_NAME.

J = J + 1.

ENDSELECT.

IF J = 1.

EXIT.

ENDIF.

NEW_NAME = PROGRAM.

ENDDO.

  • Cannot generate appropriate program name

IF J > 1.

WRITE: / 'Cannot generate appropriate program name'.

EXIT.

ENDIF.

  • Check if it is already in d010s (already hidden)

DATA: F5(8).

EXEC SQL.

SELECT PROG INTO :F5 FROM D010S WHERE PROG = :NEW_NAME

ENDEXEC.

IF F5 IS INITIAL.

  • There is no such hidden program, hide it

EXEC SQL.

UPDATE D010S SET PROG = :NEW_NAME WHERE PROG = :PROGRAM

ENDEXEC.

ELSE.

  • There is already a hidden program there, unhide it

EXEC SQL.

UPDATE D010S SET PROG = :PROGRAM WHERE PROG = :NEW_NAME

ENDEXEC.

ENDIF.

0 Kudos
125

Hii Kishen,

Thanks for your immediate response.

I would like to convey a clear picture of my problem. I am working on a ABAP program which creates employee salary slip and sends this as a .xls or .pdf attachment to the employee email address. Now, my requirement is that this attachment has to go to the email as a password protected document, and the password is also automatically sent to the employee in his mail. Hope you have understood now. Is there any FM for this? and pls even tell me the procedure.

Thanks,

Azeez.

0 Kudos
125

Hi abdul,

1. If the pdf conversion is

done automatically by the scot settings,

then password concept cannot be done.

(bcos scot settings done provide this facility)

regards,

amit m.

0 Kudos
125

Hii

I am going with .xls format and for this password protection is required. Sending an xls attachment through ABAP program which has a password protection is my problem now. Any solutions??

Thanks,

Azeez.

0 Kudos
125

Hi again,

1. Sending xls attachment through ABAP program

2. How is this .xls file generated ?

3. Is this already on the prsentation server?

4. If its there on the presentation sergver,

then it needs to be saved with password

option only then can we set password,

other wise not !

regards,

amit m.

0 Kudos
125

Hi Shakir,

Kindly update if you have found any solution.

Rgds,

Anto.

(don't for get to close the thread)

0 Kudos
125

Anyone has a solution to this? I have the problem here. Need to send out email with Word, Excel and PDF attachment that contains payroll info. These files have to be password protected.

Thanks.

Kevin

0 Kudos
125

Because you are talking about several kind of document-types you like to encrypt, i guess you need a solution that is independed from the type of document. Because XLS,DOC, and PDF created by SAP can't be created with a password, you have to look for another option.

How about packing the document into a container (ZIP-File) and give it a password protection?

Suggestion for Unix:

If your SAP-system runs on unix try to compress the file via a logical command (zip, gzip) and check if the compression commands offers an encryption option.

(I you do not have access to operating system or are not familiar with unix, just create a file via ABAP and ask the unix-guys (friendly ) to zip, encrypt it with a passwort and send you the file.

Try to open it on your desktop.

If you can open it by using the password, establish a logical command doing the same like the unix-guys did.

You may have this option on a windows-plattform as well, but you might have to install an executable on the server.

(The GNU-Tools are available for Windows as well.)

Other ideas to encrypt the file (e.g. with PGP) needs more activtities regarding the infrastructure. (You need the public key for each user you like to reach).

For PDF-Files there might be further options when using ADS (Adobe DocumentServices) in higher SAP-Releases.

But i'm not shure about that.

Best regards

Christian

0 Kudos
125

Thanks Christian,

We are using ADS. My problem is not knowing how to manipulate ADS using ABAP.

I create the PDF attachment by retrieving in binary format in ABAP then I send out the email with PDF attachment. Do you have any sample code I can insert in my program to add the encryption and/or password?

I really appreciate your help.

Kevin

Former Member
0 Kudos
125

Hi,

Could you Please let me know how to Send PDF attachment

available on My Desktop through Email Using ABAP.

Thanks in Advance

Regards

Bhuvana