2019 Dec 03 9:40 AM
Hello, I need to convert a structure with some amount fields to a char like field, and then do the opposite.
I can convert the structure to a cfield with this:
DATA: lv_content TYPE asafbtabcontent,
lo_record TYPE REF TO data.
GET REFERENCE OF ls_my_str INTO lo_record.
PERFORM record_to_cfield IN PROGRAM saplas_afb USING lo_record CHANGING lv_content.
But, how to do the opposite?
Abap 731.
Trying something like this, but values are wrong.
FIELD-SYMBOLS:
<ls_my_str> TYPE zz_my_str.
ASSIGN lv_content TO <ls_my_str> CASTING. "HANDLE lo_TYPEDESCR.
IF sy-subrc EQ 0.
ls_my_str = <ls_my_str>.
ENDIF.
I seem to remember that there was a FM or METHOD * CONTAINER * to do this conversions, but don't remember the name.
Any clue?
Thanks
Hello, I need to convert a structure with some amount fields to a char like field, and then do the opposite.
I can convert the structure to a cfield with this:
DATA: lv_content TYPE asafbtabcontent,
lo_record TYPE REF TO data.
GET REFERENCE OF ls_my_str INTO lo_record.
PERFORM record_to_cfield IN PROGRAM saplas_afb USING lo_record CHANGING lv_content.
But, how to do the opposite?
Abap 731.
Trying something like this, but values are wrong.
FIELD-SYMBOLS:
<ls_my_str> TYPE zz_my_str.
ASSIGN lv_content TO <ls_my_str> CASTING. "HANDLE lo_TYPEDESCR.
IF sy-subrc EQ 0.
ls_my_str = <ls_my_str>.
ENDIF.
I seem to remember that there was a FM or METHOD * CONTAINER * to do this conversions, but don't remember the name.
Any clue?
Thanks
2019 Dec 03 9:50 AM
Is this class what you are looking for?
CL_ABAP_CONTAINER_UTILITIES
2019 Dec 03 10:16 AM
2019 Dec 03 10:02 AM
2019 Dec 03 12:08 PM
Just to comment that using external performs is bad practice (as is using PERFORMs since they're considered obsolete now).
2019 Dec 03 5:38 PM
I have a problem with the class CL_ABAP_CONTAINER_UTILITIES.
I've created a report to save the data from a table into a txt file.
If I read the downloaded file in the same system I can read and convert the data to the structure type correctly.
But I'm trying to read this file in other system, and in this other system the method READ_CONTAINER_C is not working fine. Returns wrong data and strange characters.
Do you know what can be the problem?
Version of first system; 731 and second system; 75D S4/HANA.
Code of the method READ_CONTAINER_C in both systems is the same.
Any clue?
2019 Dec 03 8:14 PM
CL_ABAP_CONTAINER_UTILITIES is only a temporary solution when you convert a system from Non-Unicode to Unicode. In non-unicode programs, structures with packed fields could be transferred to character fields. It's considered incorrect practice since Unicode (it's not really connected to Unicode, it's just that it was a good occasion to clean ABAP code). If you want to transfer data in a standardized way, please use JSON or XML (it could be done via data clusters too, with the classes CL_ABAP_EXPIMP* (which support internal formats of several kernel versions), but I don't like it because it's a SAP proprietary method).
2019 Dec 03 5:39 PM
Thanks Matthew, It's was only a try.
I'll try to use OO in the future and not use PERFORMs any more.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |