ABAP Programs: Copying structured objects
* Using move-corresponding to copy fields with the same name
DATA: BEGIN OF MY_CUSTOMER,
ID(8) TYPE N,
NAME(25),
CITY(25),
END OF MY_CUSTOMER,
BEGIN OF CITY_OF_CUSTOMER,
CITY LIKE MY_CUSTOMER-CITY,
TEXT(30),
ID LIKE MY_CUSTOMER-ID,
END OF CITY_OF_CUSTOMER.
MY_CUSTOMER-ID = ’87654321′.
CITY_OF_CUSTOMER-TEXT = ‘Old text’.
MOVE-CORRESPONDING MY_CUSTOMER TO CITY_OF_CUSTOMER.
WRITE: / ‘Changed ID’, CITY_OF_CUSTOMER-ID,
/ ‘Unchanged text’, CITY_OF_CUSTOMER-TEXT.
* Using the move command for structures
DATA: CURRENT_CUSTOMER LIKE MY_CUSTOMER,
BEGIN OF PREVIOUS_CUSTOMER,
IDENTIFIER LIKE MY_CUSTOMER-ID,
NAME LIKE MY_CUSTOMER-NAME,
CITY LIKE MY_CUSTOMER-CITY,
END OF PREVIOUS_CUSTOMER.
CURRENT_CUSTOMER-ID = ’12345678′.
MOVE CURRENT_CUSTOMER TO PREVIOUS_CUSTOMER.
WRITE: / ‘Changed ID’, PREVIOUS_CUSTOMER-IDENTIFIER.
* Copying complete internal tables
TYPES: BEGIN OF TABLE_LINE,
FIELD_1,
FIELD_2 TYPE I,
END OF TABLE_LINE.
DATA: SOURCE_TABLE TYPE TABLE_LINE OCCURS 100,
TARGET_TABLE TYPE TABLE_LINE OCCURS 50.
MOVE SOURCE_TABLE TO TARGET_TABLE.
———————
ABAPer, mail: abap.community@gmail.com http://www.erpdb.info
If you like this post, you may as well like these too:
- ABAP Programs: Copying fields REPORT ZSOURCE0701. * move fieldsDATA: NAME(25), COUNTER TYPE I.DATA: SOURCE LIKE NAME, TARGET LIKE SOURCE.MOVE: ‘Edison’ TO NAME, 17 TO COUNTER.MOVE SOURCE TO TARGET.* Using the compute command (keyword can...
- ABAP Programs: Complex Non-Elementary Types and Data Objects REPORT ZSOURCE0408. * Nested recordsTYPES: BEGIN OF ADDRESS, CITY(25), STREET(30), END OF ADDRESS, BEGIN OF PERSON, NAME(25), ADDRESS TYPE ADDRESS, END OF PERSON.DATA RECEIVER TYPE PERSON.RECEIVER-NAME = ‘Smith’.RECEIVER-ADDRESS-CITY = ‘Big...
- ABAP Objects: Components of Class in ABAP Objects Components of Class in ABAP Objects DATA – for instance attributes METHODS – for instance methods EVENTS – for instance events Static components: CLASS-DATA – for static attributes CLASS-METHODS –...
- ABAP Objects – Class and objects Why do you need ABAP Objects? ABAP Objects oriented programming lets you to be at par with the others as this is better methodology. To understand the recent concept of...
- Not Yet Using ABAP Objects? Eight Reasons why every ABAP Developer should give it a second look. SAP Introducted ABAP objects for a while ago now. Many ABAP Developers turned in and tapped the advantages...
- ABAP Objects – Pros and Cons ABAP Objects establishes a different level of data encapsulation. In procedural programming the state of an application is held by global variables. In object-oriented programming, however, the state is kept...
- ABAP Objects for JAVA Pro’s Contains : Similarities Between Java and ABAP ABAP Special Features Download from rapidshare or mediafire....
- ABAP Source Code: Three approaches to define data objects REPORT ZSOURCE0401.* 1. Elementary typesDATA: CUSTOMER_NAME_1(25) TYPE C, VENDOR_NAME_1(25) TYPE C. * 2. Reference to an existing fieldDATA: CUSTOMER_NAME_2(25) TYPE C, VENDOR_NAME_2 LIKE CUSTOMER_NAME_2. * 3. Reference to a non-elementary...
- ABAP Source Code: Syntax of ABAP/4 Programs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 * Declaration...
- ABAP Programs: Importing from the ABAP/4 Memory REPORT ZSOURCE1402. * Internal tables which will be imported DATA: ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE, ALL_BOOKINGS LIKE BOOKINGS OCCURS 10 WITH HEADER LINE, NEW_BOOKINGS LIKE BOOKINGS OCCURS...
- ABAP Programs: Exporting to the ABAP/4 Memory REPORT ZSOURCE1401. * Work areas TABLES: CUSTOMERS, BOOKINGS. * Internal tables which will be exported DATA: ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE, ALL_BOOKINGS LIKE BOOKINGS OCCURS 10 WITH...
- Ending ABAP Programs The execution of an ABAP program is always ended when the corresponding process in the runtime environment ends. From an ABAP programmer’s perspective, this is when the last of the...
- ABAP Programs: Using where clauses REPORT ZSOURCE1104.* Work areasTABLES: BOOKINGS, CUSTOMERS.* Internal tablesDATA CUSTOMER_ORDERS LIKE BOOKINGS OCCURS 100 WITH HEADER LINE.DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE.* Selecting data with a simple where...
- ABAP Programs: Using colors REPORT ZSOURCE0807. * Display the header using an appropriate color (grayish blue)WRITE ‘Header’ COLOR COL_HEADING. * Switch the standard colorFORMAT COLOR COL_TOTAL. * Make the color less brightWRITE / ‘total...
- Some Cool Programs in ABAP and the link is :- http://www.kabai.com/abaps/q.htm...



















Leave a Reply