2009 Sep 10 9:09 AM
Hi Experts,
I am trying to upload CSV file into SAP it is working fine,
File format:
Test,12333,"Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS ",7373737
Problem:
When i am trying to SPLIT with ',' it is taking 3 column "Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS" into diff-diff columns but my requirement is i want file data into 4 fields of internal table.
-Rajneesh Gupta
Hi Experts,
I am trying to upload CSV file into SAP it is working fine,
File format:
Test,12333,"Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS ",7373737
Problem:
When i am trying to SPLIT with ',' it is taking 3 column "Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS" into diff-diff columns but my requirement is i want file data into 4 fields of internal table.
-Rajneesh Gupta
2009 Sep 10 9:13 AM
Hi, maybe split the line into workfields, fill the table with the workfields and append the line. Succes
2009 Sep 10 9:18 AM
>
> Test,12333,"Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS ",7373737
Hi,
Then you should not give comma inside "Reg. Organisational Development Delegate, TEST TEST, HFHFHFHF, JKSDFAS ", use some other delimiter inside double quotes.
Regards
Karthik D
2009 Sep 10 9:29 AM
Hi Karthik D,
I have file in this format only, this i have given a example.
-Rajneesh
2009 Sep 10 9:39 AM
Hi,
First split the file into a string variable.
Concatenate the required fileds and then move it into fieldstring and then append to the internal table.
Or split first all into six columns ,then concatenate 3, 4, 5 fields into a variable and then populate into 4 columned internal table
2009 Sep 10 9:42 AM
Hi Sreesudha Gulla,
You are talking about the static solution, but that is not the case, i don't know in which column i will get the situation.
-Rajneesh
2009 Sep 10 10:37 AM
Hi Rajneesh,
I too had the same problem some months before.
c the link below. it solved my problem. in mean time i search for my code in prog and send u.
check my code.
loop at gt_raw into gwa_raw.
if sy-tabix > 1.
split gwa_raw at ',' into table gt_string.
describe table gt_string lines gv_fields.
* If extra commas: field count higher than actual field count
if gv_fields > 10.
perform f_reassemble.
endif.
loop at gt_string into gwa_string.
replace all occurrences of '"' in gwa_string with ''.
case sy-tabix.
when 1.
gwa_cust-cust_code = gwa_string.
when 2.
gwa_cust-cust_name = gwa_string.
when 3.
:
:
when 10.
gwa_cust-osc_code = gwa_string.
endcase.
endloop.
append gwa_cust to gt_cust.
clear: gwa_cust.
endif.
endloop.
form f_reassemble .
data: lastpos type i,
lastchar type c,
currtoken type sy-tabix,
nexttoken type sy-tabix,
gwa_next type string.
loop at gt_string into gwa_string.
lastpos = strlen( gwa_string ) - 1.
lastchar = gwa_string+lastpos(1).
* field starts with quote but does not end with one =>
* must merge with the next field
if gwa_string+0(1) = '"' and lastchar ne '"'.
currtoken = sy-tabix.
nexttoken = sy-tabix + 1.
read table gt_string into gwa_next index nexttoken.
concatenate gwa_string gwa_next into gwa_string separated by ','.
modify gt_string from gwa_string index currtoken.
delete gt_string index nexttoken.
endif.
endloop.
endform. " f_reassembleRegards,
Sakthi.
Edited by: sakthi sri on Sep 10, 2009 5:42 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |