Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125

Includes in SAP ABAP

An include is a code fragment stored separately and inserted into a program using the INCLUDE statement. It’s mainly used to split a large program into manageable blocks.

 When to use:

  • To split large programs into smaller reusable blocks.
  • Often used for reusable FORM routines or declarations.
" Data decelarttion
INCLUDE ZSHVIMA_12_1.   " zshivam_12_TOP.
*
*" declare screen element. " Zshivam_12_SCR.
include zshivam_12_SCR.


*" declare you subroutine  " ZSHIVAM_12_FRM.
include zshivam_12_from.
*

*" in which report event we will be write or executing our logical code.
START-OF-SELECTION.
" call subroutine
  perform addition.

" subtract numbers  -- reference
  PERFORM subtract using p_num1 p_num2
                   CHANGING gv_total.

" BODMAS
    perform BODMAS. 

Include Program:

Subroutines in Include.

*&---------------------------------------------------------------------*
*&  Include           ZSHIVAM_12_FROM
*&---------------------------------------------------------------------*

" subcroutine for addition.
Form addition.
  gv_total p_num1 + p_num2.
  WRITE gv_total.
endform.


*&---------------------------------------------------------------------*
*&      Form  SUBTRACT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_P_NUM1  text
*      -->P_P_NUM2  text
*      <--P_LV_TOTAL  text
*----------------------------------------------------------------------*
FORM subtract  USING    p_num1
                        p_num2
               CHANGING p_lv_total.

  p_lv_total p_num1 p_num2.

  WRITE p_lv_total.
ENDFORM.


  " block design --> readable
*&---------------------------------------------------------------------*
*&      Form  BODMAS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM bodmas .
  perform addition.
  PERFORM subtract using p_num1 p_num2 CHANGING gv_subtract.
  gv_mul p_num1 * p_num2.
  WRITE gv_mul.
ENDFORM. 

Selection Screen in Include Program.

*&---------------------------------------------------------------------*
*&  Include           ZSHIVAM_12_SCR
*&---------------------------------------------------------------------*


PARAMETERS p_num1 type i,
             p_num2 type i. 

Data Declaration in Include Program

*&---------------------------------------------------------------------*
*&  Include           ZSHVIMA_12_1
*&---------------------------------------------------------------------*


DATA gv_total TYPE i,
       gv_subtract TYPE i,
       gv_mul TYPE i. 

Output:

Related Questions

Leave an answer

Leave an answer