Hola, si os veis en la necesidad de hacer un move-corresponding sólo de los campos que tiene valor para que al resto de campos de la estructura final no se les sobreescriba con valor vacío, podéis utilizar esta pequeña rutina:
*----------------------------------------------------------------------*
* CLASS lcl_utilities DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_utilities DEFINITION FINAL CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS:
move_corresponding_ignore_init
IMPORTING
i_str_source TYPE any
CHANGING
c_str_dest TYPE any.
ENDCLASS. "lcl_utilities DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_utilities IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_utilities IMPLEMENTATION.
METHOD move_corresponding_ignore_init.
DATA:
l_rcl_abap_structdescr TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS:
<fs_str_component> LIKE LINE OF l_rcl_abap_structdescr->components,
<fs_source_field> TYPE any,
<fs_dest_field> TYPE any.
l_rcl_abap_structdescr ?= cl_abap_typedescr=>describe_by_data( i_str_source ).
LOOP AT l_rcl_abap_structdescr->components ASSIGNING <fs_str_component>.
ASSIGN COMPONENT <fs_str_component>-name OF STRUCTURE c_str_dest TO <fs_dest_field>.
IF sy-subrc = 0.
ASSIGN COMPONENT <fs_str_component>-name OF STRUCTURE i_str_source TO <fs_source_field>.
ASSERT sy-subrc = 0.
IF <fs_source_field> IS NOT INITIAL.
<fs_dest_field> = <fs_source_field>.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD. "move_corresponding_ignore_init
ENDCLASS. "lcl_utilities IMPLEMENTATION
DEFINE move_corresponding_ignore_init.
lcl_utilities=>move_corresponding_ignore_init(
exporting
i_str_source = &1
changing
c_str_dest = &2
).
END-OF-DEFINITION.
Cuando queramos utilizarlo sólo habrá que llamar a la macro:
move_corresponding_ignore_init estructura1 estructura2…