cancel
Showing results for 
Search instead for 
Did you mean: 

Combing multiple characteristic values

former_member42743
Active Contributor
0 Kudos

I'm looking to perform something like the following in a variant config action

All three characteristics conatin two character country values and use table T005 as a lookup check table.

I have two organizational groups that are allowed to ban shipping products to specific countries.

For example:

- The laboratory can ban a batch from going to a country because of a failed spec.

- The governemnt group can ban a batch because some temporary ban due to embargos/regulatory approvals, etc..

Access to each characteristic is controlled via organizational groups so one group can't change the others.

So Char 1 has the value of MX (Mexico)

     Char 2 has the values PA, ES, (Panama, Spain)

We want Char 3 to have the values of MX, PA, ES.

I.e. the union set fo Char 1 and Char 2

I've tried numerous versions of this to no avail.  I can't get past the syntax check!!

Here's some of the things I've tried:

$SELF.CHAR3 = CHAR1 + CHAR2

$SELF.CHAR3 = SELF.CHAR1 + SELF.CHAR2

$SELF.CHAR3 = CHAR1 & CHAR2

$SELF.CHAR3 = SELF.CHAR1 & SELF.CHAR2

And numerous others...

Any suggestion as to how I can do this?

In the end, we'd used CHAR 3 to set the LOBM_COUNTRY_NOK characteristic that SAP provides to block shipments to these countries by accident in batch determination.

Craig

Accepted Solutions (1)

Accepted Solutions (1)

Ritz
Active Contributor
0 Kudos

Craig S,

$SELF.CHAR3 = CHAR1 + CHAR2 kind of simple syntax will only work in case of numberic characterstic , when you want to have sum of 2 values.

In the example you share i guess a variant function can help. Please see help link explaning same.

You can use a function to concatenate values for characteristics to form a text string.

‘concatenate CHAR1 CHAR2 into CHAR3’

User-Defined Functions - Variant Configuration (LO-VC) - SAP Library

Check it may help you.

Thanks

Ritesh

former_member42743
Active Contributor
0 Kudos

I looked at that.  But the Restrictions at the bottom of that link say that the input characteristics to the function used in a dependancy must be single value characteristics.  Only the export characteristic can be a multiple-value characteristic.  All three of the characteristics I'm using are multple value characteristics.

Or am I reading that wrong?

I was really hoping they had a "UNION OF (CHAR1, CHAR2)" type of command.

Craig

Ritz
Active Contributor
0 Kudos

Craig S,

I am not sure if it will work with multi-value characteristic or not , you can give it a try. I think as you need to create a custom function module a program can do this magic for you.

Thanks

Ritesh

Flavio
Active Contributor
0 Kudos

Hi Craig,

Even if user-defined functions are dealing with input single value characteristics, it is anyway possible to use the same approach and manage multi-value ones.

This can be done using the function modules

'CUPR_GET_VALLIST' to get the multi-value characteristic values

and

'CUPR_SET_VAL' to set their values back.

Basically, we will use an user-defined function as usual, whose input characteristic will just be a dummy one, and the output one will be our multi-value one (CHAR3 in the example).

The ABAP code in the function will first read the multi-value characteristics values, via the configuration instance (in our example, CHAR1 and CHAR2).

Having all the values, the function will now loop over them and set the output characteristic values accordingly.

Here a very quick sample of what it should be, just built in my sandbox system.

The function characteristics interface

The procedure that calls the function (to be allocated in the configuration profile)

The function module ABAP code (very basic, just to proof the concept was working properly)


FUNCTION ZTEST_FLAVIO.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     REFERENCE(GLOBALS) TYPE  CUOV_00

*"  TABLES

*"      MATCH STRUCTURE  CUOV_01

*"      QUERY STRUCTURE  CUOV_01

*"  EXCEPTIONS

*"      FAIL

*"      INTERNAL_ERROR

