MOVE Statement in ABAP – How to Transfer Data Between Variables
Table of Contents
- • What Does the MOVE Statement Do?
- • Basic Syntax
- ↳ Classic MOVE Syntax
- ↳ Modern Assignment Syntax (Preferred)
- • Simple MOVE Examples
- ↳ Example 1: Moving a String Value
- ↳ Output:
- ↳ Example 2: Same Thing Using the Equals Sign
- ↳ Output:
- • Automatic Type Conversion During MOVE
- ↳ Example 3: Moving an Integer to a String
- ↳ Output:
- ↳ Example 4: Moving a String to an Integer
- ↳ Output:
- ↳ Common Type Conversion Table
- • Moving Data Between Structures
- ↳ Method 1: Direct Structure Assignment
- ↳ Output:
- ↳ Method 2: MOVE-CORRESPONDING (Different Structures)
- ↳ Output:
- • MOVE-CORRESPONDING with Internal Tables
- ↳ Output:
- • MOVE vs Direct Assignment — When to Use Which?
- • Common Mistakes to Avoid
- ↳ 1. Assuming MOVE Creates a Link
- ↳ 2. Type Mismatch Runtime Errors
- ↳ 3. Forgetting That MOVE-CORRESPONDING Only Copies Matching Names
- ↳ 4. Overwriting Existing Data
- • Interactive Checkpoints
- • Summary
![]()
Once you know how to declare variables with the DATA statement, the next natural question is — how do I move data from one variable to another? That is where the MOVE statement comes in.
In real SAP projects, you are constantly transferring data. You pull a customer name from the database and put it into a local variable. You copy values from one structure to another before passing them to a function module. You move data from a work area into an internal table row. All of this involves transferring data between variables.
Now, ABAP gives you two ways to do this — the classic MOVE statement and the modern assignment operator (=). Both do the same thing, but you will see both styles in production code because older programs use MOVE and newer programs use the equals sign. You need to understand both.
This guide covers everything about data transfer in ABAP, from simple variable-to-variable moves to structure-level transfers using MOVE-CORRESPONDING.
What Does the MOVE Statement Do?
The MOVE statement copies the value from one variable (the source) into another variable (the target). After the move, both variables hold the same value, but they are still independent — changing one will not affect the other.
Think of it like copying a file on your computer. You have the original file and a copy. Editing the copy does not change the original.
Basic Syntax
Classic MOVE Syntax
MOVE source TO target.
Modern Assignment Syntax (Preferred)
target = source.
Both of these do exactly the same thing. The modern style is shorter and easier to read, so most developers prefer it today. But you will definitely see the classic MOVE syntax in legacy programs, so you need to recognize it.
Simple MOVE Examples
Example 1: Moving a String Value
REPORT z_move_basic.
DATA: lv_source TYPE string VALUE 'Hello ABAP',
lv_target TYPE string.
MOVE lv_source TO lv_target.
WRITE: 'Source:', lv_source.
NEW-LINE.
WRITE: 'Target:', lv_target.
Output:
Source: Hello ABAP
Target: Hello ABAP
Simple enough. The value from lv_source is now also in lv_target.
Example 2: Same Thing Using the Equals Sign
REPORT z_move_modern.
DATA: lv_source TYPE string VALUE 'Hello ABAP',
lv_target TYPE string.
lv_target = lv_source.
WRITE: 'Source:', lv_source.
NEW-LINE.
WRITE: 'Target:', lv_target.
Output:
Source: Hello ABAP
Target: Hello ABAP
Identical result. The = operator is just a shorter way to write MOVE ... TO ....
Automatic Type Conversion During MOVE
Here is something important that beginners often miss. When you move data between variables of different types, ABAP automatically converts the data. This is called implicit type conversion.
Example 3: Moving an Integer to a String
REPORT z_move_conversion.
DATA: lv_number TYPE i VALUE 42,
lv_text TYPE string.
lv_text = lv_number.
WRITE: 'Number:', lv_number.
NEW-LINE.
WRITE: 'As Text:', lv_text.
Output:
Number: 42
As Text: 42
ABAP converted the integer 42 into the string "42" automatically. This works for most standard type combinations.
Example 4: Moving a String to an Integer
REPORT z_move_str_to_int.
DATA: lv_text TYPE string VALUE '100',
lv_number TYPE i.
lv_number = lv_text.
WRITE: 'Text:', lv_text.
NEW-LINE.
WRITE: 'Number:', lv_number.
Output:
Text: 100
Number: 100
ABAP is smart enough to convert the text "100" into the integer 100. But be careful — if lv_text contained something like "ABC", this would cause a runtime error because ABAP cannot convert letters into a number.
Common Type Conversion Table
| Source Type | Target Type | What Happens |
|---|---|---|
| Integer (I) | String | Number becomes text (e.g., 42 → “42”) |
| String | Integer (I) | Text becomes number if valid (e.g., “100” → 100) |
| Date (D) | String | Date becomes text in YYYYMMDD format |
| String | Date (D) | Text must be 8 chars in YYYYMMDD format |
| Packed (P) | Integer (I) | Decimal part is truncated |
| Character (C) | String | Works directly, trailing spaces trimmed |
Moving Data Between Structures
In real projects, you rarely work with single variables. Most of the time, you are dealing with structures — groups of related fields. ABAP provides two ways to move data between structures.
Method 1: Direct Structure Assignment
If both structures have the exact same type, you can move one to the other directly:
REPORT z_move_structure.
TYPES: BEGIN OF ty_employee,
empid TYPE i,
name TYPE string,
city TYPE string,
END OF ty_employee.
DATA: ls_source TYPE ty_employee,
ls_target TYPE ty_employee.
ls_source-empid = 101.
ls_source-name = 'Daksh'.
ls_source-city = 'Jaipur'.
ls_target = ls_source.
WRITE: 'Target ID:', ls_target-empid.
NEW-LINE.
WRITE: 'Target Name:', ls_target-name.
NEW-LINE.
WRITE: 'Target City:', ls_target-city.
Output:
Target ID: 101
Target Name: Daksh
Target City: Jaipur
All three fields are copied in one single statement. Clean and efficient.
Method 2: MOVE-CORRESPONDING (Different Structures)
What if the two structures are not identical? What if they share some fields but not all? That is where MOVE-CORRESPONDING comes in. It copies only the fields that have the same name in both structures.
REPORT z_move_corresponding.
TYPES: BEGIN OF ty_source,
empid TYPE i,
name TYPE string,
salary TYPE p DECIMALS 2,
END OF ty_source.
TYPES: BEGIN OF ty_target,
empid TYPE i,
name TYPE string,
city TYPE string,
END OF ty_target.
DATA: ls_source TYPE ty_source,
ls_target TYPE ty_target.
ls_source-empid = 101.
ls_source-name = 'Daksh'.
ls_source-salary = '50000.00'.
MOVE-CORRESPONDING ls_source TO ls_target.
WRITE: 'Target ID:', ls_target-empid.
NEW-LINE.
WRITE: 'Target Name:', ls_target-name.
NEW-LINE.
WRITE: 'Target City:', ls_target-city.
Output:
Target ID: 101
Target Name: Daksh
Target City:
Notice what happened here:
empidandnameexist in both structures, so their values were copied.salaryexists only in the source, so it was ignored.cityexists only in the target, so it kept its initial empty value.
This is incredibly useful in real projects. For example, when you read data from a database table and need to fill a different output structure that has some matching fields and some extra fields. MOVE-CORRESPONDING handles the matching automatically.
MOVE-CORRESPONDING with Internal Tables
You can also use MOVE-CORRESPONDING between internal tables, not just single structures:
REPORT z_move_corr_itab.
TYPES: BEGIN OF ty_db_record,
matnr TYPE c LENGTH 18,
maktx TYPE c LENGTH 40,
meins TYPE c LENGTH 3,
mtart TYPE c LENGTH 4,
END OF ty_db_record.
TYPES: BEGIN OF ty_display,
matnr TYPE c LENGTH 18,
maktx TYPE c LENGTH 40,
status TYPE string,
END OF ty_display.
DATA: lt_db TYPE TABLE OF ty_db_record,
lt_display TYPE TABLE OF ty_display,
ls_db TYPE ty_db_record.
* Simulate some database records
ls_db-matnr = 'MAT001'.
ls_db-maktx = 'Steel Plate'.
ls_db-meins = 'KG'.
ls_db-mtart = 'ROH'.
APPEND ls_db TO lt_db.
ls_db-matnr = 'MAT002'.
ls_db-maktx = 'Copper Wire'.
ls_db-meins = 'M'.
ls_db-mtart = 'ROH'.
APPEND ls_db TO lt_db.
MOVE-CORRESPONDING lt_db TO lt_display.
DATA ls_display TYPE ty_display.
LOOP AT lt_display INTO ls_display.
WRITE: / ls_display-matnr, ls_display-maktx.
ENDLOOP.
Output:
MAT001 Steel Plate
MAT002 Copper Wire
Only the matching fields (matnr and maktx) were copied. The status field in the display table stays empty, and meins and mtart from the database table were ignored. This saves you from writing field-by-field assignment loops.
MOVE vs Direct Assignment — When to Use Which?
| Scenario | Use |
|---|---|
| Simple variable to variable | target = source. (modern style) |
| Legacy code maintenance | MOVE source TO target. (classic style) |
| Same-type structures | target = source. |
| Different structures with matching field names | MOVE-CORRESPONDING source TO target. |
| Internal table to internal table (partial fields) | MOVE-CORRESPONDING lt_source TO lt_target. |
In new code, always prefer the = operator for simple assignments. Use MOVE-CORRESPONDING when you need to transfer data between structures or tables that share some but not all fields.
Common Mistakes to Avoid
1. Assuming MOVE Creates a Link
MOVE copies the value. It does not create a reference. After the move, changing the source will not change the target. They are completely independent.
2. Type Mismatch Runtime Errors
Moving a text value like 'ABC' into an integer variable will cause a short dump (runtime error). Always make sure the source value is compatible with the target type.
3. Forgetting That MOVE-CORRESPONDING Only Copies Matching Names
If the field names are even slightly different (like emp_id vs empid), MOVE-CORRESPONDING will not copy that field. The names must match exactly, including case.
4. Overwriting Existing Data
When you use MOVE-CORRESPONDING to copy into a target that already has values in its unique fields, those values are preserved. Only the matching fields are overwritten. This is usually what you want, but be aware of it.
Interactive Checkpoints
Review these self-assessment cards to test your understanding:
🙋♂️ Checkpoint 1: What is the difference between MOVE and the equals (=) operator?
🙋♂️ Checkpoint 2: When should you use MOVE-CORRESPONDING instead of a direct assignment?
🙋♂️ Checkpoint 3: What happens if you try to move the string "Hello" into an integer variable?
Summary
The MOVE statement and its modern equivalent (the = operator) are fundamental to every ABAP program. You will use them hundreds of times in every project to transfer data between variables, structures, and internal tables.
For simple assignments, use the equals sign. For transferring data between different structure types that share some common field names, use MOVE-CORRESPONDING. Always be mindful of type conversions — ABAP handles many of them automatically, but incompatible types will crash your program at runtime.
If you understand these concepts well, you are ready to move on to more advanced topics like internal table operations, function modules, and modularization. These all rely heavily on data transfer between different variables and data containers.
Written by Daksh Dedha
SAP Technical ConsultantDaksh is an SAP Technical Consultant specializing in ABAP programming, SAP S/4HANA migrations, Fiori development, and BTP cloud architecture. He authors free, hands-on tutorials to make enterprise SAP education accessible to all developers.
Test Your Knowledge
Loading question...
Quiz Completed
Related Tutorials
SAP ABAP Enhancement Framework — User Exits, BADIs, and Enhancement Points
Master SAP ABAP enhancements. Learn User Exits, Customer Exits, BADIs, Enhancement Points, and Implicit/Explicit Enhancement Spots to modify standard SAP without modifying source code.
ABAP ProgrammingABAP CDS Views — Core Data Services Complete Guide for Beginners
Learn ABAP CDS Views from scratch. Understand how to create CDS views in Eclipse ADT, use annotations, associations, parameters, and build OData services with CDS.
ABAP ProgrammingMessage Handling in SAP ABAP — Complete SE91 Message Classes Guide
Master SAP ABAP message handling. Learn how to create message classes in transaction SE91, use the MESSAGE statement, handle error types A E W I S X, and pass placeholders.
Found this tutorial useful? Share it with your SAP development team.