Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create a instance for the method

Former Member
0 Likes
522

it is showing me dump error for the call method

data: i_tab type /SCMB/DM_ORDER_TAB,

grid1 TYPE REF TO /SCA/CL_SVORDER .

CALL METHOD grid1->READ_BY_IDS

EXPORTING

  • IS_CTRL =

IV_ORTYPE = gt_po_detl-ortype

  • IV_LOCKFLG = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_NOADDRESS = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_MAPID = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_DUEQUAN = /SCMB/CL_C_ORDER=>GC_FALSE

IT_ORDERID = itab_orderid

IMPORTING

ET_ORDERS = i_tab

  • ET_PROT =

.

u r attempting to use a null object reference access a component (variable 'GRID!")

an object reference must point to an object (an instance of a class ) before it can be used to acess a component either the reference was never set or it was set to null using the clear statement

3 REPLIES 3
Read only

Former Member
0 Likes
485

You are trying to access a method without creating a instance of the class....

Paste this code before you call <b>READ_BY_IDS</b> method.

data: i_tab type /SCMB/DM_ORDER_TAB,

grid1 TYPE REF TO /SCA/CL_SVORDER .

<b>create object grid1.</b>

CALL METHOD grid1->READ_BY_IDS

EXPORTING

  • IS_CTRL =

IV_ORTYPE = gt_po_detl-ortype

  • IV_LOCKFLG = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_NOADDRESS = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_MAPID = /SCMB/CL_C_ORDER=>GC_FALSE

  • IV_DUEQUAN = /SCMB/CL_C_ORDER=>GC_FALSE

IT_ORDERID = itab_orderid

IMPORTING

ET_ORDERS = i_tab

  • ET_PROT =

I hope this will solve your problem

Regards,

Ramki.

Read only

Former Member
0 Likes
485

Hi Sridhar

Try to get more into ABAP Objects,

http://help.sap.com/saphelp_47x200/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm

Please find some information about working with ABAP Class & instances. This will be very helpful and solve most of your problems.

Read only

Clemenss
Active Contributor
0 Likes
485

sridhar loganathan,

A ABAP Class is just a definition of fields/variables called attributes and routines (like in standard ABAP forms and functions) called methods. Also you can have events, don't care about before necessary.

The definition itself is just a blueprint. Nothing exists, nothing can be used before you create an instance for this definition.

DATA: grid1 TYPE REF TO /SCA/CL_SVORDER creates a 'handler' for ( to be created) instances of the class.

The statement CREATE OBJECT grid1 creates an instance of the class as defined in the 'blueprint' and assigns the reference to this instance (with all methods, attributes and events) to reference field grid1.

In 999 of 1000 cases SAP creates just one object of a class. In those cases the definition of classes and uses of object oriented programming is more or less obsolete.

Anyway: Just keep in mind that you can not uses attributes and methods of the class directly (blueprint!) but only of the instance created.

An Exception to be noted are so-called Static attributes and methods where an instance is not required. Example ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB gives the character for horizontal tab regardless of platform and char encoding (unicode!). Class ABAP_CHAR_UTILITIES defines static attribute HORIZONTAL_TAB - no instances necessary because this will never change in a given system.

Hope this sheds some light on it

Regards,

Clemens