SUBTRACT-CORRESPONDING ( SAP ABAP Keyword)

SUBTRACT-CORRESPONDING is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details.

SUBTRACT-CORRESPONDING


Basic form
SUBTRACT-CORRESPONDING rec1 FROM rec2.

Effect
Interprets rec1 and rec2 as field strings. If, for example, rec1 and rec2 are tables, executes the statement for their header lines.

Searches for all sub-fields which occur both in rec1 and rec2 and then generates, for all relevant field pairs corresponding to the component fields ni , statements of the form


SUBTRACT rec1-ni FROM rec2-ni.


The other fields remain unchanged.

With complex structures, the full names of the field pairs must be identical.

Example

DATA: BEGIN OF PERSON,
NAME(20) VALUE 'Paul',
MONEY TYPE I VALUE 5000,
END OF PERSON,
BEGIN OF PURCHASES OCCURS 10,
PRODUCT(10),
MONEY TYPE I,
END OF PURCHASES.
PURCHASES-PRODUCT = 'Table'.
PURCHASES-MONEY = 100.
APPEND PURCHASES.

PURCHASES-PRODUCT = 'Chair'.
PURCHASES-MONEY = 70.
APPEND PURCHASES.

LOOP AT PURCHASES.
SUBTRACT-CORRESPONDING PURCHASES FROM PERSON.
ENDLOOP.


The value of PERSON-MONEY is now 4830. The above SUBTRACT-CORRESPONDING statement (executed twice here) is equivalent to:


SUBTRACT PURCHASES-MONEY FROM PERSON-MONEY.



Note
All fields of the same name are subtracted, whether they are numeric or not. Here, the conversions performed are the same as with SUBTRACT and the same runtime errors can occur.

Most readed SAP Tutorials

Latest Added SAP documents

Custom Search
ABAP Tutorials ABAP Syntax BAPI SAP Jobs SAP Glossary SAP Netweaver SAP XI SAP Download SAP Interview questions

Complete SAP Study materials | SAP JOBS | PDF Tutorials   List of SAP Companies India

Google-Translate-Chinese (Simplified) BETA Google-Translate-English to French Google-Translate-English to German Google-Translate-English to Italian Google-Translate-English to Japanese BETA Google-Translate-English to Korean BETA Google-Translate-English to Russian BETA Google-Translate-English to Spanish

All of the product names here are trademarks of their respective companies. The site sapbrainsonline.com no way affiliated with SAP AG. Use information on this site at your own risk. Information furnished in the site is collected from various sites and posts from users. This site does not host any files on its server. If any compliants about the posts please contact us at sapbrain.support@gmail.com

Sitemap
web counter