*"----------------------------------------------------------------------

  DATA: w_instance    TYPE cudbt_instance,

        i_char1       TYPE cudbt_vallist,

        i_char2       TYPE cudbt_vallist,

        l_val         TYPE cudbt_val.


  IF globals-self IS INITIAL.

    w_instance = 1.

  ELSE.

    w_instance = globals-self.

  ENDIF.

  CALL FUNCTION 'CUPR_GET_VALLIST'

    EXPORTING

      instance              = w_instance

      characteristic        = 'CHAR1'

    IMPORTING

      values                = i_char1

    EXCEPTIONS

      unknown_instance      = 1

      unknown_characteristic = 2

      not_multivalued       = 3

      not_found             = 4

      internal_error        = 5

      OTHERS                = 6.

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

  CALL FUNCTION 'CUPR_GET_VALLIST'

    EXPORTING

      instance              = w_instance

      characteristic        = 'CHAR2'

    IMPORTING

      values                = i_char2

    EXCEPTIONS

      unknown_instance      = 1

      unknown_characteristic = 2

      not_multivalued       = 3

      not_found             = 4

      internal_error        = 5

      OTHERS                = 6.

  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 i_char1 INTO l_val.

    CALL FUNCTION 'CUPR_SET_VAL'

      EXPORTING

        instance              = w_instance

        characteristic        = 'CHAR3'

        val                   = l_val

      EXCEPTIONS

        unknown_instance      = 1

        unknown_characteristic = 2

        internal_error        = 3

        OTHERS                = 4.

    IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

  ENDLOOP.

  LOOP AT i_char2 INTO l_val.

    CALL FUNCTION 'CUPR_SET_VAL'

      EXPORTING

        instance              = w_instance

        characteristic        = 'CHAR3'

        val                   = l_val

      EXCEPTIONS

        unknown_instance      = 1

        unknown_characteristic = 2

        internal_error        = 3

        OTHERS                = 4.

    IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

  ENDLOOP.

ENDFUNCTION.

The result from CU50

I do hope this could be of some help.

Thanks and regards,

Flavio

former_member42743
Active Contributor
0 Kudos

Flavio - that is absoluelty awesome!!!

Just one more thing.. If I understand the help file.. I need to make sure the "dummy" single value characteistic always has a value in it so it executes. If no value in the import characteristic it doesn't work.  Correct?  So I can default in a value for it for no problem.

Now, my second question might be a bit more difficult... I create the dependency calling the function.

Do I assign that to both CHAR1 and CHAR2?  So that any changes to CHAR1 and CHAR2 will result in CHAR3 being automatically updated?

Casue we could have, for instance, a regulartory or export ban one a material which would require a user to update all batches of given material with a new banned country code.  So either CHAR1 or CHAR2 is updated by the user.

Thanks!

Craig

Ritz
Active Contributor
0 Kudos

Craig S,

My understanding.

1) Just a default will work , set it up at characterstic level and it will always trigger your dependency.

2) Dependency type procedure will be assigned to configuration profile, when ever user may change value/values for CHAR1 or CHAR2 it will trigger the procedure and generate new values for CHAR3.

3) Check if the procedure doesnt work in reassigning values , you can use constraint to achive same.

as procedures read only the first value assignment alternative, as do table calls.

Please share test result with forum.

Thanks

Ritesh

Ritz
Active Contributor
0 Kudos

flavio ciotola,

My firend , thanks for sharing your knowledge with forum. You are awasome with variant function.

Thanks

Ritesh

Flavio
Active Contributor
0 Kudos

Thank you, Craig!

As far as the "dummy" characteristic is concerned, yes you are right, I've just used a single value one, hidden, with a default value = 'X', so that the procedure is always executed.

Concerning the procedure, it has just to be allocated within the configuration profile. Any change in CHAR1 and / or CHAR2 will trigger CHAR3 to be inferred accordingly.

Thanks again and happy Variant Configuration!

Flavio

Flavio
Active Contributor
0 Kudos

Thank you Ritesh!

Indeed, user defined variant functions are powerful, and I like "playing" with them....

Thanks again and bye,

Flavio

former_member42743
Active Contributor
0 Kudos

Flavio - I had already set up the dummy, hidden characteristic exactly as you suggested including the defaulted X value at the characteristic level.  Thanks!

Ok. new wrinkle.. we don't use configuration profiles.  This is not used for a configured material.

We use this in the batch class for a regular, batch managed material.

Hence my desire to assign the dependency to CHAR1 or CHAR2 so that CHAR3 is updated automatically.  We were planning on doing this as an action.

But once my develpor gets the function progammed, I'll be able to test this in several ways to see what works best.  I'm going to try an action with the dependency assigned to CHAR1 and CHAR2 to start.

Craig

Flavio
Active Contributor
0 Kudos

Hi Craig,

As per your proposal, it should be Okay, even without a configuration profile: I made right now a quick test, removing the procedure from my config profile and adding it to the two characteristics CHAR1 and CHAR2: CHAR3 is getting computed anyway.

However, I would create a dependency type 'Procedure', and not an 'Action', as this latter usage is deprecated.

Thanks and regards,

Flavio

former_member42743
Active Contributor
0 Kudos

Thanks!  I'll try it as a procedure first!!

Craig

Answers (0)