SAP Function Modules

K_TARGETCOSTS_TOTALS_CALC SAP Function module







K_TARGETCOSTS_TOTALS_CALC 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 K_TARGETCOSTS_TOTALS_CALC into the relevant SAP transaction such as SE37 or SE80.

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


Pattern for FM K_TARGETCOSTS_TOTALS_CALC - K TARGETCOSTS TOTALS CALC





CALL FUNCTION 'K_TARGETCOSTS_TOTALS_CALC' "
  EXPORTING
*   par_auflo = SPACE           " kv042-xfeld
    par_awvrs =                 " tkv09-awvrs
    par_awvsv =                 " tkv09-awvsv   Comparison version
*   par_awwtv = '01'            " tkv09-awwtv   Comparison value type
    par_gjahr1 =                " t009b-bdatj   Fiscal year from
*   par_gjahr2 = 0              " t009b-bdatj   Fiscal year to
*   par_knach = SPACE           " kv042-xfeld   Do not display message
    par_kokrs =                 " tka00-kokrs   Controlling area
    par_meinh =                 " cosla-meinh   Allocation base unit
    par_menge =                 " cosla-lst001  Allocation base
    par_objnr =                 " cosla-objnr   Object number
*   par_plako = SPACE           " kv042-xfeld
    par_poper1 =                " t009b-poper   Posting period from
*   par_poper2 = 0              " t009b-poper   Posting period to
*   par_afout = 'X'             " kv20a-afout
*   par_mmess = SPACE           " kv042-xfeld
  TABLES
    pta_kv012 =                 " kv012
    pta_kv011 =                 " kv011
  EXCEPTIONS
    TARGETCOSTS_IMPOSSIBLE = 1  "               Target costs calculation is not possible
    SYSTEM_ERROR = 2            "
    .  "  K_TARGETCOSTS_TOTALS_CALC

ABAP code example for Function Module K_TARGETCOSTS_TOTALS_CALC





The ABAP code below is a full code listing to execute function module K_TARGETCOSTS_TOTALS_CALC 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:
it_pta_kv012  TYPE STANDARD TABLE OF KV012,"TABLES PARAM
wa_pta_kv012  LIKE LINE OF it_pta_kv012 ,
it_pta_kv011  TYPE STANDARD TABLE OF KV011,"TABLES PARAM
wa_pta_kv011  LIKE LINE OF it_pta_kv011 .


DATA(ld_par_auflo) = some text here

SELECT single AWVRS
FROM TKV09
INTO @DATA(ld_par_awvrs).


SELECT single AWVSV
FROM TKV09
INTO @DATA(ld_par_awvsv).


SELECT single AWWTV
FROM TKV09
INTO @DATA(ld_par_awwtv).


SELECT single BDATJ
FROM T009B
INTO @DATA(ld_par_gjahr1).


SELECT single BDATJ
FROM T009B
INTO @DATA(ld_par_gjahr2).


DATA(ld_par_knach) = some text here

SELECT single KOKRS
FROM TKA00
INTO @DATA(ld_par_kokrs).


DATA(ld_par_meinh) = Check type of data required

DATA(ld_par_menge) = Check type of data required

DATA(ld_par_objnr) = some text here

DATA(ld_par_plako) = some text here

SELECT single POPER
FROM T009B
INTO @DATA(ld_par_poper1).


SELECT single POPER
FROM T009B
INTO @DATA(ld_par_poper2).


DATA(ld_par_afout) = some text here

DATA(ld_par_mmess) = some text here

"populate fields of struture and append to itab
append wa_pta_kv012 to it_pta_kv012.

"populate fields of struture and append to itab
append wa_pta_kv011 to it_pta_kv011. . CALL FUNCTION 'K_TARGETCOSTS_TOTALS_CALC' EXPORTING * par_auflo = ld_par_auflo par_awvrs = ld_par_awvrs par_awvsv = ld_par_awvsv * par_awwtv = ld_par_awwtv par_gjahr1 = ld_par_gjahr1 * par_gjahr2 = ld_par_gjahr2 * par_knach = ld_par_knach par_kokrs = ld_par_kokrs par_meinh = ld_par_meinh par_menge = ld_par_menge par_objnr = ld_par_objnr * par_plako = ld_par_plako par_poper1 = ld_par_poper1 * par_poper2 = ld_par_poper2 * par_afout = ld_par_afout * par_mmess = ld_par_mmess TABLES pta_kv012 = it_pta_kv012 pta_kv011 = it_pta_kv011 EXCEPTIONS TARGETCOSTS_IMPOSSIBLE = 1 SYSTEM_ERROR = 2 . " K_TARGETCOSTS_TOTALS_CALC
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 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_par_auflo  TYPE KV042-XFELD ,
it_pta_kv012  TYPE STANDARD TABLE OF KV012 ,
wa_pta_kv012  LIKE LINE OF it_pta_kv012,
ld_par_awvrs  TYPE TKV09-AWVRS ,
it_pta_kv011  TYPE STANDARD TABLE OF KV011 ,
wa_pta_kv011  LIKE LINE OF it_pta_kv011,
ld_par_awvsv  TYPE TKV09-AWVSV ,
ld_par_awwtv  TYPE TKV09-AWWTV ,
ld_par_gjahr1  TYPE T009B-BDATJ ,
ld_par_gjahr2  TYPE T009B-BDATJ ,
ld_par_knach  TYPE KV042-XFELD ,
ld_par_kokrs  TYPE TKA00-KOKRS ,
ld_par_meinh  TYPE COSLA-MEINH ,
ld_par_menge  TYPE COSLA-LST001 ,
ld_par_objnr  TYPE COSLA-OBJNR ,
ld_par_plako  TYPE KV042-XFELD ,
ld_par_poper1  TYPE T009B-POPER ,
ld_par_poper2  TYPE T009B-POPER ,
ld_par_afout  TYPE KV20A-AFOUT ,
ld_par_mmess  TYPE KV042-XFELD .


ld_par_auflo = some text here

"populate fields of struture and append to itab
append wa_pta_kv012 to it_pta_kv012.

SELECT single AWVRS
FROM TKV09
INTO ld_par_awvrs.


"populate fields of struture and append to itab
append wa_pta_kv011 to it_pta_kv011.

SELECT single AWVSV
FROM TKV09
INTO ld_par_awvsv.


SELECT single AWWTV
FROM TKV09
INTO ld_par_awwtv.


SELECT single BDATJ
FROM T009B
INTO ld_par_gjahr1.


SELECT single BDATJ
FROM T009B
INTO ld_par_gjahr2.


ld_par_knach = some text here

SELECT single KOKRS
FROM TKA00
INTO ld_par_kokrs.


ld_par_meinh = Check type of data required

ld_par_menge = Check type of data required

ld_par_objnr = some text here

ld_par_plako = some text here

SELECT single POPER
FROM T009B
INTO ld_par_poper1.


SELECT single POPER
FROM T009B
INTO ld_par_poper2.


ld_par_afout = some text here

ld_par_mmess = 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 K_TARGETCOSTS_TOTALS_CALC or its description.