Skip to Content

Variant configuration and object dependencies with date type characteristics

Hi SCN Members.

Based on the first four characteristics we want to determine 5th charactestics VC_MODEL_YEAR

VC_REQ_PROD_DATE is single-value date format characterstics.

Requirnment is that when date is provided to VC_REQ_PROD_DATE characterstics, then based on date and other 3 characterstics, system should propose model year from the below variant table.

Exampleà

SELECT modelyear

FROM zvariant_table

INTO lv_model_year

WHERE mud = lv_mud

AND maker = lv_maker1

AND bodytype = lv_body_type1

AND valid_from <= lv_req_prod_date1

AND valid_to >= lv_req_prod_date1.

i.e. if user selects

Then only relevant (2016,2017 &2018, based on variant table) model year should appear not all like below from CT04 values

Please guide me @flavio.ciotola3 Former Member Former Member @Andreas G @keyur.mistry1 and other respected members.

Thanking you,

Regards

Ashish Mishra

3.jpg (42.2 kB)
4.jpg (33.0 kB)
1.jpg (37.3 kB)
2.jpg (66.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Aug 18, 2017 at 05:25 AM

    Hi Ashish,

    If I'm not mistaken, I fear that we cannot make use of a Constraint and a Variant Table to restrict Characteristic values, here.

    The reason being the req_prod_date is in an interval and variant table cannot manage intervals.

    But again, if I'm not mistaken... So, let's wait for other respected members and their opinions / solutions.

    Maybe, a possible solution I can see is to use an User Defined Function with a Constraint, to be checked in detail anyway.

    Thanks and bye,

    Flavio

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Ashish,

      Thank you for your reply.

      Concerning the F4 Help on characteristic value, I've just created a test scenario in my sandbox system, based on your requirements, and seems to work:

      It is however based on the assumption that characteristic VC_MODEL_YEAR has values checked via Function Module, as follows:

      In this case, we need two FM's (as it can be checked through the F1 help on this field): the first one will be the one shown in the picture, the other one will end with _F4.

      The first one is quite basic:

      The other contains the logic (SELECT...) as per your requirements (basic code that I've implemented is below).

      Additionally, we need a procedure and a variant function (User Defined function) to retrieve the characteristics values (VC_MUD, VC_MAKER, etc.) that are needed in the logic. This variant function has a very simple interface (one flag in input, another in output) and will save the characteristics values into global variables.

      Here is the procedure (to be added in the configuration profile):

      and here is the code of the variant function

      FUNCTION Z_SAVE_CHAR_VALS.
      *"----------------------------------------------------------------------
      *"*"Local Interface:
      *"  IMPORTING
      *"     REFERENCE(GLOBALS) TYPE  CUOV_00
      *"  TABLES
      *"      MATCH STRUCTURE  CUOV_01
      *"      QUERY STRUCTURE  CUOV_01
      *"  EXCEPTIONS
      *"      FAIL
      *"      INTERNAL_ERROR
      *"----------------------------------------------------------------------
      
        DATA: lv_instance TYPE cudbt_instance.
        DATA: lv_val      TYPE cudbt_val.
      
        IF globals-self IS INITIAL.
          lv_instance = 1.
        ELSE.
          lv_instance = globals-self.
        ENDIF.
      
      
      * Characteristic VC_MUD
        CALL FUNCTION 'CUPR_GET_VAL'
          EXPORTING
            instance                   = lv_instance
            characteristic             = 'VC_MUD'
          IMPORTING
            val                        = lv_val
          EXCEPTIONS
            unknown_instance           = 1
            unknown_characteristic     = 2
            multivalued_characteristic = 3
            not_found                  = 4
            internal_error             = 5
            OTHERS                     = 6.
        IF sy-subrc = 0.
          lv_mud = lv_val-atwrt.
        ELSEIF sy-subrc = 4.
          CLEAR lv_mud.
        ELSE.
        ENDIF.
      
      
      * Characteristic VC_MAKER
        CLEAR lv_val.
        CALL FUNCTION 'CUPR_GET_VAL'
          EXPORTING
            instance                   = lv_instance
            characteristic             = 'VC_MAKER'
          IMPORTING
            val                        = lv_val
          EXCEPTIONS
            unknown_instance           = 1
            unknown_characteristic     = 2
            multivalued_characteristic = 3
            not_found                  = 4
            internal_error             = 5
            OTHERS                     = 6.
        IF sy-subrc = 0.
          lv_maker1 = lv_val-atflv.
        ELSEIF sy-subrc = 4.
          CLEAR lv_maker1.
        ELSE.
        ENDIF.
      
      
      * Characteristic VC_BODY_TYPE
        CLEAR lv_val.
        CALL FUNCTION 'CUPR_GET_VAL'
          EXPORTING
            instance                   = lv_instance
            characteristic             = 'VC_BODY_TYPE'
          IMPORTING
            val                        = lv_val
          EXCEPTIONS
            unknown_instance           = 1
            unknown_characteristic     = 2
            multivalued_characteristic = 3
            not_found                  = 4
            internal_error             = 5
            OTHERS                     = 6.
        IF sy-subrc = 0.
          lv_body_type1 = lv_val-atwrt.
        ELSEIF sy-subrc = 4.
          CLEAR lv_body_type1.
        ELSE.
        ENDIF.
      
      
      * Characteristic VC_REQ_PROD_DATE
        CLEAR lv_val.
        CALL FUNCTION 'CUPR_GET_VAL'
          EXPORTING
            instance                   = lv_instance
            characteristic             = 'VC_REQ_PROD_DATE'
          IMPORTING
            val                        = lv_val
          EXCEPTIONS
            unknown_instance           = 1
            unknown_characteristic     = 2
            multivalued_characteristic = 3
            not_found                  = 4
            internal_error             = 5
            OTHERS                     = 6.
        IF sy-subrc = 0.
          CALL FUNCTION 'CTCV_CONVERT_FLOAT_TO_DATE'
            EXPORTING
              float = lv_val-atflv
            IMPORTING
              date  = lv_req_prod_date1.
        ELSEIF sy-subrc = 4.
          CLEAR lv_req_prod_date1.
        ELSE.
        ENDIF.
      
      
      * Send back the flag
        CALL FUNCTION 'CUOV_SET_FUNCTION_ARGUMENT'
          EXPORTING
            argument                = 'FLAG'
            vtype                   = 'CHAR'
            sym_val                 = 'X'
          TABLES
            match                   = match
          EXCEPTIONS
            existing_value_replaced = 1
            OTHERS                  = 2.
        IF sy-subrc <> 0.
        ENDIF.
      
      
      ENDFUNCTION.
      

      Global variables (in the function group top include) are as follows:

      Here is the code for the _F4 function:

      FUNCTION Z_MODEL_YEAR_F4.
      *"----------------------------------------------------------------------
      *"*"Local Interface:
      *"  IMPORTING
      *"     VALUE(CHARACT_NO) LIKE  CABN-ATINN OPTIONAL
      *"     VALUE(CHARACT) LIKE  CABN-ATNAM OPTIONAL
      *"     VALUE(DISPLAY) OPTIONAL
      *"     VALUE(ADDITIONAL_VALUES) LIKE  CABN-ATSON DEFAULT SPACE
      *"     VALUE(MULTIPLE_VALUES) LIKE  RCTMV-ATLIS DEFAULT SPACE
      *"     VALUE(LANGUAGE) LIKE  SY-LANGU DEFAULT SY-LANGU
      *"     VALUE(DISPLAY_WITH_LANGUAGE) OPTIONAL
      *"  TABLES
      *"      VALUES STRUCTURE  RCTVALUES OPTIONAL
      *"  EXCEPTIONS
      *"      NOT_FOUND
      *"----------------------------------------------------------------------
      
      
        DATA: BEGIN OF i_all_values OCCURS 0,
                value       TYPE atwrt,
                value_desc  TYPE atwtb,
              END OF i_all_values.
        DATA: i_ret_values LIKE ddshretval OCCURS 1 WITH HEADER LINE.
        DATA: i_old_values LIKE rctvalues  OCCURS 0 WITH HEADER LINE.
        DATA: lv_model_year LIKE zvariant_table-modelyear.
      
      
        i_old_values[] = values[].
      
      
        REFRESH values.
        CLEAR values.
      
      
        REFRESH i_all_values.
        CLEAR i_all_values.
      
      
        REFRESH i_ret_values.
        CLEAR i_ret_values.
      
      
        values-status    = 'I'.
      
      
        SELECT modelyear FROM zvariant_table
          INTO lv_model_year
          WHERE mud          = lv_mud
            AND maker        = lv_maker1
            AND bodytype     = lv_body_type1
            AND valid_from  <= lv_req_prod_date1
            AND valid_to    >= lv_req_prod_date1.
      
      
          values-value     = lv_model_year.
          values-val_descr = lv_model_year.
          APPEND values.
          CLEAR: values-value, values-val_descr.
        ENDSELECT.
      
      
      * Now, copy values in i_all_values.
        LOOP AT values.
          i_all_values-value = values-value.
          i_all_values-value_desc = values-val_descr.
          APPEND i_all_values.
        ENDLOOP.
        SORT i_all_values.
        DELETE ADJACENT DUPLICATES FROM i_all_values.
      
      
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
            retfield        = 'ATWRT'
            value_org       = 'S'
          TABLES
            value_tab       = i_all_values
            return_tab      = i_ret_values
          EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
      
      
        IF sy-subrc <> 0.
      * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      
      
        LOOP AT values.
          IF i_ret_values[] IS NOT INITIAL.
            READ TABLE i_ret_values WITH KEY fieldval = values-val_descr.
          ELSE.
            READ TABLE i_old_values WITH KEY value = values-value.
          ENDIF.
          IF sy-subrc = 0.
            values-status = 'I'.
          ELSE.
            values-status = 'D'.
          ENDIF.
          MODIFY values.
        ENDLOOP.
      
      
      ENDFUNCTION.
      

      With all this setup, the configuration simulation seems to properly work.

      I do hope this could be of some help. Please anyhow consider that the code above is very basic and with the aim to just proof the basic concept: review it carefully...

      Thanks and regards,

      Flavio

      img-166.png (48.3 kB)
      img-167.png (18.2 kB)
      img-168.png (23.8 kB)
      img-169.png (13.0 kB)
      img-170.png (11.7 kB)
  • Aug 18, 2017 at 05:20 AM

    Hello,

    Greetings,

    this should be possible with the Constraint. Did you try that?

    Br,

    Dsk

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Dhandapani,

      Yes I have created a procedure and called in config. profile-->

      But here FM is selecting only single model year, based on my above explanation. But I want to manipulate the proposed value based on my logic.

      Is there any way..?

      Thanking you,

      Regards

      Ashish Mishra

      7.jpg (22.6 kB)