Skip to Content

The transaction CK94 is used to update or create the mixing ratios.The transaction code is CK94.

But if we want to do it through a custom program, The following code will help to do it.

1.Create Mixing ratio.

TYPES:
* Tabelle für Materialbewertunsgarten mit Mischungsverhältnisse
  BEGIN OF ckmv1_mat_cratio_str,
    kalnr_mb       LIKE ckmlmv001kalnr,       “Material (MBEW-Ebene)
    kalnr_mk       LIKE ckmlmv001kalnr,       “Material (BwKreis-Ebene)
    bwkey           LIKE ckmlmv001bwkey,       “BewertKreis(Kalnr_Mb)
    matnr            LIKE ckmlmv001matnr,       “Material(Kalnr_Mb)
    bwtar            LIKE ckmlmv001bwtar,       “Bewqertungsart(Kalnr_Mb)
    misch_verh    LIKE ckmlmv003misch_verh“Mischungsverhältnis
  END OF ckmv1_mat_cratio_str,

  BEGIN OF ckmv1_alt_cratio_str,
    kalnr_pr        LIKE ckmlmv001kalnr,       “Prozeß
    kalnr_ba       LIKE ckmlmv001kalnr,       “Alternative
    kalnr_mb      LIKE ckmlmv001kalnr,       “Material (MBEW-Ebene)
    werks           LIKE ckmlmv001werks,       “Werk (Alternative)
    bwkey          LIKE ckmlmv001bwkey,       “BewertKreis(Kalnr_Mb)
    matnr           LIKE ckmlmv001matnr,       “Material(Kalnr_Mb)
    bwtar            LIKE ckmlmv001bwtar,       “Bewqertungsart(Kalnr_Mb)
    btyp             LIKE ckmlmv001btyp,        “Beschaffungstyp
    misch_verh   LIKE ckmlmv003misch_verh“Mischungsverh
*   Zusatzdaten für die Mischkalkulation
    mixcost_pc     TYPE ck_mixcost.            “Kz:Relevant f.Mischkal
    INCLUDE TYPE   ckmv1_mix001_data.          “Aus Stammsatz
    INCLUDE TYPE   ckmv1_mix003_data.          “Aus Mischverhältnis
TYPES:
*   Namen/Bezeichnungen der Beschaffungsalternative
name              TYPE ckmv1_ename,           “Editierter Name (Altern)
balt_name_str  TYPE ckmv1_name_str,        “Merkmale (Alternative)
END OF ckmv1_alt_cratio_str.

DATA:li_mmratio_tbl TYPE STANDARD TABLE OF ckmv1_mat_cratio_str,
     li_amratio_tbl TYPE STANDARD TABLE OF  ckmv1_alt_cratio_str,
     ls_amratio TYPE ckmv1_alt_cratio_str,
     ls_cki94c TYPE cki94c,
     ls_cki94a TYPE cki94a.

DATA: e_percent TYPE ckmlmv003misch_verh,

          rc        LIKE sysubrc,

          i_percent TYPE ckmlmv003misch_verh.

ls_cki94awerks  = “Plant
ls_cki94amatnr  = “Material.
ls_cki94amgtyp = ‘Z0001’. “Quantity structure type
ls_cki94abdatj   = ‘2012’.    “Current Year

*Determine the remainign values through below function modules

CALL FUNCTION ‘CKBA_MIXRATIO_PREPARE_VALUES’
* EXPORTING
*   I_MIXRATIO_VAL_TYPE       =
IMPORTING
   e_cki94c                     = ls_cki94c
   e_mmratio_tbl             = li_mmratio_tbl
   e_amratio_tbl              = li_amratio_tbl
*   E_BWTAR_STR          =
*   E_NO_RATIO                =
*   E_PLANNING_SCENE          =
  CHANGING
    c_cki94a                  = ls_cki94a
          .

READ TABLE li_amratio_tbl INTO ls_amratio INDEX 1.
IF sysubrc EQ 0.
  CALL FUNCTION ‘CKBA_MIXRATIO_CHECK’
    EXPORTING
      i_percent_check = space
      i_mixratio      = li_amratio_tbl[]
    IMPORTING
      e_returncode    = rc
      e_percent       = e_percent.

  IF rc EQ 0.
    CLEAR ls_amratio.
* clear existing quantity
    MODIFY li_amratio_tbl[]
      FROM ls_amratio
      TRANSPORTING misch_verh
      WHERE misch_verh NE 0.

* update quantity for correct line
    MOVE 100 TO ls_amratiomisch_verh.
    MODIFY li_amratio_tbl[]  FROM ls_amratio TRANSPORTING misch_verh WHERE MISCH_VERH EQ 0.

    CALL FUNCTION ‘CKML_MGV_CROSS_RATIO_UPDATE’
      EXPORTING
        iv_mgtyp      = ls_cki94amgtyp
        iv_gjahr      = ‘2012’
        iv_perio      = ‘000’
        it_alt_cratio = li_amratio_tbl[]
*       IT_MAT_CRATIO =
*       IV_VB_UPDATE  =
      .

  ENDIF.
ENDIF.

2.Update Mixing ratio

For updatign Mixing ratio, we can use the below function module.

Data: lw_bdatj    TYPE cki94abdatj,         “Posting date YYYY
        lw_mgtyp    TYPE cki94amgtyp,         “Quantity Structure Type

        lt_mixratio TYPE ckmv1_alt_cratio_tbl.

Constants:  c_per_000      TYPE ckmlmv003perio VALUE ‘000’,          “Period 000

   * Update Mix Ratio
  CALL FUNCTION ‘MIXRATIO_MAINTAIN’
    EXPORTING
      i_mgtyp                = lw_mgtyp
      i_fyear                  = lw_bdatj
      i_perio                  = c_per_000
      i_mixratio_procalt     = lt_mixratio[]
    EXCEPTIONS
      mixratio_already_exist = 1
      db_error               = 2
      mgtyp_error            = 3
      no_mixratio            = 4
      percent_error          = 5
      OTHERS                 = 6.

  IF sysubrc EQ 0.
    COMMIT WORK.

  endif.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply