Application Development 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: 

oops report

Former Member
0 Kudos

Hi firends,

I have created simple ooops report . its going dump . It is saying that "Access via 'NULL' object reference not possible." Please rectify this code.

The copde is below:

&----


*& Report YCLASS_OOPS_BANK

*&

&----


*&

*&

&----


REPORT yclass_oops_bank.

DATA: act TYPE REF TO zaccountaa.

DATA: bal TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK a. .

PARAMETERS: p_amnt TYPE dmbtr,

p_dep TYPE dmbtr,

p_witd TYPE dmbtr.

SELECTION-SCREEN END OF BLOCK a.

START-OF-SELECTION.

clear act.

CALL METHOD act->set_balance( p_amnt ).

WRITE:/ 'SET BALANCE', p_amnt.

bal = act->deposit( p_dep ).

write:/ 'Deposited ', p_dep ,' bucks making balance to ', bal.

bal = act->withdraw( p_witd ).

write:/ 'Withdrew ', p_witd ,' bucks making balance to ', bal.

thnaks

vvv

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

There are 2 problems here.

&----


*& Report YCLASS_OOPS_BANK

*&

&----


*&

*&

&----


REPORT yclass_oops_bank.

DATA: act TYPE REF TO zaccountaa.

DATA: bal TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK a. .

PARAMETERS: p_amnt TYPE dmbtr,

p_dep TYPE dmbtr,

p_witd TYPE dmbtr.

SELECTION-SCREEN END OF BLOCK a.

START-OF-SELECTION.

create object act. -


> First you should create the object.

clear act. -


> This is not required.

IF act is bound. -


> In any object related code you can have a check like this to avoid dumps.

the below code is called only if act is not initial.

CALL METHOD act->set_balance( p_amnt ).

WRITE:/ 'SET BALANCE', p_amnt.

bal = act->deposit( p_dep ).

write:/ 'Deposited ', p_dep ,' bucks making balance to ', bal.

bal = act->withdraw( p_witd ).

write:/ 'Withdrew ', p_witd ,' bucks making balance to ', bal.

ENDIF.

I hope this helps.

thnaks

Saurabh

5 REPLIES 5

Former Member
0 Kudos

Hi ,

u have to add a statement Create object act. before calling method.

Because this statement creates a instanst and ref is create only when you use this statement,

Reward Points .

raj

Former Member
0 Kudos

DATA: bal TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK a. .

PARAMETERS: p_amnt TYPE dmbtr,

p_dep TYPE dmbtr,

p_witd TYPE dmbtr.

SELECTION-SCREEN END OF BLOCK a.

START-OF-SELECTION.

DATA: act TYPE REF TO zaccountaa.

create object act.

clear act.

CALL METHOD act->set_balance( p_amnt ).

WRITE:/ 'SET BALANCE', p_amnt.

bal = act->deposit( p_dep ).

write:/ 'Deposited ', p_dep ,' bucks making balance to ', bal.

bal = act->withdraw( p_witd ).

write:/ 'Withdrew ', p_witd ,' bucks making balance to ', bal.

0 Kudos

thanks

Former Member
0 Kudos

Hi,

There are 2 problems here.

&----


*& Report YCLASS_OOPS_BANK

*&

&----


*&

*&

&----


REPORT yclass_oops_bank.

DATA: act TYPE REF TO zaccountaa.

DATA: bal TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK a. .

PARAMETERS: p_amnt TYPE dmbtr,

p_dep TYPE dmbtr,

p_witd TYPE dmbtr.

SELECTION-SCREEN END OF BLOCK a.

START-OF-SELECTION.

create object act. -


> First you should create the object.

clear act. -


> This is not required.

IF act is bound. -


> In any object related code you can have a check like this to avoid dumps.

the below code is called only if act is not initial.

CALL METHOD act->set_balance( p_amnt ).

WRITE:/ 'SET BALANCE', p_amnt.

bal = act->deposit( p_dep ).

write:/ 'Deposited ', p_dep ,' bucks making balance to ', bal.

bal = act->withdraw( p_witd ).

write:/ 'Withdrew ', p_witd ,' bucks making balance to ', bal.

ENDIF.

I hope this helps.

thnaks

Saurabh

Former Member
0 Kudos

creat a container object

call screen 100

after selection criteria

creat customer contorl provide name CONTAINER or some thing else and then

in top DATA container TYPE REF TO cl_gui_custom_container.

in pbo

CREATE OBJECT container

EXPORTING container_name = 'CONTAINER'.

now u can can use output in this container it can be a simple report or any thing