Resources‎ > ‎Sap Notes‎ > ‎

CO line item reports: Creating a user-defined field (Note 325546 )

posted Dec 1, 2010, 12:12 AM by Sen Long   [ updated Dec 1, 2010, 12:13 AM ]



The CO line item reports already provide a large number of fields for displaying.Nevertheless, you may need additional, user-defined fields from time to time.
With a customer exit you can add user-defined fields to the CO line item reports.The documentation is included in project "COOMEP01", which is accessible via Transaction SMOD.
You can actually add fields to the actual costs line item reports (for example, KSB1, KOB1, CJI3), the planned costs line item reports (for example, KSBP, KOBP, CJI4) and the commitment line item reports (for example, KSB2, KOB2, CJI5). The budget line item reports that have been developed for Release 4.6 may also be extended (for example, KOB4).
This note contains a more detailed explanation of the procedure as there are still questions concerning this problem.

Other terms


Reason and Prerequisites
  • Filling the field requires programming an ABAP exit.Thus, ABAP knowledge is needed.
  • Moreover, you have to know of course where to find the data which is to be filled into the new field.
  • You have to know how to use Transaction SMOD and CMOD, the documentation can be called up via the initial screen of CMOD by choosing "Utilities --> Apllication help".
  • First you have to decide, whether you want to extend an actual, plan or commitment line item report.Depending on the report, you have to use different exits:
          Actual      EXIT_SAPLKAEP_001
          Plan        EXIT_SAPLKAEP_002
          Commitment  EXIT_SAPLKAEP_003
          Budget      EXIT_SAPLKAEP_004
    The exits are also included in Transaction SMOD/CMOD.
  • You have to execute the following steps that are explained in detail below:
      a) The output structure has to be extended by the user-defined field.
      b) The exit has to be programmed to fill the field.
      c) View V_TKALV has to be maintained to tell the report what technical information on the new field is required.
  • In the following we use the extension of the actual cost line item report by the "Cost Center Manager" field as an example.The cost center manager is contained in the master data table of the cost centers CSKS in the VERAK field.
  • The first step is to extend the output structure of the line item report by the new field.These output structures include customer Include structures which are intended for the enhancement:
                  Output structure   Customer include structure
      Actual      KAEP_COAC          CI_RKPOS
      Plan        KAEP_COPL          CI_KAEP_COPL
      Commitment  KAEP_CM            CI_RKPOA
      Budget      KAEP_BDG          CI_KAEP_BDG
    Thus, to extend the actual line item report by the cost center manager, you extend structure CI_RKPOS.Add a new field ZZ_VERAK to this structure, as data element/component type enter VERAK (the same type that you find for the VERAK field in the CSKS). Save and activate the structure.
  • In the next step you have to program the exit.Fist select the correct exit (for the extension of the actual line item report, this is EXIT_SAPLKAEP_001).
    The exit is called up for every read line item.Via the interface of the function module you recieve
    • parameter I_REP_OBJ, which you can use to distinguish from which line item report the exit was called.The possible characteristic values can be found via the fixed values for domain KAEP_OBJ.You need this parameter because the same exit is called up for all actual (or plan or commitment) line item reports.This way you avoid possible extra work with extensions that are to be carried out for all line item reports.
    • structure CS_RECORD which contains the complete line item that is read and processed by the database, including the new field.However, this is still blank when being accessed and has to be filled with ABAP.
      Please note that this exit is passed through once for every line item!A complex or a poorly programmed exit can considerably extend the runtime of the line item reports!
      In the example of the cost center manager, you should only fill the field if the cost center line item report is actually executed.In this case I_REP_OBJECT = "KS".The first line of the exit should contain

        Check i_rep_object = 'KS'.

      This ensures that it is not further processed with other line item reports and thus does not extend their runtime.
      Now the cost center manager has to be determined.Table CSKS has to be read for this.
        select single verak from csks into cs_record-zz_verak                        where kokrs = cs_record-kokrs and
                                    kostl = cs_record-kostl and
                                  datbi >= cs_record-budat and
                                  datab <=  cs_record-budat.
  • Finally you have to maintain view V_TKALV.Here you provide the required information to the line item report which ensure that the report always correctly displays the field.

                    Call up Transaction SM34, enter "V_TKALV" and choose "Change".

    • First of all you have to provide the field and its technical settings:To do this go to the "Field catalog information" and create a new entry. As field structure enter the corresponding output structure (see above, for the actual line item reports this would be KAEP_COAC), and as Field name enter the name of the new field.For the Field group select "K", this ensures that you will find the field with the user-defined fields in the display variant/layout maintenance.You can leave the other fields blank for the time being.The meaning of the fields in detail:
      - Key flag: This characterizes the field as key field in output.
      - "Tech. Field", "Col.pos.default" and "Edit mask" are not important for user-defined fields and should therefore be left blank.
      - Text field (only as of Release 4.5):If you not only extend the report by one field but by two fields - one with a technical code and a second with the corresponding text - it is recommended to enter the name of the text field in this field for the field with the technical code.With subtotalling via the key field, the system also fills and displays the text field in the totals rows.
    • Secondly you have to provide the fields of the line item for the report that are required to fill the user-defined field in the exit.Select the newly created field in the "Field catalog information" and go to the "Selection dependencies".
      Here, add an entry for every field that you need to fill your new field. Always enter the name of your new field in the left column and to the right the field that you require to fill your field.
      You have to do this to tell the report which fields it must read in any case if the new field is to be displayed.In background processing the system only reads the fields from the database that are absolutely necessary.These are the fields of the display variant which is used for the output, plus the fields that are needed to fill the fields of the display variant.
      In the example, the fields KOKRS, KOSTL and BUDAT are needed to fill the field ZZ_VERAK.However, there is a selection dependency for the field OBJNR (you can display this by selecting the field KOSTL in the field catalog information and then display the selection dependencies).Thus, you have to add 3 entries for the selection dependencies:

             Field name    Database field to be read
             ZZVERAK      KOKRS
             ZZVERAK      OBJNR
             ZZVERAK       BUDAT
  • The extension is completed! Should the system not yet display the new field in the output, this is either due to a special buffer mechanism of the field catalogs for the output (read Note 122975 for this) or due to the fact that the new field is not yet filled (read Notes 359691 and 327821 for this).