2023 May 04 7:52 AM
Hi Experts,
I have a string which is separated by comma. However, I cannot use the SPLIT statement as the comma is used in denoting amounts as well, for e.g. "123,456,000" and also they are enclosed within quotes (please refer to the attachment). So when there are no values, they are filled with zero and separated by commas. But when there are values, it becomes complex to separate them and store them in an internal table in their respective columns. Any idea how it can be done ?
My internal table is declared as follows and I have to strore them inside the fields declared.
Regards,
Manish
BEGIN OF ty_interest_calc,<br> date(10),<br> fund_name(50),<br> cusip_isin(15),<br> acnt_no(10),<br> div_rate(13),<br> ded_rate(13),<br> daily_div(13),<br> mtd_div(10),<br> position_local(12),<br> fx_rate(1),<br> position_usd(12),<br> nav(1),<br> shares(12),<br> acnt_name(50),<br> curr(3),<br> company_name(20),<br> tax_id(10),<br> END OF ty_interest_calc.<br>
2023 May 04 8:12 AM
This looks like normal CSV format.
Try cl_rsda_csv_converter to read data from the string to your structure. There are many examples how to use this class 🙂
2023 May 04 8:12 AM
This looks like normal CSV format.
Try cl_rsda_csv_converter to read data from the string to your structure. There are many examples how to use this class 🙂
2023 May 04 8:34 AM
tomas.buryanek
Thanks for the tip with the class, Tomas! It might come in handy in the future!
Cheers
Bärbel
2023 May 04 9:53 AM
8b889d0e8e6f4ed39f6c58e35664518f You are welcome 🙂
By the way, I used this class quite many times already, and it was always helpful and without a problem.
2023 May 04 10:21 AM
2023 May 04 8:28 AM
Be careful to <br> tags in the code you posted. You may fix it via Actions > Edit. This is correct formatting:
TYPES : BEGIN OF ty_interest_calc,
date(10),
fund_name(50),
cusip_isin(15),
acnt_no(10),
div_rate(13),
ded_rate(13),
daily_div(13),
mtd_div(10),
position_local(12),
fx_rate(1),
position_usd(12),
nav(1),
shares(12),
acnt_name(50),
curr(3),
company_name(20),
tax_id(10),
END OF ty_interest_calc.
2023 May 04 8:29 AM
Also, you can show the image directly in your question (with just copy/paste)
2023 May 04 8:33 AM
manish.malakar0316
Hi Manish!
Do you have control over the string format and/or can request a change from "," to something rarely used in field content like e.g. "|"? This would be a lot easier than trying to wrestle with the variable nature of where a comma can show up.
A comma or even semi-colon are rarely a good option to use as a field delimiter because they tend to show up in user entered content or numbers as in your case.
Cheers
Bärbel