Application Development and Automation 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: 

Encrypt txt and xls file on AL11 without PI. I have to use GPG as our OS is LINUX.

virendra_kedia1
Explorer
0 Kudos
2,157

Hello Experts!

I have read many posts on GPG encryption and I am not able to find the exact solution, hence raising a new thread.

Requirement: We have multiple files on AL11 directory we need to encrypt them and move the encrypted files to different folder (later to be consumed by third party).

What I have tried so far: I tried creating SM69 events with OS command as 'gpg', parameters of OS command '-e', additional parameters '-r <userid> <AL11 path of file>' - It is giving me error no public key.

Question 1: Where should I pass public key, with which command?

We have received public key which is around 1600 long characters and the FM 'SXPG_EXECUTE_COMMAND' additional parameters is only 255 characters.

Question 2: How to accommodate this along with file path?

Even I tried below code:

CALL 'SYSTEM' ID 'COMMAND' FIELD lv_cmd ID 'TAB' lt_tab[].

Where lv_cmd contains public key too alongwith AL11 path, But I am getting sy-subrc = 1, and lt_tab[] is empty.

FYI: GPG is installed @OS level.

Request you to guide me on correct path. I think I am very close to solution but very far too 😞

Any hint/help would be appreciated.

Regards

Virendra Kedia

7 REPLIES 7

Jelena_Perfiljeva
Active Contributor
0 Kudos
1,415

Why do you have to do this in SAP? It seems like an independent process that could be done at the OS level, outside of SAP ERP.

As an alternative, instead of calling GPG (exe?) you could create a BAT file, assuming the key is not something dynamically generated from SAP.

p244500
Active Contributor
0 Kudos
1,415

Hi,

Just suggesting , download your file to location and encrypt it using bat file. This BAT file can call using SAP. You have to call BAT file in same download program.Execute bat file using below BAPI. In the bat file execute your exe file or encrypt software.

 CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
    EXPORTING
*     DOCUMENT               = "'C:\test\encrypt.bat'
      APPLICATION            = 'C:\test\encrypt.bat'
      PARAMETER              = ''
      DEFAULT_DIRECTORY      = ''
      MAXIMIZED              = ' '
      MINIMIZED              = 'X' "If you need the DOS window to be minimized
    EXCEPTIONS
      CNTL_ERROR             = 1
      ERROR_NO_GUI           = 2
      BAD_PARAMETER          = 3
      FILE_NOT_FOUND         = 4
      PATH_NOT_FOUND         = 5
      FILE_EXTENSION_UNKNOWN = 6
      ERROR_EXECUTE_FAILED   = 7
      OTHERS                 = 8.


Sandra_Rossi
Active Contributor
0 Kudos
1,415

Undoubtedly, you should try GPG via Linux command line, and when OK, you will try to use SXPG_EXECUTE_COMMAND. Did you import the public key? It's nicely explained here for example: https://yanhan.github.io/posts/2017-09-27-how-to-use-gpg-to-encrypt-stuff.html?source=post_page-----...

former_member197078
Participant
0 Kudos
1,415

Hi @virendra.kedia,

I have the similar requirement as your, Can you share me the solution information wich you have resolved the above requirment.

Thanks,

Suunil

0 Kudos
1,415

Hello Sunil,

For this case we are uploading normal files in AL11 and then basis is encrypting it using some batch files with OS commands.

former_member197078
Participant
0 Kudos
1,415

Hi virendra.kedia

Thank for the inforamtion,

It will be very helpful if you Can share the information how they are doing it OS command . you can share me through email sunilroys@gmail.com.

Thanks,

Suunil

virendra_kedia1
Explorer
0 Kudos
1,415

Hello Sunil,

For this case we are uploading normal files in AL11 and then basis is encrypting it using some batch files with OS commands.