0% found this document useful (0 votes)
37 views9 pages

Creation of Usual Abap Class

Abap classes for ooabap

Uploaded by

Venkat Venky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views9 pages

Creation of Usual Abap Class

Abap classes for ooabap

Uploaded by

Venkat Venky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MAIL: abap.guravarao23@gmail.

com Linkdin: Gurava Rao SAP ABAP Fresher

CREATION OF USUAL ABAP CLASS


 Types of classes

a) Global classes -> Transaction code : SE24( Class Builder) , We can reuse the
global classes.

▪ There are 4 types of global class.

▪ Usual ABAP class

▪ Exception class

▪ Persistence class

▪ Unit test class

b) Local Classes -> Dedicated to one program only.

We can create local classes with the help of SE38 transaction code.

Requirement :-
Input is sales document number ,I will display the details of sales document
number, It's means input is sales document number , output is details of sales
document number
 Go to Class Builder ( SE24 ) We need to pass the object type name and
,CLICK on Create button

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher


Provide the Description Click on Save button


 Go for method we need to provide Method Name Choose the Level is Instance method
and visibility is PUBLIC


Go for PARAMETERS PVBELN IS Importing and remaining all Parameters are exporting

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher


 Now we need to write logic for Method Double click on method

method DISPLAY.

SELECT SINGLE ERDAT ERZET ERNAM VBTYP


FROM VBAK
INTO ( PERDAT, PERZET, PERNAM, PVBTYP )
WHERE VBELN = PVBELN.

IF SY-SUBRC <> 0.
RAISE WRONG_INPUT.

ENDIF.
endmethod.

Save (Ctrl + s ) Check ( Ctrl + f2) And Activate ( Ctrl + f3 )

Provide the Input And click on Execute ( f8 )

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

How to call usual Abap Class method in side Program


Instance Method
Instance Method -> We need to create a object to call that method.

-> Instance Method

Go to ABAP Editor ( SE38 ) and create a executeble program


REPORT ZPRG1_23.

DATA : LV_ERDAT TYPE ERDAT.


DATA : LV_ERZET TYPE ERZET.
DATA : LV_ERNAM TYPE ERNAM.
DATA : LV_VBTYP TYPE VBTYP.

DATA : LO_OBJECT TYPE REF TO ZUSUAL_ABAP_CLASS_23.


PARAMETERS : P_VBELN TYPE VBELN_VA.

CREATE OBJECT LO_OBJECT.

CALL METHOD LO_OBJECT->DISPLAY


EXPORTING
PVBELN = P_VBELN
IMPORTING
PERDAT = LV_ERDAT
PERZET = LV_ERZET
PERNAM = LV_ERNAM
PVBTYP = LV_VBTYP
EXCEPTIONS
WRONG_INPUT = 1
others = 2
.

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

IF SY-SUBRC <> 0.
MESSAGE E001(ZMSG_23).
ELSE.

WRITE : / LV_ERDAT,
/ LV_ERZET,
/ LV_ERNAM,
/ LV_VBTYP.

ENDIF.

CALL THE CLASS METHOD :-

Go for Pattern button choose the radio button ABAP


Objects Patterns

 Pass the Instance whatever We created object and class


name and when you click on f4 help of method automatically
method name will be Visible Click on Enter

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

Which is our out put

Static Method :
Static Method -> There is no need to create a object.

=> Static Method.

REPORT ZPRG1_23.

DATA : LV_ERDAT TYPE ERDAT.


DATA : LV_ERZET TYPE ERZET.
DATA : LV_ERNAM TYPE ERNAM.
DATA : LV_VBTYP TYPE VBTYP.

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

DATA : LO_OBJECT TYPE REF TO ZUSUAL_ABAP_CLASS_23.


PARAMETERS : P_VBELN TYPE VBELN_VA.

CALL METHOD ZUSUAL_ABAP_CLASS_23=>DISPLAY


EXPORTING
PVBELN = P_VBELN
IMPORTING
PERDAT = LV_ERDAT
PERZET = LV_ERZET
PERNAM = LV_ERNAM
PVBTYP = LV_VBTYP
EXCEPTIONS
WRONG_INPUT = 1
others = 2
.
IF SY-SUBRC <> 0.
MESSAGE E001(ZMSG_23).
ELSE.

WRITE : / LV_ERDAT,
/ LV_ERZET,
/ LV_ERNAM,
/ LV_VBTYP.
ENDIF.

Execute the program

LOCAL CLASS :
Local Classes -> Dedicated to one program only.

We can create local classes with the help of SE38 transaction code.

Class Definition : Declarations.

Class Implementation: Logic

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

REPORT ZPRG_LOCAL_CLASS_23.

DATA : LV_ERDAT TYPE ERDAT.


DATA : LV_ERZET TYPE ERZET.
DATA : LV_ERNAM TYPE ERNAM.
DATA : LV_VBTYP TYPE VBTYP.

PARAMETERS : P_VBELN TYPE VBELN_VA.

CLASS CLASS1 DEFINITION.


PUBLIC SECTION.
METHODS DISPLAY IMPORTING PVBELN TYPE VBELN_VA
EXPORTING PERDAT TYPE ERDAT
PERZET TYPE ERZET
PERNAM TYPE ERNAM
PVBTYP TYPE VBTYP
EXCEPTIONS WRONG_INPUT.
ENDCLASS.

CLASS CLASS1 IMPLEMENTATION.

METHOD DISPLAY.

SELECT SINGLE ERDAT ERZET ERNAM VBTYP


FROM VBAK
INTO ( PERDAT, PERZET, PERNAM, PVBTYP )
WHERE VBELN = P_VBELN.

RAISE WRONG_INPUT.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA : LO_OBJECT TYPE REF TO CLASS1.


CREATE OBJECT LO_OBJECT.

LO_OBJECT->DISPLAY( EXPORTING PVBELN = P_VBELN


IMPORTING PERDAT = LV_ERDAT
PERZET = LV_ERZET
PERNAM = LV_ERNAM
PVBTYP = LV_VBTYP
EXCEPTIONS WRONG_INPUT = 1 ).

WRITE : / LV_ERDAT,

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com
MAIL: abap.guravarao23@gmail.com Linkdin: Gurava Rao SAP ABAP Fresher

/ LV_ERZET,
/ LV_ERNAM,
/ LV_VBTYP.

Provide the input Sales Document Number

Press f8

IF YOU HAVE ANY OPPORTUNITIES ON SAP ABAP AS A FRESHER REFER ME AND SEND ME ,
abap.guravarao23@gmail.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy