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

Merge functionality when using editable fields in ALV

Former Member
0 Likes
867

In my report I have a field which is editable. I discovered that the merge functionality disappeared when the field is made editable. Can someone please help me with this query. Thanks in advance.

Amrutha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
831

Amrutha..,

is there a sort option on that . i mean you have any sort option built based on that field.

Regards

Vijay

8 REPLIES 8
Read only

Former Member
0 Likes
831

hi Amrutha,

can u be little more specific and explain some more, so that i will try to do it out.

Read only

Former Member
0 Likes
832

Amrutha..,

is there a sort option on that . i mean you have any sort option built based on that field.

Regards

Vijay

Read only

0 Likes
831

Yes there is a sort option in the field. Normally when a field is sorted if values of the field is duplicated then they are merged.

eg. if we have 2 fields say,

AAA abc

BBB efg

AAA bcd

then normally if I sort by first column output would be

AAA abc

bcd

BBB efg

but if I make anyone field editable then this merge functionality is lost and the output becomes,

AAA abc

AAA bcd

BBB efg

But I want this merge functionality to be retained even if field is made editable.

Thanks,

Amrutha

Read only

0 Likes
831

Hi,

what is the input field, you have check box or some other input field other than check box.please let me know.

Regards

Vijay

Read only

0 Likes
831

If it is Check Box, then you can proceed the following way....

it works above 4.7 (from ECC 5.0)

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 = 'MATNR'.
x_fieldcat-seltext_l = 'MATNR'.
x_fieldcat-col_pos   = 1.
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   = 2.
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   = 3.
x_fieldcat-tabname   = 'IT_VBAP'.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.

x_fieldcat-fieldname = 'ID'.
x_fieldcat-seltext_l = 'CHECK'.
x_fieldcat-outputlen = 4.
x_fieldcat-icon  = 'X'.
x_fieldcat-col_pos   = 4.
x_fieldcat-hotspot  = 'X'.
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 <> 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

Regards

Vijay

Read only

0 Likes
831

Yes, my input field is a check-box.

Thanks & Regards,

Amrutha

Read only

0 Likes
831

in that case the above code works very well.

Check it.

it can be done with the help of ICONS. please get back if you have any doubts.

Regards

Vijay

Read only

Former Member
0 Likes
831

Need to award points for Vijay in providing the solution.