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: 

Using ALV display variants using class CL_ALV_VARIANT

Former Member
0 Kudos

Hello,

I am working on developing an ALV report and I want to limit the use of Function calls and Forms. I would rather use Method calls using classes, using a more ABAP Object-Oriented approach. Searching for any documentation on the class on SDN has proved fruitless. So, my question is, has anyone had any success implementing display variants on an ALV report using the CL_ALV_VARIANT class methods?

9 REPLIES 9

Former Member
0 Kudos

Brian,

I have not implemented the class, but the parameters look more or less same as that of the function module, Is there a specific issue that you are facing?

Can you give some details?

Regards,

Ravi

0 Kudos

Hi Ravi,

I am trying to implement the F4 selection help when selecting the Variant from the Selection Screen. I have been using method SELECT_VARIANT because it calls the LT_F4_FOR_VARIANTS funtion within its source code. Problem is that when it executes the method, the program errors out when it tries to assign a table to a field symbol. I am not sure what table it is looking for because the description of the attribute MT_OUTTAB is 'Original Data Table'. I assume that when I create the object for CL_ALV_VARIANT, I should pass the table to it, but I don't know what table the program is looking for that early in the execution.

Any help would be much appreciated.

Regards,

Brian

0 Kudos

For F4 help on variant on selection screen you can use this code -

parameters alv_def like disvariant.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR alv_def.

PERFORM alv_f4.

form alv_f4.

alv_variant-report = sy-repid.

CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

EXPORTING

is_variant = alv_variant

i_save = 'A'

IMPORTING

es_variant = alv_variant

EXCEPTIONS

not_found = 2.

IF sy-subrc = 2.

MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

alv_def = alv_variant-variant.

ENDIF.

ENDFORM.

Cheers

Former Member
0 Kudos

Thank you for the code, however, I am trying to get away from the function call. I have used that same code in past programs, but I would like to utilize the Methods of the CL_ALV_VARIANT class rather than the function module call.

Former Member
0 Kudos

Thank you for all your help, however I found the solution on my own. If anyone is interested in seeing how I implemented the display variant using methods, let me know.

Thanks,

Brian

0 Kudos

Hi Brian,

I'm interested in how u implemented it, could you share the code with me.

Mail: jgtang82@yahoo.com

Regards,

-Tim

0 Kudos

Hi there

I'm also interested to know on how to do this. thanks alot for sharing.

pls send to andrew_chiam@hotmail.com

0 Kudos

Hi Brian,

I am also trying to use classes but I got stuck at handling variants for reports in particular at instantiating the cl_alv_variant. I don't quite know what to pass for it_output

Thanks in advance,

0 Kudos

Can you please send your solution to: prteewaree AT hotmail.com?

Thanks,

Pramod.