Created
December 13, 2013 05:25
-
-
Save njames/7940126 to your computer and use it in GitHub Desktop.
copy from one structure to another copy of the same structure and only overwrite the new items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
METHOD copy_structure . | |
* parameters | |
* i_new type any | |
* i_old type any | |
* final - changing type any | |
* copy by component only if the new value is populated else take | |
* the existing component | |
DATA: _componentno TYPE i VALUE 0 | |
. | |
FIELD-SYMBOLS: <field_new> TYPE ANY | |
, <field_old> TYPE ANY | |
. | |
final = i_old. | |
DO. | |
_componentno = _componentno + 1. | |
ASSIGN COMPONENT _componentno OF STRUCTURE final TO <field_old>. | |
ASSIGN COMPONENT _componentno OF STRUCTURE i_new TO <field_new>. | |
IF sy-subrc <> 0. | |
EXIT. | |
ELSE. | |
IF <field_old> IS ASSIGNED | |
AND <field_new> IS ASSIGNED | |
AND <field_new> IS NOT INITIAL. | |
<field_old> = <field_new>. | |
ENDIF. | |
ENDIF. | |
ENDDO. | |
ENDMETHOD. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment