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: 

Reading Dynamically assigned internal table attribute of class in Class Method

janisar_munshi
Participant
0 Kudos

Gurus,
I am making a class for an ALV Reporting utility for the project. This utility is for quick alv reporting without much of the effort.
Class method "Display_ALV" is accepting Internal table as parameter that I am assigning to the instance attribute "gt_data Type Ref To DATA" with accessibility as public.

r
With use of standard ALV class provided by sap I am able to generate the alv based on the internal table and its fields.

Now, the issue I am facing is while handling double click event.  I am assigning the instance attribute using


CREATE DATA gt_data like it_table . (It_table is importing parameter of any type assigned to instance attribute during display method)

This table I am reading in the Event Handle Method.

"METHOD handle_dblclick.

FIELD-SYMBOLS: <fs_table> TYPE REF TO data.

data lv_matnr type matnr.

  RAISE EVENT alv_dblclick EXPORTING  row     = row

                                      column  = column.

ASSIGN gt_data->* to <fs_table>.

READ TABLE <fs_table> assigning <wa> index row.

if sy-subrc = 0.

  SET PARAMETER ID 'MAT' FIELD <wa>-matnr. "For example

"( Field name MATNR is reading from the field catalog based on the column number so practically there may be any field of any type)

  CALL TRANSACTION 'MM43' AND SKIP FIRST SCREEN. "This transaction code also I am accepting in the import parameter.

endif.

ENDMETHOD."

I am getting error while reading table gt_data that "Read table dbtab" is not supported in OO Context.

Please help.

Thanks,
Janisar

1 ACCEPTED SOLUTION

former_member184569
Active Contributor
0 Kudos

When declaring field symbol, dont give type ref to data, just give type standard table.

FIELD-SYMBOLS: <fs_table> TYPE Standard table.

5 REPLIES 5

arindam_m
Active Contributor
0 Kudos

Hi,

Try looking into CL_SALV_TABLE,  CL_SALV_EVENTS_TABLE and DEMO Codes would give you an idea how you can build the events for your class.

Your class design has to be similar in design to these standard classes for the interaction to work. You can check their usages should help you design it.

Cheers,

Arindam

0 Kudos

Thank you Arindam for the response.

My ALV Functionality and Event is working perfectly fine. my method is also called on double click.

What I need is to read the instance attribute based on the row and col.

I tried searching on the web for the same but they are working fine with normal abap reporting but not in OO context.

Thanks,

Janisar

former_member184569
Active Contributor
0 Kudos

When declaring field symbol, dont give type ref to data, just give type standard table.

FIELD-SYMBOLS: <fs_table> TYPE Standard table.

0 Kudos

Hello Susmitha,

I am working in SAP FPM (WDP/FPM). As suggested by I have declared the field symbol of type standard table. Still dump or run time error.

In my application, CS_DATA is dynamically changing the structure. Every time different structure is loading.

My code:

    FIELD-SYMBOLS: <ls_data>       TYPE standard table,

  <ls_data_title> TYPE any,

<LFS_value> type any.

IF NOT cs_data IS INITIAL.

ASSIGN cs_data->* TO <ls_data>.

IF <ls_data> IS ASSIGNED.

ASSIGN COMPONENT 'TITLE' OF STRUCTURE <ls_data> TO <ls_data_title>.

IF <ls_data_title> IS ASSIGNED AND <ls_data_title> IS NOT INITIAL.

ASSIGN COMPONENT 'ZZEHSM_NEW_NR'  OF STRUCTURE <ls_data> TO <LFS_value>.

IF <LFS_value> IS ASSIGNED.

MOVE '2016-06-0001' to <LFS_value>.

ENDIF.

ENDIF.

UNASSIGN: <ls_data_title>, <LFS_value>.

ENDIF.

.


Dump is at statement: ASSIGN cs_data->* TO <ls_data>.

Can you please suggest.

Thanks,

Yerukala Setty



Former Member
0 Kudos

Hi,

Try declaring field symbol of type any. It will take the structure type automatically.

Regards,

Chandresh