SAP Function Modules

CALCULATION_SHEET SAP Function module







CALCULATION_SHEET is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name CALCULATION_SHEET into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: CO09
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM CALCULATION_SHEET - CALCULATION SHEET





CALL FUNCTION 'CALCULATION_SHEET' "
  EXPORTING
    application =               " kalc-applid   Calling application - 1st key part
    key =                       " kalc-form_key  Key field for storage and retrieval
*   version = SPACE             " kalc-version  Version of the saved formulas
*   recalc = SPACE              "               Initial->dialog, not initial->list with formulas
*   display = SPACE             "               Initial->change, not initial->display
*   display_lst = SPACE         "               Value = "X": edit formulas for printing
*   changed_value =             " sy-datar      Save changed value of a component
*   changed =                   " sy-datar      Value = "X": save changed formula
*   flg_recalc_to_bom = SPACE   "
  IMPORTING
    changed_value =             " sy-datar      Save changed value of a component
    changed =                   " sy-datar      Value = "X": save changed formula
  TABLES
    in_col =                    " calc_col      Table of column elements
    in_join =                   " calc_join     Join row and column tables
    in_row =                    " calc_row      Table of row elements
  EXCEPTIONS
    APPLICATION_ERROR = 1       "
    CALCULATION_ERROR = 2       "
    CALC_TABLE_ERROR = 3        "
    KEY_ERROR = 4               "
    VERSION_ERROR = 5           "
    OTHERS = 6                  "
    .  "  CALCULATION_SHEET

ABAP code example for Function Module CALCULATION_SHEET





The ABAP code below is a full code listing to execute function module CALCULATION_SHEET including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_changed_value  TYPE SY-DATAR ,
ld_changed  TYPE SY-DATAR ,
it_in_col  TYPE STANDARD TABLE OF CALC_COL,"TABLES PARAM
wa_in_col  LIKE LINE OF it_in_col ,
it_in_join  TYPE STANDARD TABLE OF CALC_JOIN,"TABLES PARAM
wa_in_join  LIKE LINE OF it_in_join ,
it_in_row  TYPE STANDARD TABLE OF CALC_ROW,"TABLES PARAM
wa_in_row  LIKE LINE OF it_in_row .


SELECT single APPLID
FROM KALC
INTO @DATA(ld_application).


SELECT single FORM_KEY
FROM KALC
INTO @DATA(ld_key).


SELECT single VERSION
FROM KALC
INTO @DATA(ld_version).

DATA(ld_recalc) = 'some text here'.
DATA(ld_display) = 'some text here'.
DATA(ld_display_lst) = 'some text here'.
DATA(ld_changed_value) = 'some text here'.
DATA(ld_changed) = 'some text here'.
DATA(ld_flg_recalc_to_bom) = 'some text here'.

"populate fields of struture and append to itab
append wa_in_col to it_in_col.

"populate fields of struture and append to itab
append wa_in_join to it_in_join.

"populate fields of struture and append to itab
append wa_in_row to it_in_row. . CALL FUNCTION 'CALCULATION_SHEET' EXPORTING application = ld_application key = ld_key * version = ld_version * recalc = ld_recalc * display = ld_display * display_lst = ld_display_lst * changed_value = ld_changed_value * changed = ld_changed * flg_recalc_to_bom = ld_flg_recalc_to_bom IMPORTING changed_value = ld_changed_value changed = ld_changed TABLES in_col = it_in_col in_join = it_in_join in_row = it_in_row EXCEPTIONS APPLICATION_ERROR = 1 CALCULATION_ERROR = 2 CALC_TABLE_ERROR = 3 KEY_ERROR = 4 VERSION_ERROR = 5 OTHERS = 6 . " CALCULATION_SHEET
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 6. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_changed_value  TYPE SY-DATAR ,
ld_application  TYPE KALC-APPLID ,
it_in_col  TYPE STANDARD TABLE OF CALC_COL ,
wa_in_col  LIKE LINE OF it_in_col,
ld_changed  TYPE SY-DATAR ,
ld_key  TYPE KALC-FORM_KEY ,
it_in_join  TYPE STANDARD TABLE OF CALC_JOIN ,
wa_in_join  LIKE LINE OF it_in_join,
ld_version  TYPE KALC-VERSION ,
it_in_row  TYPE STANDARD TABLE OF CALC_ROW ,
wa_in_row  LIKE LINE OF it_in_row,
ld_recalc  TYPE STRING ,
ld_display  TYPE STRING ,
ld_display_lst  TYPE STRING ,
ld_changed_value  TYPE SY-DATAR ,
ld_changed  TYPE SY-DATAR ,
ld_flg_recalc_to_bom  TYPE STRING .


SELECT single APPLID
FROM KALC
INTO ld_application.


"populate fields of struture and append to itab
append wa_in_col to it_in_col.

SELECT single FORM_KEY
FROM KALC
INTO ld_key.


"populate fields of struture and append to itab
append wa_in_join to it_in_join.

SELECT single VERSION
FROM KALC
INTO ld_version.


"populate fields of struture and append to itab
append wa_in_row to it_in_row.
ld_recalc = 'some text here'.
ld_display = 'some text here'.
ld_display_lst = 'some text here'.
ld_changed_value = 'some text here'.
ld_changed = 'some text here'.
ld_flg_recalc_to_bom = 'some text here'.

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name CALCULATION_SHEET or its description.