ALV Sort Vertical Merging
I am trying to display a table in a subscreen,
1. I have made my sort table and passed it to the set_table_first_display.
lw_sort-spos = '1'.
lw_sort-fieldname = 'KUNNR'.
lw_sort-up = c_x.
* Append Work Area to the Table
APPEND lw_sort TO p_sort.
CLEAR lw_sort.
2. I have also made sure that the No_merging field is not marked in the fieldcatalog and layout.
But inspite of all of this, the cells do NOT get vertically merged.
I was under the impression, In ALV Grid Display, the Sort Criterion by default makes the column contents Vertically merged.
Basically I am getting this as a display,
1400 -------other data -----
1400 -------other data -----
1500 -------other data -----
1500 -------other data -----
I want this,
1400 -------other data -----
-------other data -----
1500 -------other data -----
-------other data -----
How do I achieve this? Doesnt this generally come default in ALV Grid?
Also let me add, my display table is editable, so does this default vertical merge get turned off in any scenario?
Has anyone encountered this/something similar?
Would be thrilled to get a solution.
Thanx.
Message was edited by: Prasenjit Guha
Message was edited by: Prasenjit Guha
Hi Serdar thank you for your post.
How do you suggest I achieve the following for an editable grid.
Current Display,
1400 -------other data -----
1400 -------other data -----
1500 -------other data -----
1500 -------other data -----
I want this,
1400 -------other data -----
-------other data -----
1500 -------other data -----
-------other data -----
Similar Messages
-
SORT Not merging similar fields if there are any editable fields in the ALV
Hi All,
I have two issues with my OOPS ALV report.
1) Standard sort is not working :
Output of the report looks like this
WBS TEXT Period 1 Period 2
A Total hours 1 1
A Total hours 1 1
A Total COSt 1 1
A Total COST 1 1
My agenda is to calculate sub total of period1 and period 2 based on fields WBS and TEXT, my output should look like
WBS TEXT Period 1 Period 2
A Total hours 1 1
1 1
Total hours 2 2 ( Sub total )
A Total COST 1 1
1 1
Total COST 2 2 ( Sub total )
To achieve this i pass these two fields in the sort table and pass field subtot = 'X' for TEXT field.
It is working fine, i am getting the sub totals but the WBS field are not grouped( Even though it is a standard functionality).
my output looks like
WBS TEXT Period 1 Period 2
A Total hours 1 1
A Total hours 1 1
Total hours 2 2 ( Sub total )
A Total COST 1 1
A Total COST 1 1
Total COST 2 2 ( Sub total )
I have few editable fields in my output, i came to know this issue is because of the editable fields. have anybody come across the same error.
Please let me know how to achieve the standard sort ( Merging similar values ) functionality even if the output has editable fields.
2) IS it possible to get two Grand total based on a field value . In my example , my TEXT field will always have value either 'Total hours' or 'Total COST'
my output should look like this.
WBS TEXT Period 1 Period 2
A Total hours 1 1
1 1
Total hours(A) 2 2 ( Sub total )
A Total COST 1 1
1 1
Total COST(A) 2 2 ( Sub total )
B Total hours 1 1
1 1
Total hours(B) 2 2 ( Sub total )
B Total COST 1 1
1 1
Total COST(B) 2 2 ( Sub total )
GRAND TOTAL HOURS 4 4
GRAND TOTAL COST 4 4.
Response will be appreciated.
Thanks & Regards,
Rajanidhi Rajasekeran
Edited by: Julius Bussche on Jul 14, 2008 7:39 PMHi
If I make the editable field to non editable then sort & cell merge is happening but if I make any of the field as editable then merge is not working shall i request you the solution
Regards-Sreeni -
Hotspot-clicking (Insert function) plus ALV Sorting
Hi,
I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected.
Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
Will appreciate any help on this.
Thanks!
MichaelHello Michael
Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
*& Report ZUS_SDN_ALVGRID_HOTSPOT_SORT
*& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
REPORT zus_sdn_alvgrid_hotspot_sort.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbap.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab TYPE STANDARD TABLE OF ty_s_outtab
WITH DEFAULT KEY.
DATA: gt_outtab TYPE ty_t_outtab.
DATA:
gd_okcode TYPE ui_func,
gd_repid TYPE syrepid,
gt_sort TYPE lvc_t_sort,
gt_fcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
ms_sel_row TYPE lvc_s_row. " selected row
CLASS-METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed
e_onf4
e_onf4_before
e_onf4_after
sender,
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_data_changed.
FIELD-SYMBOLS: <lt_outtab> TYPE ty_t_outtab.
BREAK-POINT.
ENDMETHOD. "handle_data_changed
METHOD handle_hotspot_click.
" define local data
DATA: ls_outtab TYPE ty_s_outtab,
ld_msg TYPE bapi_msg.
BREAK-POINT.
CLEAR: lcl_eventhandler=>ms_sel_row.
ms_sel_row = e_row_id.
READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
ls_outtab-posnr
INTO ld_msg.
message i398(00) with ld_msg.
" Trigger PAI
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'INSERT'
* IMPORTING
* rc =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
PARAMETERS:
p_vkorg TYPE vkorg DEFAULT '0001' OBLIGATORY.
START-OF-SELECTION.
** SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
** UP TO 200 ROWS
** WHERE vkorg = p_vkorg.
SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
UP TO 100 ROWS.
PERFORM init_controls.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog.
PERFORM set_layout_and_variant.
PERFORM set_sorting.
" Register EDIT event
CALL METHOD go_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SET HANDLER:
lcl_eventhandler=>handle_data_changed FOR go_grid,
lcl_eventhandler=>handle_hotspot_click FOR go_grid.
* Link the docking container to the target dynpro
gd_repid = syst-repid.
CALL METHOD go_docking->link
EXPORTING
repid = gd_repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
* Display data
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_bypassing_buffer = abap_true
is_variant = gs_variant
i_save = 'A'
* i_default = 'X'
is_layout = gs_layout
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = gt_outtab
it_fieldcatalog = gt_fcat
it_sort = gt_sort
* it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
** CALL METHOD go_grid->refresh_table_display
*** EXPORTING
*** IS_STABLE =
*** I_SOFT_REFRESH =
** EXCEPTIONS
** finished = 1
** OTHERS = 2.
** IF sy-subrc ne 0.
*** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
** ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN 'INSERT'.
PERFORM insert_row.
WHEN OTHERS.
" Check for changed data at the frontend (= grid control)
CALL METHOD go_grid->check_changed_data( ).
ENDCASE.
CALL METHOD go_grid->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form INIT_CONTROLS
* text
* --> p1 text
* <-- p2 text
FORM init_controls .
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
others = 6.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid
EXPORTING
i_parent = go_docking
EXCEPTIONS
others = 5.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " INIT_CONTROLS
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog.
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'VBAP' " 'VBAK'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
** LOOP AT gt_fcat INTO ls_fcat.
** CASE ls_fcat-fieldname.
** WHEN 'VBELN' OR
** 'ERDAT' OR
** 'ERZET' OR
** 'ERNAM' OR
** 'AUART' OR
** 'NETWR' OR
** 'WAERK'.
** CONTINUE.
** WHEN OTHERS.
** ls_fcat-no_out = abap_true.
** ENDCASE.
** MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
** ENDLOOP.
* Only non-key fields are editable
** ls_fcat-edit = 'X'.
** MODIFY gt_fcat FROM ls_fcat
** TRANSPORTING edit
** WHERE ( fieldname NE space ).
ls_fcat-hotspot = abap_true.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING hotspot
WHERE ( fieldname = 'AUART' OR
fieldname = 'VBELN' ).
** DELETE gt_fcat FROM 15 TO 99.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
*& Form SET_LAYOUT_AND_VARIANT
* text
* --> p1 text
* <-- p2 text
FORM set_layout_and_variant .
CLEAR: gs_layout,
gs_variant.
gs_layout-cwidth_opt = abap_true.
gs_variant-report = syst-repid.
gs_variant-handle = 'GRID'.
ENDFORM. " SET_LAYOUT_AND_VARIANT
*& Form SET_SORTING
* text
* --> p1 text
* <-- p2 text
FORM set_sorting .
* define local data
DATA: ls_sort TYPE lvc_s_sort.
REFRESH: gt_sort.
CLEAR: ls_sort.
ls_sort-spos = 1.
ls_sort-fieldname = 'VBELN'.
ls_sort-up = abap_true.
APPEND ls_sort TO gt_sort.
CLEAR: ls_sort.
ls_sort-spos = 1.
ls_sort-fieldname = 'POSNR'.
ls_sort-up = abap_true.
APPEND ls_sort TO gt_sort.
ENDFORM. " SET_SORTING
*& Form INSERT_ROW
* text
* --> p1 text
* <-- p2 text
FORM insert_row .
* define local data
DATA: ls_outtab TYPE ty_s_outtab,
ld_order TYPE vbeln.
READ TABLE gt_outtab INTO ls_outtab
INDEX lcl_eventhandler=>ms_sel_row-index.
ld_order = ls_outtab-vbeln.
" Find last item of sales order
LOOP AT gt_outtab INTO ls_outtab
WHERE ( vbeln = ld_order ).
ENDLOOP.
" Create next item:
add 10 to ls_outtab-posnr.
" NOTE: added at the end of the list
APPEND ls_outtab TO gt_outtab.
" NOTE: insert new row AFTER selected row => works, too
** INSERT ls_outtab INTO gt_outtab
** INDEX lcl_eventhandler=>ms_sel_row-index.
ENDFORM. " INSERT_ROW -
Cell auto-resize after vertical merge of two cells.
Ladies and Gents,
That is my question.
I am creating a sheet for grants and as part of my "Degree Program Profile" template project.
My intent is to have six column headings spread between columns "A" through "J".
"Date Earned" occupies cells A2/A3 "vertically merged with text centered vertically".
"X No. of Times" occupies cells B2/B3 "......................".
"Target Major/Target Minor" occupies cells C2/C3 and D2/D3 "...............".
"Awarding Entity" occupies cells E2/E3 F2/F3 G2/G3 "..................".
"Reason for Award" occupies cells H2/H3 I1/I2 ".................".
"Amount" is supposed to occupy cells J2/J3 "........................". <- this is the trouble area.
When I merge cells J1 and J2 on my spreadsheet, numbers automatically resizes the entire row to a smaller "single row" of cells.
How do prevent this from happening?Thanks I got it.
The behavior is much more spectacular that what you wrote and it's reproducible.
You merged A2 & A3, B2 & B3, C2 & D2 & C3 & D3,
E2 & F2 & G2 & E3 & F3 & G3 , H2 & I 2 & H3 & I3
Merging H2 & H3 behave as a special un-merge action.
We get : C2 & D2, E2 & F2 & G2, H2 & I 2
but the cells of row 3 are no longer merged to cells of row 2 and no longer merged in the row.
In other words, every cells of row 3 retrieve their independence.
This behavior is always striking if we apply the merge feature to every cells in a row.
If I add a column K to your table, the problem doesn't surface.
I made an other attempt.
Before merging the described groups of cells, I inserted - character in every cells of row 3.
I inserted the string "row 4" in the cell A4.
Then I merged the described way.
Before merging J2 & J3, I has two tabs numbers 2 & 3 for this couple of rows.
When I merged J2 & J3, what was a couple of rows loose it's status and became a single row 2
and the string "row 4" is in row 3 !
If rows 2 & 3 were defined as header rows, after the merge tasks, the Table is described as having only two header rows.
I guess that you already understood that I will file a report upon what resemble to a bug.
Yvan KOENIG (VALLAURIS, France) dimanche 5 juin 2011 10:11:57
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
Hi Guru's
i am use alv sort in my report .
i use following code.
but it gives me DUMP ERROR.
my code like this.
DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
FORM do_sort .
it_sort-spos = 1.
it_sort-fieldname = 'vbeln'.
it_sort-tabname = 'it_vbak'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
it_sort-group = '*'.
it_sort-expa = 'X'.
APPEND it_sort.
it_sort-spos = 2.
it_sort-fieldname = 'posnr'.
it_sort-tabname = 'it_vbap'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
it_sort-group = '*'.
it_sort-expa = 'X'.
APPEND it_sort.
ENDFORM.
please tell me where is the error.
Thanks in advance.
Regards.
Sam.Hi,
Try the following code
DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
FORM do_sort .
it_sort-spos = 1.
it_sort-fieldname = 'VBELN'.
it_sort-tabname = 'IT_VBAK'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
it_sort-group = '*'.
it_sort-expa = 'X'.
APPEND it_sort.
it_sort-spos = 2.
it_sort-fieldname = 'POSNR'.
it_sort-tabname = 'IT_VBAP'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
it_sort-group = '*'.
it_sort-expa = 'X'.
APPEND it_sort.
ENDFORM.
Hope this will have u.
If it is helpful provide point.
Thanks. -
Please help!
When i run an ALV report in foreground, there is cell-merge when a column is sorted.
However, when the ALV run @ background, why the cell-merge cannot work ? All data is listed, rather than is summarized into a block for all rows with the same field content.
Please Advice
Regards
AnnieHi,
see this example.
TABLES : vbak.
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " Document currency
END OF gt_vbak.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form f_read_data
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM.
rgds,
bharat. -
ALV Sorting Not Working after Adding Checkbox to ALV
Hi All.
I am currently doing an ALV report using REUSE_ALV_GRID_DISPLAY function. I am sorting the list by Employee Name and Personnel Area. It works fine where the personnel are field and employee name field are merger together for same personnel are and employee name. But afterwards I added a checkbox field to the internal table and the list outputs a checkbox for each line. Afer putting the checkbox the list no long merges the same personnel are and employee name fields according to original sorting.
Can anyone explain if there is a way to solve this?
Thanks a lot.
Lilyyes there is a way. Just see this..
There is no Straight forward solution. There is a work around.
REPORT ztest_check_box .
TYPE-POOLS: slis,icon.
DATA: BEGIN OF it_vbap OCCURS 0,
vbeln LIKE vbap-vbeln,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
kunnr LIKE vbak-kunnr,
kwmeng LIKE vbap-kwmeng,
check TYPE c,
id TYPE icon-id,
END OF it_vbap.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv.
DATA: x_fieldcat TYPE slis_fieldcat_alv.
DATA: it_sort TYPE slis_t_sortinfo_alv,
x_sort TYPE slis_sortinfo_alv.
SELECT vbak~vbeln
vbak~kunnr
vbap~posnr
vbap~matnr
vbap~kwmeng
INTO CORRESPONDING FIELDS OF TABLE it_vbap
FROM vbak JOIN vbap
ON vbak~vbeln = vbap~vbeln.
SORT it_vbap BY matnr.
DELETE it_vbap WHERE matnr IS INITIAL.
LOOP AT it_vbap.
it_vbap-id = '@T9@'.
MODIFY it_vbap.
ENDLOOP.
x_fieldcat-fieldname = 'ID'.
x_fieldcat-seltext_l = 'CHECK'.
x_fieldcat-outputlen = 4.
x_fieldcat-icon = 'X'.
x_fieldcat-col_pos = 1.
x_fieldcat-hotspot = 'X'.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'MATNR'.
x_fieldcat-seltext_l = 'MATNR'.
x_fieldcat-col_pos = 2.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'KUNNR'.
x_fieldcat-seltext_l = 'KUNNR'.
x_fieldcat-col_pos = 3.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-col_pos = 4.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-col_pos = 5.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'KWMENG'.
x_fieldcat-seltext_l = 'KWMENG'.
x_fieldcat-col_pos = 6.
x_fieldcat-do_sum = 'X'.
x_fieldcat-tabname = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_sort-fieldname = 'MATNR'.
x_sort-spos = 1.
x_sort-up = 'X'.
x_sort-group = 'X'.
x_sort-subtot = 'X'.
APPEND x_sort TO it_sort.
CLEAR x_sort.
x_sort-fieldname = 'KUNNR'.
x_sort-spos = 2.
x_sort-up = 'X'.
APPEND x_sort TO it_sort.
CLEAR x_sort.
x_sort-fieldname = 'VBELN'.
x_sort-spos = 3.
x_sort-up = 'X'.
APPEND x_sort TO it_sort.
CLEAR x_sort.
*DATA:x_layout TYPE lvc_s_layo.
*x_layout-box_fname = 'CHECK'.
*x_layout-no_rowmark = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* is_layout = x_layout
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = it_fieldcat
it_sort = it_sort
TABLES
t_outtab = it_vbap[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc ne 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form itab_user_command
* text
* -->WHATCOMM text
* -->WHATROW text
FORM user_command USING whatcomm TYPE sy-ucomm selfield TYPE
slis_selfield.
IF selfield-fieldname = 'ID'.
READ TABLE it_vbap INDEX selfield-tabindex.
IF sy-subrc = 0.
IF it_vbap-check = ''.
it_vbap-id = '@R7@'.
it_vbap-check = 'X'.
ELSE.
it_vbap-id = '@T9@'.
it_vbap-check = ''.
ENDIF.
MODIFY it_vbap INDEX selfield-tabindex.
ENDIF.
ENDIF.
selfield-refresh = 'X'.
ENDFORM. "itab_user_command
if you want to make the above code to work in lower versions then you have to do this..
then maintain the ICON using the view V_ICON from SM30 add the New Entry.
get the properties from the below screen shot.
http://img404.imageshack.us/img404/3338/testig9.png -
ALV Object Model - Merged Cells
Hi all
When utilizing ALV Object Model, how do I display cells as merged when they have the same content?
Can someone help me out?
Thank you very much!Hello Yun
In dialog cells are merged automatically as soon as you sort the column containing repeated values.
Thus, when you call method SET_TABLE_FOR_FIRST_DISPLAY you should additionally provide parameter IT_SORT with the appropriate entries.
For example, you want to sort your ALV list according to COL_A (1st) and COL_B (2nd):
ls_sort-spos = 1.
ls_sort-fieldname = 'COL_A'.
ls_sort-up = 'X'. " sort ascending
append ls_sort to lt_sort.
ls_sort-spos = 2.
ls_sort-fieldname = 'COL_B'.
ls_sort-up = 'X'. " sort ascending
append ls_sort to lt_sort.
Regards
Uwe -
HI ABAPer's,
In my ALV Report i am using the sort option for all fields,In this report PO no one column and PO line item one column.
If i am using the Sort layout option for both fields all similar values is merge but my requirement is for each PO the line item should be merge not for all values,Could you please help regarding this.
Eg: PO No POLine
101 1
2
3
102 1
103 1
104 1
2
105 1
Like that but now output is
Eg: PO No POLine
101 1
2
3
102 1
103
104
2
105 1 like this could yoHi,
Please try sorting only PO No.
In the case single PO containing same line items : Use delete adjascent duplicates.
In case Line item are coming 1
3
2 jumbled order : sort the Line no: in internal table only not In ALV option.
Best Regards,
Ashiq Hafeez -
ALV sort/group disfunction ?!
Hi there,
I'm a bit helpless because of the sort/group function my ALV should do. Current situation is that I'm using an CL_GUI_ALV_GRID.
CALL METHOD gr_config_alv_1_2->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_sort = sort_table
it_outtab = config_1_2_table
it_fieldcatalog = cat_config_fieldcat_alv
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3.
IF sy-subrc <> 0.
EXIT.
ENDIF.
So you can see that I'm using it_sort to tell the ALV how to sort the it_outtab. [Result looks like this|http://fabianvogt.com/alv_1.jpg].
What the it_sort does is sorting the it_outtab ASCENDING for the coloum "GRP" (display-name: "Bezugstyp"). So far so good...But I know that CL_GUI_ALV_GRID normally does some kind of grouping by merging cells with the same content. [This would look like that|http://fabianvogt.com/alv_2.jpg].
In my case it does not work and I don't have any idea why. I searched the CLASS for a hint or maybe an attribute which has to be filled/flagged to do this kind of grouping.
Looking forword to your help!Hi everyone!
I've checked BCALV_TEST_GRID. Basically they do it the same way I'm trying. I found out that I have the possibility to set ls_layout-no_merging to control, whether cells with the same content are merged or not. By default no_merging is set SPACE, so the cells should be merged - NOT in my case.
Even if I set no_merging = ' ' (SPACE) manually, the merging won't be done.
Running out ouf ideas ...
NEWS:
I did some kind of a workaround, in my opinion even a nicer way to realize my purpose. So take a look at what I did right now:
(take a look at the screenshots in my previous posts for your better understanding)
- The old 'GRP' field (old content: 'B',' K', 'M') is now filled with 'Belegbezug', 'Kundenbezug', 'Materialbezug' and is set NO_OUT (fieldcatalogue).
- I insterted a field called 'CNT' type I, which i use to create Totals/Subtotals.
- NO_TOTLINE = 'X' (Layout) --> total line is not shown; only subtotals
- TOTALS_BEF (Layout) --> subtotals are placed on top
[So this is what I got now|http://fabianvogt.com/alv3.jpg]. Much better than before!!!
My only problem is now, that the 'CNT' coloum looks pretty ugly and has no function except doing the sum thing.
I tried to make it invisible using the fieldcatalogue (NO_OUT / TECH), but then the total lines disappear :/
Any suggestions?
Edited by: Fabian Vogt on Oct 4, 2010 4:35 PM -
hi there experts...
I´m doing an alv report and I want to know if it's possible to sort the alv like I'm going to explain:
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'EKGRP'.
WA_SORT-TABNAME = 'T'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = 2.
WA_SORT-FIELDNAME = 'EKNAM'.
WA_SORT-TABNAME = 'T'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
I want to sort this two fields in order that, i just want to group the equal values of EKNAM that correspond to a single value of EKGRP nad not to group all equal values of EKNAM with diferent EKGRP values.
Output Example of what I want:
EKGRP | EKNAM | DESC
-----------|----------|-------------
1 | 001 | blabla1
|----------|-------------
| 002 | blabla2
| |-------------
| | blabla3
-----------|----------|-------------
2 | 002 | blabla4
| |-------------
| | blalba5
|--------- |--------------
| 012 | blabla6
With normal sort, value 002 for EKNAM field is grouped independently from the value of EKGRP field...
Is it possible to do??
Tanks
Edited by: Hermano.Andrade on Apr 8, 2009 5:59 PMHI,
Refer to this link..https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/sortinALV
Opp's sorry it is not possible...if the value is same for the corresponding two values in the different sort column then the values are merged and displayed at first instead of showing once again if any change in the any of the values in other sort column.
Instead you can update the internal table in the same way as required and display as the output. The restriction on this you need to disable the sort buttons on the alv and no other operations to be performed. -
Need help in ALV Header to merge the columns.
HI All,
I have to create an ALV report with below Header in which i have to merge the data.
Col1
col2
Col3
col.3.1
col 3.2
col3.3
Please let me know how to create fieldcatalog for the above layout.
Thanks
PiyushREPORT zhier_alv.
TYPE-POOLS : slis.
TABLES : mseg.
DATA : BEGIN OF itab_head OCCURS 0,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
mblnr LIKE mseg-mblnr,
menge LIKE mseg-menge,
END OF itab_head.
DATA : BEGIN OF itab_item OCCURS 0,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
mblnr LIKE mseg-mblnr,
menge LIKE mseg-menge,
END OF itab_item.
DATA : t_fcat TYPE slis_t_fieldcat_alv,
key_info TYPE slis_keyinfo_alv,
t_eve TYPE slis_t_event,
gt_subtot TYPE slis_t_sortinfo_alv,
subtot LIKE LINE OF gt_subtot,
t_listhead TYPE slis_t_listheader,
st_line TYPE slis_listheader.
DATA : t_mtdoc LIKE mseg-mblnr.
SELECT-OPTIONS : mat FOR mseg-matnr.
INITIALIZATION.
PERFORM build_cat USING t_fcat.
PERFORM build_eve.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
*& Form build_cat
text
-->TEMP_FCAT text
FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
DATA : wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-seltext_m = 'Material'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_HEAD'.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-seltext_m = 'Plant'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITEM'.
wa_fcat-fieldname = 'MBLNR'.
wa_fcat-seltext_m = 'Material Doc.'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB_ITEM'.
wa_fcat-fieldname = 'MENGE'.
wa_fcat-seltext_m = 'Quantity'.
wa_fcat-do_sum = 'Y'.
APPEND wa_fcat TO temp_fcat.
CLEAR wa_fcat.
subtot-spos = 1.
subtot-fieldname = 'MATNR'.
subtot-tabname = 'ITAB_HEAD'.
subtot-up = 'X'.
subtot-group = 'X'.
subtot-subtot = 'X'.
subtot-expa = 'X'.
APPEND subtot TO gt_subtot.
ENDFORM. "build_cat
*& Form build_eve
text
FORM build_eve.
DATA : wa_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = t_eve
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF sy-subrc = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE t_eve INTO wa_eve WITH KEY name = 'TOP_OF_PAGE'.
IF sy-subrc = 0.
wa_eve-form = 'TOP_OF_PAGE'.
MODIFY t_eve FROM wa_eve INDEX sy-tabix.
ENDIF.
ENDFORM. "build_eve
*& Form get_data
text
FORM get_data.
SELECT matnr werks mblnr menge FROM mseg INTO CORRESPONDING FIELDS OF
TABLE itab_item
WHERE matnr IN mat.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
key_info-header01 = 'MATNR'.
key_info-item01 = 'MATNR'.
key_info-header02 = 'WERKS'.
key_info-item02 = 'WERKS'.
key_info-header03 = 'MBLNR'.
key_info-item03 = 'MBLNR'.
key_info-header04 = 'MENGE'.
key_info-item04 = 'MENGE'.
REFRESH itab_head.
LOOP AT itab_item.
ON CHANGE OF itab_item-matnr OR itab_item-werks.
MOVE-CORRESPONDING itab_item TO itab_head.
APPEND itab_head.
ENDON.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = 'ZHIER_ALV'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fcat
it_sort = gt_subtot
it_events = t_eve[]
i_tabname_header = 'ITAB_HEAD'
i_tabname_item = 'ITAB_ITEM'
is_keyinfo = key_info
TABLES
t_outtab_header = itab_head
t_outtab_item = itab_item
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "dis_data
*& Form user_Command
text
-->U_COMM text
-->SELFIELD text
FORM user_command USING u_comm TYPE sy-ucomm selfield TYPE slis_selfield
CASE u_comm.
WHEN '&IC1'.
READ TABLE itab_item INDEX selfield-tabindex.
t_mtdoc = itab_item-mblnr.
SET PARAMETER ID 'MBN' FIELD t_mtdoc.
CALL TRANSACTION 'MIGO' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "user_Command
*& Form top_of_page
text
FORM top_of_page.
CLEAR st_line.
st_line-typ = 'H'.
st_line-info = 'Krupa'.
APPEND st_line TO t_listhead.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_listhead
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM. "top_of_page
if it is use then give point -
Hi Experts,
I have encountered a peculiar situation with respect to ALV, using sort. The problem is as follows:
1. I have an internal table with 3 fields, upon which I am supposed to implement a sort criteria on the first two fields.
2. My data is something like this, for ex:
abc 1 a
abc 1 b
cde 1 a
cde 1 b
3. I have applied sort criteria, on the first two fields and passed to the fm "REUSE_ALV_GRID_DISPLAY'.
4. Now the output is as follows:
abc 1 a
-- b
cde -- a
--- -- b
Here ( -- ) dotted lines mean the identical entry from the previous row...
5. My requirement is I want the output as:
abc 1 a
--- -- b
cde 1 a
--- -- b
I mean the sort critetia of the second column should follow the first(adjacent column) sort criteria
I hope it is clearly explained, and kindly let me know how this can be solved..
Thank you,
ShashiHi Bala,
The suggested solution is not giving the desired results..
This happens because, when i sort the entries i mentioned earlier, remains the same, even after the two explicit sort statements on the internal table.
Kindly check the same and let me know.
Regards,
Shashi -
Multiple columns from a query sorted vertically
Is it possible to sort a query resultset vertically, with
multiple columns across the page, in the following manner, with
page breaks after 40 rows? I can get it to sort horizontally just
fine with tables, but how can it be done vertically as shown?
JONES, Abby JONES, Betty JONES, Dawn JONES, Frank
JONES, Adam JONES, Bill JONES, Debbie JONES, Gayle
JONES, Alice JONES, Bob JONES, Denton JONES, Henry
JONES, Ben JONES, Cathy JONES, Emma JONES, JohnThis will get you started. I assume you had the appropriate
order by clause in your query. I also assume you want 4 columns per
line.
My approach would be to convert the query to an array and
then output the array.
columns = 4;
maxrows = 40;
recordsperpage = columns * rows;
records = query.recordcount;
myArray = ArrayNew(2);
ThisColumn = 1;
ThisRow = 1;
if (records gt recordsperpage)
LoopTill = recordsperpage;
else
LoopTill = records;
for ( ii = 1; ii lte LoopTill; ii = ii + 1){
myArray[ThisRow][ThisColumn] = query.field[ii];
increment ThisRow;
if (ThisRow = MaxRows + 1) {
ThisRow = 1;
increment ThisColumn;
} // if
} // looop
You can do the rest -
hi
need to sort alv data, but the entries are like header and item
means first line is of header data and if has items then
the items will be displayed starting from second line but some columns for all items
will be empty (means header data at the top line refers)
now second header data comes and then its items.
in such case how to sort the ALV basing on the header number.
while sorting all the items are going at the bottom since it has no header number in its line
and header items are coming at the top
how to sort these entries correctlyHi,
Try this
DATA : gt_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
PERFORM fill_sort. " Filling sort of REUSE_ALV_GRID_DISPALY
FORM fill_sort .
wa_sort-fieldname = 'MATNR'.
wa_sort-up = c_x.
APPEND wa_sort TO gt_sort.
CLEAR wa_sort.
ENDFORM. " FILL_SORT
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_grid_title = text-012
is_layout = wa_slis_layout
it_sort = gt_sort[]
it_fieldcat = gt_fieldcat[]
i_save = 'A'
TABLES
t_outtab = <fs_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Maybe you are looking for
-
EFI Update 2.0 won't install
Every time I try to install the 2.0 EFI update the machine restarts, beeps, bongs, shows the firmware update screen briefly, restarts and bongs again, then goes into a cycle of doing this a couple more times before eventually giving up and booting. T
-
ITunes 10.6.1.7 cannot access
I open iTunes program (10.6.1.7). After waiting a while, I found error as in blue text below and cannot open iTunes program. I already try 1. Repair program by iTune software 2. Remove iTunes and intall it again However, the problem still happen. Ple
-
Hello Experts, I am a workflow novice, just starting out. I have copied the standard PO release workflow - WS20000075 and inserted a send mail step before activity "Release of purchase order". This was because I would like to send the PO as a PDF att
-
FIRST_TIME and NEXT_TIME columns in v$archived_log view
Oracle Version : 11.2 OS Platform : Solaris 10 Could anyone please explain what FIRST_TIME and NEXT_TIME columns in v$archived_log are? Oracle Documentation (below) and googling didn't help. http://docs.oracle.com/cd/E18283_01/server.112/e1
-
HT4623 Since downloading lastest update ios6 cannot connect to iTunes Store anyone help?
Since downloading ios6 can't connect to iTunes