ABAP Programs: Updating multiple entries in a database table
REPORT ZSOURCE1304.
* Work area
TABLES CUSTOMERS.
* Internal table for changed entries
DATA CHANGED_CUSTOMERS LIKE CUSTOMERS OCCURS 50
WITH HEADER LINE.
* Filling the internal table
SELECT * FROM CUSTOMERS INTO TABLE CHANGED_CUSTOMERS
WHERE CITY = SPACE.
LOOP AT CHANGED_CUSTOMERS.
CHANGED_CUSTOMERS-CITY = ‘City unknown’.
MODIFY CHANGED_CUSTOMERS.
ENDLOOP.
* Updating the database table with values from the internal table
UPDATE CUSTOMERS FROM TABLE CHANGED_CUSTOMERS.
* Updating the database table according to a where condition
UPDATE CUSTOMERS SET CITY = ‘City unknown’
WHERE CITY = SPACE.
———————
ABAPer, mail: abap.community@gmail.com http://www.erpdb.info
If you like this post, you may as well like these too:
- ABAP Programs: Updating single entries in a database table REPORT ZSOURCE1303.* Work areaTABLES CUSTOMERS.* Record used as alternative work areaDATA MY_CUSTOMER LIKE CUSTOMERS.* Updating one entry from the work areaCUSTOMERS-ID = ’12345678′.CUSTOMERS-CITY = ‘Village’.UPDATE CUSTOMERS.IF SY-SUBRC 0. WRITE: ‘Entry...
- ABAP Programs : Inserting multiple entries in a database table REPORT ZSOURCE1302.* Work areaTABLES CUSTOMERS.* Internal table for new entriesDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE.* Filling the internal tableALL_CUSTOMERS-ID = ’12345678′.ALL_CUSTOMERS-NAME = ‘Brown’.APPEND ALL_CUSTOMERS.ALL_CUSTOMERS-ID = ’11111111′.ALL_CUSTOMERS-NAME =...
- ABAP Programs: Modifying multiple entries in a database table REPORT ZSOURCE1306.* Work areaTABLES CUSTOMERS.* Internal table for changed entriesDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 50 WITH HEADER LINE.* Filling the internal tableSELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS WHERE CITY...
- ABAP Programs: Deleting multiple entries from a database table REPORT ZSOURCE1308.* Work areaTABLES CUSTOMERS.* Internal table for deleted entriesDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 50 WITH HEADER LINE.* Filling the internal tableSELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS WHERE CITY...
- ABAP Programs: Inserting single entries in a database table REPORT ZSOURCE1301.* Work areaTABLES CUSTOMERS.* Record used as alternative work areaDATA MY_CUSTOMER LIKE CUSTOMERS.* Inserting one entry from the work areaCUSTOMERS-ID = ’12345678′.CUSTOMERS-NAME = ‘Brown’.INSERT CUSTOMERS.IF SY-SUBRC 0. WRITE: /...
- ABAP Programs: Deleting single entries from a database table REPORT ZSOURCE1307.* Work areaTABLES CUSTOMERS.* Deleting an entryCUSTOMERS-ID = ’12345678′.DELETE CUSTOMERS. ~ end of post ~ ———————ABAPer, mail: abap.community@gmail.com http://www.erpdb.info...
- ABAP Programs: Modifying single entries in a database table REPORT ZSOURCE1305.* Work areaTABLES CUSTOMERS.* Modifying an entryCUSTOMERS-ID = ’12345678′.CUSTOMERS-CITY = ‘Village’.MODIFY CUSTOMERS. ~ end of post ~ ———————ABAPer, mail: abap.community@gmail.com http://www.erpdb.info...
- ABAP Programs: Filling an internal table from a database table REPORT ZSOURCE1203.* Work area for a database tableTABLES CUSTOMERS.* Defining an internal table with header lineDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE.* Filling the internal table (previous content...
- ABAP Programs: Reading single entries REPORT ZSOURCE1105.* Work area for a database tableTABLES CUSTOMERS.* Reading a single entrySELECT SINGLE * FROM CUSTOMERS WHERE ID = ’87654321′.IF SY-SUBRC = 0. WRITE CUSTOMERS-NAME.ELSE. WRITE ‘Customer not found.’.ENDIF.~~~...
- ABAP Programs: Appending multiple lines REPORT ZSOURCE1205.* Work area for a database tableTABLES CUSTOMERS.* Defining internal tablesDATA: ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE, OLD_CUSTOMERS LIKE CUSTOMERS OCCURS 10 WITH HEADER LINE.* Filling both...
- ABAP Programs: Using a Logical Database REPORT ZSOURCE1502. * Work areas TABLES: CUSTOMERS, BOOKINGS. * Reading data GET CUSTOMERS. WRITE / CUSTOMERS-NAME. GET BOOKINGS. WRITE: AT /3 BOOKINGS-FLDATE....
- ABAP Programs: Using table parameters REPORT ZSOURCE1006. * Work area of database table and internal table for later useTABLES CUSTOMERS.DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 50 WITH HEADER LINE.* Calling a form with a table parameterPERFORM...
- ABAP Programs: Using a dynamic table name REPORT ZSOURCE1110.* Variables for later useDATA: TABLENAME(10), COUNT_ROWS TYPE I.* Setting the table name dynamicallyMOVE ‘CUSTOMERS’ TO TABLENAME.* Selecting dataSELECT COUNT( * ) FROM (TABLENAME) INTO COUNT_ROWS.WRITE: TABLENAME, COUNT_ROWS. ~...
- ABAP Programs: A simple internal table REPORT ZSOURCE1201.* Work area for a database tableTABLES CUSTOMERS.* Defining an internal tableDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100.* Reading all entries of the database table into the internal tableSELECT *...
- Fieldinfo & Values for download for any database table as input Sample code with screen shots where User enters a table name and gets in ALV the list of all the fields in table with their salient characteristics and the key...



















Leave a Reply