08-29-2014 8:32 AM
Dear Experts,
I use 'GUI_UPLOAD' for uploading of the CSV-File into my ALV and I need that whatever information this list contains, only numbers (well no letters)
will be uploaded into the grid.
My current code for uploading looks following:
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename
filetype = 'ASC'
TABLES
data_tab = ta_csv_data.
LOOP AT ta_csv_data INTO v_string.
IF sy-tabix = 1.
CONTINUE.
ENDIF.
SPLIT v_string AT ';'
INTO
wa_csv-vkorg
wa_csv-matnr
wa_csv-preis.
APPEND wa_csv TO ta_csv.
CLEAR wa_csv.
Is this somehow possible?
Thank you in advance
BR, Denis
08-29-2014 9:41 AM
Thank Simone, Klaus for your feedbacks,
but I don't understand how declaring of the field WA_CSV-PREIS as a character, will help me to avoid the uploadning of the letters?
BR
Denis
08-29-2014 8:37 AM
Hi,
either your field catalog has wrong definitions, or your wa_csv fields are defined numeric instead of alpha.
Regards,
Klaus
08-29-2014 8:39 AM
08-29-2014 8:45 AM
Hi Simone.
ta_csv_data TYPE STANDARD TABLE OF zst_preisupload
ta_csv TYPE STANDARD TABLE OF zst_preisupload
Structure zst_preisupload:
UPDATE: actually I need the number only for Prices, but the Datatyp is already CURR...
08-29-2014 8:52 AM
First of all (not related to your issue, but maybe....): why you split at ';' if you are uploading data into an internal table with the correct structure?
WA_CSV how it's declared?
My suggestion
DATA: ta_csv_data type table of string,
wa_csv should be a full char structure
vkorg type vkorg,
matnr type matnr,
preis (10)
->upload ta_csv_data as now
loop at ta_csv_data into lv_string
split as now into wa_csv
move-corresponding wa_csv to TA_CSV
append ta_csv.
endloop
08-29-2014 8:54 AM
Hi,
how are the WA_CSV fields defined?
WA_CSV-PREIS must be a character type for upload. After upload you may convert it to currency type.
Regards,
Klaus
08-29-2014 8:56 AM
Thank you for fast feedbac, Simone,
well without spliting the information will be written just as a string.
I have declared WA_CSV following:
wa_csv LIKE LINE OF ta_csv
.
08-29-2014 9:00 AM
As stated also by Klaus, if you use split, you have to declare DESTINATION FIELDS type char.
IF you have separators, then TA_CSV_TAB should not be declare like your structure: look at it, the Zstructure got no separator!
08-29-2014 9:41 AM
Thank Simone, Klaus for your feedbacks,
but I don't understand how declaring of the field WA_CSV-PREIS as a character, will help me to avoid the uploadning of the letters?
BR
Denis
08-29-2014 9:45 AM
Sorry, i completly misunderstood the request.
You got your data correctly uploaded then and want to remove all non numeric characters?
08-29-2014 9:52 AM
No problem, may be I should describe it more clear.
Yes, the data are uploaded and look good and yes I want to remove all non numeric characters
08-29-2014 9:57 AM
From here
DATA lv_text TYPE string VALUE 'ab000cdeSDFf34534gh1ASDF234ijk5abc0'.
WRITE : /,'Before Replace :',lv_text. REPLACE ALL OCCURRENCES OF REGEX '[[:alpha:]]' IN lv_text WITH ''.
WRITE : /,'After Replace :',lv_text.
Output: Before Replace : ab000cdeSDFf34534gh1ASDF234ijk5abc0 7
After Replace : 00034534123450
[[:alpha:]]
specifies any alphabet in lower or upper case.
Remember that there is no space between the single quotes in the WITH clause.
You have to do it for your char fields
08-29-2014 10:36 AM
There can be other non-numeric characters like special character, which will not be removed when you remove all alphabets. Instead, you should replace all occurrences of regex '\D' which means anything which is not '\d', which means non-numeric characters.
08-29-2014 10:54 AM
Thank you for the advise, Manish. I already was thoinking how to solve it in term also to avoid special characters, but when I use
REPLACE ALL OCCURRENCES OF REGEX '\D' IN v_string WITH ''
for some reason happening following:
Excel: ALV:
is there may be some possibility to replace ALL but not REGEX [digit] ?
08-29-2014 11:13 AM
Hi, Denis!
Have you tried to shorten the file for uploading and debugging thorougthly what's happening there?
is there may be some possibility to replace ALL but not REGEX [digit] ?
It seems to me that "\D" regex should do exactly that trick.
You can check the document for description of some more regular expressions.
08-29-2014 12:53 PM
Your delimiter is also getting deleted when \D (non-numeric) is used. So instead of deleting all '\D', you can apply negation and delete all '[^\d;]' , assuming semicolon ; is your field separator. I haven't tested it but I think it will work fine.
In case it doesn't work, post the non-working code here.
08-29-2014 12:57 PM
Now I kow what the problem is about.
in my string I do split by ';' and it also will be replaced by " "...
Could it be possible to make exaption for ";" somehow?
08-29-2014 1:01 PM
Thank you Manish!
Small question: and what, when I'd like to do 2 exaptions: for ; and for , ?
It's possible?
08-29-2014 1:07 PM
Yes, it is possible. Big brackets [ ] define a set. [abc] means it would match either a or b or c.
[^abc] would match anything other than a or b or c as negation operator ^ is used.
In your case, \d is digit and semicolon is also part of negation set. To add comma to it, use '[^\d;,]'
08-29-2014 1:09 PM