‎2007 Jun 13 9:11 AM
Hi all ,
I would like to transfer the oracle data to sql2000 , my idea is :
- 1. write a external java program ( call trans.jar ) on oracle db server machine ( call sql2000 server to invoke the dtsrun.exe )
- 2. create a dts package on sql2000 server .
- 3. write an abap program in sap ( when the end-user execute this program , the trans.jar will call the dts package on sql2000 server ) .
I know that we can use sm69 to define the external program , but i don't know how to use abap/4 to invoke this external program ? has someone can tell me how to do ?
Thanks a lot !
Best Regards,
Carlos
‎2007 Jun 13 9:14 AM
You can use the function module <b>SXPG_COMMAND_EXECUTE</b> to execute external commands
Please find my sample code for it.
*&---------------------------------------------------------------------*
*& Form TRIGGER_EXT_OS_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_F_UNIX text
*----------------------------------------------------------------------*
form TRIGGER_EXT_OS_COMMAND using P_F_UNIX type SXPGCOLIST-PARAMETERS.
data: begin of IEPCOL occurs 100.
include structure BTCXPM.
data: end of IEPCOL.
BTCXPM = Log message from external program to calling program
data: W_STATUS like EXTCMDEXEX-STATUS.
* EXTCMDEXEX = Parameters of SXPG_COMMAND_EXECUTE
data: W_HOST like RFCDISPLAY-RFCHOST.
* RFCDISPLAY = Display structure for RFCDES maintenance "M5
* The External operating system command ZECOM is created * using thetransaction SM69. For any changes to the
* command goto SM69 and for executing and testing use
* the transaction SM49.
W_HOST = SY-HOST.
call function 'SXPG_COMMAND_EXECUTE'
exporting
COMMANDNAME = 'ZECOM'
ADDITIONAL_PARAMETERS = P_F_UNIX
OPERATINGSYSTEM = SY-OPSYS
TARGETSYSTEM = W_HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
importing
STATUS = W_STATUS
tables
EXEC_PROTOCOL = IEPCOL
exceptions
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
WRONG_ASYNCHRONOUS_PARAMETERS = 12
CANT_ENQ_TBTCO_ENTRY = 13
JOBCOUNT_GENERATION_ERROR = 14
others = 15.
if SY-SUBRC <> 0.
case SY-SUBRC.
when 1.
message E138(ZSM) with 'No permission to Execute ' 'External O/S command'.
when 2.
message E138(ZSM) with 'External O/S Command not found'.
when 3.
message E138(ZSM) with 'Parameters too long.' 'Exceeds the limit of 128 characters'.
when 4.
message E138(ZSM) with 'Security risk. ' 'The Command contains impermissible characters'.
when 5.
message E138(ZSM) with 'Wrong check call interface. Check the command.'.
when 6.
message E138(ZSM) with 'Error while starting the External O/S Command'.
when 7.
message E138(ZSM) with 'Error getting the return ' 'code of the External O/S command'.
when 8.
message E138(ZSM) with 'Unknown error'.
when 9.
message E138(ZSM) with 'Some mandatory parameter is not supplied'.
when 10.
message E138(ZSM) with 'Too many parameters. ' 'Check the additional parameter'.
when 11.
message E138(ZSM) with 'Illegal command'.
when others.
message E138(ZSM) with 'Unknown error'.
endcase.
else.
if W_STATUS = 'O'.
if UNIX_FILE cs '.ES'.
message S138(ZSM) with 'File FTP Successfull..!'.
* External O/S command to' 'FTP the above file to' 'ES FTP server succesfully!' P_F_UNIX.
endif.
else.
message I138(ZSM) with 'Ext O/S command to FTP the ' 'abv file to ext UNIX system not executed due to:'.
loop at IEPCOL.
write:/ SY-TABIX, IEPCOL-MESSAGE,255 ' '.
endloop.
endif.
endif.
endform. " TRIGGER_EXT_OS_COMMAND
Regards
Gopi