cancel
Showing results for 
Search instead for 
Did you mean: 

CUOBJ value in constraints

Former Member
0 Kudos

Hello Experts,

I'm trying to use a function in a constraint that has the CUOBJ number of my actual

configuration as input.

FUNCTION MYFUNCTION

( Input_cuobj = <something_that_contains_the_cuobj> )

I don't knwo which characteristic (if any) does hold the cuobj-value or where to

get it from.

Best Regards

Torsten

Accepted Solutions (0)

Answers (1)

Answers (1)

Flavio
Active Contributor
0 Kudos

Hi ,

actually, it looks like a little bit weird to use CUOBJ inside a function..... anyway, you can get it from MARC-CUOBJ as far as the material master is concerned, and from MARC-CUOBJ from the sales order item perspective. For production order item, it's from AFPO-CUOBJ.

Maybe you can create reference characteristics to these table fields and work with them accordingly.

Thanks and regards,

Flavio

Former Member
0 Kudos

Hi Flavio,

thanks for your answer. There's a table where the CUOBJ shows up for the object we use the VC for. That's Equipments and the table EQUI with the field EQUI-CUOBJ.

I try to explain what I want to do. We have Equipments with configurations bound to them. The configurator is part of the Equipment-Transactions (ie02/ie03). So, if you use the configurator to change characteristics, than you have a single configuration at Hand, that belongs to a single Equipment. In our case, the values, that should be selectable, are dependent on the Equipment and therefor the configuration.

Anyway, I can't access datatables from within constraints, as far as I know.

Flavio
Active Contributor
0 Kudos

Thank you, Torsten for your reply and explanation.

I would then suggest to try creating a reference characteristic to EQUI-CUOBJ, as per the enclosed SAP help link:

Creating Reference Characteristics - Characteristics (CA-CL-CHR) - SAP Library

I hope this could be of some help.

Thanks and regards,

Flavio

Former Member
0 Kudos

Hi Flavio,

we thought about the reference characteristic before. The Problem is, that the characteristic is not filled with any value. At least not automatically. We don't know how this should be done.

Best Regards

Torsten

Flavio
Active Contributor
0 Kudos

Hi Torsten,

I'm really sorry that it isn't working.

As a possible workaround, what about a procedure, that shall run just before your contraint, calling an user defined function (variant function)

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

that in turn will read the db table EQUI for CUOBJ?

I hope this could be of any help.

Thanks and regards,

Flavio

Former Member
0 Kudos

Hi Flavio,

that's what I'm already trying (see initial post). The point is that I need the CUOBJ

as input for the function. I can't get the CUOBJ via a function!

Best Regards

Torsten

Flavio
Active Contributor
0 Kudos

Hi Torsten,

Well, actually I was thinking of a procedure that shall call a variant function that is getting the CUOBJ.

In detail, assuming we have two characteristics, one for the Equipment number ( say, EQUI_EQUNR) and the other for the Configuration object (say, EQUI_CUOBJ), we shall first create the variant function (CU67) with the two characteristics, as follows:

So, Equipment number is the input characteristic, and CUOBJ is the output one.

The code for the function could be something like this (see the above link for details about variant functions):


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_equi_equnr  TYPE atwrt,

        w_equi_cuobj  TYPE atflv.

  DATA: w_equnr       TYPE equnr,

        w_cuobj       TYPE cuobj.

* Equipment code

  CALL FUNCTION 'CUOV_GET_FUNCTION_ARGUMENT'

    EXPORTING

      argument      = 'EQUI_EQUNR'

    IMPORTING

      sym_val       = w_equi_equnr

    TABLES

      query         = query

    EXCEPTIONS

      arg_not_found = 1

      OTHERS        = 2.

  IF sy-subrc <> 0.

    RAISE internal_error.

  ENDIF.

  MOVE w_equi_equnr TO w_equnr.


* Reading Db table for CUOBJ

  SELECT SINGLE cuobj FROM equi

    INTO w_cuobj

    WHERE equnr = w_equnr.

  MOVE w_cuobj TO w_equi_cuobj.

* Sending back the CUOBJ value

  CALL FUNCTION 'CUOV_SET_FUNCTION_ARGUMENT'

    EXPORTING

      argument                = 'EQUI_CUOBJ'

      vtype                   = 'NUM'

      num_val                 = w_equi_cuobj

    TABLES

      match                   = match

    EXCEPTIONS

      existing_value_replaced = 1

      OTHERS                  = 2.

  IF sy-subrc <> 0.

    RAISE internal_error.

  ENDIF.

Basically, the function gets EQUI_EQUNR as input parameter, then is making a Select in EQUI table, getting CUOBJ. This latter is then transferred back to the function output paramater (EQUI_CUOBJ characteristic).

The function is called within a procedure, as follows:

The procedure shall run before your constraint, thus passing to it the CUOBJ.

Let's try to test this possibility in your Dev system, and let me know....

Thanks and regards,

Flavio

Former Member
0 Kudos

Hi Flavio,

I know about the Connection of equnr and cuobj via the datatable equi.

My Problem is, that there is no characteristic that contains either of them nad I don't know a way to create one, that would be filled correctly.

What you showcased was exactly, what I was doing. But I simply miss the equnr or cuobj as Input.

Best Regards

Torsten

Flavio
Active Contributor
0 Kudos

Hi Torsten,

I do believe you can create those two characteristics.

And the one for Equipment, shall be a reference characteristic:

This shall make it inherit the Equipment Nr from master data.

The one for CUOBJ shall instead get the config object after running the above procedure + function.

I hope this could help.

Thanks and regards,

Flavio