Skip to Content

alv grid colon names

Hello ,

I have to write a rapport with 'REUSE_ALV_GRID_DISPLAY' fm . The list has to show all users and the roles that are assigned to each of them .

The list has to look something like below

User | role_A | role_b | role_123 | role_54 | role_11 | role_56 |

user1 X X X X

user2 X

user3 X X

I have to pick all roles from system ( agr_define) and use their names as a colon name . Please can someone explain how I can transfer each value from

table to column name of internal table that will be displayed .

Thanks

Chris

Moderator message: Not enough research before posting. Please refer to concept dynamic internal tables.

Message was edited by: Kesavadas Thekkillath

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2012 at 11:40 AM

    Hi,

    Do something like this.

    Create a dynamic internal table to hold the values.

    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, “ Dynamic internal table name

    <fs_dyntable>, “ Field symbol to create work area

    <fs_fldval> type any. “ Field symbol to assign values

    DATA: t_newtable TYPE REF TO data,

    t_newline TYPE REF TO data,

    t_fldcat TYPE slis_t_fldcat_alv,

    t_fldcat TYPE lvc_t_fcat,

    wa_it_fldcat TYPE lvc_s_fcat,

    wa_colno(2) TYPE n,

    wa_flname(5) TYPE c.


    wa_it_fldcat-fieldname = 'USR'. " Add the User field first

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 12.

    APPEND wa_it_fldcat TO t_fldcat.

    LOOP AT gt_agr_define INTO wa. " Add roles to the internal table structure

    wa_it_fldcat-fieldname = wa-agr_name.

    wa_it_fldcat-datatype = 'CHAR'.

    wa_it_fldcat-intlen = 1.

    READ TABLE t_fldcat WITH KEY fieldname = wa-agr_name TRANSPORTING NO FIELDS.

    IF sy-subrc NE 0.

    APPEND wa_it_fldcat TO t_fldcat.

    ENDIF.

    ENDLOOP.

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    it_fieldcatalog = t_fldcat

    IMPORTING

    ep_table = t_newtable.

    ASSIGN t_newtable->* TO <t_dyntable>. " Dynamic internal table

    * Create dynamic work area and assign to FS

    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.

    ASSIGN t_newline->* TO <fs_dyntable> " This is your dynamic work area.

    * Filling Data to the new dynamic table

    LOOP AT gt_agr_define INTO wa.

    ASSIGN COMPONENT wa-agr_name OF STRUCTURE <fs_dyntable> TO <fs_fldval>.

    IF sy-subrc = 0.

    <fs_fldval> = 'X'.

    ENDIF.

    ENDLOOP.

    You will need to work with this as base and modify accordingly.

    This may have syntax errors, because I dont have access to SAP now.

    Thanks,

    Shambu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.