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

Append an Internal Table in OO

Former Member
0 Likes
1,836

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
954

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.

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
954

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

Read only

Former Member
0 Likes
955

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.

Read only

0 Likes
954

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

Read only

Former Member
0 Likes
954

Understood.Thanks a lot.