2008 Mar 25 11:53 AM
Hi Gurus
I've another problem. I've added checkbox to fieldcat. Problem is that when I check or uncheck it, no values are written back to table that I passed to this FM (for example on User_Command event, when user is pushing button) Data are written when I double click on checkbox (event DATA_CHANGED is triggered then). It's a problem that I don't know how to solve. Any ideas?
2008 Mar 25 12:11 PM
Hi,
I think you are trying to print the records which u selected in
first level list.
The following code displays the selected rows in secondary list
from first level report.
TABLES:
spfli.
TYPE-POOLS:
slis.
DATA:
BEGIN OF t_spfli OCCURS 0,
checkbox.
INCLUDE STRUCTURE spfli.
DATA: END OF t_spfli.
DATA:
t_sspfli LIKE STANDARD TABLE OF t_spfli .
DATA:
fs_spfli LIKE LINE OF t_sspfli.
DATA:
fs_layout TYPE slis_layout_alv,
w_program TYPE sy-repid.
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE t_spfli.
*fs_layout-info_fieldname = 'COLOR'.
fs_layout-box_fieldname = 'CHECKBOX'.
w_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_callback_pf_status_set = 'FLIGHT'
i_callback_user_command = 'SPFLI_INFO'
i_structure_name = 'SPFLI'
is_layout = fs_layout
TABLES
t_outtab = t_spfli
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 FLIGHT
&----
text
----
-->RT_EXTAB text
----
FORM flight USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'FLIGHT' EXCLUDING rt_extab.
ENDFORM. "FLIGHT
&----
*& Form SPFLI_INFO
&----
text
----
-->UCOMM text
-->SELFIELD text
----
FORM spfli_info USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
selfield-refresh = 'X'.
CASE ucomm.
WHEN 'FLIGHT'.
LOOP AT t_spfli.
IF t_spfli-checkbox = 'X'.
t_spfli-checkbox = ' '.
t_spfli-color = 'C51'.
MODIFY t_spfli TRANSPORTING checkbox.
fs_spfli = t_spfli.
APPEND fs_spfli TO t_sspfli.
ENDIF.
ENDLOOP.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
CLEAR fs_spfli.
fs_layout-info_fieldname = 'COLOR'.
fs_layout-confirmation_prompt = 'X'.
fs_layout-key_hotspot = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
TABLES
t_outtab = t_sspfli
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.
REFRESH t_sspfli.
ENDFORM. "SPFLI_INFO
Reward,if it is useful.
Thanks,
Chandu
2008 Mar 25 11:59 AM
hi,
what u exactly want to di?
here i have created one report which having check box...
when i check them and press one button, i get detail info of that records...
is that u want?
2008 Mar 25 12:04 PM
After some selection screen REUSE_ALV_GRID_DISPLAY is run. User is checking or unchecking checkboxes. User is pushing button on toolbar. I'm getting info about it in USER_COMMAND event, but when I'm reading data from table that was passed to FM I've old data in there (no informations regarding which checkboxes were set or unset).
2008 Mar 25 12:14 PM
hi,
ya if u use check box, it will not set any value in internal table...i have also tried ..
what u want after checking some records?
2008 Mar 25 12:11 PM
Hi,
I think you are trying to print the records which u selected in
first level list.
The following code displays the selected rows in secondary list
from first level report.
TABLES:
spfli.
TYPE-POOLS:
slis.
DATA:
BEGIN OF t_spfli OCCURS 0,
checkbox.
INCLUDE STRUCTURE spfli.
DATA: END OF t_spfli.
DATA:
t_sspfli LIKE STANDARD TABLE OF t_spfli .
DATA:
fs_spfli LIKE LINE OF t_sspfli.
DATA:
fs_layout TYPE slis_layout_alv,
w_program TYPE sy-repid.
SELECT *
FROM spfli
INTO CORRESPONDING FIELDS OF TABLE t_spfli.
*fs_layout-info_fieldname = 'COLOR'.
fs_layout-box_fieldname = 'CHECKBOX'.
w_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_callback_pf_status_set = 'FLIGHT'
i_callback_user_command = 'SPFLI_INFO'
i_structure_name = 'SPFLI'
is_layout = fs_layout
TABLES
t_outtab = t_spfli
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 FLIGHT
&----
text
----
-->RT_EXTAB text
----
FORM flight USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'FLIGHT' EXCLUDING rt_extab.
ENDFORM. "FLIGHT
&----
*& Form SPFLI_INFO
&----
text
----
-->UCOMM text
-->SELFIELD text
----
FORM spfli_info USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
selfield-refresh = 'X'.
CASE ucomm.
WHEN 'FLIGHT'.
LOOP AT t_spfli.
IF t_spfli-checkbox = 'X'.
t_spfli-checkbox = ' '.
t_spfli-color = 'C51'.
MODIFY t_spfli TRANSPORTING checkbox.
fs_spfli = t_spfli.
APPEND fs_spfli TO t_sspfli.
ENDIF.
ENDLOOP.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
CLEAR fs_spfli.
fs_layout-info_fieldname = 'COLOR'.
fs_layout-confirmation_prompt = 'X'.
fs_layout-key_hotspot = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_program
i_structure_name = 'SFLIGHT'
is_layout = fs_layout
TABLES
t_outtab = t_sspfli
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.
REFRESH t_sspfli.
ENDFORM. "SPFLI_INFO
Reward,if it is useful.
Thanks,
Chandu
2008 Mar 25 12:14 PM
Chandu I can't see solution to my problem inside of your code. Beside you're using other REUSE_ALV_LIST_DISPLAY and I was writting about REUSE_ALV_GRID_DISPLAY
Dhwani I want to delete from DB entries that were selected by User.
Edited by: Marcin Cholewczuk on Mar 25, 2008 1:15 PM
2008 Mar 25 12:22 PM
I had the same problem a few days ago.
I resolved this problem by using a field which hotspot activated in the catalog, and it had an icon like [ ], then when the user push the hotspot in the line, It triggered an event, and then i changed the icon for another like this [x].
Try this if you want and luck.
2008 Mar 25 12:24 PM
ok,
i am providing code....
i have created one button to already existing status named 'DET'.
i have writen code to display detail info...
u need to write code for delete entries..
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
sel, "stores which row user has selected
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
fieldcatalog1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
DATA : BEGIN OF det_tab OCCURS 0,
ebeln LIKE ekpo-ebeln,
END OF det_tab.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
* fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
* fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
* fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
* fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
* fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
* fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
* fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
* fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
gd_layout-box_fieldname = 'SEL'.
"set field name to store row selection
* gd_layout-edit = 'X'. "makes whole ALV table editable
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_STAT'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = it_ekko
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. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*------------------------------------------------------------------*
* FORM USER_COMMAND *
*------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'DET'. "user presses SAVE
CLEAR det_tab.
REFRESH det_tab.
LOOP AT it_ekko INTO wa_ekko WHERE sel = 'X'.
MOVE-CORRESPONDING wa_ekko TO det_tab.
APPEND det_tab.
<UR CODE>
ENDLOOP.
ENDCASE.
ENDFORM. "user_command
reward if usefull....
2008 Mar 25 12:28 PM
hi,
do like this..
i have tried...
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'DET'. "user presses SAVE
CLEAR det_tab.
REFRESH det_tab.
LOOP AT it_ekko INTO wa_ekko WHERE sel = 'X'.
DELETE FROM ekpo WHERE ebeln = wa_ekko-ebeln.
IF sy-subrc = 0.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
ENDLOOP.
ENDCASE.
ENDFORM. "user_command