<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to execute a external command ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-a-external-command/m-p/2371635#M525517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;        I would like to transfer the oracle data to sql2000 , my idea is :&lt;/P&gt;&lt;P&gt;           - 1. write a external java program ( call trans.jar ) on oracle db server machine ( call sql2000 server to invoke the dtsrun.exe )&lt;/P&gt;&lt;P&gt;           - 2. create a dts package on sql2000 server .&lt;/P&gt;&lt;P&gt;           - 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 ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        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 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Jun 2007 08:11:03 GMT</pubDate>
    <dc:creator>carlos_zhang3</dc:creator>
    <dc:date>2007-06-13T08:11:03Z</dc:date>
    <item>
      <title>How to execute a external command ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-a-external-command/m-p/2371635#M525517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;        I would like to transfer the oracle data to sql2000 , my idea is :&lt;/P&gt;&lt;P&gt;           - 1. write a external java program ( call trans.jar ) on oracle db server machine ( call sql2000 server to invoke the dtsrun.exe )&lt;/P&gt;&lt;P&gt;           - 2. create a dts package on sql2000 server .&lt;/P&gt;&lt;P&gt;           - 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 ) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        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 ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2007 08:11:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-a-external-command/m-p/2371635#M525517</guid>
      <dc:creator>carlos_zhang3</dc:creator>
      <dc:date>2007-06-13T08:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute a external command ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-a-external-command/m-p/2371636#M525518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the function module &amp;lt;b&amp;gt;SXPG_COMMAND_EXECUTE&amp;lt;/b&amp;gt; to execute external commands&lt;/P&gt;&lt;P&gt;Please find my sample code for it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  TRIGGER_EXT_OS_COMMAND
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;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 &amp;lt;&amp;gt; 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
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2007 08:14:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-execute-a-external-command/m-p/2371636#M525518</guid>
      <dc:creator>gopi_narendra</dc:creator>
      <dc:date>2007-06-13T08:14:43Z</dc:date>
    </item>
  </channel>
</rss>

