2008 May 23 5:34 AM
Hi All,
How to Use an internal Table in classes.How to use these internal tables in one or more classes declared locally & How to append it?I need an example in OO ABAP.
Thanks & Regards,
Ravi S
2008 May 23 6:00 AM
Hi UWe,
Thanks for UR Reply.But how to pass these Internal Tables as parameters in Methods.
Also I'm trying to understand this Append statement in.
METHOD CREATE_TEAM.
DO TEAM_MEMBERS TIMES.
CREATE OBJECT BIKER EXPORTING TEAM_ID = ID
MEMBERS = TEAM_MEMBERS.
APPEND BIKER TO BIKER_TAB.
CALL METHOD BIKER->STATUS_LINE IMPORTING LINE = STATUS_LINE.
APPEND STATUS_LINE TO STATUS_LIST.
ENDDO.
ENDMETHOD.
in the link [Sap Help for Using Methods|http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6554f411d194a60000e8353423/content.htm]
can u explain the above statement about Append.
Thanks & Regards,
Ravi S.
Hi UWe,
Thanks for UR Reply.But how to pass these Internal Tables as parameters in Methods.
Also I'm trying to understand this Append statement in.
METHOD CREATE_TEAM.
DO TEAM_MEMBERS TIMES.
CREATE OBJECT BIKER EXPORTING TEAM_ID = ID
MEMBERS = TEAM_MEMBERS.
APPEND BIKER TO BIKER_TAB.
CALL METHOD BIKER->STATUS_LINE IMPORTING LINE = STATUS_LINE.
APPEND STATUS_LINE TO STATUS_LIST.
ENDDO.
ENDMETHOD.
in the link [Sap Help for Using Methods|http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6554f411d194a60000e8353423/content.htm]
can u explain the above statement about Append.
Thanks & Regards,
Ravi S.
2008 May 23 5:49 AM
Hello Ravi
If you have abandoned using header lines you know already how to do this. Basically itabs in classes are always based on table types.
DATA:
lt_return TYPE bapirettab, " table type of BAPIRET2
ls_return TYPE bapiret2.
" OR: ls_return LIKE LINE OF lt_return.
...
LOOP AT lt_return INTO ls_return.
...
ENDLOOP.
The same is true for static/instance attributes.
Regards
Uwe
2008 May 23 6:00 AM
Hi UWe,
Thanks for UR Reply.But how to pass these Internal Tables as parameters in Methods.
Also I'm trying to understand this Append statement in.
METHOD CREATE_TEAM.
DO TEAM_MEMBERS TIMES.
CREATE OBJECT BIKER EXPORTING TEAM_ID = ID
MEMBERS = TEAM_MEMBERS.
APPEND BIKER TO BIKER_TAB.
CALL METHOD BIKER->STATUS_LINE IMPORTING LINE = STATUS_LINE.
APPEND STATUS_LINE TO STATUS_LIST.
ENDDO.
ENDMETHOD.
in the link [Sap Help for Using Methods|http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6554f411d194a60000e8353423/content.htm]
can u explain the above statement about Append.
Thanks & Regards,
Ravi S.
2008 May 23 9:50 AM
Hello Ravi
I added the relevant coding from the SAP docu. Please check my comments in the coding below.
...
TYPES: BIKER_REF TYPE REF TO C_BIKER,
BIKER_REF_TAB TYPE STANDARD TABLE OF BIKER_REF
WITH DEFAULT KEY,
BEGIN OF STATUS_LINE_TYPE,
FLAG(1) TYPE C,
TEXT1(5) TYPE C,
ID TYPE I,
TEXT2(7) TYPE C,
TEXT3(6) TYPE C,
GEAR TYPE I,
TEXT4(7) TYPE C,
SPEED TYPE I,
END OF STATUS_LINE_TYPE.
...
DATA: ID TYPE I,
STATUS_LINE TYPE STATUS_LINE_TYPE,
STATUS_LIST TYPE SORTED TABLE OF STATUS_LINE_TYPE
WITH UNIQUE KEY ID,
BIKER_TAB TYPE BIKER_REF_TAB,
BIKER_SELECTION LIKE BIKER_TAB,
BIKER LIKE LINE OF BIKER_TAB.
METHODS: WRITE_LIST.
ENDCLASS.
...
METHOD CREATE_TEAM.
DO TEAM_MEMBERS TIMES.
" Biker instance is created. The biker has a private instance attribute STATUS_LINE
" of TYPE status_line_type (i.e. a structure).
CREATE OBJECT BIKER EXPORTING TEAM_ID = ID
MEMBERS = TEAM_MEMBERS.
APPEND BIKER TO BIKER_TAB.
" Here we read the private attribute STATUS_LINE from the biker instance.
CALL METHOD BIKER->STATUS_LINE
IMPORTING
LINE = STATUS_LINE.
" And here the STATUS_LINE is added to the itab STATUS_LIST
" which is a (sorted) table type of TYPE status_line (see above)
APPEND STATUS_LINE TO STATUS_LIST.
" Thus, method CREATE_TEAM collect the status lines of the bikers in the team.
ENDDO.
ENDMETHOD.Regards
Uwe
2008 May 24 6:50 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |