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

REUSE_ALV_GRID_DISPLAY function

Former Member
0 Likes
1,317

Hello,

with 'REUSE_ALV_GRID_DISPLAY'function, once displayed,

I need to show in a label, a field from the List, is there a way to do this. I did try and see if a user command occurs , when I select a line, but there was not one generated.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,279

hi,

check this code..

report  ztest_alv_check     message-id zz           .

type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
      it_fieldcat type slis_t_fieldcat_alv,
      l_layout type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type slis_t_event.

data: begin of itab occurs 0,
      vbeln like vbak-vbeln,
      posnr like vbap-posnr,
      chk(1),
     end of itab.

select vbeln
       posnr
       from vbap
       up to 20 rows
       into table itab.

x_fieldcat-fieldname = 'CHK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.


call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
    i_callback_program       = sy-repid
    is_layout                = l_layout
    i_callback_pf_status_set = 'STATUS'
    i_callback_user_command  = 'USER_COMMAND'
    it_fieldcat              = it_fieldcat
  tables
    t_outtab                 = itab
  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 status using p_extab type slis_t_extab.
*- Pf status
  set pf-status 'STATUS'.
endform.                 " STATUS
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

  case r_ucomm.

    when '&IC1'.
      if rs_selfield-fieldname = 'VBELN'.
      message i000 with 'clicked on row and field' rs_Selfield-tabindex
      rs_selfield-fieldname.
      endif.
  endcase.
endform.                    "USER_COMMAND

before testing create the pf-status and set the function code for f2 key.

Regards

vijay

14 REPLIES 14
Read only

Former Member
0 Likes
1,279

Hi

You need to implement a USER_COMMAND event.

Set the field IS_LAYOUT-F2CODE = <CODE FOR DOUBLE CLICK>

Insert the name of routine for user command in to parameter I_CALLBACK_USER_COMMAND

It has to be like that

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

IF R_UCOMM = <CODE FOR DOUBLE CLICK>.

  • Here write your code

ENDIF.

ENDFORM.

Max

Read only

Former Member
0 Likes
1,279

Hi sims,

when I select a line, but there was not one generated.

Event will occur when we DOUBLE-CLICK

a line.

1. There are some parameters

in the FM which are passed,

and a new FORM has to be written.

2. Just copy paste this code in new program.

3. It will display list of company.

On double-clicking on the alv,

it will again display the clicked company code.

Important code has been marked.

4.

REPORT abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

*----


Select Data

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


Display

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid "<-------Important

i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

*----


  • CALL BACK FORM

*----


FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

READ TABLE itab INDEX whatrow-tabindex.

WRITE itab-bukrs.

ENDFORM. "ITAB_user_command

regards,

amit m.

regards,

amit m.

Read only

0 Likes
1,279

Hi,

I found it responded to the double click as well, but when I looked in whatcomm, there was no value in it,

also is it possible to define a user command for a single click?

Thanks

Read only

Former Member
0 Likes
1,279

Can you explain a little more, what exactly are you trying to do?

You can have a tool tip for each column in the field catalog, if that is what you are looking for.

Regards,

Ravi

Read only

0 Likes
1,279

Hi,

what I have is an alv grid generated. one of the columns has a price field. When the user selects all the lines they are interested in, I want a label displaying the total of all the prices selected.

thanks

Read only

0 Likes
1,279

Hi

You have to define a code for the sum in the status gui,

so the in the routine USER_COMMAND:

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

IF R_UCOMM = 'SUM'.

  • here calculate the total and show the label with the result.

ENDIF.

ENDFORM.

So you have to create a new status gui as copy of std grid gui.

In the parameter I_CALLBACK_PF_STATUS_SET you indicate the name of the routine to set your new status:

FORM set_pf_status USING rt_extab TYPE slis_t_extab

SET PF-STATUS <MY GUI> EXCLUDING rt_extab.

ENDFORM.

Max

Read only

0 Likes
1,279

Hi,

I did that and used Choose , F2 option, but again, the only event it responds to is double click, although now I do see the code for it?

