Skip to Content
<!–
.code {
border-style : solid ;
border-width: 1px ;
border-color: #000000 ;
background-color: #E4E5E8 ;
}
–>

Here is a simple shell script that enables you to make an RFC call (SOAP based) to the Web Application Server, and to parse the results without any of that new fangled stuff!

Some time ago, I wanted a simple HTTP client that only needed the bare minimum to compile ie. just libc, so I wrote
microhttp. I have used this in the example below, but this could easily be replaced with the Perl LWP POST command line tool, wget, curl, or lynx (heck – it may even be possible to do with the telnet client too?) – I just wanted to demonstrate that it could be done with a more or less POSIX set of tools.



#!/bin/sh

  1. encode the authentication details for the Authorization Header


USER=”DEVRFC”
PASSWD=”DEVELOPER”
PASS=` echo “$The specified item was not found.:$” | uuencode -m – | grep -v -E ‘====|begin’`

  1. do the SOAP call via HTTP


MYOUT=`microhttp -1 -n -a POST -u http://seahorse.local.net:8000/sap/bc/soap/rfc  \
                      -r ‘User-Agent: MHTTP1/0’ \
                      -r ‘Host: seahorse.local.net’ \
                      -r ‘Accept: text/xml’ \
                      -r ‘Accept: multipart/*’ \
                      -r ‘Content-Type: text/xml; charset=iso-8859-1’ \
                      -r ‘Connection: close’ \
                      -r “Authorization: Basic $” \
                      -r ‘SOAPAction: “urn:sap-com:document:sap:rfc:functions#RFC_READ_REPORT”‘ \


EOF`

  1. get the contents of QTAB
  2. parse out the row markers
  3. translate unicode characters


echo $MYOUT | sed -e ‘s/^\(.<QTAB>\)\(.\)\(
The environment I used for this was:

    • RedHat 9
    • SAP NetWeaver 4 evaluation system, should work with R/3 6.x+

And whats the point of all this I hear you say – well how many times do you have automated admin tasks around your R/3 system where you would like to integrate some simple RFC related function into a script – well now you can.

Having been an Administrator of systems both SAP and not, it would have often been useful to beable to integrate data sourced from an SAP system in to automated tasks (most commonly shell scripts in cron jobs) – this is a door by which it could be achieved, without having any specific higher level programming language/module dependencies (OK. I hope I haven’t offended any sed programmers out there …:-)

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Craig Cmehil
    Could you reformat your weblog – my resolution isn’t big enough to see everthing I actually have to highlight and drag my mouse to the right to see all the data 🙁
    (0) 
    1. Mark Finnern
      The code was interpreted by some browsers as HTML code.

      We did a find and replace on the code block so that<converted to<and > converted to &gt

      That did the trick. Thanks to Terrie Miller form O’Reilly who actually did it.

      Best, Mark.

      (0) 

Leave a Reply