Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Concatenation problem

Former Member
0 Likes
1,578

The object key is a combination of matnr werks charg (18 + 4 + 10) All fields should be left justified and filled with blank to the right to get objek. How to do this?

matnr = '0236.0260'.
werks = 'P002'.
charg = '0100220048'

objek = '0236.0260        P0020100220048'.

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
1,481

Hi,

Please try this.


DATA: MATNR TYPE MCHA-MATNR,
      WERKS TYPE MCHA-WERKS,
      CHARG TYPE MCHA-CHARG,
      OBJEK TYPE CHAR40.

MATNR = '0236.0260'.
WERKS = 'P002'.
CHARG = '0100220048'.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    INPUT  = MATNR
  IMPORTING
    OUTPUT = MATNR.
                                                 
MOVE: MATNR TO OBJEK(18),
      WERKS TO OBJEK+18(4),
      CHARG TO OBJEK+22(10).
                                   
WRITE OBJEK.

Regards,

Ferry Lianto

11 REPLIES 11
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,481

Define a internal structure with the 3 fields.

DATA: BEGIN OF concat,
  matnr TYPE matnr,
  werks TYPE werks_d,
  charg TYPE charg_d,
END OF concat..

Then just move the fields.

Regards

Read only

Former Member
0 Likes
1,481

Hi Megan,

Before doing the concatenation do the conversion of each field using the Conversion routines and do concatenation.

<b>Reward for Helpful answers</b>

-Satish

Read only

Former Member
0 Likes
1,481
DATA: BEGIN OF w_tdname,
        matnr TYPE mcha-matnr,
        werks TYPE mcha-werks,
        charg TYPE mcha-charg,
      END OF w_tdname.
DATA: objek TYPE char40,
w_tdname-matnr = '0236.0260'.
w_tdname-werks = 'P002'.
w_tdname-charg = '0100220048'.
CONCATENATE w_tdname-matnr w_tdname-werks w_tdname-charg INTO objek.
WRITE:/ objek.

This returns 236.0\260P0020100220048

Read only

Former Member
0 Likes
1,481

Hi

Here u can try like this

concatenate it_matnr it_werks ' ' it_charg.

U can define number of spaces to left also here

<b><u>

Note:</u></b> Here It_matnr, werks, charg are innternal table fields

or try like this also

SCROLL LIST RIGHT.

Check this sample you can do like this also

DATA: ALPHA1(10) TYPE C VALUE 'ABCDEFGHIJ', 
      ALPHA2(12) TYPE C, 
      ALPHA3     TYPE STRING. 
ALPHA3 = ALPHA2 = ALPHA1. 
SHIFT ALPHA1 RIGHT. 
SHIFT ALPHA2 RIGHT. 
SHIFT ALPHA3 RIGHT. 

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

Read only

Former Member
0 Likes
1,481

Hi,

Use the CONVERSION_EXIT_ALPHA_INPUT for matnr, Werks and Chanrg before doing the concatinate

Concatinate MATNR WERKS CHARG into OBJEK

Regards

Sudheer

Read only

0 Likes
1,481

This does not work!!

I need objek to be 0236.0\260 P0020100220048

DATA: BEGIN OF w_tdname,

matnr TYPE mcha-matnr,

werks TYPE mcha-werks,

charg TYPE mcha-charg,

END OF w_tdname.

DATA: objek TYPE char40.

w_tdname-matnr = '0236.0\260'.

w_tdname-werks = 'P002'.

w_tdname-charg = '0100220048'.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_tdname-matnr

IMPORTING

output = w_tdname-matnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_tdname-werks

IMPORTING

output = w_tdname-werks.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_tdname-charg

IMPORTING

output = w_tdname-charg.

CONCATENATE w_tdname-matnr w_tdname-werks w_tdname-charg INTO objek.

CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'

Message was edited by:

Megan Flores

Read only

Former Member
0 Likes
1,481


data:  objkey type string.
concatenate matnr werks charg into obkey RESPECTING BLANKS.

OBKEY should be of type string..

If u want it to be of type C.. then take another variable.

DATA: V_OBKEY(32) type C.

V_OBKEY = OBJKEY.

Reward for useful answer

regards

Pradeep

Read only

Former Member
0 Likes
1,481

Hi,

Here is the Sulution

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' " this is for material

EXPORTING

input = w_tdname-matnr

IMPORTING

output = w_tdname-matnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_tdname-werks

IMPORTING

output = w_tdname-werks.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_tdname-charg

IMPORTING

output = w_tdname-charg.

CONCATENATE w_tdname-matnr w_tdname-werks w_tdname-charg INTO objek.

Read only

Former Member
0 Likes
1,481

Check this code ;


DATA:  l_matnr(18) TYPE c,
       l_werks(4) TYPE c,
       l_charg(10) TYPE c,
       st_obkey TYPE string,
       l_obkey(32) TYPE c.

l_matnr = '0236.0260'.
l_werks = 'P002'.
l_charg = '0100220048'.

CONCATENATE l_matnr l_werks l_charg INTO st_obkey RESPECTING BLANKS.
l_obkey = st_obkey.

WRITE:/ l_obkey.

Reward for useful Answer

Regards

Pradeep

Read only

0 Likes
1,481

Respecting Blanks is giving me an error

DATA: l_matnr(18) TYPE c,
      l_werks(4) TYPE c,
      l_charg(10) TYPE c,
      st_obkey TYPE string,
      l_obkey(32) TYPE c.

l_matnr = '0236.0260'.
l_werks = 'P002'.
l_charg = '0100220048'.

CONCATENATE l_matnr l_werks l_charg INTO st_obkey respecting blanks.

l_obkey = st_obkey.

WRITE:/ l_obkey.

Read only

ferry_lianto
Active Contributor
0 Likes
1,482

Hi,

Please try this.


DATA: MATNR TYPE MCHA-MATNR,
      WERKS TYPE MCHA-WERKS,
      CHARG TYPE MCHA-CHARG,
      OBJEK TYPE CHAR40.

MATNR = '0236.0260'.
WERKS = 'P002'.
CHARG = '0100220048'.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    INPUT  = MATNR
  IMPORTING
    OUTPUT = MATNR.
                                                 
MOVE: MATNR TO OBJEK(18),
      WERKS TO OBJEK+18(4),
      CHARG TO OBJEK+22(10).
                                   
WRITE OBJEK.

Regards,

Ferry Lianto