2016 Mar 02 9:08 PM
Hello all,
I'm working on NW7.5.
As I understand from the documentation, the new CORRESPONDING statement works based on components or fields.
I have a BAPI returning values in a table as a character-like sequence:
IT-VALUEPART1(240)
IT-VALUEPART2(240)
IT-VALUEPART3(240)
IT-VALUEPART4(240)
If the first 240 characters for VALUEPART1 are filled, keeps ongoing with VALUEPART2 and so on. It can even fill up all of them and start over the process by adding a new line to the table.
The information needs to be moved to a proper field structure. The way I would approach this is by looping through the components of the target structure and matching the relevant character portions.
Is there any way the new CORRESPONDING or CL_ABAP_CORRESPONDING can help me here?
Kind regards,
Andres.
2016 Mar 03 2:31 PM
I am not sure what exactly is the content of the valuepart fields, can you give an example?
I assume something in there like: 'field1 = value1, field2 = value2', and you have a target structure with fields field1 and field 2, and want to store value1 and value 2 in there?
If this is the case, i don't think CORRESPONDING can help. In all its forms, it just compares field names, never the stored values.
regards,
Thomas
2016 Mar 06 9:19 PM
Hi Thomas, thanks for your response.
It would be:
field1 = valuepart1(2)
field2 = valuepart1+2(10)
field3 = valuepart1+10(1)
field4 = valuepart1+11(3)
So characters of VALUEPART# is broken down into the target structure with meaningful fields.
I don't think it can be solved by CORRESPONDING, but thought better ask outside...
Cheers,
Andres.
2016 Mar 07 1:58 AM
Hello Andres,
I suggest to use the methods of class CL_ABAP_CONTAINER_UTILITIES to copy data from a BAPIPAREX structure to another structure.
JNN
2016 Mar 07 3:57 AM
Hi Jacques,
That was useful, although CL_ABAP_CONTAINER won't map the whole BAPIPAREX typed structure to the target structure with meaningful fields, as CL_ABAP_CONTAINER=>READ_CONTAINER_C( ) takes a String Sequence as parameter, not a structure of string sequences as BAPIPAREX is.
Kind regards,
Andres.
2016 Mar 07 10:58 AM
if you use subfields no, but as all those are character fields you can use a simple offset like
call method cl_abap_container_utilities=>read_container_c
exporting
im_container = i_extension_out+30
importing
ex_value = e_extend_structure
exceptions
illegal_parameter_type = 1
others = 2.
No CORRESPONDING options were harmed in the sample.
Regards,
Raymond