Methode-Parameter Bezugstyp Tabelle

Die Objektorientierung mit ABAP®: Vererbung, Dynamische Programmierung, GUI Controls (u.a. ALV im OO).

Methode-Parameter Bezugstyp Tabelle

Postby Jesper2188 » Fri Nov 09, 2012 11:58 am

Hallo zusammen,
ich drehe mich im Kreis....
Ich will eine Methode einer Klasse verwenden. Ein Parameter der Methode hat Bezugstyp einen Tabellentyp aus Dictionary. Zeilentyp des Tabellentyps ist als Referenztyp - Referierte Typ - cl_eine_klasse definiert. Wenn ich eine interne Tablle definiere als TYPE o.g. Tabellentyp und verwede ich sie im Parameter der Methode, bekomme ich Fehlermeldung, daß meine interne Tabelle nicht typkompatibel zum formalen Parameter ist.

Code:
.....
.....
"tables
DATA: component_itab TYPE CKF_COMPONENT_TABLE. "(tabelle in Repository mit Zeilentyp - Klasse)
....
....

CALL METHOD
LR_WRAP_MATERIAL->IF_OBJECT_OF_COSTING~GET_COSTING_COMPONENTS
EXPORTING
IM_IF_COMPONENT_FACTORY = component_itab "und da kommt die Fehlermeldung!


was mache ich falsch?
Gruß
Jarda
Jesper2188
.
.
 
Posts: 5
Joined: Mon Aug 09, 2010 2:51 pm

Re: Methode-Parameter Bezugstyp Tabelle

Postby Jonny2227 » Fri Nov 09, 2012 1:33 pm

Sali,

dein Aufruf ist auch falsch - denn die emthode hat einen Import und einen Export Parameter und du gibst deine Tabelle dem Import Parameter mit
... so müsste der Aufruf aussehen

DATA: component_itab TYPE CKF_COMPONENT_TABLE.
data factory type i.

CALL METHOD
LR_WRAP_MATERIAL->IF_OBJECT_OF_COSTING~GET_COSTING_COMPONENTS
( EXPORTING IM_IF_COMPONENT_FACTORY = factory
Importing = ex_components = component_itab ).

... was in Factory drin stehen müsste kann ich dir nicht sagen - dazu einfach die Doku zum Interface / Klasse beachten !

Gruss Jens
Jonny2227
....
....
 
Posts: 605
Joined: Wed Mar 01, 2006 3:16 pm

Re: Methode-Parameter Bezugstyp Tabelle

Postby Tron » Fri Nov 09, 2012 2:16 pm

Moin,
hier ein Beispiel mit der Übergabe einer REFERENZ eines Tabellentyps an eine Methode:
Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. REPORT  ZTEST_REF_TO.
  2.  
  3. data gclass type ref to Z_MY_APPLCLASS.
  4. data ls_tline type TLINE.
  5.  
  6. DATA: component_itab TYPE tsftext.
  7. data ref_comp_tab type ref to tsftext.
  8.  
  9. CREATE OBJECT gclass .
  10.  
  11. GET REFERENCE OF component_itab INTO ref_comp_tab .
  12.  
  13. ls_tline-TDFORMAT = '*'.
  14. ls_tline-TDLINE = 'Hallo'.
  15. append ls_tline to component_itab.
  16. ls_tline-TDLINE = 'Forum'.
  17. append ls_tline to component_itab.
  18.  
  19. * ref_comp_tab ist hier mit REF TO TSFTEXT deklariert
  20. CALL METHOD gclass->get_userid
  21.   EXPORTING
  22.     mytable = ref_comp_tab.
  23.  
  24. free gclass.
  25.  
GeSHi ©


gruß Jens
Tron
.....
.....
 
Posts: 1112
Joined: Sat Aug 04, 2007 10:21 pm

Re: Methode-Parameter Bezugstyp Tabelle

Postby Jesper2188 » Fri Nov 09, 2012 8:37 pm

Hallo Jens,
upss, habe mich übersechen. export<->import........
DANKE!!!
Gruß
Jarda
Jesper2188
.
.
 
Posts: 5
Joined: Mon Aug 09, 2010 2:51 pm


Return to ABAP Objects®

Who is online

Users browsing this forum: No registered users and 2 guests