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

Problem with concatenate .

Former Member
0 Likes
846

Hi,

Please check this code....

LOOP AT IT_USER_UPLOAD INTO WA_USER_UPLOAD.

L_LENGTH = STRLEN( WA_USER_UPLOAD-BP_CODE ).

L_COUNT = 7 - L_LENGTH.

DO L_COUNT TIMES.

CONCATENATE C_CODE_Z WA_USER_UPLOAD-BP_CODE INTO C_USERID.

ENDDO.

ENDLOOP.

My value like this ...

Wa_user_upload = 123

C_code = 0

My result is 0123 but i want 0000123 pls help me how it is possible.

Ans will be rewarded by points.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
827

Hi,

for output as you needed, please add this code also :

<b>CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = c_userid

IMPORTING

OUTPUT = c_userid.</b>

I hope, it can help you

Reward points, if helpful,

Sandeep Kaushik

9 REPLIES 9
Read only

Former Member
0 Likes
827

hi,

try by givining c_code = 0000.

thanks

Read only

Former Member
0 Likes
827

use UNPACK statement.

Sameer

Read only

Former Member
0 Likes
827

Hi Gurprit,

Make C_USERID as NUMC 7 and use UNPACK command after moving values.

LOOP AT IT_USER_UPLOAD INTO WA_USER_UPLOAD.

L_LENGTH = STRLEN( WA_USER_UPLOAD-BP_CODE ).

L_COUNT = 7 - L_LENGTH.

DO L_COUNT TIMES.

CONCATENATE C_CODE_Z WA_USER_UPLOAD-BP_CODE INTO C_USERID.

UNPACK C_USRID.

ENDDO.

Regards,

Hemant

Read only

Former Member
0 Likes
828

Hi,

for output as you needed, please add this code also :

<b>CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = c_userid

IMPORTING

OUTPUT = c_userid.</b>

I hope, it can help you

Reward points, if helpful,

Sandeep Kaushik

Read only

Former Member
0 Likes
827

Hi,

Take the field C_CODE_Z as Numeric length 4

Regards

Sudheer

Read only

Former Member
0 Likes
827

Hi,

I think you can do it this way:

Let the max count = 7 be in variable.

lv_max = 7.

lv_diff = lv_max - lv_length.

if lv_length = lv_max.

c_userid = WA_USER_UPLOAD-BP_CODE.

else.

lv_index = lv_index + 1.

while lv_index LE lv_diff.

concatenate C_CODE_Z WA_USER_UPLOAD-BP_CODE INTO C_USERID.

lv_index = lv_index + 1.

endwhile.

Please remember to clear the lv_index field once you are done and you want to start afresh.

Hope it was useful.

Thanks,

Sandeep.

Read only

Former Member
0 Likes
827

if

WA_USER_UPLOAD-BP_CODE

is of type Charecter.....

then use

function module

CONVERSION_EXIT_ALPHA_INPUT

<b>Sample code....</b>

data a(5) type c.

a = '123'.

write 😕 a.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = a

IMPORTING

OUTPUT = a .

write 😕 a.

Regards

vasu

Read only

0 Likes
827

Hi,

the problem is:

youe have to do it in 2 steps:

if l_count > 0.
CONCATENATE C_CODE_Z WA_USER_UPLOAD-BP_CODE INTO C_USERID.
endif.
l_count = l_count - 1.
do l_count times.
CONCATENATE C_CODE_Z C_USERID INTO C_USERID.
enddo.

or in one step.


C_USERID = WA_USER_UPLOAD-BP_CODE.
do l_count times.
CONCATENATE C_CODE_Z C_USERID INTO C_USERID.
enddo.

regards,

Gianpietro

Read only

Former Member
0 Likes
827

Hi,

Use the below coding,

DATA: BEGIN OF itab OCCURS 0,

c1(7) TYPE c,

END OF itab.

DATA: temp TYPE c VALUE '0',

l1 TYPE i,

count TYPE i.

DATA: t1(7) TYPE c.

itab-c1 = '111'.

APPEND itab.

itab-c1 = '22'.

APPEND itab.

itab-c1 = '333'.

APPEND itab.

LOOP AT itab.

t1 = itab-c1.

l1 = STRLEN( t1 ).

count = 7 - l1.

CLEAR itab-c1.

WHILE count > 0.

count = count - 1.

CONCATENATE temp itab-c1 INTO itab-c1.

ENDWHILE.

CONCATENATE itab-c1 t1 INTO itab-c1.

WRITE:/ itab-c1.

ENDLOOP.