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

Doing 3 methods in one implementation

Former Member
0 Likes
1,078

hi all ,

there is option instead of doing this 3 methods to do one that can do the same for all objects

i cant using perform since this implementation is under class .

Regards

Chris

method input :

IT_USERID	TYPE ZT_DM_USER_RANGE_VALUE

method implementation

  DATA: ls_userid TYPE C_user_range_value,
        ls_rang_usrs TYPE LINE OF ty_range_users.

  LOOP AT it_userid INTO ls_userid.
    ls_rang_usrs-sign = 'I'.
    ls_rang_usrs-option = 'EQ'.
    ls_rang_usrs-low = ls_userid-userid.
    APPEND ls_rang_usrs TO mt_user_range.
  ENDLOOP.

method input :

IT_USERID	TYPE Ztor_coer_id

method implementation

  DATA: ls_con_type TYPE Zor_coer_id,
        ls_rang_cons TYPE LINE OF ty_range_con.

  LOOP AT it_con_type INTO ls_con_type.
    ls_rang_cons-sign = 'I'.
    ls_rang_cons-option = 'EQ'.
    ls_rang_cons-low = ls_con_type.
    APPEND ls_rang_cons TO mt_cons_range.
  ENDLOOP.

method input :

IT_USERID	TYPE Ztm_apd

method implementation

  DATA: ls_apd TYPE Zm_apd,
      ls_rang_apd TYPE LINE OF ty_range_apd.

  LOOP AT it_apd INTO ls_apd.
    ls_rang_apd-sign = 'I'.
    ls_rang_apd-option = 'EQ'.
    ls_rang_apd-low = ls_apd.
    APPEND ls_rang_apd TO mt_apd_range.
  ENDLOOP.

Moderator message - Moved to the correct forum

Edited by: Rob Burbank on Oct 19, 2009 10:02 AM

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
1,048

Use standard dynamic programming techniques -


DATA. lp_data TYPE REF TO DATA.

CREATE lp_data LIKE LINE OF input table.
ASSIGN lp_data->* TO <ls_table>.

ASSIGN COMPONENT ... OF STRUCTURE <ls_table> TO <l_field>.

LOOP AT input table INTO <ls_table>.
  <l_field> = some value.

10 REPLIES 10
Read only

matt
Active Contributor
0 Likes
1,049

Use standard dynamic programming techniques -


DATA. lp_data TYPE REF TO DATA.

CREATE lp_data LIKE LINE OF input table.
ASSIGN lp_data->* TO <ls_table>.

ASSIGN COMPONENT ... OF STRUCTURE <ls_table> TO <l_field>.

LOOP AT input table INTO <ls_table>.
  <l_field> = some value.

Read only

matt
Active Contributor
0 Likes
1,048
method importing IT_data TYPE any table
       exporting et_range TYPE any table.
 
method implementation
 
DATA: lp_data TYPE REF TO DATA.

FIELD-SYMBOLS: <ls_data_wa> TYPE ANY,
             <ls_rang_wa> TYPE ANY,
             <l_sign> TYPE ANY,
             <l_opt>   TYPE ANY,
             <l_low>  TYPE ANY.

CREATE DATA lp_data LIKE LINE OF et_range.
ASSIGN lp_data->* TO <ls_rang_wa>.

ASSIGN COMPONENT 'SIGN' OF STRUCTURE <ls_rang_wa> TO <l_sign>.
ASSIGN COMPONENT 'OPTION'  OF STRUCTURE <ls_rang_wa> TO <l_opt>.
ASSIGN COMPONENT 'LOW' OF STRUCTURE <ls_rang_wa> TO <l_low>.

  <l_sign> = 'I'.
  <l_opt> = 'EQ'.
  LOOP AT it_data ASSIGNING <ls_data_wa>..
    <l_low> = <ls_data_wa>.
    APPEND <ls_rang_wa> TO et_range.
  ENDLOOP.
Read only

Former Member
0 Likes
1,048

Hi Matt,

thanks !

in method signatrue i cant define variable as type table of ,

what i can i just type any there is way to overcome it ?

since i had problem with this statement

CREATE DATA lp_data LIKE LINE OF et_range.

Regards

Chris

Read only

matt
Active Contributor
0 Likes
1,048

Define the importing and exporting parameter as "TYPE... ANY TABLE", just as I said. If you're having trouble with CREATE DATA, could you please be specific what trouble you are having.

I use this stuff all the time, so I know it works.

matt

Read only

Former Member
0 Likes
1,048

HI Matt,

Yes u are right ,

i have anoter problem with the line

APPEND <ls_rang_wa> TO et_range.

i get this error :

You cannot use explicit or implicit index operations on tables with

types "HASHED TABLE" or "ANY TABLE". "ET_RANGE" has the type "ANY

TABLE". It is possible that before "ET_RANGE".

any idea ?

Regards

Chris

Read only

matt
Active Contributor
0 Likes
1,048

Yes, you can't use APPEND with a table that's "ANY TABLE", because it could be a HASHED TABLE. So you either use INSERT <ls_range_wA INTO TABLE et_range. Or, better, since et_range is always a table of ranges, you narrow the range to type STANDARD TABLE.

I suggest you read the help on the various table types - it's fairly fundemental to ABAP programming.

matt

Read only

Former Member
0 Likes
1,048

HI Matt,

i read the help and i not sure that i got the point of_: you narrow the range to type STANDARD TABLE._

do u mean to create range table on the ddic ?

Regards

Chris

Read only

matt
Active Contributor
0 Likes
1,048

No, I mean instead of defining the type of et_range as "ANY TABLE", you define it as "STANDARD TABLE".

matt

Read only

Former Member
0 Likes
1,048

Thanks Matt !

Read only

naimesh_patel
Active Contributor
0 Likes
1,048

You can create a MACRO in the tab "Macros" in class builder.

Check help on Macros for how to use it.

Regards,

Naimesh Patel