Sei sulla pagina 1di 2

Advanced substitutions in FI

Added by Milosavljevic Sreten, last edited by Nathan Genez on Oct 29, 2007 (view change)

Theory for beginning


Not so rare thing to occur in FI implementation is need to change standard behavior of the system. It may begin with light and simple substitutions, for example to put specific text in header or line item of posted document, but it can be also complex one, with several entering conditions and changing fields which are standard locked for change. I would skip explaining how does it really works, because it can be read in SAP documentation, just to mention three parts of every substitution:

Prerequisite represents conditions which has to be fulfilled in order to substitution to work. There are in total three structures where you can find data for this conditions and these are: BSEG (document items), SYST (ABAP system fields) and BKPF (document header). There are three so called "Callup points" where you can run your substitution: document header, line item and complete document. In all this three callup point structures BKPF and SYST are available for conditions, and BSEG is available only in line item and complete document place.

Substitution value is a field (string or number) which should replace value entered. For i.e. for documents entered which are type SA (in prerequisite this would be BKPF-BLART = 'SA'), field ZUONR should be filled some text, so BKPF-ZUONR = 'test'. So, in this case substitution value is 'test'.

Substitution exit is used when you need more complex substitution. In previous example imagine that you want to fill field ZUONR with document date + user who entered document. This can not be achieved by simple field to field assignment; you must write a user-exit. User exit represents routine to replace data in substitution. Every user exit you write must begin with U, and that state that user exit is user defined one. I will not write more about this because there is good documentation regarding writing user-exits, so I point you on standard SAP documentation. Let us do something more fun

Constrains and how to avoid them


Here is an example. Imagine that for some reason, and now don't think about reasons because when you need to avoid standard SAP rules always is some strange reason behind it, you need to change tax code when you post documents which some special transaction type and posting to exact GL account. You are experienced in writing substitutions and you write simple prerequisite rule for it: BSEG-VORG = 'ABGA' and BSEG-HKONT = '570000' and you wish that this substitution occurs on complete document event. But when you try to find MWSKZ as field to substitute, you can not find it in a list. There is a solution. Each field which can be substituted is in table GB01. Go to transaction SE11 and check is field available for substituting. You need to check field BOOLCLASS and search for class 015 which stands for substitution on complete document level, CLASSTYPE 'S' which stands for fields that needs to be substituted, table BSEG, and field which should be substituted in this case MWSKZ. If field can be substituted, it must not have BEXCLUDE marked. So, in this case, you need to clear this mark for this field. I will write procedure which worked for me just once on 4.7 system, but never after. Go to transaction SM30 and enter view V_GB01c and press Maintain. Enter bool class 015, class type S, table BSEG and field MWSKZ and save it. If there is no error, good for you, but if error occurs, you have to use workaround. We need to write a little ABAP code which should update table BSEG for this fields. Code should look like this: SPAN Unknown macro: { font-family} .L1S33 Unknown macro: { color}

.L1S52 Unknown macro: { color} update gb01 set bexclude = ' ' where boolclass = '015' and classtype = 'S' and bcltab = 'BSEG' and bclfield = 'MWSKZ'. Now you can see field MWSKZ in list for substitution and use it. But this is not end. If you now run transaction where substitution should occur nothing will happen. For this field actually be used in substitution, program RGUGBR00 must be run. This program regenerates all programs where substitution is used. Choose Application area FI, Callup point 015, regenerate main program, generate substitutions, generate substitution usage, generate substn exp. routines and you are ready to go!

And some interesting side effects


Now you can check what you did with your substitution. Check table BSEG if prerequisite rules are true and you will see that result is good and you can get wrong impression that everything works. But then if you check table BSET, which also gets updated with data related only for taxes, you will see that it was not updated at all. Why this is happening? I would not explain too deeply, because I was investigating this for some time and found out that it is not always wisest choice to do in contrary what SAP recommends. I will point you to note 42615 where is clearly stated that SAP is not responsible for side effects produced when modifying GB01 and you will have no support when some error occurs. Bottom line would be, not to discourage you to modify GB01 because when you are thinking about it for sure you have good reason for it. But I would point out that you should spend some more time to investigate possible unwished side effects like this one in order to be sure that your substitution is doing exactly what you intend.

Additional informations

Trace. Move your mouse on substitution and go to menu -> Extras -> Activate total trace. Now when you start transaction and enter data something like debugging screen will appear and you will be able to see is your substitution is running, which data are available in current moment.... For i.e. you can make substitution to run on transaction F-32 and put that in condition, but in fact SYST-TCODE is FB1D and you will see this in trace.

Think twice what are you trying to accomplice with substitution. And not only because previously described side effects. For example, you wish to substitute cost center based on some data in BSEG, so at first moment you may think that you need to substitute BSEG-KOSTL, which is locked for substituting. But, think about Cost center substitutions and structure COBL where this is standard.

Activating and deactivating of substitution. Transaction OBBH, here you can mark each substitution rule as activated or deactivated. When you create some rule, it will not work until you mark it as Active. service.sap.com and help.sap.com. Spend some time trying to find more informations here, it may save you a lot of time and energy, I'm speaking from own experience

Comments (1)

Show Comments

Potrebbero piacerti anche