Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to create 'CSV' files with 'SAP_CONVERT_TO_TEXT_FORMAT'

former_member600549
Participant
0 Kudos

I am getting a dump when I use the functional call sometimes. Sometimes it works correctly.

       CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
         EXPORTING
              I_FIELD_SEPERATOR    = '|'
              "I_LINE_HEADER        = I_LINE_HEADER
              I_FILENAME           = fname
         TABLES
              I_TAB_SAP_DATA       = <fs_temp_data_standard>
         CHANGING
              I_TAB_CONVERTED_DATA = conv_data
         EXCEPTIONS
              CONVERSION_FAILED    = 1
              OTHERS               = 2.

2019-02-22-07-34-03-abap-runtime-errors.png

'In this case, the operand "op1" has the non-character-type "I". The current program is flagged as a Unicode program. In the Unicode context, type X fields are seen as non-character-type, as are structures that contain non-character-type components.'

How do I correct it, or should I build the csv files manually?

I wonder if this is related, I imported a table from memory into a table I made dynamically. This is the data I'm trying to convert. I wonder if a mismatch error were to happen and I ignore it it may cause problems later. When I remove 'IGNORING STRUCTURE BOUNDARIES' the import fails.

 IMPORT sel_tab TO <fs_data> ind_empty TO flag
   FROM MEMORY ID me->report_name IGNORING STRUCTURE BOUNDARIES.
1 ACCEPTED SOLUTION

matt
Active Contributor

I think you'll have to create the CSV manually as Simon suggests. To convert from numeric to character, WRITE is usually a good option. You need to know the types of each field, so that you can know when to use the field value directly, and when they might need converting to character. You can get this through RTTS.

10 REPLIES 10

SimoneMilesi
Active Contributor

The dump is self speaking: you need a table with all fields character type while you have a field (OP1?) type I.

If you use the table for more works/things, i'd choose to manually write the CSV file (not big deal nor hug work at all) so i avoid to create a specular table with all the fields char type

former_member600549
Participant
0 Kudos

I am dynamically creating this table, is there a way to change the fields after it is created?

raymond_giuseppi
Active Contributor

What's your SAP version, did you search and find a note such as 1855878 - Supplement to SAP_CONVERT_TO_TEX_FORMAT (where 'I' was added)

0 Kudos

I am using 4.6c

When you work on such an old version, it's better to provide this information in initial post 😉

0 Kudos

When I manually create the CSV files without using SAP_CONVERT_TO_TEX_FORMAT, the date fields and timestamp fields no longer have there format.

I want yyyy-mm-dd and HH:mm:ss, however the dashes and colons are only present if I use the function module, not if I create it manually. I guess i will look into the note for SAP_CONVERT_TO_TEX_FORMAT but I don't have hope it will work with such an old system.

matt
Active Contributor
0 Kudos

No. You can't.

matt
Active Contributor

I think you'll have to create the CSV manually as Simon suggests. To convert from numeric to character, WRITE is usually a good option. You need to know the types of each field, so that you can know when to use the field value directly, and when they might need converting to character. You can get this through RTTS.

Sandra_Rossi
Active Contributor

I just tested SAP_CONVERT_TO_TEX_FORMAT and it works "fine" for many types like X, P and F, only the type I was handled lately by note 1855878 as stated by Raymond. Anyway, this function module is not released to customers, so that's a good advice to write our own custom solution (and that's a simple algorithm so no excuse).

matt
Active Contributor

I've always written my own anyway - SAP_CONVERT_TO_TEX_FORMAT is an R/3 FM, not available in BW and other SAP systems.