‎2008 Mar 31 7:17 AM
Hi all,
I have a requirement wherein I have to concatenate some fields to get my new concatenated field.There are some blank records in the table i m taking data from.say like this
Columns: A B C D
DATA: 23 bhd g56
Column C is blank in this case n I want to concatenate A,B,C and D seperated by '-'
Now after concatenation output is 23-bhd--g56
I dnt want hyphen to cm for blank fields aswell
sud cm like this 2-bhd-g56
Is it possible?
‎2008 Mar 31 7:22 AM
add this statement after concatenate.
REPLACE ALL OCCURRENCES OF '--' IN:
text1 WITH '-'.
This will solve your problem.
‎2008 Mar 31 7:22 AM
add this statement after concatenate.
REPLACE ALL OCCURRENCES OF '--' IN:
text1 WITH '-'.
This will solve your problem.
‎2008 Mar 31 7:25 AM
Hi Bharath,
This will work if there is only one fields missing but wat if we two missing filds in continuation?
‎2008 Mar 31 7:32 AM
REPLACE ALL OCCURRENCES OF '--*' IN:
text1 WITH '-'
This will work.
‎2008 Mar 31 7:36 AM
After replace occurences statement use
CONDENSE text NO-GAPS.
‎2008 Mar 31 7:45 AM
It is working fine for previous replace code.but if i give '--*' it is not working for any of them
‎2008 Mar 31 8:25 AM
Hi,
Hope it will solve yer prob.
while sy-subrc = 0.
REPLACE ALL OCCURRENCES OF '--' IN text WITH '-'.
endwhile.
‎2008 Mar 31 8:37 AM
Thanx Shameem,it worked:)
one silly question- wat exactly sy-subrc does?
‎2008 Mar 31 9:01 AM
Hi,
It checks whether expression or statement or condition is successful or not
Return value set by the following ABAP statements. In general, a content of 0 means that the statement was executed without problems.
‎2008 Mar 31 7:23 AM
Hi,
before concatenating, check c is initial or not.
IF NOT c IS INITIAL.
CONCATENATE A B C D INTO NEW SEPARATED BY '-'.
ELSE.
CONCATENATE A B D INTO NEW SEPARATED BY '-'.
ENDIF.
‎2008 Mar 31 7:25 AM
Hi deepika...
Write the below code..
if a = space.
then do..
concatenate b '-' c '-' d .
endif.
if b = space.
then do..
concatenate a '-' c '-' d .
endif.
if c = space.
then do..
concatenate a '-'b '-' d .
endif.
if d = space.
then do..
concatenate a '-' b '-' c.
endif.
reward points always gives motivation....
‎2008 Mar 31 7:39 AM
Hi Deepika if you ABCD are the coulmns of internal table
you can use the code below:
LOOP AT p_final_table ASSIGNING <fs_record>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_buf = <fs_comp>.
CLEAR lf_buf.
ENDDO.
if not A is initial and not B is initial and not C is initial "<<<<<< look
CONCATENATE lf_line co_line_feed INTO lf_line sperated by '-'.
hope its helpful...
Edited by: Jackandjay on Mar 31, 2008 2:41 AM