SAP has an "easy" to use tool called the Business Connector for querying your SAP system. You throw some XML at a URL, it does Java-ish things to poke and prod SAP, and gives you XML back. It - correctly - dies if you give it bad XML. Unfortunately, it returns broken XML itself. So I use a little shell script to fetch the data and clean it with perl. I use perl instead of sed because I also need to do a few other transformations on the data for which my sed-fu is not strong enough:
if test `curl -s -w %{http_code} -u $SAP_USER:$SAP_PASS -d $BC_XMLDAT
+A -o $TEMPFILE $BC_URL` == 200 ; then
echo Successfully retrieved data, now correcting it
(cat $TEMPFILE && echo -n '</xml>') |
perl -pne '
s/&/&/g;
# and a few other corrections
' > corrected.xml
else
echo Error fetching data from Business Connector
exit 1
fi
In the long term I want to switch to using
sap::rfc so I don't have to do this - and hopefully avoid all that XML nastiness.
Now I'll admit that the perl involved is utterly trivial, but I think this demonstrates just how good a "glue" perl can be for sticking other languages and software packages together. The shell script above is in fact embedded in a Makefile, and the resulting XML file is later munged with more perl.
NB, the perl code here originates with a colleague; the shell and make wrapper is mine.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.