Application Development and Automation 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: 
Read only

CORRESPONDING

andrs_sarcevic
Contributor
0 Likes
1,359

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.

5 REPLIES 5
Read only

ThomasKruegl
Participant
0 Likes
1,303

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

Read only

0 Likes
1,303

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.

Read only

nomssi
Active Contributor
0 Likes
1,303

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

Read only

0 Likes
1,303

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.

Read only

0 Likes
1,303

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