2010 May 24 11:42 PM
Dear all,
I have a requirement mentioned below.
I have a internal table with columns
ZPER1
ZOPR2
ZOPR3.......TO ZOPR50
I want to concatenate all fields 1 to 50 in string. I want to avoid writting this 50 fields.
Is there any way we can do this?
Regards,
Vinit
2010 May 25 12:15 AM
Hi,
You can use field symbols, like:
DATA: W_TEXT(1000),
W_IDX TYPE I,
W_NN(2) TYPE C.
FIELD-SYMBOLS: <FS> TYPE ANY.
W_IDX = 1.
WHILE W_IDX<51.
W_NN = W_IDX.
W_XX = 'ZOPER'.
ASSIGN (W_XX) TO <FS>.
CONCATENATE W_TEXT <FS> INTO W_TEXT.
W_IDX = W_IDX + 1.
ENDWHILE.
Best regards,
Leandro Mengue
2010 May 25 12:06 AM
Hi,
DATA: BEGIN OF DATA_TAB,
ZPER1
...
ZOPR50
END OF DATA_TAB.
DATA: W_TEXT(1000) TYPE C.
...fill your fields and:
W_TEXT = DATA_TAB.
Best regards,
Leandro Mengue
2010 May 25 12:13 AM
Hi,
Thanks for u r reply.
The problem is I have other fields in my internal table as well other that 1 to 50 which i do not wish to concatenate.
2010 May 25 12:38 AM
Hi,
You may use also:
DATA: BEGIN OF DATA_TAB,
FIELD1
...
ZOPR1
...
ZOPR50
END OF DATA_TAB.
DATA: W_TEXT(1000) TYPE C,
W_POS TYPE I,
W_TAM TYPE I.
...fill your fields and:
DESCRIBE DISTANCE BETWEEN DATA_TAB-FIELD1 AND DATA_TAB-ZOPER1 INTO W_POS IN BYTE MODE.
W_TAM = 50 * 4. " => adjust 4 to the size of zopr1.
W_TEXT = DATA_TAB+W_POS(W_TAM).
Best regards,
Leandro Mengue
2010 May 25 12:41 AM
Really sorry,
Missed out on one point.
I want to concatenate separated by comma.
2010 May 25 12:42 AM
2010 May 25 12:43 AM
Hi,
No problem:
CONCATENATE W_TEXT <FS> ';' INTO W_TEXT.
Best regards,
Leandro Mengue
2010 May 25 12:15 AM
Hi,
You can use field symbols, like:
DATA: W_TEXT(1000),
W_IDX TYPE I,
W_NN(2) TYPE C.
FIELD-SYMBOLS: <FS> TYPE ANY.
W_IDX = 1.
WHILE W_IDX<51.
W_NN = W_IDX.
W_XX = 'ZOPER'.
ASSIGN (W_XX) TO <FS>.
CONCATENATE W_TEXT <FS> INTO W_TEXT.
W_IDX = W_IDX + 1.
ENDWHILE.
Best regards,
Leandro Mengue
2010 May 25 12:37 AM
Hi,
What is use of W_NN in your code? How I will change ZOPER1 then 2....to 50?
2010 May 25 12:40 AM
Hi,
Sorry, change this:
W_XX = 'ZOPER'.
by
CONCATENATE 'ZOPER' W_NN INTO W_XX.
Best regards,
Leandro Mengue