cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenating the characteristics

Former Member
0 Kudos

How can i concatenate values of 2 characterstics

Char A= 100

CHAR B=RED

Both values are entered by user at the time of sales order configuration

How can i get

Char c= 100RED

Regards,

Manish Phatak

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Manish,

It looks like concatenation wont work in dependencies.

You need to use function modules - Like the example case mentioned. take you abaper help in creating one and try out. Hope this helps.

Function Call

This example uses an action to show how you can use functions to infer values.

For example, you can use a function to link the values of several characteristics together, so that these values form the value of another characteristic.

In our example, a computer manufacturer wants to use labels on PCs to show at a glance which casing the PC has, how big the hard disk is, and which processor is installed.

The PC has characteristic CASING for the casing, CPU for the processor, and HD for the hard disk. The text for the label is the value of characteristic LABEL_ID.

To calculate the value of characteristic LABEL_ID, you create function module Z_LABEL_ID, and a function with the same name, and assign characteristics CASING, CPU, HD, and LABEL_ID to the function. You define the first value assignment alternative such that characteristics CASING, CPU, and HD are input parameters for determining the value of characteristic LABEL_ID.

You use this function in an action as follows:

FUNCTION Z_LABEL_ID

(CASING = $ROOT.CASING,

CPU = $ROOT.CPU,

HD = $ROOT.HD,

LABEL_ID = $SELF.LABEL_ID)

The characteristics on the left-hand side are characteristics of the function. The characteristics on the right-hand side are characteristics of the PC. Characteristic LABEL_ID must be referred to with the variable $SELF, because LABEL_ID is a characteristic of the object currently being processed. Otherwise, values cannot be inferred. The default object $ROOT is assumed for the other characteristics.

You allocate this action to the configuration profile of material PC.

As soon as values are assigned to characteristics CASING, CPU, and HD the function sets a value for characteristic LABEL_ID.

You configure the PC, assigning the following values to characteristics CASING, CPU, and HD:

CASING = ‘TW’ (character format)

CPU = ‘586’ (character format)

HD = 1275 (numeric format)

These values are transferred to function module Z_LABEL_ID as import parameters in table QUERY. In function module Z_LABEL_ID, the characteristics and values are read from the interface table using function module CUOV_GET_FUNCTION_ARGUMENT.

If you want to format the value of a numeric characteristic as an integer (1275) and not as a decimal figure (1,275.00), the value transferred by function module CUOV_GET_FUNCTION_ARGUMENT must be converted to an integer. To do this, use the command ‘move value_num to value_int’.

If you want to use the value in calculations, it may be better to use the decimal figure, rather than convert the figure to an integer.

Characteristic names must be entered in upper case letters in code. Lower case characters are not converted automatically.

The ABAP command CONCATENATE links the characteristic values together to form a character string. Individual values are separated by hyphens. This character string is transferred to ID_CHAR. Function module CUOV_SET_FUNCTION_ARGUMENT returns the value for characteristic LABEL_ID and transfers this value to table MATCH.

The value ‘TW-586-1275’ is set for characteristic LABEL_ID in this configuration.

The code in the function module for the function is as follows:

Example of Code for Function Module Z_LABEL_ID

function Z_LABEL_ID.

*"----


""Local interface:

*" IMPORTING

*" VALUE(GLOBALS) LIKE CUOV_00 STRUCTURE CUOV_00

*" TABLES

*" QUERY STRUCTURE CUOV_01

*" MATCH STRUCTURE CUOV_01

*" EXCEPTIONS

*" FAIL

*" INTERNAL_ERROR

*"----


data: id_char like cuov_01-atwrt, for the result of the concatenation

value1 like cuov_01-atwrt, for the characteristic ‘CASING’

value2 like cuov_01-atwrt, for the characteristic ‘CPU’

value3_num like cuov_01-atflv, for the numeric characteristic ‘HD’

value3_int(4) type N

dash(1) type c value '-'.

..initialize table with export parameters.............................

refresh match.

*..get value of input characteristic CASING

call function 'CUOV_GET_FUNCTION_ARGUMENT'

exporting

argument = 'CASING'

importing

sym_val = value1

tables

query = query

exceptions

arg_not_found = 01.

if sy-subrc <> 0.

raise internal_error.

endif.

*..get value of input characteristic CPU

call function 'CUOV_GET_FUNCTION_ARGUMENT'

exporting

argument = 'CPU'

importing

sym_val = value2

tables

query = query

exceptions

arg_not_found = 01.

if sy-subrc <> 0.

raise internal_error.

endif.

*..get value of input characteristic HD

call function 'CUOV_GET_FUNCTION_ARGUMENT'

exporting

argument = 'HD'

importing

num_val = value3_num

tables

query = query

exceptions

arg_not_found = 01.

if sy-subrc <> 0.

raise internal_error.

endif.

*..all numeric characteristics would need to be

*..converted to integer fields, because the CUOV_GET_FUNCTION_ARGUMENT

*..delivers them as floats !

move value3_num to value3_int

*..do the concatenation

concatenate value1

dash

value2

dash

value3_int

into id_char.

*..add result to the table of output characteristics

call function 'CUOV_SET_FUNCTION_ARGUMENT'

exporting

argument = 'LABEL_ID'

vtype = 'CHAR'

sym_val = id_char

tables

match = match

exceptions

existing_value_replaced = 01.

endfunction.

Answers (3)

Answers (3)

Former Member
0 Kudos

This is possible using string operator ||,

like $self.x = $self.y || $self.z

just in case someone still wondering after 8 years.

br,

David

Former Member
0 Kudos

Hi manish,

Thanks for rewarding points.

Likewise please also reward suitable points for your previously initiated and answered threads.

Regards

Ram

Former Member
0 Kudos

code as follows:

concatenate $self.A $self.B into $self.C

Reward points and close the thread.

Rgds

Ram

Former Member
0 Kudos

Dear Sir,

I have entered the code with procedure, but the syntax error is comming as follows

Syntax error in simple action/procedure

Please can u review the code

The code is follows

concatenate $self.INORGCOATGSM $self.MATERIALTYPE into

$self.MATERIALTYPEANDGSM

Former Member
0 Kudos

I have entered the code with procedure, but the syntax error is comming as follows

Syntax error in simple action/procedure

Please can u review the code

The code is follows

concatenate $self.INORGCOATGSM $self.MATERIALTYPE into

$self.MATERIALTYPEANDGSM