SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

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.

multiple variable update within select single ABAP 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.

DATA ls_vbak TYPE vbak.

 FROM vbak
 INTO ls_vbak-kunnr
 WHERE vbeln = '0000301633'.

SELECT audat auart vbtyp
 FROM vbak
 WHERE vbeln = '0000301633'.

DATA lwa_vbak TYPE vbak.
SELECT SINGLE * INTO lwa_vbak FROM vbak WHERE vbeln = '0000301633'.
ls_vbak-kunnr = lwa_vbak-kunnr.
ls_vbak-audat = lwa_vbak-audat.
ls_vbak-auart = lwa_vbak-auart.
ls_vbak-vbtyp = lwa_vbak-vbtyp.

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.


Install SAP Free
CRM Companies List
Web Based CRM Software

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.