Running BDC from my Editable ALV output
Hi All,
I want to run a bdc for my ALV output. Here the problem is the layout is editable so the values can be changed. I want to pick the values which is modified in my ALV output then using that i should run my BDC Program.
How to catch the input given in my ALV output.
Thank in advance.
Arun.
Hi, check following link:
[https://wiki.sdn.sap.com/wiki/display/ABAP/Editable%20ALV%20through%20OOPS|https://wiki.sdn.sap.com/wiki/display/ABAP/Editable%20ALV%20through%20OOPS]
Similar Messages
-
Capture contents from an editable alv
I'm trying to capture fields from an editable alv. I have an update button in the application toolbar. So when i press this button, whatever changes I have done on the screen, the internal table should get updated. I'm using the function module REUSE_ALV_GRID_DISPLAY.
Can anybody help me out??Yes you can,
If you have access to the element in the context that is bound to the row in the ALV then you can connect the message. Marking a * is not possible by default with the WD message manager and you willl need to do it manually. Use the element method of the message manager API for this purpose. -
Hi all ,
Iam Generating ALV Grid using OOPs method, In the output list Iam editing some of the entries , now i need to store the edited output in a custom table.
Can anyubody tell me how to capture these changes into an internal table.
Early replies would be rewarded points.
Thanks In advance,
NehaHi Neha,
check this code
*& Report ZLAXMI_REPORT6 *
REPORT ZLAXMI_REPORT6 NO STANDARD PAGE HEADING
MESSAGE-ID ZZ
LINE-SIZE 132
LINE-COUNT 65 .
TABLES: MARA.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF T_MARA,
MATNR TYPE MARA-MATNR, "Material Number
ERSDA TYPE MARA-ERSDA, "Creation date
BRGEW TYPE MARA-BRGEW, "Gross weight
NTGEW TYPE MARA-NTGEW, "Net weight
MTART TYPE MARA-MTART, "Material type
MBRSH TYPE MARA-MBRSH, "Industry Sector
REC_SEL TYPE C , "checkbox
END OF T_MARA.
V A R I A B L E S
DATA: V_REPID LIKE SY-REPID,
V_FLAG(1) TYPE C.
CONSTANTS :
C_X(1) TYPE C VALUE 'X',
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS',
C_FC_DELETE(6) TYPE C VALUE 'DELETE',
C_FC_MODIFY(6) TYPE C VALUE 'MODIFY',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
C_USER_COMMAND_MODIFY TYPE SLIS_FORMNAME
VALUE 'F_USER_COMMAND_MODIFY',
C_ICON_DELETE TYPE ICON-NAME VALUE 'ICON_DELETE', " Icon,Delete'
C_ICON_CANCEL TYPE ICON-NAME VALUE 'ICON_CANCEL', " Icon,Cancel'
C_FC_SAVE(4) TYPE C VALUE 'SAVE'.
*internal table declarations.
DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_MODIFY TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_TEMP TYPE STANDARD TABLE OF MARA WITH HEADER LINE,
*-ALV Internal Tables.
*--Field Catalog
IT_FIELDCAT TYPE STANDARD TABLE OF
SLIS_FIELDCAT_ALV WITH HEADER LINE,
*--Layout
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
*--Sort
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV ,
**-Structure for excluding function codes
WA_EXTAB TYPE SLIS_EXTAB,
**-To hold function codes to be excluded in ALV toolbar
IT_EXTAB TYPE SLIS_T_EXTAB.
*selection screen.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_ERSDA FOR MARA-ERSDA.
SELECTION-SCREEN: END OF BLOCK B1.
*--Radio buttons to select either Display/Delete/Modify
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME
TITLE TEXT-002.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-003.
PARAMETERS: P_DISP RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-005.
PARAMETERS: P_UPD RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-004.
PARAMETERS: P_DEL RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN END OF BLOCK B2 .
AT SELECTION-SCREEN.
PERFORM VALIDATE_SCREEN.
*start of selection
START-OF-SELECTION.
*clear the internal tables to be used.
CLEAR: IT_MARA,IT_MARA[],
V_FLAG.
*get the data
PERFORM GET_DATA.
*end of selection
END-OF-SELECTION.
IF IT_MARA[] IS INITIAL.
MESSAGE I000 WITH
'No Records found for the given Selection Criteria'(012).
ELSE.
*do alv process
V_REPID = SY-REPID.
*--Sort the Output Fields
PERFORM SORT_FIELDS.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM SET_LAYOUT.
IF P_DISP = C_X.
*--Exclude any Buttons on the Appn tool bar
perform change_default_pf_status.
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_UPD = C_X.
*--Exclude DELETE Button on the appn tool bar
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_DEL = C_X.
*--Exclude MODIFY button on appn tool bar
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDIF.
*--Exclude SAVE button for all options
MOVE 'SAVE' TO WA_EXTAB-FCODE. " SAVE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
*--Display ALV output
PERFORM LIST_DISPLAY TABLES IT_MARA
USING C_USER_COMMAND.
ENDIF.
*& Form get_data
text
--> p1 text
<-- p2 text
FORM GET_DATA .
SELECT MATNR
ERSDA
BRGEW
NTGEW
MTART
MBRSH
FROM MARA
INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR
AND ERSDA IN S_ERSDA.
IF SY-SUBRC <> 0.
*no records selected leave processing
STOP.
ENDIF.
SORT IT_MARA.
ENDFORM. " get_data
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM SORT_FIELDS .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'ERSDA'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
ENDFORM. " sort_fields
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCAT .
IT_FIELDCAT-COL_POS = '1'.
IT_FIELDCAT-FIELDNAME = 'MATNR'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'Material number'(022).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '2'.
IT_FIELDCAT-FIELDNAME = 'ERSDA'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'Created on'(023).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '3'.
IT_FIELDCAT-FIELDNAME = 'BRGEW'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'GROSS WEIGHT'(024).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '4'.
IT_FIELDCAT-FIELDNAME = 'NTGEW'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'NET WEIGHT'(025).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '5'.
IT_FIELDCAT-FIELDNAME = 'MTART'.
IT_FIELDCAT-OUTPUTLEN = '3'.
IT_FIELDCAT-SELTEXT_L = 'Material type'(026).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '6'.
IT_FIELDCAT-FIELDNAME = 'MBRSH'.
IT_FIELDCAT-OUTPUTLEN = '25'.
IT_FIELDCAT-SELTEXT_L = 'Industry sector'(027).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-FIELDNAME = 'REC_SEL'.
IT_FIELDCAT-NO_OUT = C_X.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
ENDFORM. " build_fieldcat
*& Form list_display
text
-->P_IT_MARA text
-->P_C_USER_COMMAND text
FORM LIST_DISPLAY TABLES P_IT_MARA
USING P_USER_COMMAND TYPE SLIS_FORMNAME.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
I_CALLBACK_USER_COMMAND = P_USER_COMMAND
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING = IT_EXTAB[]
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = P_IT_MARA
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. " list_display
*& Form F_SET_PF_STATUS
Set PF_STATUS STANDARD modifying the standard toolbar
by excluding some buttons
-->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
CLEAR : WA_EXTAB,
IT_EXTAB.
*--Set the Modified PF status for the ALV.
SET PF-STATUS 'ALV_STATUS_01' EXCLUDING RT_EXTAB.
ENDFORM. " SET_PF_STATUS
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
RS_SELFIELD-REFRESH = C_X.
IF R_UCOMM = C_FC_DELETE.
*--User Selected DELETE button.
PERFORM DELETE_SELECTED_RECORDS.
ELSEIF R_UCOMM = C_FC_MODIFY.
*--If user selects MODIFY button.
PERFORM CHANGE_RECORDS.
ENDIF.
ENDFORM. "F_USER_COMMAND
*& Form POP_UP_CONFIRMATION
text
<--P_ANSWER text
FORM POP_UP_CONFIRMATION
CHANGING P_ANSWER TYPE C.
DATA:
L_TITLE(14) TYPE C, " Title of pop-up
L_TXT_QUESTION(52) TYPE C, " Text displayed in pop-up
L_DISP_CANCEL TYPE C, " Display 'Cancel' button?
L_BTN1 TYPE ICON-NAME, " Icon on button 1
L_BTN2 TYPE ICON-NAME. " Icon on button 2
L_TITLE = 'Delete'(017). " delete
L_TXT_QUESTION = 'Are you sure to delete?'(018).
L_BTN1 = C_ICON_DELETE.
L_BTN2 = C_ICON_CANCEL.
**-Display pop-up asking user for confirmation
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = L_TITLE
TEXT_QUESTION = L_TXT_QUESTION
TEXT_BUTTON_1 = 'Yes'
ICON_BUTTON_1 = L_BTN1
TEXT_BUTTON_2 = 'No'
ICON_BUTTON_2 = L_BTN2
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = 'X'
IMPORTING
ANSWER = P_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Error executing function module:'(019)
'POPUP_TO_CONFIRM'.
ENDIF.
ENDFORM. "pop_up_confirmation
*& Form set_layout
text
--> p1 text
<-- p2 text
FORM SET_LAYOUT .
IF P_DEL = C_X OR P_UPD = C_X.
*--Allow Input only if user choose 'UPDATE'/ 'DELETE' radio buttons
WA_LAYOUT-BOX_FIELDNAME = 'REC_SEL'.
WA_LAYOUT-BOX_TABNAME = 'IT_MARA'.
ENDIF.
*--Display Header based on the user selection
IF P_DISP = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Display '(036).
ELSEIF P_DEL = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Delete '(037).
ELSEIF P_UPD = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Change '(038).
ENDIF.
ENDFORM. " set_layout
*& Form change_default_pf_status
text
--> p1 text
<-- p2 text
FORM CHANGE_DEFAULT_PF_STATUS .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_default_pf_status
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND_MODIFY USING R_UCOMM LIKE SY-UCOMM "#EC *
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_ANSWER TYPE C. "#EC *
IF R_UCOMM = C_FC_SAVE.
*user selected save button
READ TABLE IT_MODIFY WITH KEY REC_SEL = 'X'.
*check if user selected atleast one line.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ENDIF.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
*--Check the entered values are valid or not.
IF NOT ( it_modify-status = 'A' OR
it_modify-status = 'C' OR
it_modify-status = 'E' ).
*--User Entered invalid value for STATUS field,so Display Error Msg
CLEAR R_UCOMM.
MESSAGE e000 WITH 'Invalid value '''(031)
'' for Status in the Record # '(032)
sy-tabix.
ENDIF.
ENDLOOP.
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MODIFY TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
*--start new code
DATA : IT_TEMP2 LIKE STANDARD TABLE OF MARA WITH HEADER LINE.
SELECT * FROM MARA
INTO TABLE IT_TEMP2
FOR ALL ENTRIES IN IT_TEMP
WHERE MATNR = IT_TEMP-MATNR.
IF SY-SUBRC = 0.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
READ TABLE IT_TEMP2 WITH KEY MATNR = IT_MODIFY-MATNR.
IF SY-SUBRC = 0.
IT_TEMP2-NTGEW = IT_MODIFY-NTGEW.
IT_TEMP2-BRGEW = IT_MODIFY-BRGEW.
MODIFY IT_TEMP2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
ENDIF.
*modify mara table with the changed values
MODIFY MARA FROM TABLE IT_TEMP2 .
*--end new code
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
*--Display message with Success in Updating database
MESSAGE I000 WITH SY-DBCNT
' Record(s) has been Updated'(020).
CLEAR :
IT_MARA,
IT_MARA[].
*get-data again from database.
PERFORM GET_DATA.
RS_SELFIELD-REFRESH = C_X.
ELSE.
*--Error occurred
MESSAGE I000 WITH 'Error occured in Modifying the database'(021).
ENDIF.
ENDIF.
ENDFORM. "f_user_command_modify
*& Form validate_screen
text
--> p1 text
<-- p2 text
FORM VALIDATE_SCREEN .
DATA : LV_MATNR LIKE MARA-MATNR.
*--validate product
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
INTO MARA-MATNR
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
*--Error
MESSAGE E000 WITH 'Invalid Material'(034).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form delete_records
text
--> p1 text
<-- p2 text
FORM DELETE_RECORDS .
LOOP AT IT_MARA.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display Success Message to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(010).
ELSE.
*--Error occured in deletion
MESSAGE I000 WITH 'Error occured in Deleting the Record(s)'(011).
ENDIF.
CLEAR: IT_MARA,
IT_MARA[],
IT_TEMP,
IT_TEMP[].
V_FLAG = C_X.
STOP.
ENDFORM. " delete_records
*& Form delete_selected_records
text
--> p1 text
<-- p2 text
FORM DELETE_SELECTED_RECORDS .
DATA : L_ANSWER(1) TYPE C.
READ TABLE IT_MARA WITH KEY REC_SEL = C_X.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Delete'(013).
EXIT.
ELSE.
*--Ask for delete confirmation
PERFORM POP_UP_CONFIRMATION
CHANGING L_ANSWER.
IF L_ANSWER = '1'. " 'Yes'
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display completed work information to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(014).
*--Clear the Internal tables
CLEAR: IT_MARA,
IT_MARA[].
*--Reselects entries from Database again & display in ALV
PERFORM GET_DATA.
ELSE.
*--Error occured
MESSAGE I000 WITH
'Error occured in Deleting the Record(s)'(015).
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " delete_selected_records
*& Form change_records
text
--> p1 text
<-- p2 text
FORM CHANGE_RECORDS .
READ TABLE IT_MARA WITH KEY REC_SEL = 'X'.
*--check user selected at least 1 record to MODIFY or not
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ELSE.
CLEAR : IT_MODIFY,
IT_MODIFY[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
IT_MODIFY = IT_MARA.
APPEND IT_MODIFY.
CLEAR IT_MODIFY.
ENDLOOP.
*--Change PF status for this new ALV list.
PERFORM CHANGE_PF_STATUS_AGAIN.
*--Change Field Catalog to make INPUT enabled.
READ TABLE IT_FIELDCAT WITH KEY FIELDNAME = 'NTGEW'.
IT_FIELDCAT-INPUT = C_X.
MODIFY IT_FIELDCAT INDEX SY-TABIX.
*--Call ALV LIST DISPLAY with this new values.
PERFORM LIST_DISPLAY TABLES IT_MODIFY
USING C_USER_COMMAND_MODIFY.
ENDIF.
ENDFORM. " change_records
*& Form change_pf_status_again
text
--> p1 text
<-- p2 text
FORM CHANGE_PF_STATUS_AGAIN .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_pf_status_again
Regards,
Laxmi. -
Can we edit alv output list.
hi happy new year to everybody ......
can anybody tell me that can we create aditable alv list ...
how can we.....Hi,
Yes you can create an Editable ALV.
I am giving you an example of Editable ALV in OOPs.
Example:
Take a Custom container in Screen 100 and name it "LIST_AREA".
REPORT ZSB_ALV_EDITABLE_SAMPLE.
TABLES: SFLIGHT.
DATA: gc_container TYPE scrfname VALUE 'LIST_AREA',
gc_custom_container TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
gc_grid TYPE REF TO CL_GUI_ALV_GRID,
gs_layout TYPE LVC_S_LAYO,
gt_fieldcat TYPE LVC_T_FCAT.
DATA: ok_code TYPE SY-UCOMM.
DATA: gt_outtab TYPE TABLE OF SFLIGHT.
*DYNPRO
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '100'.
CREATE OBJECT gc_custom_container
EXPORTING
container_name = gc_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT gc_grid
EXPORTING
i_parent = gc_custom_container
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5 .
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
PERFORM prepare_layout CHANGING gs_layout .
PERFORM get_alv_display.
ENDMODULE.
*& Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
OK_CODE = SY-UCOMM.
IF OK_CODE = 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
CLEAR OK_CODE.
ENDIF.
ENDMODULE.
FORM prepare_field_catalog CHANGING gt_fieldcat TYPE LVC_T_FCAT.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
I_STRUCTURE_NAME = 'SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fieldcat[].
ENDFORM.
FORM prepare_layout changing p_gs_layout TYPE lvc_s_layo.
p_gs_layout-zebra = 'X'.
p_gs_layout-edit = 'X'.
ENDFORM. " prepare_layout
FORM get_alv_display .
SELECT * FROM sflight INTO TABLE gt_outtab UP TO 10 ROWS.
CALL METHOD gc_grid->set_table_for_first_display
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = gs_layout
CHANGING
it_outtab = gt_outtab
IT_FIELDCATALOG = gt_fieldcat
ENDFORM. " get_alv_display
Regards,
Sachin -
Compare editable alv output with database fields
I generated 1 editable alv report with attaching flat file data,
but i want to change the wrong fields in alv output and compare with database filds for validation.
but when i do this . it takes previous entries of flat file.
how can i solve it?Your title is much better than in the first post, however your problem description hasn't changed.
Let me guess, you are importing a flat file, present the contents in an editable ALV grid, some values are being changed, and now the changed values do not reflect in the internal table, instead you are seeing the values as imported from the file?
If yes -> FAQ, please search for the many previous discussions of this topic.
Thomas -
Message connected to a cell from an editable alv
hi,
is it possible to connect a message (via message manager) with the changed cell in an editable alv? I mean the changed cell should be marked with an "*" for example.
I am working with the ON_CELL_ACTION event with my alv.Yes you can,
If you have access to the element in the context that is bound to the row in the ALV then you can connect the message. Marking a * is not possible by default with the WD message manager and you willl need to do it manually. Use the element method of the message manager API for this purpose. -
hi,
I have successfully displayed data in the ALV GRID(in Read-ONLY mode) by using the function of class "CL_GUI_ALV_GRID" . But I have not been able to display the data in the edit mode .I want that the user should be able to edit the data displayed in the ALV GRID (and final data should be stored in the transparent table), but I have not been able to add that functionality . Can anyone please tell me how to do the same (any function that I need to call ??) .
Thanx
sagarHi Sagar,
there was a similar question in this forum and Vijay Babu Dudla wrote a nice sample report:
editing alv output
Best Regards,
Stefan -
Handle deletion in an editable alv
Hi,
I have an editable alv . When I delete a record from this editable alv , I also want to delete it from the corresponding database .
Please could someone tell me how we can capture the particular record selected for deletion in this editable alv .
Regards,
Sushanth H.S.Hello Sushanth
Assuming that you can only delete entire rows but not modify rows (editable cells) you could use a simple approach by storing a PBO image of your data.
For a sample report have a look at report ZUS_SDN_ALV_EDITABLE_1A in Issue with CHECK_CHANGED_DATA method of CL_GUI_ALV_GRID class
By comparing GT_OUTTAB_PBO and GT_OUTTAB (PAI data) you can simply find out the deleted records.
Alternatively, you may use a more sophisticated approach:
[Comparing Two Internal Tables - A Generic Approach|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/comparing%2btwo%2binternal%2btables%2b-%2ba%2bgeneric%2bapproach]
This approach will also be helpful if the ALV rows can be modified because in this case you have to find out the MODIFIED rows.
Regards
Uwe -
How to get rid of the loop in ALV output from At selection screen event?
I have several push buttons on a selection screen.
Clikc on a button, then it pops up an editable ALV report. (This gets triggered AT SELECTION SCREEN event.). REUSE_ALV_GRID_DISPLAY_LVC..
On the ALV output, I enabled F4 for a couple of fields. Once I click on the F4 button, ONF4 method gets triggerd and a pop up appears with custom search helps.
choose a line and it fills the cell.
Upto this it works fine.
Now I click on the BACK button at the ALV output, it takes me to the selection screen. I click on the button again, it show the editable ALV. Now when I click on the F4 button, the pop up comes up twice and the cell gets filled from the second pop - up.
How to control this?
Probably I am not refreshing something?
(I am using REUSE_ALV_GRID_DISPLAY_LVC and tooks ome code for ONF4 event from BCALV_*DATATYPES (forgot the exact name) program.)
Thanks,
VenHi,
FORM refresh_grid USING pw_grid TYPE REF TO cl_gui_alv_grid.
*Work area
DATA : wal_stable TYPE lvc_s_stbl.
CHECK NOT pw_grid IS INITIAL.
wal_stable-col = c_check.
wal_stable-row = c_check.
*Method to refresh grid
CALL METHOD pw_grid->refresh_table_display
EXPORTING
is_stable = wal_stable
i_soft_refresh = c_check
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDFORM. " refresh_grid
Thanks,
Sree. -
Reg editing alv in output mode
Hi,
Cud any one let me know how to edit alv ?
im using fcat-edit = 'x' option in function module approach....but even then im not able to edit columns/fields....?
how to edit columns/rows using function modules and OOPs methos in alv????
Thanks
JayHi
i am sending you a code where the output field is edtable in the ALV oop
you can understand very easily
reward if usefull
*& Report ZAMIT_ALV_OOP_EDITABLE
REPORT ZAMIT_ALV_OOP_EDITABLE.
*data declaration
DATA: G_CONTROL TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA: T_FCAT TYPE LVC_T_FCAT,
WA_FCAT TYPE LVC_S_FCAT.
DATA: I_ZAMIT TYPE TABLE OF ZAMIT_SHIP_TAB WITH HEADER LINE.
DATA: I_INDEX TYPE I.
DATA: G_OK_CODE TYPE SY-UCOMM.
DATA: G_OK_CODE1 TYPE SY-UCOMM.
SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
CALL SCREEN 9000.
SCREEN FORMS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*& Module STATUS_9000 OUTPUT
text
MODULE STATUS_9000 OUTPUT.
SET PF-STATUS 'PF9001'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9000 OUTPUT
*& Module CREATE_CONTROL OUTPUT
text
MODULE CREATE_CONTROL OUTPUT.
CREATE OBJECT G_CONTROL
EXPORTING
PARENT =
CONTAINER_NAME = 'G_CUSTOM_CONTROL'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " CREATE_CONTROL OUTPUT
*& Module CREATE_ALV OUTPUT
text
MODULE CREATE_ALV OUTPUT.
CREATE OBJECT G_ALV
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = G_CONTROL
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " CREATE_ALV OUTPUT
*& Module DISPLAY_ALV OUTPUT
text
MODULE DISPLAY_ALV OUTPUT.
PERFORM PREPARE_FIELD_CATALOG.
CALL METHOD G_ALV->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME = 'SFLIGHT'
IS_VARIANT =
I_SAVE = 'X'
I_DEFAULT = 'X'
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING = T_TOOLBAR[]
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = I_ZAMIT[]
IT_FIELDCATALOG = T_FCAT
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " DISPLAY_ALV OUTPUT
*& Form PREPARE_FIELD_CATALOG
text
--> p1 text
<-- p2 text
FORM PREPARE_FIELD_CATALOG .
REFRESH T_FCAT.
CLEAR WA_FCAT.
<b> WA_FCAT-COL_POS = 1.
WA_FCAT-COLTEXT = 'SHIPMENT NO.'.
WA_FCAT-FIELDNAME = 'ZSHIP_NO'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-edit = 'X'.</b>
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 2.
WA_FCAT-COLTEXT = 'DOC TYPE'.
WA_FCAT-FIELDNAME = 'ZDOC_TYP'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 3.
WA_FCAT-COLTEXT = 'NAME_CR'.
WA_FCAT-FIELDNAME = 'ZNAME_CR'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 4.
WA_FCAT-COLTEXT = 'SHIP_TYP'.
WA_FCAT-FIELDNAME = 'ZSHIP_TYP'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = 5.
WA_FCAT-COLTEXT = 'LEG_IND'.
WA_FCAT-FIELDNAME = 'ZLEG_IND'.
WA_FCAT-REF_TABLE = 'I_ZAMIT'.
WA_FCAT-KEY = 'X'.
APPEND WA_FCAT TO T_FCAT.
CLEAR WA_FCAT.
ENDFORM. " PREPARE_FIELD_CATALOG
*& Module LEAVE INPUT
text
MODULE LEAVE INPUT.
LEAVE PROGRAM.
ENDMODULE. " LEAVE INPUT
*& Module USER_COMMAND_9000 INPUT
text
MODULE USER_COMMAND_9000 INPUT.
IF G_OK_CODE = 'CHANGE'.
DATA: VALUE TYPE C,
COL TYPE I ,
ROW TYPE LVC_S_ROW,
COLNO TYPE LVC_S_COL,
ROWNO TYPE LVC_S_ROID.
CALL METHOD G_ALV->GET_CURRENT_CELL
IMPORTING
E_ROW = I_INDEX
CALL METHOD G_ALV->GET_CURRENT_CELL
IMPORTING
E_ROW =
E_VALUE = VALUE
E_COL = COL
ES_ROW_ID = ROW
ES_COL_ID = COLNO
ES_ROW_NO = ROWNO.
READ TABLE I_ZAMIT INDEX I_INDEX.
CALL SCREEN 9001 STARTING AT 10 10 .
ENDIF.
ENDMODULE. " USER_COMMAND_9000 INPUT
*& Module STATUS_9001 OUTPUT
text
MODULE STATUS_9001 OUTPUT.
SET PF-STATUS 'PF9002'.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_9001 OUTPUT
*& Module USER_COMMAND_9001 INPUT
text
MODULE USER_COMMAND_9001 INPUT.
IF G_OK_CODE1 = 'SAVE'.
MODIFY ZAMIT_SHIP_TAB FROM I_ZAMIT.
SELECT * FROM ZAMIT_SHIP_TAB INTO TABLE I_ZAMIT.
CALL METHOD G_ALV->REFRESH_TABLE_DISPLAY.
CALL SCREEN 9000.
ENDIF.
ENDMODULE. " USER_COMMAND_9001 INPUT -
Editable ALV- I need to increase curr to be 12 chars from 8 chars in o/p.
I am getting problem in Editable ALV, I wanted to increase the currency field from 8 chars to 12 chars at the output.
But after the output i am able to enter only eight chars.
I want '123456789012' but i am able to put only '12345678'.
Plz have alook.hi !
check the length of field in your data declaration
you can set the length of o/p field in alv for that just check
intlen or outputlen in fieldcat
but by using these you can not update these in your internal table b'coz of your type declaration for that field -
Error message when running editable alv
Hi all,
I hava a problem with an editable ALV. I created it with the following method wddoinit:
METHOD wddoinit .
initialize ALV Component
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
Get model data
DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
DATA:
l_value TYPE REF TO cl_salv_wd_config_table.
l_value = l_ref_interfacecontroller->get_model( ).
set read only mode to false (and display edit toolbar)
DATA: lr_table_settings TYPE REF TO
if_salv_wd_table_settings.
lr_table_settings ?= l_value.
lr_table_settings->set_read_only( abap_false ).
set cell editor for input fields (~make colum editable)
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column_settings ?= l_value.
lr_column = lr_column_settings->get_column( 'SAMPLE' ).
CREATE OBJECT lr_input_field
EXPORTING
value_fieldname = 'SAMPLE'.
lr_column->set_cell_editor( lr_input_field ).
ENDMETHOD.
But when I run the Web Dynpro Application I get an error message with the note:
"Access over "Null" Object Reference not possible" ( I translated it from german to english )
The error occures in the line:
lr_column->set_cell_editor( lr_input_field ).
But what is wrong?
Thanks for your help!!
Regards
IngmarSorry. I'm stupid. I didn't the "Sample" for column and field!!!
But:
How can I reach that not only one cell is editable, but the whole table? And how can I save the data that I put in, when I add a new line?
Thanks!! -
Retrieve changed record from editable alv grid
hello,
i am new to alv grid... i am facing some problems working on it... plz help me solve my problems...
i have created an alv grid displaying the timesheet of some employee's...
the worktime cells are editable and rest of the information is read only...
the worktime is changed and then a SAVE button is pushed...
how do i retrieve the changed time into my internal table?
once i update the internal table, i can modify the database table...
thank you.Hi,
Refer this program:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
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 pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'.
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
* when the function code is SAVE then save records into internal table
WHEN 'SAVE'.
* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
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.
"now at this time you have modified internal table
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
"alv output is refreshed as per changes in internal table
"now you can include code to modify your ztable from internal table
ENDCASE.
ENDFORM. "USER_COMMAND
Regards,
Tarun -
Function Module to edit the ALV Output
Hi,
I have an ALV report output.I need the edit values based on some conditions in the ALV output and
save the changes. Is there any function module to edit the output and proceed further.
Thanks in advance.
Regards,
NavasFirst create the field catalog of the field that you want to edit in this way
WA_fieldcat-fieldname = 'MENGE'.
WA_fieldcat-qfieldname = 'MEINS'.
WA_fieldcat-seltext_m = 'PO Quan.'
WA_fieldcat-edit = 'X' .
Secondly you keep a custom button like 'SAVE' in the toolbar and also try to keep a checkbox in your ALV.
for checkbox you have to keep a following code snippet in your finallly displayed interanal table:
chk(1) TYPE c, and in the fieldcatalog you have to write following piece of code
WA_fieldcat-fieldname = 'CHK'.
WA_fieldcat-seltext_m = 'CheckBox'.
WA_fieldcat-checkbox = 'X'.
WA_fieldcat-edit = 'X' .
WA_fieldcat-input = 'X'.
WA_fieldcat-tabname = 'IT_FINAL'.
WA_fieldcat-col_pos = 1.
then you have to set the parameter i_callback_user_command = 'USER_COMMAND'
of FM REUSE_ALV_GRID_DISPLAY.
Then write a subroutine like the following one to handle the SAVE operation
FORM user_command USING I_r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA:l_cntr TYPE i.
CASE I_r_ucomm.
WHEN '&ZXZ'.
CLEAR l_cntr.
CLEAR WA_final.
LOOP AT IT_final INTO WA_final.
IF WA_final-chk = 'X'.
l_cntr = l_cntr + 1.
ENDIF.
ENDLOOP.
IF l_cntr GT 1.
MESSAGE i011.
ELSEIF l_cntr = 1.
READ TABLE IT_final INTO WA_final WITH KEY chk = 'X'.
MODIFY IT_final FROM WA_final TRANSPORTING menge
WHERE chk = 'X'.
CLEAR WA_final.
PERFORM disp_alv. <<<This is to display the refreshed alv after saving your data
endif.
ENDCASE.
ENDFORM. -
Issue in Excel download from ALV output
Dear Experts,
I have generated an ALV Output using FM "REUSE_ALV_GRID_DISPLAY". When i try to download the ALV Output in Excel spreadsheet, I am not getting the data in Excel sheet. Kindly help me in this regard.
Thanks in advance,
Regards,
Ramesh Manoharanhi ramesh,
Please try below options.
after getting the ALV disply , Go to Menu LIST->Export->Spreadsheet.or microsoft excel view (Cntrl + Shift + F7)
It will give some options to see the data in spread sheet format, hope you can save this to local desktop also.
or
please check the extension, it should be .XLS not .XLSX .some times .XLSX format wont be supported
regards,
pradeep
Edited by: Pradeep Kandgal on Aug 4, 2010 6:54 PM
Edited by: Pradeep Kandgal on Aug 4, 2010 6:54 PM
Maybe you are looking for
-
Voice memos gone after ios 7 upgrade
The voice memos on my phone are gone following the update to IOS 7. Does anyone know why they disappeared and how I can get them back on the phone. I have an iphone 5. I backed up before the update but I do not see the voice memos in my itunes lib
-
Podcasts are downloaded to the wrong folder
I've moved my library to a network drive (Y:). However, new podcasts are still being downloaded to My Documents/My Music/iTunes/Podcasts The Media folder location has been changed to Y:\Shared Music in the preferences, and there doesn't appear to be
-
From ADS, we can get the source "map" like this:<br /><loadContent source="file://C:/map.pdf" out="map" /> <br /><br />How can I get the source fileIn1 path specify here?<br /><br />var xmlShell ='<?xml version="1.0" encoding="UTF-8"?>\n\<br /><DDX x
-
How to get time specification detail from database
Dear All, How can I get the time specification detail from data base? Time specification is a 32 bit hexadecimal no type guid_32. Function wfd_timespec_reload provide the modified time specification detail. FUNCTION wfd_timespecs_reload ""Local Inter
-
Compiling (or not) in JBuilder8
Hi there. Does anybody out there have any experience with JBuilder8? I have a problem compiling my stuff. Let's say that I have 3 java-files (A.java, B.java & C.java). Since B needs C and A needs B, i need to compile C first... import B; class A { im