EDIT field in ALV GRID and on SAVE it has to update the DB Table
Hi Experts,
I have searched lot of forums...
But i had not got the exact solution for this...
I have multiple records that displayed in the ALV output screen and i had modified more than one record and then click on save.
It has to modify all the lines that i had changed in the EDITABLE FIELD.
Can any one help me in doing so...
Sample code will be more help full....
Thanks in advance,
Kruthik
Hi Kruthik
Check [=> OO ALV Event DATA_CHANGED <= |http://abaptips.com/?p=70], hope you will get idea.
Please reply in case of any confusion.
Thanks and Best Regards,
Faisal
Similar Messages
-
Va02 screen input first save it has to update the data base table
I am working on VA02.
For only one user(delivery block)should be block and when we are changing in sales order document for that user it has to update the VBAK table.
for second save i'm able to updating but i want to update at first save only.
thanks,
sree.I want to update the DB table VBAK. and the user exit is:
here is my coding: my requirement is to block a field i.e LIFSK in va02 and after saving that and i have checked vbak table then in lifsk the blocked db is updated IN TABLE CONTENTS.LATER IF I SAVE IT ANOTHER TIME WITHOUT ANY MODIFICATIONS THE FIELD IS NOT UPDATED.
now the problem is with updation .i have blocked the field.
Please help me its urgent
FORM USEREXIT_MOVE_FIELD_TO_VBAK.
tables: knkk.
if not vbak-kunnr is initial.
if vbak-auart NE 'ZFD' and
vbak-auart NE 'ZCR2' and
vbak-auart NE 'ZRE' and
vbak-auart NE 'ZSD'.
select single * from KNKK
where KUNNR = vbak-kunnr
and KKBER = '8000'.
if sy-subrc = 0.
clear vbak-LIFSK.
ENDIF.
IF NOT SY-UNAME = 'FINCOMM1' AND SY-TCODE = 'VA02'.
SELECT SINGLE LIFSK FROM VBAK INTO LIFSK1 WHERE VBELN = VBAK-VBELN.
IF LIFSK1 NE ' '.
vbak-LIFSK = ' '.
ELSEif vbak-auart eq 'ZCR2'.
vbak-LIFSK = 'Z1'.
ELSE.
vbak-LIFSK = 'Z6'.
endif.
if sy-tcode eq 'VA02' . "added on 22/05/2008
if screen-name = 'VBAK-LIFSK'.
screen-input = 1.
modify screen.
update vbak.
endif.
ENDIF.
ENDIF.
endif.
endif.
if sy-tcode eq 'VA02' AND sy-uname NE 'FINCOMM1'. "added on 22/05/2008
if screen-name = 'VBAK-LIFSK'.
screen-input = 1.
modify screen.
update vbak.
endif.
endif.
endform.
Thanks,
sri. -
How and where does SAP standard programs update the master tables...
Hello there,
How and where does SAP standard programs update the master tables...
to be precise.. if a (any) transaction occurs the programs behind it holds the data in temporary structures.
where and when does it get updated in the master table.
can anyone tell me how it happens?
I Know that from the where used list one can find the corresponding table but most of the time it wont suffice
I am expecting a proper answer.
Santosh BHello Santosh,
you need to do some self-reading on the following topic
Updates in the SAP System (BC-CST-UP)
http://help.sap.com/saphelp_47x200/helpdata/en/e5/de86e135cd11d3acb00000e83539c3/frameset.htm
Regards,
Siddhesh -
hi
can i make the fields of one of the columns of one of the rows as editable in ALV_GRID FM..?
if so pls guide me how do i do it..
after the user edits the data in the field, can i save that in another variable or another internal table? or modify the same internal table?
pls send me an example code also...
thanks in advance
srinihi,
editable alv:
chk this link.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_editable.htm
then u can capture the events in USER COMMAND.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm
See these threads
Re: Making selected alv rows editable
Re: selective edit in ALV grid
REPORT ZSRI_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
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 -
Disable editable field in ALV grid using OOPS
I have following requirements,
Displaying ALV grid output with most of the fields editable.
Validations on data entered for each fields,for error messages
Query :
I want to make all the fields except the field in ERROR in display only mode
similar to case when we do validation of fields in table controls.HI
check the below links lot of info and examples r there for OOPS
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.allsaplinks.com/
http://www.sap-img.com/
http://www.sapgenie.com/
http://help.sap.com
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Check these sample code
data : begin of it_mara occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara.
data : begin of it_mara1 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara1.
data : begin of it_mara2 occurs 0,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of it_mara2.
data : t_fieldcat type lvc_t_fcat,
t_fieldcat1 type lvc_t_fcat,
s_fieldcat like line of t_fieldcat.
data : s_layout type lvc_s_layo.
data : control type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
data: begin of wa ,
mark type flag,
matnr type matnr,
mtart type mtart,
meins type meins,
end of wa.
class lcl_events_box definition.
public section.
methods :
*Handler_Data_Changed for event Data_Changed of cl_gui_alv_grid
*imporTing er_data_changed,
Handler_User_Command for event User_Command of cl_gui_alv_grid
imporTing e_ucomm,
Handler_ToolBar for event ToolBar of cl_gui_alv_grid
importing E_object E_interactive.
endclass.
class lcl_events_box implementation.
method Handler_user_command.
PERFORM FORM_USERCOMMAND CHANGING E_UCOMM.
endmethod.
method Handler_ToolBar.
PERFORM FORM_TOOLBAR CHANGING E_OBJECT E_INTERACTIVE
E_OBJECT->MT_TOOLBAR.
endmethod.
ENDCLASS.
start-of-selection.
data : w_events type ref to lcl_events_box.
select matnr mtart meins from mara into corresponding fields of table
it_mara.
call screen 100.
*& Module pbo_module OUTPUT
text
MODULE pbo_module OUTPUT.
if GRID is initial.
CREATE OBJECT CONTROL
EXPORTING
CONTAINER_NAME = 'CUST_CTRL'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = CONTROL.
PERFORM BUILD_CATALOG.
PERFORM BUILD_CATALOG1.
PERFORM BUILD_LAYOUT.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara[]
IT_FIELDCATALOG = t_fieldcat.
CREATE OBJECT W_EVENTS.
SET HANDLER : W_EVENTS->HANDLER_TOOLBAR FOR GRID,
W_EVENTS->HANDLER_USER_COMMAND FOR GRID.
CALL METHOD GRID->SET_TOOLBAR_INTERACTIVE.
ELSE.
call method grid->refresh_table_display.
ENDIF.
ENDMODULE. " pbo_module OUTPUT
*& Form BUILD_CATALOG
FORM BUILD_CATALOG .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MARK'.
S_FIELDCAT-CHECKBOX = 'X'.
S_FIELDCAT-eDIT = 'X'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT.
S_FIELDCAT-COL_POS = '4'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT.
ENDFORM. " BUILD_CATALOG
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
FORM BUILD_LAYOUT .
S_LAYOUT-ZEBRA = 'X'.
S_LAYOUT-CWIDTH_OPT = 'X'.
S_LAYOUT-GRID_TITLE = 'Material Details'.
ENDFORM.
" BUILD_LAYOUT////////////////////////////////////
" USER_COMMAND_0100 INPUT
*& Form FORM_USERCOMMAND
text
<--P_E_UCOMM text
form FORM_USERCOMMAND changing p_e_ucomm.
CASE P_E_UCOMM.
WHEN 'INT1'.
DO.
READ TABLE IT_MARA INDEX SY-INDEX TRANSPORTING MARK MATNR.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF IT_MARA-MARK = 'X'.
read table it_mara into wa TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING WA TO IT_MARA1.
READ TABLE IT_MARA1 TRANSPORTING MATNR MTART MEINS .
MOVE-CORRESPONDING IT_MARA1 TO IT_MARA2.
APPEND IT_MARA2.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = s_layout
CHANGING
IT_OUTTAB = it_mara2[]
IT_FIELDCATALOG = t_fieldcat1.
SET PARAMETER ID 'MAT' FIELD IT_MARA-MATNR.
CALL TRANSACTION 'MM02'.
. ENDIF.
ENDIF.
ENDDO.
ENDCASE.
endform. " FORM_USERCOMMAND
*& Form FORM_TOOLBAR
text
<--P_E_OBJECT text
<--P_E_INTERACTIVE text
<--P_E_OBJECT_>MT_TOOLBAR text
FORM FORM_TOOLBAR CHANGING P_E_OBJECT TYPE REF TO
CL_ALV_EVENT_TOOLBAR_SET
P_E_INTERACTIVE
MT_TOOLBAR TYPE TTB_BUTTON.
DATA WAL_BUTTON TYPE STB_BUTTON.
*WAL_BUTTON-ICON = ICON_status_reverse.
WAL_BUTTON-TEXT = 'GO'.
WAL_BUTTON-QUICKINFO = 'PROCEED'.
waL_button-FUNCTION = 'INT1'.
WAL_BUTTON-BUTN_TYPE = 0.
WAL_BUTTON-DISABLED = SPACE.
insert WAL_BUTTON INTO P_E_OBJECT->MT_TOOLBAR index 1.
endform. " FORM_TOOLBAR
*& Module PF-STATUS OUTPUT
text
module PF-STATUS output.
set pf-status 'Z7PSTAT'.
endmodule. " PF-STATUS OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
module USER_COMMAND_0100 input.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
*& Form BUILD_CATALOG1
text
--> p1 text
<-- p2 text
form BUILD_CATALOG1 .
S_FIELDCAT-COL_POS = '1'.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-SCRTEXT_M = 'MATERIAL'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '2'.
S_FIELDCAT-FIELDNAME = 'MTART'.
S_FIELDCAT-SCRTEXT_M = 'MATERL TYPE'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
S_FIELDCAT-COL_POS = '3'.
S_FIELDCAT-FIELDNAME = 'MEINS'.
S_FIELDCAT-SCRTEXT_M = 'UOM'.
APPEND S_FIELDCAT TO T_FIELDCAT1.
endform. " BUILD_CATALOG1
check the below link may be useful for you
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
<b>Reward all helpfull answers</b>
Regards -
Editable field in ALV GRID/LIST
Hi All,
I developed an alv program in which 10 rows is there. In alv grid/list first column is check box. I want 1,5 and 10th row is editable for first column (check box) while rest is not editable. Can you please give solution for same. Please tell me simple method not oops methos
coz I have taken FM REUSE_ALV_GRID_DISPLAY or REUSE_ALV_LIST_DISPLAY.
Thanks,
Rakeshgoto se38.
BCALVEDIT*
press F4
many examples are there..
BCALV_GRID_EDIT try this... -
Issue on sorting the fields in ALV Grid
I have created a report in ALV Grid I have sorted the fields using slis_sortinfo_alv to avoid the duplicates . I could display the output in sorted fashion, but when I export it to a file it is displaying in the same fashion as it is in the database that is in the allowing duplicates.. I cant use DELETE ADJACENT DUPLICATES as it will delete the adjacent records . i need help from you guys please help me...
Hi,
As you have data in your internal table that is to be displayed in the alv grid display.
So, instead you can sort the internal table on that field and then can delete the duplicate records comparing that very field.
Use code:-
sort <itab> by <field_name>. "to sort
delete adjacent duplicates from <itab> comparing <field_name>. "to delete duplicate entries
This will delete all the duplicates records for the column.
Now you can use this internal table to display the data in the ALV grid.
Or if you dont wish to delete the data from the initial internal table, then you can use a temporary internal table of same structure and use:-
it_temp = itab.
sort it_temp by <field_name>. "to sort
delete adjacent duplicates from it_temp comparing <field_name>. "to delete duplicate entries
Now you can use this internal table to be displayed as alv output.
Hope this helps you.
Thanks & Regards,
Tarun -
How to save the edited fields in ALV list
Hi
hope you could help me find a solution, I made my fields editable in ALV grid display as you can see in the code ZID_NUM, ZLAST_NAME and ZMIDDLE_NAME is editable..
an example scenario would be if I execute the program it will show me 5 lines, all the fields can be edited by the user...(example he edited all data in the result). When he press save, it will automatically update the ztable (ZMEMPLIST in this case). How do you go about the saving?
thanks!!
select * from zmemplist client specified
into corresponding fields of table it_ztable.
it_fieldcat-fieldname = 'ZID_NUM'.
it_fieldcat-seltext_m = ' ID Number '.
it_fieldcat-col_pos = 1.
it_fieldcat-input = 'X'.
it_fieldcat-edit = 'X'.
append it_fieldcat to it_fieldcat.
clear it_fieldcat.
it_fieldcat-fieldname = 'ZLAST_NAME'.
it_fieldcat-seltext_m = ' Last Name '.
it_fieldcat-col_pos = 2.
it_fieldcat-input = 'X'.
it_fieldcat-edit = 'X'.
append it_fieldcat to it_fieldcat.
clear it_fieldcat.
it_fieldcat-fieldname = 'ZFIRST_NAME'.
it_fieldcat-seltext_m = ' First Name '.
it_fieldcat-col_pos = 3.
it_fieldcat-input = 'X'.
it_fieldcat-edit = 'X'.
append it_fieldcat to it_fieldcat.
clear it_fieldcat.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
it_fieldcat = it_fieldcat[]
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
tables
t_outtab = it_ztable.
*& Form user_command
Handling custom function codes
-->R_UCOMM Function code value
-->RS_SELFIELD Info. of cursor position in ALV
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when 'SAVE'.
endformHi Lawrence,
Include follwoing code on your user command for 'SAVE'.
*& Form user_command
* Handling custom function codes
* -->R_UCOMM Function code value
* -->RS_SELFIELD Info. of cursor position in ALV
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when 'SAVE'.
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.
............... " your action
* endform
Hope this will sovle your query.
Pratik Vora -
Editing An ALV Grid and saving finally.
Hİ !
former Abap programmer I have modified CN47N as ZCN47N and made the some of the fields of the grid Editable.
The user changes some of the fields and then press Enter occasionally. When he wants to save he clicks a Save button.
If I use
call method g_d_grid->set_ready_for_input
exporting
i_ready_for_input = 1.
call method g_d_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter
exceptions
error = 1
others = 2.
the "data_changed " event of the ALV grid is fired every time the user press Enter BUT CAPTURES ONLY THE LAST EDITS.
But I can update the neighboring cells of the editable cells immediately by this way.
If I disable the mc_evt_enter event , The user can save ALL of the changes with the firing of gr_grid->checked_changed_data which fires the data_changed event.
But by this way I can not update the neighboring cells of the editable cells with the explanation of the editable cells.
My Question:
1) Will data_changed_finished event suit better than data_changed_?
2) Is there a moderate way in which I can use the enter key and capture all the changes that have been made in the grid ?
thanks.
erkan.DATA_CHANGED triggers as soon as you enter the value and move away to different cell. Parameter ER_DATA_CHANGED of the handler method of DATA_CHANGED would have MT_GOOD_CELLS and MT_BED_CELLS. Based on this you can validate the values and update the Protocol table using the method ADD_PROTOCOL_ENTRY.
If you have to modify other cells based on the entered cells, you need to use this DATA_CHANGED method, because here you can get / change the data of the cell using the method GET_CELL_VALUE & MODIFY_CELL. in this method, the entered data is not yet visible in your ALV data table.
DATA_CHANGED_FINISHED triggers after the data has been updated in the ALV data table. So, if you wish to change the other cells it too late. You need to modify the table and call the refresh method to actually refresh the data.
Regards,
Naimesh Patel -
Regarding Editable Quantity field in ALV Grid
Hi Experts,
I need your advice in this 2 scenarios.
1.I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator. If i take a char field and display the field is editable then user may mistakenly type a,bcd...z/ special characters which it should not capture. Is there any char data type data element which accepts only integers. Because after that i need to save that value in z database table quantity field.
2. when there i raised an error message after validation of that editable field in alv output(by events), the user wants all other rows in that grid as uneditable except the row which has got error till this error is solved. Is this possible. If yes how.
Please share your valuable suggestions.Hi abilash n
as in dictionary, all quantity fields should have a reference to the unit field which then defines the number of decimals.
The rest is done automatically as long as you do it standard way. In field catalog you have to set the fcat-qfieldname to the name of the field that has the unit.
If you do so, also totals will be grouped by unit.
SAP has really done a great thing by inventing units for quantities (and currency keys for currency amounts). Only developers do not understand and thus refuse to use it.
Regards,
Clemens -
ALV-Grid and update dynpro fields
Hi!
I've created a dynpro with an ALV-Grid for Data-Overview and fields on the dynpro to change additional data.
My ALV has one editable column, when this value change I calculate other value for a field dynrpo, but I canu2019t see this change in my field dynpro.
How can I update my data filed dynpro when changing the selected row at the ALV.
I use the method handle_data_changed to obtain changes in ALV-Grid and it works fine, but I canu2019t update my fileds on the dynpro, when changing value in ALV.
Thanks for any hints!
Lili.This error occurs becuase when you change anything on the ALV, control is not triggering the PAI and PBO of your dynpro. Hence your values are not getting updated in the dynpro field.
You should call the CL_GUI_CFW=>DISPATCH in PAI module to trigger the PAI also after the event has been triggered in the ALV.
CALL METHOD CL_GUI_CFW=>DISPATCH
importing return_code = return_code.
* a control event occured => exit PAI
if return_code <> cl_gui_cfw=>rc_noevent.
clear g_ok_code.
exit.
endif.
Regards,
Naimesh Patel -
hiii
when doing editable field in alv
you set
i_fieldcat-edit = C_X
i_fieldcat-input = C_X
P_selfield-refresh = C_X
this is not working when i click on save the internal table is not keeping the change i have edit on the screen and the p_selfield value also has still the old value.
but when i double click the p_selfield is keeping the editable value. Please advise ??hi,
Check out this sample program.The part for 'EDIT' is in Bold..
report zalv_color_display_edit.
type-pools: slis.
tables : zcust_master2.
types : begin of wi_zcust_master2,
zcustid like zcust_master2-zcustid,
zcustname like zcust_master2-zcustname,
zaddr like zcust_master2-zaddr,
zcity like zcust_master2-zcity,
zstate like zcust_master2-zstate,
zcountry like zcust_master2-zcountry,
zphone like zcust_master2-zphone,
zemail like zcust_master2-zemail,
zfax like zcust_master2-zfax,
zstat like zcust_master2-zstat,
field_style type lvc_t_styl,
end of wi_zcust_master2.
data: it_wi_zcust_master2 type standard table of wi_zcust_master2
initial size 0,
wa_zcust_master2 type wi_zcust_master2.
data: fieldcatalog type slis_t_fieldcat_alv with header line.
data: it_fieldcat type lvc_t_fcat,
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.
perform data_retrieval.
perform set_specific_field_attributes.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
form build_fieldcatalog.
wa_fieldcat-fieldname = 'ZCUSTID'.
wa_fieldcat-scrtext_m = 'CUSTOMER ID'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZCUSTNAME'.
wa_fieldcat-scrtext_m = 'CUSTOMER NAME'.
wa_fieldcat-col_pos = 1.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZADDR'.
wa_fieldcat-scrtext_m = 'ADDRESS'.
wa_fieldcat-col_pos = 2.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZCITY'.
wa_fieldcat-scrtext_m = 'CITY'.
wa_fieldcat-col_pos = 3.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZSTATE'.
wa_fieldcat-scrtext_m = 'STATE'.
wa_fieldcat-col_pos = 4.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZCOUNTRY'.
wa_fieldcat-scrtext_m = 'COUNTRY'.
wa_fieldcat-col_pos = 5.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZPHONE'.
wa_fieldcat-scrtext_m = 'PHONE NUMBER'.
wa_fieldcat-col_pos = 6.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZEMAIL'.
wa_fieldcat-scrtext_m = 'EMAIL'.
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 = 'ZFAX'.
wa_fieldcat-scrtext_m = 'FAX'.
wa_fieldcat-col_pos = 8.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ZSTAT'.
wa_fieldcat-scrtext_m = 'STATUS'.
wa_fieldcat-col_pos = 9.
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
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
tables
t_outtab = it_wi_zcust_master2
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
text
--> p1 text
<-- p2 text
form data_retrieval .
data: ld_color(1) type c.
select zcustid zcustname zaddr zcity zstate zcountry zphone zemail
zfax zstat up to 10 rows from zcust_master2 into corresponding fields of
table it_wi_zcust_master2.
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 following code sets it to be disabled(display only) if 'ZFAX'
is NOT INITIAL.
loop at it_wi_zcust_master2 into wa_zcust_master2.
if wa_zcust_master2-zfax is not initial.
ls_stylerow-fieldname = 'ZFAX' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
append ls_stylerow to wa_zcust_master2-field_style.
modify it_wi_zcust_master2 from wa_zcust_master2.
endif.
endloop.
endform. "set_specific_field_attributes
Hope this helps you,
Arunsri -
ALV GRID and Integrated ITS 7 (SAP GUI for HTML) - dissapears on reload
Hi All,
We have a custom report that uses an ALV grid to display information to the user. Within this grid, there are fields that are display only and fields that are editable. Also, the grid is wider than the screen's width. It works fine in ECC. It also worked fine when we were using ITS 6.4.
We have recently upgraded to ITS 7. Now when we run the report using a Transaction iView (in EP 7) or the Webgui service (SAP GUI for HTML), if a field that is editable has focus when an event is triggered that reloads the grid, the screen becomes blank. So, you can click the Save button and the screen goes blank, also, there are date fields in the grid and if you choose a new date, the grid reloads and the screen becomes blank.
We have found that when the screen is blank, you can use the "Page Up" button on your keyboard and the last few columns of the grid will appear. As if the entire grid has moved off-screen to the left.
If you click onto a non-editable field and refresh or save, the grid returns to its normal state.
We are on Basis Patch level 15.
Does anyone have any ideas on how to fix this?
Also, does anyone know of a standard SAP transaction we can call from the Webgui that would have a similar setup...with an ALV grid containing editable and non-editable fields? We would like to rule out any errors in the report itself. Since it worked before we upgraded and it works fine in ECC. This would be a really big help too.
Thank you so much!
-KevinHi,
Thanks Raymond, I have seen Note 314568. I could not get the second link to work but I have looked at just about every Note in reference to Integrated ITS 7 and Tables or ALV Grids and there are very many, so it would appear that SAP has had a hard time with implementing this control, but I have not seen any instance that matches the problem we are having.
Unfortunately, SAP will not investigate this unless we can provide a standard Transaction that exhibits the same behavior.
If anyone knows of a standard SAP Transaction that displays an ALV Grid that is wider than the screen (requiring a horizontal scroll bar) and with editable and non-editable fields, that would be fantastic. If we can test against that, then we would know for sure if this is a problem with ITS / SAP GUI for HTML, or if there is an issue with this specific report.
Thanks!
-Kevin -
How to make a field of ALV Grid to use a Search Help?
Hi;
I have a ALV grid with a field catalog. Say the field is 'USR000'.
F4availabl = 'X' . for the field in the field catalog.
I have prepared search help named ZEV_PROTYPE that uses tha table ZEV_PROTYPES.(two fields in the table :ProType and Text).
Is it possible to make the field in ALV grid to use this search help if F4 is pressed on the field. ?
Which structure of the ALV must be used for that ? Is it Field Catalog ?
Would you please help me ?
erk.Hi,
If you have a Z data element and the search help is attached to it, you can just give the reference table and field in the field catalog for the editable ALV field, and the search help should appear.
Regards,
Sagar -
What is ALV grid and describe its implementation procedure
Hi all,
Can you tell me the step by step implementation procedure of ALV gridhi..
Steps To Use ALV Grid in a Program
1. Declare reference variables for,
Container (class CL_GUI_CUSTOM_CONTAINER) and
Grid (class CL_GUI_ALV_GRID)
Example
DATA: grid TYPE REF TO cl_gui_alv_grid,
custom_container TYPE REF TO cl_gui_custom_container
2. Create Standard Screen and a container on that screen and give a name to that container ( Use custom control button from tool bar) . This name will be used to link the container we have created on the screen with the object reference of class CL_GUI_CUSTOM_CONTAINER, which we have declared in the first step
3. Call the screen which has been created
4. Instantiate the container control and the ALV Grid Control in PBO of the screen.
Example
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
CONTAINER_NAME = u2018MY_CONTAINER'.
CREATE OBJECT grid
EXPORTING
I_PARENT = custom_container.
ENDIF
5. For displaying the data, call the method set_table_for_first_display of object reference of CL_GUI_ALV_GRID.
Example
CALL METHOD grid->set_table_for_first_display
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT =
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
CHANGING
IT_OUTTAB =
IT_FIELDCATALOG =
IT_SORT =
IT_FILTER =
EXCEPTION
INVALID_PARAMETER_COMBINATION =
PROGRAM_ERROR =
TOO_MANY_LINES =
others =
EXPLANATION OF SOME IMPORTANT PARAMETERS.
I_BYPASSING_BUFFER & I_BUFFER_ACTIVE :
When the program is run for the first time, the fields present in the output table and their positions are stored in a buffer. So the buffer is taken as reference for the successive executions. In order to bypass this buffer the above parameter values should be u2018Xu2019 and u2018 u2018(space) respectively. If these values are not passed to the function module, the changes made in the structure of the internal table will not be reflected in the output.
I_STRUCTURE_NAME:
If the structure of your output table corresponds to a structure stored in the Data Dictionary (DDIC), the ALV Grid Control can use this information to generate the field catalog automatically. Pass the table structure as parameter. In this case, all fields of this DDIC structure are displayed in the list.
IS_VARIANT :
It allows the user to save and reuse the layout. It is a structure of type DISVARIANT and contain the display variant name. It facilitates pre-assignment for a layout, rather than displaying report and then choosing displaying variant.
I_SAVE:
This single character variable specifies whether the user specific display variants can be saved or not.
The I_SAVE "Options for saving layouts" parameter can have the following values:
U Only user specific layouts can be saved
X Only global layouts can be saved
A Both user specific and global layouts can be saved
Space Layouts can not be saved
IS_LAYOUT:
This structure of type LVC_S_LAYO
is used to control the layout of the ALV. Two important fields are:
GRID TITLE. : Title of grid
ZEBRA : Alternate lines in list are displayed in different colors.
IT_FIELDCATALOG:
This internal table of type LVC_T_FCAT
is used to specify the position of various fields in the report itab.
There are three ways we can fill the field catalog table
1. Automatically through data dictionary structure (DDIC). In this case we pass the table structure to I_STRUCTURE_NAME.
2. Manually in ABAP program. Filling the internal table of type LVC_T_FCAT
1. . With each row corresponding to each column of output table. Each row of this table will hold value like
i). TABNAME & FIELDNAME specifies the reference fields for F1 help
ii). CTABNAME & CFIELDNAME specifies the reference fields for currency formatting
iii). QTABNAME & QFIELDNAME specifies the reference fields for quantity formatting
iv). SELTEXT_L holds the long description of the field
v). SELTEXT_M holds the medium description of the field
vi). SELTEXT_S holds the small description of the field
vii). KEY specifies the Key field ( cannot be hidden )
viii). OUTPUTLEN species the output length of the field
ix). DO_SUM specifies that subtotal is required on this field
x). NO_OUT specifies a hidden field
3. Semi-Automatically by combining the above 2 procedures.
Call function Module REUSE_ALV_FIELDCATALOG_MERGE and pass DDIC
structure or the output table to generate the field catalog.
Add additional Rows or modify existing properties of the fields to be displayed.
hope this will help you.
regards
lokesh
Maybe you are looking for
-
NEW FOLDER, for word processing, like Page and others?
We're with a new IMac & iWork. We want to start a folder for docs if not also templates. It is for a word processing folder under Page, iWork and new Mac OSX.
-
Direct Connection ABAP Proxy and Java Proxy possible ????
Hi Folks , As i read as direct connection possible between 2 SAP systems only .. and also i read as WS Direct Connection u2013 (Java) .. What it means ?? is it ABAP Proxy to Java Proxy using Direct connection ?? Like Java Client Proxy and ABAP Serve
-
Some browser doesn't display the MW page correctly
after installing Maintenance Wizard 2.17, some browser doesn't display the MW page correctly, some menu function is missing. The display problem is not for everyone, some user's browser have no problem. Some user's IE are displaying it correctly. i.e
-
MRP+Batch determination/restriction complex scenario
I have a very complex issue with MRP and Batch Determination. Here is my situation. Please help me find a solution. I have materials which are batch managed and each material can have numerous batches based on the quality (80%, 70%, 90%). Materials c
-
Query and Device Collection by Department
Hi all, I am trying to figure out how to build a query and a device collection that is by department. In the administration of sccm 2012 sp1 I added the attribute "department" but I do not see a way to build a query that shows: user name/computer n