The € operator - supporting the Euro and SAP RFC_READ_TABLE

Recently we have started to use a new technique for extracting data from SAP. We dynamically create predicates for RFC_READ_TABLE . This technique has been very successful and we use it more and more. But there are some problems with our technique and RFC_READ_TABLE. We have to specify the entire predicate in one statement for each search. An example show you what I mean. We like to  find to parts A and B in factory 1100.
A natural predicate for this is:
 “PLANT EQ ’1100’ and (MATNR EQ ‘A’ or MATNR EQ ‘B’)”.
But this is not possible with the current technique, to build the predicate we have to write something like:
“(PLANT EQ ’1100’ and MATNR EQ ‘A’) or (PLANT EQ ’1100’ and MATNR EQ ‘B’)”.
This is not only unnecessary cumbersome, you want to be as precise and succinct as possible since it gives the DB-optimizer a better chance to efficiently walk through the database, and also the buffer in SAP for the predicate is limited, to make this even worse the row length for predicates in RFC_READ_TABLE is limited to 72 chars. Why?? Well its the amount of information a good ol’ punch card can carry.
Clearly the functionality described in the link above needed some enhancement, better support for creating dynamic predicates for RFC_READ_TABLE. And that’s where the € operator  comes in. The euro currency can do with some help, and I do what I can by introducing the € operator to popularize the euro. I think I’m first to introduce the € sign in a programming language, (the Integration Tag Language). The € operator syntax:
$ok = €()filename
It is a bit hard to explain the inner workings of the € operator, but some examples will hopefully show how it works. Example:

            ,('NO_DATA',' ')
            ,('OPTIONS', (MANDT EQ '300' and KAPPL EQ 'M' AND WERKS EQ '1100')/path/file)
Take a look at the OPTIONS row in the example above, here we see the € operator in action. The expression between the parentheses  is the ‘constant’ part of the predicate  and connected to the expressions in the file with an AND like:
MANDT EQ '300' and KAPPL EQ 'M' AND WERKS EQ '1100'” AND ( filerow1 OR filerow2 OR … last_filerow)
A ‘real’ example:
In this example I extract rows from SAP table A17 for predicates (materials) generated in the first job genArray1 .  When running this example schedule the € operator  expands the OPTIONS expression into  this PHP array:
At last; the € operator conveniently chops the array elements into 72 char strings so RFC_READ_TABLE gets the input in punch card format :)

No comments:

Post a Comment