Ehich code should I use, or can it respond to a single click?

Read only

0 Likes
1,279

Hi

for the single click you should active the HOT SPOT attribute in the catalog table.

Max

Read only

0 Likes
1,279

Sorry Max,

not sure how to do this, could you please explain?

Read only

0 Likes
1,279

hi,

Go to SE41 give the Program name SAPLKKBL

and status as STANDARD

now click Copy status (CTRL+F6), now give your Program name , and PF-status and copy it. now save it and activate the pf-satus which you have copied.and add fcode for F2 function key to it. and use it in your PF-status form.

pass that status using the parameter call back status option.

Regards

vijay

Read only

0 Likes
1,279

Hi

In the parameter IT_FIELDCAT you can transfer the attributes for the field, here you can set the field flag HOTSPOT for the fields you need.

In this way the doubleclick (for that fields) is triggered by a single click.

Max

Read only

Former Member
0 Likes
1,280

hi,

check this code..

report  ztest_alv_check     message-id zz           .

type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
      it_fieldcat type slis_t_fieldcat_alv,
      l_layout type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type slis_t_event.

data: begin of itab occurs 0,
      vbeln like vbak-vbeln,
      posnr like vbap-posnr,
      chk(1),
     end of itab.

select vbeln
       posnr
       from vbap
       up to 20 rows
       into table itab.

x_fieldcat-fieldname = 'CHK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.


call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
    i_callback_program       = sy-repid
    is_layout                = l_layout
    i_callback_pf_status_set = 'STATUS'
    i_callback_user_command  = 'USER_COMMAND'
    it_fieldcat              = it_fieldcat
  tables
    t_outtab                 = itab
  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 status using p_extab type slis_t_extab.
*- Pf status
  set pf-status 'STATUS'.
endform.                 " STATUS
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

  case r_ucomm.

    when '&IC1'.
      if rs_selfield-fieldname = 'VBELN'.
      message i000 with 'clicked on row and field' rs_Selfield-tabindex
      rs_selfield-fieldname.
      endif.
  endcase.
endform.                    "USER_COMMAND

before testing create the pf-status and set the function code for f2 key.

Regards

vijay

Read only

0 Likes
1,279

Hi Vijay,

I did get the program to work, but again it only responds to double click , and not sing click?

Any Ideas?

Thanks

Read only

Former Member
0 Likes
1,279
report  ztest_alv_check     message-id zz           .

type-pools: slis.
data: x_fieldcat type slis_fieldcat_alv,
      it_fieldcat type slis_t_fieldcat_alv,
      l_layout type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type slis_t_event.

data: begin of itab occurs 0,
      vbeln like vbak-vbeln,
      posnr like vbap-posnr,
      chk(1),
     end of itab.

select vbeln
       posnr
       from vbap
       up to 20 rows
       into table itab.

x_fieldcat-fieldname = 'CHK'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
x_fieldcat-input = 'X'.
x_fieldcat-edit = 'X'.
x_fieldcat-checkbox = 'X'.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
<b>x_fieldcat-hotspot = 'X'.</b>
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.

x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
append x_fieldcat to it_fieldcat.
clear x_fieldcat.


call function 'REUSE_ALV_GRID_DISPLAY'
  exporting
    i_callback_program       = sy-repid
    is_layout                = l_layout
    i_callback_pf_status_set = 'STATUS'
    i_callback_user_command  = 'USER_COMMAND'
    it_fieldcat              = it_fieldcat
  tables
    t_outtab                 = itab
  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 status using p_extab type slis_t_extab.
*- Pf status
  set pf-status 'STATUS'.
endform.                 " STATUS
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
form user_command using r_ucomm     like sy-ucomm
                               rs_selfield type slis_selfield.

  case r_ucomm.

    when '&IC1'.
      if rs_selfield-fieldname = 'VBELN'.
      message i000 with 'clicked on row and field' rs_Selfield-tabindex
      rs_selfield-fieldname.
      endif.
  endcase.
endform.                    "USER_COMMAND

Now check it.

regards

vijay