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

ALV Display fromant using grid function module

Former Member
0 Likes
548

ALV

i have created table types (tt1) with f1,f2,f3 and f4 and (tt2) f5 and f6 using different line types.

Now i want display column order f6,f4,f3,f2,f5 and f1 in alv output .

it should happen before displaying the alv out put.

i don'T want go for ALV varient methood and change layout after ALV display.

any thoughts about this logic...

...Nandha

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
520

When building the field catalog, simply add them to the field cat internal table in that order. Or if you are using the MERGE function module, you could possible loop thru it and reset the column number in the order that you want.

Regards

Rich HEilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
521

When building the field catalog, simply add them to the field cat internal table in that order. Or if you are using the MERGE function module, you could possible loop thru it and reset the column number in the order that you want.

Regards

Rich HEilman

Read only

0 Likes
520

For example, say you are using the MERGE field catalog, notice in this example, i'm loop thru the field catalog and changing the column position numbers.



type-pools: slis.

data: begin of xma,
       matnr like makt-matnr,
       maktx like makt-maktx,
       fld1(10) type c,
       fld2(10) type c,
       end of xma.

data: ima like standard table of xma with header line.
data: fieldcat type slis_t_fieldcat_alv.
data: wa_fieldcat like line of fieldcat.
data: repid type syrepid.

repid = sy-repid.

select matnr maktx
                 into table ima
                       from makt
                             up to 100 rows
                                where spras = sy-langu.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
     exporting
          i_program_name     = repid
          i_internal_tabname = 'XMA'
          i_inclname         = repid
          i_bypassing_buffer = 'X'
     changing
          ct_fieldcat        = fieldcat.


loop at fieldcat into wa_fieldcat.
  case wa_fieldcat-fieldname.
    when 'FLD1'.
      wa_fieldcat-col_pos = '1'.
    when 'FLD2'.
      wa_fieldcat-col_pos = '2'.
    when 'MATNR'.
      wa_fieldcat-col_pos = '3'.
    when 'MAKTX'.
      wa_fieldcat-col_pos = '4'.
  endcase.
  modify fieldcat from wa_fieldcat index sy-tabix.
endloop..

call function 'REUSE_ALV_GRID_DISPLAY'
     exporting
          it_fieldcat = fieldcat
     tables
          t_outtab    = ima.

Regards,

Rich HEilman

Read only

0 Likes
520

You can do the same thing when building your field catalog manually, just give the COL_POS a value for the sequence you want.

Regards,

Rich Heilman

Read only

former_member194669
Active Contributor
0 Likes
520

Nandha,

Create a field catalog of whichever order in which you need the fields and then pass this fieldcatalog to

if you are use REUSE* fm then pass this as import parameter

of

if you are using class set_table_first_display then pass fieldcatalog as import table parameter.

Search this site , you will get lot of example programs

aRs