01-21-2014 9:26 AM
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
01-21-2014 9:32 AM
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.
01-21-2014 9:32 AM
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.
01-21-2014 9:36 AM
01-21-2014 9:47 AM
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
01-21-2014 9:50 AM
User has the option to position the fields when choosing field.
Nabheet
01-21-2014 10:15 AM
Hi Vijaykrishna,
Its a layout issue.
Read the below document and assign like Please use I_SAVE = 'A'.
Arivazhagan S
09-29-2014 6:26 AM
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
09-29-2014 8:00 AM
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.
09-29-2014 11:58 AM
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.