2008 Jul 13 1:34 PM
hi, if the material number is with numbers, for example, 1000000001, we can use FM CONVERSION_EXIT_ALPHA_INPUT to add the leading zeros to make the material to 18 char.
But if the material number is with character, how should I make it to 18 char.
I need to CONCATENATE MATNR VKORG VTWEG INTO V_NAME. But the MATNR must be 18 char. Many thanks in advance!
2008 Jul 13 1:51 PM
1st convert the material to 18 char by using FM
CONVERSION_EXIT_MATN1_INPUT.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = matnr
IMPORTING
OUTPUT = matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
Than use the material for concatenation purpose...
CONCATENATE MATNR VKORG VTWEG INTO V_NAME.
Regards,
joy.
1st convert the material to 18 char by using FM
CONVERSION_EXIT_MATN1_INPUT.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = matnr
IMPORTING
OUTPUT = matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
Than use the material for concatenation purpose...
CONCATENATE MATNR VKORG VTWEG INTO V_NAME.
Regards,
joy.
2008 Jul 13 1:51 PM
1st convert the material to 18 char by using FM
CONVERSION_EXIT_MATN1_INPUT.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = matnr
IMPORTING
OUTPUT = matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
Than use the material for concatenation purpose...
CONCATENATE MATNR VKORG VTWEG INTO V_NAME.
Regards,
joy.
2008 Jul 13 2:04 PM
it is not OK, maybe the concatenate ignore the spaces....so can anyone tell how should i do to keep the spaces?
2008 Jul 13 2:15 PM
Ok..try this...
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = matnr
IMPORTING
OUTPUT = matnr
EXCEPTIONS
LENGTH_ERROR = 1
OTHERS = 2
.
IF sy-subrc 0.
ENDIF.
CONSTANTS: c_space TYPE syhex02 VALUE '00a0'. " Value for space
DATA: g_space TYPE string,
l_pos type i,
l_pos1 type i.
Get the actual value for a space*
g_space = cl_abap_conv_in_ce=>uccp( c_space ).
L_pos = strlen( matnr ).
l_pos1 = 18 - l_pos.
Do l_pos1 times.
matnr+l_pos(1) = g_space.
L_pos = l_pos + 1.
Enddo.
Than use the material for concatenation purpose...
CONCATENATE MATNR VKORG VTWEG INTO V_NAME.
By this way u can keep the trailing spaces...
Regards,
Joy.
2008 Jul 13 2:29 PM
2008 Jul 13 2:32 PM
It is OK..here # represents trailing space. Just to confirm that take a download of that concatenated value..u will find that # is replaced by space..pl. check..
Regards,
Joy.
2008 Jul 13 3:21 PM
oh, i tried, it's not OK, i want to use the V_NAME to read the sales text in FM READ_TEXT.
For example, matnr: R999-100
VKORG : 0001
VTWEG : 01
The v_name must be 'R999-100 000101', it can't be 'R999-100##########000101'
2008 Jul 13 3:28 PM
Ok. then try this solution..
DATA: g_space TYPE string,
l_pos type i,
l_pos1 type i.
L_pos = strlen( matnr ).
l_pos1 = 18 - l_pos.
Do l_pos1 times.
matnr+l_pos(1) = '#'.
L_pos = l_pos + 1.
Enddo.
Than use the material for concatenation purpose...
CONCATENATE MATNR VKORG VTWEG INTO V_NAME.
Replace ALL OCCURRENCES of '#' in v_name with space in CHARACTER MODE.
Regards,
Joy.
2008 Jul 14 5:37 AM
Hi,
If u dont want leading zeros then u can directly use concatenate statement.
CONCATENATE material sales org distribution channel INTO v_name.
If u want the trailing blanks the u have to do like this.
MOVE matnr TO v_name.
v_name+18(4) = sales org.
v_name+22(3) = distribution channel.
This will keep the trailing blanks. U can arrange the exact position as per ur req.
Thanks,
Vinod.
2008 Jul 13 2:00 PM
Hi Check below sample code. U can replace sales org and dist channel with ur varaibles.
DATA: l_matnr TYPE mara-matnr VALUE 'AWE465464654',
l_len TYPE i,
l_string TYPE string.
CONSTANTS: c_vkorg TYPE vbak-vkorg VALUE '3CR',
c_vtweg TYPE vbak-vtweg VALUE '01'.
WRITE l_matnr.
l_len = 18 - strlen( l_matnr ).
DO l_len TIMES.
CONCATENATE '0' l_matnr INTO l_matnr.
ENDDO.
CONCATENATE l_matnr c_vkorg c_vtweg INTO l_string.
WRITE l_string.
Thanks,
Vinod.
2008 Jul 13 2:06 PM
Hi, adding leading zeros is not right, the material number with char. is with the spaces at the end of strings.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |