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

INCLUDE <CNTAIN>. error

Former Member
0 Likes
875

Hello All,

I get this error:

Include <CNTAIN>

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

"ENDCLASS".

Here is the code:

INCLUDE <CNTAIN>.

METHOD CREATENBOBJECT.

DATA: newvariable(12) type n.

swc_get_element container 'REQUISITION_NUM' newvariable.

CALL FUNCTION 'ZHRWPC_EREC_CREATE_EREC_OBJECT'

EXPORTING

notif_objid = notificationid

notif_type = notificationtype

IMPORTING

return = return

EXCEPTIONS

no_isr_update = 1

database_error = 2

general_error = 3

req_object_found = 4

no_erec_approval = 5

erec_sys_error = 6

status_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

  • Messages already raised, exceptions should be handled here

  • due to workflow intricacy.

ENDIF.

What is wrong with the code.

Thanks and Regards.

Srinivas

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
755

Everything must be inside the METHOD...ENDMETHOD.





METHOD CREATENBOBJECT.


INCLUDE <CNTAIN>.

DATA: newvariable(12) type n.
swc_get_element container 'REQUISITION_NUM' newvariable.


CALL FUNCTION 'ZHRWPC_EREC_CREATE_EREC_OBJECT'
EXPORTING
notif_objid = notificationid
notif_type = notificationtype
IMPORTING
return = return
EXCEPTIONS
no_isr_update = 1
database_error = 2
general_error = 3
req_object_found = 4
no_erec_approval = 5
erec_sys_error = 6
status_error = 7
OTHERS = 8.

IF sy-subrc <> 0.
* Messages already raised, exceptions should be handled here
* due to workflow intricacy.
ENDIF.

Regards,

Rich Heilman

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
756

Everything must be inside the METHOD...ENDMETHOD.





METHOD CREATENBOBJECT.


INCLUDE <CNTAIN>.

DATA: newvariable(12) type n.
swc_get_element container 'REQUISITION_NUM' newvariable.


CALL FUNCTION 'ZHRWPC_EREC_CREATE_EREC_OBJECT'
EXPORTING
notif_objid = notificationid
notif_type = notificationtype
IMPORTING
return = return
EXCEPTIONS
no_isr_update = 1
database_error = 2
general_error = 3
req_object_found = 4
no_erec_approval = 5
erec_sys_error = 6
status_error = 7
OTHERS = 8.

IF sy-subrc <> 0.
* Messages already raised, exceptions should be handled here
* due to workflow intricacy.
ENDIF.

Regards,

Rich Heilman

Read only

0 Likes
755

Hi Rich,

Thanks for your reply. I did like you said. Now the error changed to:

Include <CNTAIN>

Within classes and interfaces, you can only use "TYPE" to refer to ABAP

Dictionary types, not "LIKE" or "STRUCTURE".

Kindly help me out here.

Regards

Srinivas

Read only

0 Likes
755

I will need to log on to my system at work. I'll get back.

Regards,

RIch Heilman

Read only

0 Likes
755

Seems that classes have issues with the INCLUDE statement. You can simply copy our the macro definition from the INCLUDE and put it directly into the method.



method createnbobject.


  data: container type table of swcont.

  data: newvariable(12) type n.


  define swc_get_element.
    call function 'SWC_ELEMENT_GET'
         exporting
              element   = &2
         importing
              field     = &3
         tables
              container = &1
         exceptions
              not_found = 8
              is_null   = 4
              others    = 1.
  end-of-definition.

  swc_get_element container 'REQUISITION_NUM' newvariable.


endmethod.

Regards,

RIch Heilman

Read only

0 Likes
755

Hi Rich,

Did you mean like this:

METHOD CREATENBOBJECT.

INCLUDE <CNTAIN>.

DATA: newvariable(12) type n.

DATA: container type table of swcont.

define swc_get_element.

call function 'SWC_ELEMENT_GET'

exporting

element = &2

importing

field = &3

tables

container = &1

exceptions

not_found = 8

is_null = 4

others = 1.

end-of-definition.

swc_get_element container 'REQUISITION_NUM' newvariable.

CALL FUNCTION 'ZHRWPC_EREC_CREATE_EREC_OBJECT'

EXPORTING

notif_objid = notificationid

notif_type = notificationtype

IMPORTING

return = return

EXCEPTIONS

no_isr_update = 1

database_error = 2

general_error = 3

req_object_found = 4

no_erec_approval = 5

erec_sys_error = 6

status_error = 7

OTHERS = 8.

IF sy-subrc <> 0.

  • Messages already raised, exceptions should be handled here

  • due to workflow intricacy.

ENDIF.

ENDMETHOD.

If yes, I am getting an error:

Include <CNTAIN>

Within classes and interfaces, you can only use "TYPE" to refer to ABAP

Dictionary types, not "LIKE" or "STRUCTURE".

Thanks and Regards

Srinivas

Read only

0 Likes
755

Hi Rich,

It did solve the problem, I didn't remove the Include statement last time.

Thanks and Regards!

Srinivas