‎2012 Jan 26 2:22 PM
How can I concatenate the data where CUDC = 1. Sample data:
CUDC RECORD DATA
1 1 002232:2:1-002223:2:3-002346:2:2-002306:2:3-002314:6:8-002321:6:8-002346:6:6-002333:7:3-002433:8:3-
002433:9:3-002413:10:10-002435:10
1 2 :3-002431:19:3-002430:20:3-002431:21:3-002431:22:3
expected result
1 1 [0022]32:2:1-23:2:3-46:2:2-[0023]06:2:3-14:6:8-21:6:8-46:6:6-[0024]33:7:3-33:8:3-33:9:3-13:10:10-35:10:3-
31:19:3-30:20:3-31:21:3-31:22:3
thanks in advance.
Edited by: kapishr on Jan 26, 2012 3:22 PM
‎2012 Jan 26 2:36 PM
let itab1 and itab2 both be copies of same data.
sort itab1 by cudc and delete adjacent duplicates comparing cudc.
loop at itab1.
loop at itab2 where cudc = itab1-cudc.
concatenate itab1-record itab2-record to itab1-record.
endloop.
modify itab1. or use field symbols.
endloop.above code is psuedocode, check respective syntaxes while implementing.
‎2012 Jan 26 2:36 PM
let itab1 and itab2 both be copies of same data.
sort itab1 by cudc and delete adjacent duplicates comparing cudc.
loop at itab1.
loop at itab2 where cudc = itab1-cudc.
concatenate itab1-record itab2-record to itab1-record.
endloop.
modify itab1. or use field symbols.
endloop.above code is psuedocode, check respective syntaxes while implementing.
‎2012 Jan 26 2:48 PM
‎2012 Jan 26 3:40 PM
The three column of internal table are CUDC RECORD and DATA
CUDC
1
1
2
2
3
RECORD
1
2
1
2
1
Data
002232:2:1-002223:2:3-002346:2:2-002306:2:3-002314:6:8-002321:6:8-002346:6:6-002333:7:3-002433:8:3-002433:9:3-002413:10:10-002435:10
:3-002431:19:3-002430:20:3-002431:21:3-002431:22:3
002232:2:1-002223:2:3-002346:2:2-002306:2:3-002314:6:8-002321:6:8-002346:6:6-002333:7:3-002433:8:3-002433:9:3-002413:10:10-002435:10
:3-002431:19:3-002430:20:3-002431:21:3-002431:22:3:002431:19:3-000030:20:3-0000031:21:3-000031:22:3:000031:19:3-000030:20:3-000031:21:3
002431:19:3-002430:20:3-002431:21:3-002431:22:3
I have to concatenate the data based on CUDC and sort the record column accordingly
Thanks and regards
Edited by: kapishr on Jan 26, 2012 4:43 PM
Edited by: Rob Burbank on Jan 26, 2012 11:47 AM
‎2012 Jan 27 3:43 AM
Assuming the DATA has a field length of 20, and for each CUDC. its corresponding DATA has values of maximum 20... Therefore, may I ask how should your concatenated result be like?
I simplify your internal table as such(using ~ as delimiter), correct me if I'm wrong
CUDC(x1)RECORD(x1)DATA(x6)
11AAAAA
12BBBBBB
21CCCCCC
22DDDDDD
31EEEEEE
Using the above example, please explain how should the result be?
Edited by: bloodcool on Jan 27, 2012 11:44 AM
‎2012 Jan 27 6:22 AM
Hello Kapishr,
Here is a code you can use :
data : wa_tab like line of itab, "work area of your itab.
temp1(50) type c, "itab - your internal table that is containing above fields.
temp2(50) type c, "assuming data length can not be more than 50 chars.
"
"
tempn(50) type c.
Loop at itab into wa_tab.
Case wa_tab-CUDC.
When '1'
Concatenate temp1 wa_tab-DATA into temp1.
When '2'
Concatenate temp2 wa_tab-DATA into temp2.
"
"
"
When 'n'
Concatenate tempn wa_tab-DATA into tempn.
Endcase.
Endloop.After using above code you can use temp1-temp2-......tempn data wherever you want.
Kind Regards,
Kerim.
Edited by: Kerim Merih Kılıç on Jan 27, 2012 7:23 AM
‎2012 Jan 27 6:39 AM
Thanks for helping me, I am new to programming and so I m having trouble explaining..
This is the data that I have
CUDCRECORDDATA~LENGTH
11002232:2:1-002223:2:3-002246:2:2-002306:2:3-002314:6:8-002321:6:8-002346:6:6-002433:7:3-002433:8:3-002433:9:3-002413:10:10-002435:10~132
12:3-002431:19:3-002430:20:3-002431:21:3-002431:22:3~50
21002232:2:1-002223:2:3-002246:2:2-002306:2:3-002314:6:8-002321:6:8-002346:6:6-002433:7:3-002433:8:3-002433:9:3-002413:10:10-002435:10~length
22:3-002431:19:3-002430:20:3-002431:21:3-002431:22:3-002431:19:3-000030:20:3-0000031:21:3-000031:22:3:000031:19:3-000030:20:3-000031:21:3~length
31002431:19:3-002430:20:3-002431:21:3-002431:22:3~length
Required output
CUDCRECORDDATA~LENGTH
11(0022)32:2:1-23:2:3-46:2:2-(0023)06:2:3-14:6:8-21:6:8-46:6:6-(0024)33:7:3-33:8:3-33:9:3-13:10:10-35:10:3-31:19:3-30:20:3-31:21:3-31:22:3~102
21(0022)32:2:1-23:2:3-46:2:2-(0023)06:2:3-14:6:8-21:6:8-46:6:6-(0024)33:7:3-33:8:3-33:9:3-13:10:10-35:10:3-31:19:3-30:20:3-31:21:3-31:22:3-31:19:3-(0000)30:20:3-31:21:3-31:22:3-31:19:3-30:20:3-31:21:3~length
31(0024)31:19:3-30:20:3-31:21:3-21:22:3~length
the length at end of each row is for calculating the length of the data
The first six digits is for time hhmmss,
I need to club (hhmm)ss-ss... and so on and club the records based on CUDC as well.
the digits after colon( is not to be analysed.
thanks and regards.
‎2012 Jan 27 6:43 AM
You can use the code I wrote above.
temp1-temp2-temp3 contains data that you want. If you don't want to concatenate data after ':' then you can take the part before it:.(ie concatenate tempx itab-DATA+6 into tempx)
Kind Regards,
Kerim.
‎2012 Jan 30 9:38 AM
you need to first breakdown data table into another internal table, before merging them back.
for identification sake, i named the table as below:
- CUDC_DATA, your original table
- CUDC_BREAKDOWN, the breakdown data table
- CUDC_RESULT, result table
1) Concatenate the DATA for each set of CUDC from CUDC_DATA table into a string variable (e.g. tmpstring)
2) Process each CUDC's tmpstring into CUDC_BREAKDOWN where you should
- get every single group of hhmmss:xx:xx, the delimiter should be '-'. Use SPLIT function
- break the group to 2 different fields, where the 1st 4 char(HHMM) is field #1, and the remaining field #2
- append the current CUDC value, field #1 and field #2 into CUDC_BREAKDOWN
3) Repeat the process until all CUDC's DATA has been breakdown into CUDC
Now, you should merge back the data back to CUDC_RESULT, from CUDC_BREAKDOWN table
4) For every CUDC, it would indicate a start of a new record
5) For each new set of field #1 encountered, concatenate the HHMM value to the data field in CUDC_RESULT
6) Then concatenate every field #2 to the data field in CUDC_RESULT
7) Do until all CUDC are completed.