Update Multiple Variables in ABAP Select Single Statement
ABAP tutorial shows how to update multiple variables in a single ABAP SELECT statement for SAP programmers. Instead of using local structure for multiple variable update, ABAP developers can use ABAP Select statement with UP TO 1 ROWS and map field values in INTO variables list.
Below ABAP code script demonstrates how ABAP developer can update multiple variables using SELECT SINGLE statement.
Sample ABAP code includes 3 code blocks. In first block, there is a SELECT SINGLE statement where ABAP programmer can only update one variable value. This sample shows how easy and efficient to use SELECT SINGLE ABAP statement for moving a field value into a local variable.
Second ABAP statement using SELECT command for selecting single row by UP TO 1 ROWS enables developer to update multiple variable values at the same time.
Source fields from database tables are in the SELECT fields list and corresponding target variables are listed in INTO variable list.
In fact, here in this case although ABAP programmer can not use SELECT SINGLE, SELECT statement with UP TO 1 ROWS enables us to reach the same result.
Unfortunately, we have an additional line of code for ENDSELECT.
I included a third code block where ABAP developers can store data row into a local structure. And later using this local structure, it is possible to update any number of field with structure data.