Views 537
Visitors 353

Examples 03 - Complex Types (Structures)

Home 
| Top Page | Threads |
Previous  Next

Objective

Transaction Code

SE38 - ABAP Editor

Tables

 

Support

 

 

Creating Report

Program Name        : YEXAMPLES_03

Title                : Complex Types (Structures)

2.Declare Global Variable

*----------------------------------------------------------------------*

*GLOBAL VARIABLE DECRALATION

*----------------------------------------------------------------------*

*First Style

types : begin of ty_wa,

          a type i,

          b type i,

          hasil type p decimals 2,

        end of ty_wa.

 

Data : l_wa1 type ty_wa.          " Sturcture (Workarea)

 

 

*Second Style

data: begin of l_wa2,

          a type i,

          b type i,

          hasil type p decimals 2,

      end of l_wa2.               " Sturcture (Workarea)

 

3.Create Input Screen/Selection

*----------------------------------------------------------------------*

*Input Screen/Selection

*----------------------------------------------------------------------*

parameter p_a like l_wa1-a default 12.

parameter p_b like l_wa1-b default 14.

 

4.Create Main Program

*======================================================================*

*MAIN PROGRAM

*Execute after Input Screen

*======================================================================*

START-OF-SELECTION.

l_wa1-a = p_a.

l_wa1-b = p_b.

 

l_wa1-hasil = l_wa1-a / l_wa1-b.

 

write : / 'WA dari variabel A = ', l_wa1-a,

        / 'WA dari variabel B = ', l_wa1-b,

        / 'WA dari variabel Hasil = ', l_wa1-hasil.

 

5.Activated and run
6.Finished

 

 

Result

Input Selection

abap_tutorial0003

Output

abap_tutorial0004

 

Source Code

*&---------------------------------------------------------------------*

*& Report  YEXAMPLES_03                                                *

*&                                                                     *

*&---------------------------------------------------------------------*

*&                                                                     *

*&                                                                     *

*&---------------------------------------------------------------------*

 

REPORT  yexamples_03                            .

 

*----------------------------------------------------------------------*

*GLOBAL VARIABLE DECRALATION

*----------------------------------------------------------------------*

*First Style

types : begin of ty_wa,

          a type i,

          b type i,

          hasil type p decimals 2,

        end of ty_wa.

 

Data : l_wa1 type ty_wa.          " Sturcture (Workarea)

 

 

*Second Style

data: begin of l_wa2,

          a type i,

          b type i,

          hasil type p decimals 2,

      end of l_wa2.               " Sturcture (Workarea)

 

*----------------------------------------------------------------------*

*Input Screen/Selection

*----------------------------------------------------------------------*

parameter p_a like l_wa1-a default 12.

parameter p_b like l_wa1-b default 14.

 

*======================================================================*

*MAIN PROGRAM

*Execute after Input Screen

*======================================================================*

START-OF-SELECTION.

l_wa1-a = p_a.

l_wa1-b = p_b.

 

l_wa1-hasil = l_wa1-a / l_wa1-b.

 

write : / 'WA dari variabel A = ', l_wa1-a,

        / 'WA dari variabel B = ', l_wa1-b,

        / 'WA dari variabel Hasil = ', l_wa1-hasil.

 

User Threads | New Thread ( Only for Donators )

Threads Last Post Replies Views