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 Grid

Former Member
0 Likes
901

Hello,

I am using an ALV grid to display inventory movement. Everything is working correctly, I just need to be able to display the columns in a different order than is currently display on the ALV. I have the internal table in the order that I want the information to be displayed, but it is not coming out that way. Any advice would be greatly appreciated.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
884

Danielle,

The order of the fields is controlled by the fieldcatalog that gets built for the ALV. There should be a column position field that can be updated.

Either that or the user can change the layout themselves once in the Grid using the layout functions available.

Chris

Hello,

I am using an ALV grid to display inventory movement. Everything is working correctly, I just need to be able to display the columns in a different order than is currently display on the ALV. I have the internal table in the order that I want the information to be displayed, but it is not coming out that way. Any advice would be greatly appreciated.

Regards

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
884

Misunderstood question

Regards,

Rich Heilman

Read only

0 Likes
884

You do not have to set the column position, if you don't, then the order is taken by the order in which the fields were added to the field catalog, not the order of the fields in the internal table.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
885

Danielle,

The order of the fields is controlled by the fieldcatalog that gets built for the ALV. There should be a column position field that can be updated.

Either that or the user can change the layout themselves once in the Grid using the layout functions available.

Chris

Read only

Former Member
0 Likes
884

Hi

The order of colunm depends of the position it's setted in catalog table.

You can change it updating the value of field col_pos of structure IT_FIELDCAT.

Fm REUSE_ALV_FIELDCATALOG_MERGE is usually used to build catalog table, you should have a code like this:

gt_repid = sy-repid.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = gt_repid

i_internal_tabname = 'T_OUTPUT'

i_inclname = gt_repid

changing

ct_fieldcat = gt_fieldcat[].

This fm results a catalog table where the colunms have the same order as internal table is defined.

So if you need change positions you can use a code like this:

loop at gt_fieldcat into ls_fieldcat.

case ls_fieldcat-fieldname.

when '......'. ls_fieldcat-col_pos = <pos>.

.............

endcase.

modify gt_fieldcat from ls_fieldcat.

endloop.

Max

P.s.: Have you solved your problem of yesterday?

Read only

Former Member
0 Likes
884

Hi,

You can build your Field catalog as per your requirement.

Check the below code.

Data : WA_FLDCAT TYPE LVC_S_FCAT,

LT_FLDCAT TYPE LVC_T_FCAT.

WA_FLDCAT-COL_POS = '1'. <column position>

WA_FLDCAT-FIELDNAME = 'FINANCIER_ID'. <field name in the Internal table>

WA_FLDCAT-REF_TABLE = <Database Table Name>.

WA_FLDCAT-REF_FIELD = 'FINANCIER_ID'. <Field Name in Database>

WA_FLDCAT-TABNAME = 'LT_FINANCIER'. <Internal Table Name>

WA_FLDCAT-OUTPUTLEN = '20'. <output lenght>

WA_FLDCAT-NO_OUT = SPACE.

WA_FLDCAT-EDIT = 'X'. <to make field editable>

WA_FLDCAT-SCRTEXT_M = 'Financier ID'(006). <Header text>

WA_FLDCAT-F4AVAILABL = '1'. <to activate F4 help>

WA_FLDCAT-CHECKTABLE = '/ILAP/TRN_CLOSE'. <check table>

APPEND WA_FLDCAT TO LT_FLDCAT01.

CLEAR WA_FLDCAT.

Based on your requirement you can assign different column numbers to different fields in your internal table.

Regards,

Vara

Read only

Former Member
0 Likes
884

hi,

i hope you are using the fm to populate the fieldcat.

in that case you need to modify the col_pos.

read the it_fieldcat with fieldname and modify the col_pos.

regards

vijay

Read only

Former Member
0 Likes
884

Thanks for all your advice. I did have everything set up correctly and after a few debugging sessions, it was displaying the way the fields are set up in the ITAB. So everything is fine now.

Thanks again!