Application Development 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: 

Parameter type compatable for workarea and internal table.

Former Member
0 Kudos
440

how to declare parameter of a class method , so that it can accept a workarea or an internal table ?

4 REPLIES 4

Clemenss
Active Contributor
0 Kudos
170

If it is not a RETURNING parameter, you may use TYPE ANY. But then you must determined the actual type (table or not) and assign it to a field-symbol. Otherwise you may get errors in syntax check.

If you tell us what you are going to do (details please), we can help you.

Regards

Clemens

Former Member
0 Kudos
170

We are to create document change log, for that the class we have created, should accept either  a workarea or internal table of any kind.

I was trying to create a import parameter of type 'ANY", but when iam trying to pass internal table its erroring out.

0 Kudos
170

Hello Sirisha,

You can design your methods to accept either tables / structures of any types. Below is a working example of passing any DDIC type as structure and working on it in further mehtods.

Check out this sample code.

   

 

CLASS lcl_zclass DEFINITION.

  TYPE-POOLS: abap.

  PUBLIC SECTION.

    DATA:
       mt_dfies       TYPE DDFIELDS  read-only,    
       r_dfies        TYPE DFIES.


    METHODS:
      constructor
        IMPORTING
          value(id_tabname)   TYPE tabname,

       method1
         IMPORTING
           value(it_dfiesTYPE DDFIELDS.

ENDCLASS.

CLASS lcl_zclass IMPLEMENTATION.
  METHOD constructor.


    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        tabname              = id_tabname
*       FIELDNAME            = ' '
*       LANGU                = SY-LANGU
*       LFIELDNAME           = ' '
*       ALL_TYPES            = ' '
*       GROUP_NAMES          = ' '
*       UCLEN                =
*     IMPORTING
*       X030L_WA             =
*       DDOBJTYPE            =
*       DFIES_WA             =
*       LINES_DESCR          =
     TABLES
       DFIES_TAB            = me->mt_dfies
*       FIXED_VALUES         =
     EXCEPTIONS
       NOT_FOUND            = 1
       INTERNAL_ERROR       = 2
       OTHERS               = 3
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  ENDMETHOD.

  METHOD method1.
    LOOP AT mt_dfies INTO r_dfies.
       BREAK-POINT.
    ENDLOOP.

  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
" Instantiate your class and use its methods
  DATA:  go_myclass  TYPE REF TO lcl_zclass.

  CREATE OBJECT go_myclass
    EXPORTING
      id_tabname = 'TVARVC'.

    CALL METHOD go_myclass->method1
      EXPORTING
        it_dfies = go_myclass->mt_dfies.

Regards,

Shyam

kumud
Active Contributor
0 Kudos
170

Hello Sirisha,

I just tried to build a method which imports a table of type 'ANY' and for structure I used the type 'DATA'  and it works.

Inside the method I used Field-symbols as below:

FIELD-SYMBOLS: <FS_TAB> TYPE ANY TABLE,
                            <FS_STR> TYPE DATA.

   ASSIGN MI_TABLE TO <FS_TAB>.   "MI_TABLE is importing parameter of type ANY. Pass by Value.
   ASSIGN MI_STRUC TO <FS_STR>.  " MI_STRUC is importing param. of type DATA. Pass by Value.

Are you looking for something else or something specific? Do let know.

Regards,

Kumud