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: 

Help regarding testing.

Former Member
0 Kudos
117

Hello All,

I am new to ABAP. I want to test my "first" class that reads values from tables using select statement based on an imported key. I have no idea how to test. Can anybody guide me in testing.

Kind Regards.

Srinivas

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
93

You could simply test it using the test icon in class builder, SE24. Or you can write a quick little program which uses this class.

Regards,

Rich Heilman

17 REPLIES 17

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
94

You could simply test it using the test icon in class builder, SE24. Or you can write a quick little program which uses this class.

Regards,

Rich Heilman

0 Kudos
93

I am a total newbie Rich. So you may have to be little slow and specific with your answer. Although ful points rewarded.

0 Kudos
93

Sorry. Go to SE24 and enter the class name and click the "Test" icon. The one that looks like a wrench. Next you will see the methods of the class, simply execute one of your methods. The next screen will present you with the results, if you are actually passing something back.

Regards,

Rich Heilman

0 Kudos
93

Hi Rich,

Where can I find information on basic coding in ABAP. Like I want to see if I am able to compile and print text to the console. Say hello world. Can you just briefly tell me what statement I need to use to print "hello world".

Regards.

0 Kudos
93

You can simply create a report program and use the WRITE statement.

report  zsrinivas.

write:/ 'Hello World'.

Regards,

Rich Heilman

0 Kudos
93

Hi Rich,

When I activate the code, I am getting error:

"Class ZPOSITION_INFORMATION,Method EXTRACT_DATA

You may only define methods between "CLASS ... IMPLEMENTATION" and

"ENDCLASS"."

This is the source code:

data: emp_type char 50,

end_d date 8,

loc char 4,

pers_sub char 4,

pos_title char 40,

start_d date 8 .

method EXTRACT_DATA .

select single empneededby from hrp9007 into start_date

where OBJID = POSITION_NUMBER .

write start_date .

write "hello world"

endmethod.

Kind Regards.

Seenu

0 Kudos
93

Are you trying to implement a local class in a report program? Or are you creating this class in SE24 using the class builder?

Regards,

RIch Heilman

0 Kudos
93

I used se24 and created the class ZPOSITION_INFORMATION and transported it later.

Now the code is the method ZEXTRACT_DATA. But when I looked in the class, it is empty. But when I activate the class I get "object(s) activated".

When I activate the method ZEXTRACT_DATA, I get

"Class ZPOSITION_INFORMATION,Method EXTRACT_DATA

You may only define methods between "CLASS ... IMPLEMENTATION" and

"ENDCLASS". "

Regards.

0 Kudos
93

Please post the code within the METHOD exactly as you see it in SE24.

Regards,

RIch Heilman

0 Kudos
93

data: emp_type char 50,

end_d date 8,

loc char 4,

pers_sub char 4,

pos_title char 40,

start_d date 8 .

method EXTRACT_DATA .

select single empneededby from hrp9007 into start_date

where OBJID = POSITION_NUMBER .

write start_date .

write "hello world" .

endmethod.

PS: "Where POSITION_NUMBER is the imported parameter for this method."

0 Kudos
93

You must be sure to include ALL coding within the METHOD.... ENDMETHOD statements.




method EXTRACT_DATA .

data: emp_type char 50,
end_d date 8,
loc char 4,
pers_sub char 4,
pos_title char 40,
start_d date 8 .


select single empneededby from hrp9007 into start_date
where OBJID = POSITION_NUMBER .

write start_date .
write "hello world" .

endmethod.


Regards,

RIch Heilman

0 Kudos
93

Hi Rich,

Now am getting someother error. I copied and pasted your code. I get:

"Class ZPOSITION_INFORMATION,Method EXTRACT_DATA

Unable to interpret "CHAR". Possible causes: Incorrect spelling or

comma error."

0 Kudos
93

You must make sure that you are using the corrent syntax when defining your DATA statements.



data: emp_type type char50,
      end_d type sy-datum,
      loc type char04,
      pers_sub type char04,
      pos_title type char40,
      start_d type sy-datum .


or....



data: emp_type(50) type c,
      end_d type sy-datum,
      loc(4) type c,
      pers_sub(4) type c,
      pos_title(40) type c,
      start_d type sy-datum .

Regards,

Rich Heilman

0 Kudos
93

Thanks for bearing with me Rich. But I still get one more error

"Class ZPOSITION_INFORMATION,Method EXTRACT_DATA

Field "POSITION_NUMBER" is unknown. It is neither in one of the

specified tables nor defined by a "DATA" statement. "DATA" statement."

Because POSITION_NUMBER is the value being passed to this method as a parameter. But since I am never calling this method. I get this error. Can you please tell me how I should call this method with a dummy/default value.

Kind Regards.

0 Kudos
93

POSITION_NUMBER must be defined as an IMPORTING parameter in the PARAMETER list of the method. There is a button called "Parameters", click this button to add this as a parameter.

Regards,

Rich Heilman

0 Kudos
93

I already did Rich and I am getting the error. Only I don't know how to give initial default value. Or even, is this the problem of not giving the initial value.

Regards.

Srinivas

0 Kudos
93

You were right, I added it in import parameters. Now the error changed to:

Class ZPOSITION_INFORMATION,Method EXTRACT_DATA

Field "ENDMETHOD" is unknown. It is neither in one of the specified

tables nor defined by a "DATA" statement. "DATA" statement.

Kind regards.

Srinivas.