Calling Unix commands using CALL SYSTEM command in PeopleSoft SQR & sample code

Surfersclick Forums ERP Applications PeopleSoft Calling Unix commands using CALL SYSTEM command in PeopleSoft SQR & sample code

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Sai Sai 7 months, 2 weeks ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4204
    Profile photo of Sai
    Sai
    Participant

    Sometimes you may need to call Unix commands/call unix scripts from SQR, in that case CALL SYSTEM command comes in handy.
    Below is the syntax of CALL SYSTEM command-

    SYNTAX:

    CALL SYSTEM USING command status [WAIT|NOWAIT]

    Explanation:
    SYSTEM– Specifies that this CALL command issues an operating system command.
    command – Specifies the operating system command to execute. The command can be a quoted string, string variable, or column.
    status;- Contains the status returned by the operating system. The status must be a numeric variable. The value returned in status is system-dependent as follows:UNIX/Linux: Zero (0) indicates success. Any other value is the system error code.PC/ Microsoft Windows: A value less than 32 indicates an error.
    WAIT|NOWAIT – (Microsoft Windows only): WAIT specifies that SQR suspend its execution until the CALL SYSTEM command has finished processing. NOWAIT specifies that SQR start the CALL SYSTEM command but continue its own processing while that command is in progress.
    For Microsoft Windows, the default is NOWAIT. On UNIX\Linux operating systems the behavior is always WAIT.

    SAMPLE CODE:

    Below is sample code to run COPY command from SQR using CALL SYSTEM.

    let $cmd = 'cp /home/directory1/test.csv /home/directory2/test.csv'
    
    display $cmd
    
       CALL SYSTEM USING $cmd #call_status WAIT
       
     evaluate #call_status
       when = 0
              display 'Valid connection'
              break
       when = 1
              display 'ERROR: Connection cannot be made to SF'         
              break
       when = 2
              display 'Valid Log File'
              break
       when = 3
              display 'ERROR: Log file does not exist for file transfer'         
              break
       when = 4
              display 'File'
              break      
       when = 5
              display 'file does not exist for file transfer'         
              break       
     end-evaluate
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Lost Password

Register