2007 Sep 13 11:02 AM
Hi all,
1) I m showing my itab data into ALV grid with one column editabe(for input from user).
2) When I press SAVE button, system is asking for confirmation with pop up.
4) Now on the pop up when user presses 'yes' then data should be save to the itab or wise it should not be saved to the itab.
So pleas assist me how the user input in ALV can be saved to your correspoinding itab, which is used for ALV.
<b>Take ur ponits.</b>
2007 Sep 13 11:14 AM
This method will save the data entered by the user on editable alv .
*TO GET THE VALUES ENTERD BY THE USER ON THE ALV SCREEN
IF grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = grid.
ENDIF.
*To get back the user entered data on the grid
IF NOT grid IS INITIAL.
CALL METHOD grid->check_changed_data.
ENDIF.
check this will be use full for your development
This method will save the data entered by the user on editable alv .
*TO GET THE VALUES ENTERD BY THE USER ON THE ALV SCREEN
IF grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = grid.
ENDIF.
*To get back the user entered data on the grid
IF NOT grid IS INITIAL.
CALL METHOD grid->check_changed_data.
ENDIF.
check this will be use full for your development
2007 Sep 13 11:07 AM
Hi,
Just modify the internal table if it is yes else dont do anything.
Call function popup......
-.........
If sy-subrc = 0.
Modify itab.
endif.
<b>Reward if helpful.</b>
2007 Sep 13 11:13 AM
Hi Pradeep ,
in alv if u modify any data in ur display then that data is automaticaly changed in ur table which is displayed so if the user preses 'yes ' then u dont need to do anythng or else if he presses no then u take a copy of ur table and then again copy the old contents int new one for exp.
itab[] = itab_copy[].
tell me if this works .
Thanks
Rohit
Reward if helpful . .
2007 Sep 13 11:24 AM
Ya it happens only when we copy standard menu in se41.
But here i am using my menu. when i m clicking on yes for confirmation...i m putting break-point there, the data in the grid & itab are different...not showing the data entered by the user...
Wish u understand.
2007 Sep 13 11:14 AM
This method will save the data entered by the user on editable alv .
*TO GET THE VALUES ENTERD BY THE USER ON THE ALV SCREEN
IF grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = grid.
ENDIF.
*To get back the user entered data on the grid
IF NOT grid IS INITIAL.
CALL METHOD grid->check_changed_data.
ENDIF.
check this will be use full for your development
2007 Sep 13 11:14 AM
hI Pradeep,
try this
Function module to display the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
CASE P_UCOMM.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
WHEN 'SAVE'.
loop at itab into wA_itab.
modify itab from wa_itab.
endloop.
ENDCASE.
ENDFORM.
2007 Sep 13 11:15 AM
you can also chk this blog for some info
/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers
2007 Sep 13 11:23 AM
Hi
If you want it to be done with REUSE_ALV_GRID_DISPLAY
1. Add one more field to final internal table of length 1 as first field
CHK(1).
2. in fieldcatalog
wa_fieldcat-fieldname = 'CHK'.
wa_fieldcat-checkbox = 'X'.
wa_fielcat-edit = 'X'.
3. in layout
wa_layout-box_fname = 'CHK'.
4. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
5. FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFLD TYPE SLIS_SELFIELD.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data
CASE P_UCOMM.
ENDCASE.
ENDFORM.
If you want it to be done with REUSE_ALV_GRID_DISPLAY_LVC , chk my blog
/people/community.user/blog/2007/01/10/displaychange-mode-of-editable-fields-in-alv-using-function-modules-but-not-custom-containers
Check this sample report
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
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,
field_style TYPE lvc_t_styl, "FOR DISABLE
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.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
* Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
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'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
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 set_specific_field_attributes
*&---------------------------------------------------------------------*
* populate FIELD_STYLE table with specific field attributes
*----------------------------------------------------------------------*
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
* Populate style variable (FIELD_STYLE) with style properties
*
* The NETPR field/column has been set to editable in the fieldcatalog...
* The following code sets it to be disabled(display only) if 'NETPR'
* is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
endform. " set_specific_field_attributesCheck out these sample programs
BCALV_GRID_01
This program illustrates how the events for print processing PRINT_TOP_OF_PAGE,
PRINT_END_OF_PAGE, PRINT_TOP_OF_LIST,PRINT_END_OF_LIST are handled. The
corresponding handler methods control the appearance of the list printed.
BCALV_GRID_02
Show a detail list in an amodal window. There is no second dynro needed in contrast to
BCALV_GRID_03.
BCALV_GRID_03
This program implements a function on event DOUBLE_CLICK. According to the selected line data
from table SBOOK is selected and displayed by a second ALV Control in a dialog dynpro.
BCALV_GRID_04
Illustrates the use of exceptions (lights or leds). According to the values of SFLIGHT-SEATSOCC, the
lights are set to 1 (red), 2 (yellow) or 3 (green).
BCALV_GRID_05
Demonstrate the creation of an own toolbar button.
BCALV_GRID_06
Demonstrate the creation of an own context menu.
BCALV_GRID_07
Append a menu button to the standard toolbar.
BCALV_GRID_08
Append a menu with default button to the standard toolbar. It is exactly the same as
BCALVC_TB_WITH_MENU except for methods HANDLE_MENU_BUTTON and HANDLE_TOOLBAR.
Editable ALV grids
BCALV_EDIT_01
This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
BCALV_EDIT_02
This report illustrates how to set chosen cells of an ALV Grid Control editable.
BCALV_EDIT_03
In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
The report checks the input value(s) semantically and provides protocol messages in case of error
BCALV_EDIT_04
This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
implement the saving of the new data.
BCALV_EDIT_05
This example shows how to use checkboxes within an ALV Grid Control. You learn:
(1) how to define a column for editable checkboxes for an attribute of your list
(2) how to evaluate the checked checkboxes
(3) how to switch between editable and non-editable checkboxes
BCALV_EDIT_06
This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
Grid Control.
BCALV_EDIT_07
This example shows how to define dropdown listboxes for particular cells of your output table.
BCALV_EDIT_08
This report implements an ALV Grid Control with an application specific F4 help. The following aspects
are dealt with:
(1) how to replace the standard f4 help
(2) how to pass the selected value to the ALV Grid Control
(3) how to build an f4 help, whose value range depend on a value of another cell.
Check this link
Reward all helpfull answers
Regards
Pavan
2007 Sep 13 11:17 AM
hi,
use this ..
<b> DATA: P_TITLEBAR TYPE STRING,
P_QUESTION TYPE STRING.
if sy-ucomm eq 'SAVE'.
P_TITLEBAR = 'Title'.
P_QUESTION = 'Do you Wish to Update in Database Table ? '.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = P_TITLEBAR
DIAGNOSE_OBJECT = ' '
TEXT_QUESTION = P_QUESTION
TEXT_BUTTON_1 = 'Ja'(001)
ICON_BUTTON_1 = 'ICON_OKAY'
TEXT_BUTTON_2 = 'Nein'(002)
ICON_BUTTON_2 = 'ICON_CANCEL'
DEFAULT_BUTTON = '1'
DISPLAY_CANCEL_BUTTON = 'X'
USERDEFINED_F1_HELP = ' '
START_COLUMN = 25
START_ROW = 6
POPUP_TYPE = 'STATUS'
IV_QUICKINFO_BUTTON_1 = ' '
IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
ANSWER = P_ANSWER.
TABLES
PARAMETER =
endif.
chk for p_answer and do the code...
With Rgds,.
S.BArani</b>
2007 Sep 13 11:17 AM
hi pradeep..
this is the process
1. rise a pop-up for confirmation using regular fm.
2. get the selected row index for saving.
3. if variable is initial.. rise a msg like : select atleast 1 row
4.read ur itab using that index.
5. do validations on entered data if any
6. check if u have to lock & unlock the DB tables if the same data is to be updated into DB tables.
7. modify ur itab also simultaneously using that index.
lemme know if u need any more
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |