SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Trigger UNIX Script from SAP



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Apr 13, 2008 1:20 pm    Post subject: Trigger UNIX Script from SAP Reply with quote

Code:
Data: unix_cmd(50).
unix_cmd = 'chmod 664 /sapdata/DEV/home/travelers'.
translate unix_cmd to lower case.
call 'SYSTEM' id 'COMMAND' field unix_cmd.
write: / sy-subrc.


OR

Code:
***********************************************************************
* Create and run a UNIX command programmatically
***********************************************************************
* The destination must be set up and configured from tcode SM59
* see note OSS 63930
*
* rfcexec, this service must be started from UNIX
* UX syntax to start service:
* rfcexec -aUNIX_COMMAND -g sap01 -x sapgw00 &
*
* rfcexec - program, /sapmnt/DEV/exe
* UNIX_COMMAND - program ID from SM59, case sensitive
* sap01 - AP_Gateway_hostname
* sapgw00 - Gateway_Service
*
* Transaction SMGW, monitor the gateway (Goto/Logged on clients)
*
*Number LU name TP Name Syst.type Host name Host address
*
* 0 sap01 sapgw00 LOCAL_R3 sap01 10.1.193.50
* 233 sap01 UNIX_COMMAND REGISTER_TP sap01 10.1.193.50


***********************************************************************
* Could replace this unsupported SAP syntax, Call 'SYSTEM'
*
*data: begin of tabl occurs 0,
* line(200),
*end of tabl.
*call 'SYSTEM' id 'COMMAND' field comm
* id 'TAB' field tabl-*sys*.

***********************************************************************
data: command(256).
data : begin of ret occurs 10, " results of unix command
text(80),
end of ret .
***********************************************************************
data: i_connected_systems type table of gwy_system.
data: w_connected_systems type gwy_system.
data: w_message(80).
*
parameter: p_junk(4) default 'Junk'.
***********************************************************************
*
*
start-of-selection.
*
call function 'GWY_READ_CONNECTED_SYSTEMS'
* EXPORTING
* GWHOST =
* GWSERV =
* DISCONNECT =
tables
connected_systems = i_connected_systems
* EXCEPTIONS
* GWY_UNKNOWN_OPCODE = 1
* GWY_COMMUNICATION_FAILURE = 2
* GWY_GET_TAB_FAILED = 3
* GWY_NEWLINE_FAILED = 4
* GWY_TABLEN_TOO_SHORT = 5
* GWY_GET_OPCODE_FAILED = 6
* GWY_GET_GWHOST_FAILED = 7
* GWY_GET_GWSERV_FAILED = 8
* GWY_MONITOR_DISABLED = 9
* OTHERS = 10
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
read table i_connected_systems into w_connected_systems
with key tpname = 'UNIX_COMMAND'.
if sy-subrc ne 0.
perform display_error_messages.
stop.
endif.
***********************************************************************
*COMMAND = 'ls '. " command
*COMMAND = 'ls -lt'. " command, newest at top
command = 'ls -osra'.

call function 'RFC_REMOTE_PIPE'
* DESTINATION 'SERVER_EXEC'
destination 'UNIX_COMMAND'
exporting
command = command
read = 'X'
tables
pipedata = ret.
loop at ret.
write ret.
endloop.
*
*
end-of-selection.
*
*&---------------------------------------------------------------------*
*& Form Display_error_messages
*&---------------------------------------------------------------------*
form display_error_messages .
data: begin of listtab occurs 0,
field(80),
end of listtab.

listtab-field = 'Program UNIX_COMMAND is not registered.'.
append listtab.
listtab-field = 'Tell Basis person about the error'.
append listtab.
listtab-field = ' '.
append listtab.
listtab-field = 'UX syntax to start service: '.
append listtab.
listtab-field = 'rfcexec -aUNIX_COMMAND -g sap01 -x sapgw00'.
append listtab.
listtab-field = ' '.
append listtab.
listtab-field = 'Program aborted,'.
listtab-field+19 = sy-cprog.
append listtab.

call function 'POPUP_WITH_TABLE_DISPLAY_OK'
exporting
endpos_col = 70
endpos_row = 20
startpos_col = 10
startpos_row = 10
titletext = 'Registered program error'
* IMPORTING
* CHOISE =
tables
valuetab = listtab
* EXCEPTIONS
* BREAK_OFF = 1
* OTHERS = 2
.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

endform. " Display_error_messages
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Connect to External system, Unix и Perl All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.