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: 
Read only

capture exception in CALL 'SYSTEM' ID 'COMMAND' FIELD

Former Member
0 Likes
2,277

Dear All,

I am sending emails using system command and need to catch the exception whether the call system is successful or

not. Any exception available on this?

REgards,

Harsha

My sample code below

CONCATENATE '/home_sap/prdweb/testmail/test.sh' zemail_2_schhead-email INTO w_os SEPARATED BY space.

     CONCATENATE 'Purple_data_'   to_dt   INTO sub.

     CONCATENATE w_os sub INTO w_os SEPARATED BY space.

     CONCATENATE w_os 'Purple_data.' INTO w_os SEPARATED BY space.                                                                                                                            .

     CONCATENATE w_os '[email protected]' INTO w_os SEPARATED BY space.

     CONCATENATE w_os 'helloworld' INTO w_os SEPARATED BY space.

     CONCATENATE w_os    file_nm  INTO w_os SEPARATED BY space.

     CONCATENATE w_os zsmtpip-ip  INTO w_os SEPARATED BY space.

     CALL 'SYSTEM' ID 'COMMAND' FIELD w_os.

     WRITE 😕 w_os.

Dear All,

I am sending emails using system command and need to catch the exception whether the call system is successful or

not. Any exception available on this?

REgards,

Harsha

My sample code below

CONCATENATE '/home_sap/prdweb/testmail/test.sh' zemail_2_schhead-email INTO w_os SEPARATED BY space.

     CONCATENATE 'Purple_data_'   to_dt   INTO sub.

     CONCATENATE w_os sub INTO w_os SEPARATED BY space.

     CONCATENATE w_os 'Purple_data.' INTO w_os SEPARATED BY space.                                                                                                                            .

     CONCATENATE w_os '[email protected]' INTO w_os SEPARATED BY space.

     CONCATENATE w_os 'helloworld' INTO w_os SEPARATED BY space.

     CONCATENATE w_os    file_nm  INTO w_os SEPARATED BY space.

     CONCATENATE w_os zsmtpip-ip  INTO w_os SEPARATED BY space.

     CALL 'SYSTEM' ID 'COMMAND' FIELD w_os.

     WRITE 😕 w_os.

4 REPLIES 4
Read only

Former Member
0 Likes
1,403

Look for sy-subrc along with below exceptions.


Exceptions

Non-Catchable Exceptions

  • Cause: You are not authorized to call this C function.
    Runtime Error: CALL_C_FUNCTION_NO_AUTHORITY

  • Cause: The system function specified is unknown.
    Runtime Error: CALL_C_FUNCTION_NOT_FOUND

  • Cause: The system function SYSTEM is deactivated (in CALL 'SYSTEM')
    Runtime Error: CALL_SYSTEM_DISABLED
Read only

Former Member
0 Likes
1,402

Hi,

You can check ABAP keywork documentation.

Thanks

KH

Read only

0 Likes
1,402

Thanks, the exception doesn't suit my requirement.

IS there any way to output system command in abap code?

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,402

Why didn't you use the "official" Function Modules as described In  online documentation as Programming with External Commands : Programming Techniques (SXPG_CALL_SYSTEM: Run an External Command (Express Method) , etc.)

Regards,

Raymond