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

Using BO method in function.

Former Member
0 Likes
2,370

Hi

I would like to use Business object method in my function. In BOR browser is e.g. object Flight object type SFLIGHT. I have tried to call this object method with:

FLIGHT=>create( ).

and

SFLIGHT=>create( ).

and compiler response is always

Class not known.

What should I do??

Regards

Bogdan

Message was edited by: Bogdan Rokosa

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,840

Thanks for answer:)

I must this tutorial studying a little

I have heard about SWC macros but I unfortunately can't use it:( I know, i should <object> include. But when I try do it (add to includes node in function module) i have a message:

Object <OBJECT> already exists

then when i try use macro:

Statement SWC_GET_ELEMENT not defined.

What is not correct?

17 REPLIES 17
Read only

Former Member
0 Likes
1,840

Have you ever heard of the SWC-macros?!

First you have to instantiate your SFLIGHT with

SWC_CREATE_OBJECT <field to hold obj instance> <obj type> <key of obj>

. After this you have access to all attributes and methods of your SFLIGHT instance.

Then create the object container with

SWC_CONTAINER <container>

.

Call the method you want with

SWC_CALL_METHOD <filed to hold obj instance> <name of method> <container>

.

Greets

--MIKE

Read only

Former Member
Read only

Former Member
0 Likes
1,841

Thanks for answer:)

I must this tutorial studying a little

I have heard about SWC macros but I unfortunately can't use it:( I know, i should <object> include. But when I try do it (add to includes node in function module) i have a message:

Object <OBJECT> already exists

then when i try use macro:

Statement SWC_GET_ELEMENT not defined.

What is not correct?

Read only

0 Likes
1,840

Please post your code if possible. That would make safe a lot of time spent on speculations otherwise!

Read only

0 Likes
1,840

Hi Mike

I have tried e.g. with code

FUNCTION Z_BO_TEST.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"----------------------------------------------------------------------

DATA: flight TYPE SWC_OBJECT.

SWC_CREATE_OBJECT flight SFLIGHT '1111'.
SWC_CONTAINER cont.
SWC_CREATE_CONTAINER cont.
SWC_SET_ELEMENT cont <par1> <Value1>.
.
.
.
SWC_CALL_METHOD flieght getlist cont.
ENDFUNCTION.

That is function module in function group. I can't this function compile (try include object). Where and how can i do it?

regards

bogdan

Read only

0 Likes
1,840

What is the object type (SWO1) of your 'FLIGHT' object?

Read only

0 Likes
1,840

I dod not check this code, but this is the way it should work:


* structure to save the key to instantiate SFLIGHT
* ATTENTION: This structure must be filled before 
* instantiating the object !!!!
DATA: BEGIN OF gs_sflight_key,
				mandt LIKE sflight-mandt,
				carrid LIKE sflight-carrid,
				connid LIKE sflight-connid,
				fldate LIKE sflight-fldate,
			END OF gs_sflight_key.

DATA: go_sflight TYPE swc_object.

* generate swc container
SWC_CONTAINER gc_container.

* instantiate object GO_SFLIGHT with key GS_SFLIGHT_KEY
SWC_CREATE_OBJECT go_sflight 'SFLIGHT' gs_sflight_key.

* instantiate container
SWC_CREATE_CONTAINER gc_container.

* call method DISPLAY of obj instance GO_SFLIGHT within
* conatiner GC_CONTAINER
SWC_CALL_METHOD go_sflight 'DISPLAY' gc_container.

Read only

0 Likes
1,840

Please don't define a new include in your function group program.

Just put the include statement

INCLUDE <cntn01>.

in your function group's top include ( XXXTOP include...)...Where you declare global data ...

Cheers,

Ram

Read only

0 Likes
1,840

Hi Mike

I can't compile this example

I have written:

*&---------------------------------------------------------------------*
*& Module pool       ZZZZZTEST                                         *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

include <object>.

* structure to save the key to instantiate SFLIGHT
* ATTENTION: This structure must be filled before
* instantiating the object !!!!
DATA: BEGIN OF gs_sflight_key,
				mandt LIKE sflight-mandt,
				carrid LIKE sflight-carrid,
				connid LIKE sflight-connid,
				fldate LIKE sflight-fldate,
			END OF gs_sflight_key.

DATA: go_sflight TYPE swc_object.

* generate swc container
SWC_CONTAINER gc_container.

* instantiate object GO_SFLIGHT with key GS_SFLIGHT_KEY
SWC_CREATE_OBJECT go_sflight 'SFLIGHT' gs_sflight_key.

* instantiate container
SWC_CREATE_CONTAINER gc_container. "!!!!!!!!!!!!!

* call method DISPLAY of obj instance GO_SFLIGHT within
* conatiner GC_CONTAINER
SWC_CALL_METHOD go_sflight 'DISPLAY' gc_container.

and i have got a compiler message:

"Statement is not accessible "

in line with "!!!!!!!!!!!!!)

I have superseded macros with his code and that works.

I have no idea what exactly should I do to use this macros

Regards

Bogdan

Read only

0 Likes
1,840

Than do not execute the following line


SWC_CREATE_CONTAINER gc_container.

Just comment it out.

What happens now?!

Read only

0 Likes
1,840

you might check my last response and try that also.

Further, I am not sure you first wrote the code in a FM and then a module pool..

In case you are doing it in an FM ...

Call the include <cntn01> in your top include along with the global data declaration...

And also that cntn01> is sufficient for your work <object> is not required.

Cheers,

Ram

Read only

0 Likes
1,840

Hi Ram

excuse me, I have tried with function module and program

In program I can use include at the beginning my code. Where and how should I do that in function group?

Would you like to explain me that exactly?

Regards

Bogdan

Read only

0 Likes
1,840

Hi Mike

selfsame error occured in next line

Read only

0 Likes
1,840

You have to include <cntn01> in the top include of your function group!

Read only

0 Likes
1,840

I am stupid

Thanks a lot for help and patience:)

Bogdan

Read only

0 Likes
1,840

Why are you stupid?! Was this the cause for your problem?? Really??????

Don´t forget to reward points...

Read only

0 Likes
1,840

Hi Mike

The reason was lack of include.

And if I am stupid und why hmmmm I think that is not goot subjcet for this forum

Thanks once more for your help.

Bogdan