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: 

How to set column position in ALV Grid layout

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Experts, Good day.

I have developed a ALV (Grid) Report with 12 columns. But by default the report should display only 10 columns and if required the User will select the remaining two fields (NAME1 (2), SORTL (3)  from the layout.

For that I have filled the fieldcatlog as below:

  wa_fcat-seltext_m  = 'Customer'.

   wa_fcat-fieldname  = 'KUNAG'.

   wa_fcat-outputlen  = '10'.

   WA_FCAT-COL_POS    = 1.

   append wa_fcat to it_fcat.

   clear wa_fcat.

   WA_FCAT-SELTEXT_M  = 'NAME'.

   WA_FCAT-FIELDNAME  = 'NAME1'.

   WA_FCAT-OUTPUTLEN  = '15'.

   WA_FCAT-COL_POS    = 2.

   WA_FCAT-NO_OUT     = 'X'.

   APPEND WA_FCAT TO IT_FCAT.

   CLEAR WA_FCAT.

   WA_FCAT-SELTEXT_M  = 'MARKET PLACE'.

   WA_FCAT-FIELDNAME  = 'SORTL'.

   WA_FCAT-OUTPUTLEN  = '12'.

   WA_FCAT-COL_POS    = 3.

   WA_FCAT-NO_OUT     = 'X'.

   APPEND WA_FCAT TO IT_FCAT.

   CLEAR WA_FCAT.

   wa_fcat-seltext_m  = 'Month'.

   wa_fcat-fieldname  = 'SPMON'.

   wa_fcat-outputlen  = '7'.

   WA_FCAT-COL_POS    = 4.

   append wa_fcat to it_fcat.

   clear wa_fcat.


And the output is fine. But here the problem is when the User is selecting those required two fields from layout, those are appending/displaying at last. But my User requires them at position 2 and 3.


Can we achieve this? If yes, please let me how to achieve this.


Thank you,

-Vijay

1 ACCEPTED SOLUTION

0 Kudos

If your using OOPS ALV , You can use the method SET_COLUMN_POSITION of the class cl_salv_columns.

You can also achieve user related fields to be displayed , by sorting fields in layout.

8 REPLIES 8

0 Kudos

If your using OOPS ALV , You can use the method SET_COLUMN_POSITION of the class cl_salv_columns.

You can also achieve user related fields to be displayed , by sorting fields in layout.

0 Kudos

Hi Sapna,

I am not using OOALV, just used REUSE_ALV_GRID_DISPLAY.

0 Kudos

Hi Vijay,

Please check creating table dynamically and use the internal table in the ALV FM.

http://wiki.scn.sap.com/wiki/display/ABAP/Dynamic+Internal+table

Hope it might help you.

With Regards,

Giriesh M

0 Kudos

User has the option to position the fields when choosing field.

Nabheet

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi Vijaykrishna,

Its a layout issue.

Read the below document and assign like Please use I_SAVE = 'A'.

  • ' ' = Display variants cannot be saved
  • Defined display variants (such as delivered display variants) can be selected for presentation regardless of this indicator. However, changes cannot be saved.
  • 'X' = Standard save mode
  • Display variants can be saved as standard display variants.Saving display variants as user-specific is not possible.
  • 'U' = User-specific save mode
  • Display variants can only be saved as user-specific.
  • 'A' = Standard and user-specific save mode
  • Display variants can be saved both as user-specific and as standardvariants. Users make their choice on the dialog box for saving thedisplay variant.

Arivazhagan S

Former Member
0 Kudos

Hi Vijaykrishna,

                      You should check in declaration part, It's  important declare each an every field serial order. and In the field catalog section take a variable and its increase the value for each an every fields options and pass the variable in COL_POS. and the the values put in all are caps like 'EBELN', 'I_FINAL'.


Ex-

DATA : C_POS TYPE i.

C_POS
= C_POS + 1.
w_fldcat
-fieldname = 'EBELN'.
w_fldcat
-tabname   = 'I_FINAL'.
w_fldcat
-col_pos   = C_POS.
w_fldcat
-hotspot   = 'X'.
w_fldcat
-seltext_l = 'PO NO'.
w_fldcat
-emphasize = 'C510'.
APPEND w_fldcat TO i_fldcat.
CLEAR : w_fldcat.

C_POS
= C_POS + 1.
w_fldcat
-fieldname = 'EBELP'.
w_fldcat
-tabname   = 'I_FINAL'.
w_fldcat
-col_pos   = C_POS.
w_fldcat
-hotspot   = 'X'.
w_fldcat
-seltext_l = 'PO Item'.
w_fldcat
-emphasize = 'C501'.
APPEND w_fldcat TO i_fldcat.
CLEAR : w_fldcat.

C_POS
= C_POS + 1.
w_fldcat
-fieldname = 'MATNR'.
w_fldcat
-tabname   = 'I_FINAL'.
w_fldcat
-col_pos   = C_POS.
w_fldcat
-emphasize = 'C511'.
w_fldcat
-seltext_l = 'Material NO'.
APPEND w_fldcat TO i_fldcat.
CLEAR : w_fldcat.


Thanks


AnoopMayamkote
Participant
0 Kudos

DATA ; pos type i value '0'


pos = pos + 1

w_fldcat-fieldname = 'MATNR'.
w_fldcat
-tabname   = 'IT_FINAL'.
w_fldcat
-col_pos   = POS.
w_fldcat
-hotspot   = 'X'.
w_fldcat
-seltext_l = 'Material'.

APPEND w_fldcat TO i_fldcat.
CLEAR : w_fldcat.

Former Member
0 Kudos

Hi,

The field that you add, appear up of selected field in displayed columns:

Example:

If you select the first field, columns are added to the end of the list.

Best regards.