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

Former Member
0 Likes
877

Hi,

I need to display some of the line numbers(item number) of purchase orders in a popup..Then i want to select using clicking the check box which want to come in frnt of the line numbers in tht window..

How to do this..Can anyone give me a sample code

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
819

Check this sample 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),
color(4),
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-hotspot = 'X'.
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.


DATA selfield TYPE  slis_selfield.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
  EXPORTING
    i_title                 = 'Select Data'
    i_selection             = 'X'
    i_zebra                 = 'X'
    i_screen_start_column   = 5
    i_screen_start_line     = 5
    i_screen_end_column     = 50
    i_screen_end_line       = 10
    i_checkbox_fieldname    = 'CHK'
    i_tabname               = 'ITAB'
    i_scroll_to_sel_line    = 'X'
    it_fieldcat             = it_fieldcat
    i_callback_program      = sy-repid
    i_callback_user_command = 'USER_COMMAND'
  IMPORTING
    es_selfield             = selfield
  TABLES
    t_outtab                = itab
  EXCEPTIONS
    program_error           = 1.

*&---------------------------------------------------------------------*
*&      Form  STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM status USING p_extab TYPE slis_t_extab.

  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.

  DATA: gd_repid LIKE sy-repid, "Exists
  ref_grid TYPE REF TO cl_gui_alv_grid.
  IF ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = ref_grid.
  ENDIF.
  IF NOT ref_grid IS INITIAL.
    CALL METHOD ref_grid->check_changed_data .
  ENDIF.

  LOOP AT itab WHERE chk = 'X'.
    itab-color = 'C300'.
    MODIFY itab INDEX sy-tabix TRANSPORTING color.
  ENDLOOP.
  rs_selfield-refresh = 'X'.
  BREAK-POINT.

ENDFORM. "USER_COMMAND

Hi,

I need to display some of the line numbers(item number) of purchase orders in a popup..Then i want to select using clicking the check box which want to come in frnt of the line numbers in tht window..

How to do this..Can anyone give me a sample code

3 REPLIES 3
Read only

Former Member
0 Likes
819

Hi Mahesh,

The below code doesn't have check boxes in it but it is a dynamic ALV display with a popup..In this code there is a facility for multiple selection as well and you can try it by setting it to 'X' ..try various methods involving below code so that to suffice ur requirements.. hoping this will help you.

Code:

DATA: BEGIN OF t_heading,

infotype(8),

subtype(7),

old_start_date(14),

old_end_date(14),

start_date(14),

end_date(14).

DATA: END OF t_heading.

  • Internal table with the details of the employee

DATA: BEGIN OF t_details OCCURS 0,

infotype LIKE p0001-infty,

subtype LIKE p0001-subty,

old_start_date(10),

old_end_date(10),

start_date(10),

end_date(10).

DATA: END OF t_details.

DATA: title(70),

w_funccode TYPE sy-xcode.

title = 'Info: The following IT0014 records are delimited:'.

t_heading-infotype = 'INFOTYPE'.

t_heading-subtype = 'SUBTYPE'.

t_heading-old_start_date = 'OLD START DATE'.

t_heading-old_end_date = 'OLD END DATE'.

t_heading-start_date = 'NEW START DATE'.

t_heading-end_date = 'NEW END DATE'.

t_DETAILS-infotype = '0014'.

t_DETAILS-subtype = '2200'.

t_DETAILS-old_start_date = '20.08.2006'.

t_DETAILS-old_end_date = '31.12.9999'.

t_DETAILS-start_date = '20.08.2006'.

t_DETAILS-end_date = '20.08.2008'.

append T_DETAILS.

t_DETAILS-infotype = '0014'.

t_DETAILS-subtype = '2202'.

t_DETAILS-old_start_date = '15.07.2006'.

t_DETAILS-old_end_date = '31.12.9999'.

t_DETAILS-start_date = '15.07.2006'.

t_DETAILS-end_date = '30.08.2008'.

append T_DETAILS.

  • Call function for displaying a pop-up

CALL FUNCTION 'G_DISPLAY_SELECTION_DYNPRO'

EXPORTING

allow_print = ' '

dynp_title = title

extended_display = ' '

first_index = 1

number_of_rows = 30

sel_title1 = t_heading

show_also_1 = 'X'

start_column = 25

start_row = 14

width_of_titles = '1'

WITHOUT_SELECTION = ' '

allow_sort = ' '

TABLES

sel_table = t_details

EXCEPTIONS

no_lines = 1

no_line_picked = 2

OTHERS = 3.

if SY-SUBRC EQ 0 .

Move sy-xcode TO w_funccode.

if w_funccode EQ 'GOON'.

  • delimit

ENdif.

endif.

Cheers,

Jacks M.

Read only

Former Member
0 Likes
819

Hi,

Handle the CLICK EVENT on the Initial ALV Display, and hold the value and hit the data with that value and get the approprate data and display those values(data) to the POP UP ALV using the Function module - REUSE_ALV_POPUP_TO_SELECT.

For code you can refer the standard program BCALV_GRID_AND_POPUP (se38) for your requirement (for double click and navigation).

Read only

Former Member
0 Likes
820

Check this sample 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),
color(4),
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-hotspot = 'X'.
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.


DATA selfield TYPE  slis_selfield.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
  EXPORTING
    i_title                 = 'Select Data'
    i_selection             = 'X'
    i_zebra                 = 'X'
    i_screen_start_column   = 5
    i_screen_start_line     = 5
    i_screen_end_column     = 50
    i_screen_end_line       = 10
    i_checkbox_fieldname    = 'CHK'
    i_tabname               = 'ITAB'
    i_scroll_to_sel_line    = 'X'
    it_fieldcat             = it_fieldcat
    i_callback_program      = sy-repid
    i_callback_user_command = 'USER_COMMAND'
  IMPORTING
    es_selfield             = selfield
  TABLES
    t_outtab                = itab
  EXCEPTIONS
    program_error           = 1.

*&---------------------------------------------------------------------*
*&      Form  STATUS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM status USING p_extab TYPE slis_t_extab.

  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.

  DATA: gd_repid LIKE sy-repid, "Exists
  ref_grid TYPE REF TO cl_gui_alv_grid.
  IF ref_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = ref_grid.
  ENDIF.
  IF NOT ref_grid IS INITIAL.
    CALL METHOD ref_grid->check_changed_data .
  ENDIF.

  LOOP AT itab WHERE chk = 'X'.
    itab-color = 'C300'.
    MODIFY itab INDEX sy-tabix TRANSPORTING color.
  ENDLOOP.
  rs_selfield-refresh = 'X'.
  BREAK-POINT.

ENDFORM. "USER_COMMAND