Skip to Content
author's profile photo Former Member
Former Member

Change the field order in ALV when using LVC_FIELDCATALOG_MERGE

Hi,

is it possible to change the order of fields displayed in an alv grid if using LVC_FIELDCATALOG_MERGE FM instead of building the fieldcat field by field ?

Thanks,

Tom.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 11:45 AM

    Hi,

    DATA : WA_FIELDCAT LIKE LINE OF FIELDCAT.

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = SY-REPID

    I_INTERNAL_TABNAME = 'STR_OUTPUT'

    • I_STRUCTURE_NAME =

    • I_CLIENT_NEVER_DISPLAY = 'X'

    I_INCLNAME = 'ZSGCS_R_WEEK_TRAK_DAYS_TO_INVO'

    I_BYPASSING_BUFFER = 'X'

    I_BUFFER_ACTIVE = 'X'

    CHANGING

    CT_FIELDCAT = FIELDCAT[].

    LOOP AT FIELDCAT INTO WA_FIELDCAT.

    CASE WA_FIELDCAT-FIELDNAME.

    WHEN 'SEQNR'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-002.

    WA_FIELDCAT-COL_POS = '1'.

    WHEN 'KUNUM'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-006.

    WA_FIELDCAT-COL_POS = '2'.

    WHEN 'AUFNR'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-007.

    WA_FIELDCAT-COL_POS = '3'.

    WHEN 'KTEXT'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-008.

    WHEN 'VKORG'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-009.

    WHEN 'VTWEG'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-010.

    WHEN 'SPART'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-011.

    WHEN 'VKBUR'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-012.

    WHEN 'VKGRP'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-013.

    WHEN 'IDAT2'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-014.

    WHEN 'DLATT'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-003.

    WHEN 'VBELN'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-027.

    WHEN 'DINVO'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-004.

    WHEN 'DTOIN'.

    WA_FIELDCAT-SELTEXT_L = WA_FIELDCAT-SELTEXT_M =

    WA_FIELDCAT-SELTEXT_S = WA_FIELDCAT-REPTEXT_DDIC = TEXT-005.

    ENDCASE.

    MODIFY FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.

    ENDLOOP.

    Regards,

    Rajasekhar Reddy.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 23, 2008 at 11:25 AM

    <snip>

    matt

    removed because it was nonsense.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 12:40 PM

    Of course.

    It's (the field catalog) just a standard internal table which reflects the structure or table you want to display in the grid.

    However you'll have to re-order your data table as well .

    (Same is true in the OO model as well).

    The easiest way however is just to change and save the layout as Vijay above suggested. Here you can omit columns, re-arrange, sum etc etc. (Also for the OO model)

    just save the layouts you want.

    cheers

    jimbo

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 11:36 AM

    hi,

    You can change the order of display when you create a field Catalog field by field.

    Here in this FM you have a merged Field Catalog.

    You can change the Order of display.

    Reagrds

    Sumit Agarwal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 11:37 AM

    hi tom

    modify the fieldcatalog internal table ( column position and row position fields col_pos & row_pos ) as your need

    regards

    deva

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 23, 2008 at 11:41 AM

    First get the Field catalog from the Function

    And now loop the fieldcatalog and change the positions using coding.

    col_pos

    it is difficult to code if you have more columns.

    But work with layouts of ALV. here you can arrange the columns which ever you way you want and save it as Layout Variant.

    and use that Layout Variant for Future

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2008 at 10:56 AM

    Hi,

    You can make your output ALV list fields to appear in any order which you like!! On the ALV list output screen, go to Settings on the menu bar & select Change Layout under the Layout option in Settings...You can re-arrange the order of appearence if the fileds using this & you can save this layout...In your code you can use the FM 'REUSE_ALV_VARIANT_F4'..This will give you an option on the selection-screen itself to choose the layout which you want to display(with the order of field appearcnce of your choice).

    This is the standard way & it works gr8!!

    (ALSO: This method does not require to change the field catalogu as per the order of appearence of fields in the output .)

    Regards

    AnkurGodre

    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.