2006 Apr 24 3:10 PM
Hi All,
I am displaying matnr and maktx using ALV grid display. MAKTX is an editable field. On changing the material description on the screen and then clicking the button 'NEW' on the Application Toolbar, will let me display the modified description alongwith the material number in the next screen.
I have written the following code. This code enables me to edit but the required functionality is not getting performed on clicking the NEW button. What to do next?
How to capture the modified data from the screen to the internal table T_MAT?
&----
*& Report ZEDITABLE_MAT_DESCRIPTION *
*& *
&----
*& *
*& *
&----
REPORT Z6PM_EDITABLE_MAT_DESCRIPTION no standard page heading message-id zp.
----
*Purpose: To edit material description on clicking new button on the
application toolbar
----
----
Type Declaration *
----
TYPE-POOLS: SLIS.
TYPES: BEGIN OF TYPE_MAT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TYPE_MAT.
TYPES: TYPE_T_MAT TYPE STANDARD TABLE OF TYPE_MAT.
----
Internal Table Definition *
----
DATA: T_MAT TYPE TYPE_T_MAT.
----
Work Area *
----
DATA: WA_MAT TYPE TYPE_MAT.
----
Variables *
----
DATA: V_MATNR TYPE MATNR.
DATA: V_MATNR1 TYPE MATNR.
----
Variables used for ALV *
----
*Fieldcat
TYPES: slis_t_fieldcat_alv type slis_fieldcat_alv.
DATA: T_FIELDCAT TYPE STANDARD TABLE OF SLIS_T_FIELDCAT_ALV.
*Layout
DATA: T_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Event
DATA: T_EVENTCAT TYPE SLIS_T_EVENT.
*Progam Name Variable
DATA: V_PROG_NAME LIKE SY-REPID.
----
Selection-Screen *
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_MATNR FOR V_MATNR.
SELECTION-SCREEN END OF BLOCK B1.
----
At Selection-Screen *
----
AT SELECTION-SCREEN.
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR INTO V_MATNR1
UP TO 1 ROWS
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E035.
ENDIF.
ENDIF.
----
Start of Selection *
----
START-OF-SELECTION.
Fetching Data from Database
PERFORM Z_FETCH_DATA.
Fieldcatalog.
PERFORM Z_FILL_DATA.
Layout
PERFORM Z_LAYOUT.
Events
PERFORM Z_EVENT CHANGING T_EVENTCAT.
Display Material No. and Description
PERFORM Z_DISPLAY_DATA.
&----
*& Form Z_FETCH_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_FETCH_DATA .
IF NOT S_MATNR[] IS INITIAL.
REFRESH T_MAT.
SELECT PMATNR QMAKTX
FROM MARA AS P
INNER JOIN MAKT AS Q
ON PMATNR = QMATNR
INTO TABLE T_MAT
WHERE P~MATNR IN S_MATNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC <> 0.
MESSAGE E035.
ELSE.
SORT T_MAT BY MATNR.
ENDIF.
ENDIF.
endform. " Z_FETCH_DATA
&----
*& Form Z_DISPLAY_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_DISPLAY_DATA .
V_PROG_NAME = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_PROG_NAME
I_CALLBACK_PF_STATUS_SET = 'ALV_MENU'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = TEXT-004
I_GRID_SETTINGS =
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = T_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENTCAT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = T_MAT
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. " Z_DISPLAY_DATA
&----
*& Form Z_FILL_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_FILL_DATA .
DATA: S_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
REFRESH T_FIELDCAT.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-TABNAME = 'T_MAT'.
S_FIELDCAT-SELTEXT_M = TEXT-002.
S_FIELDCAT-KEY = 'X'.
S_FIELDCAT-COL_POS = 0.
S_FIELDCAT-OUTPUTLEN = 18.
S_FIELDCAT-EMPHASIZE = 'X'.
S_FIELDCAT-REF_FIELDNAME = 'MARA-MATNR'.
S_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
S_FIELDCAT-FIELDNAME = 'MAKTX'.
S_FIELDCAT-TABNAME = 'T_MAT'.
S_FIELDCAT-SELTEXT_M = TEXT-003.
S_FIELDCAT-EDIT = 'X'.
S_FIELDCAT-COL_POS = 1.
S_FIELDCAT-OUTPUTLEN = 18.
S_FIELDCAT-EMPHASIZE = 'X'.
S_FIELDCAT-REF_FIELDNAME = 'MAKT-MAKTX'.
S_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
endform. " Z_FILL_DATA
&----
*& Form Z_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
form Z_LAYOUT .
T_LAYOUT-ZEBRA = 'X'.
endform. " Z_LAYOUT
&----
*& Form Z_EVENT
&----
text
----
<--P_T_EVENTCAT text
----
form Z_EVENT changing p_t_eventcat TYPE SLIS_T_EVENT.
DATA: S_EVENT TYPE SLIS_ALV_EVENT.
Get All Events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_T_EVENTCAT
EXCEPTIONS
LIST_TYPE_WRONG = 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.
CLEAR S_EVENT.
READ TABLE T_EVENTCAT WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO S_EVENT.
IF SY-SUBRC = 0.
MOVE 'ZF_PF_STATUS' TO S_EVENT-FORM.
APPEND S_EVENT TO P_T_EVENTCAT.
ENDIF.
CLEAR S_EVENT.
READ TABLE P_T_EVENTCAT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO S_EVENT.
IF SY-SUBRC = 0.
MOVE 'ZF_USER_COMMAND' TO S_EVENT-FORM.
APPEND S_EVENT TO P_T_EVENTCAT.
ENDIF.
endform. " Z_EVENT
&----
*& Form ZF_PF_STATUS
&----
text
----
form zf_pf_status using p_extab type slis_t_extab.
set pf-status 'ALV_MENU'.
endform. " PF_STATUS_SET
&----
*& Form ZF_USER_COMMAND
&----
text
----
*
----
FORM ZF_USER_COMMAND USING S_UCOMM LIKE SY-UCOMM P_SELFIELD TYPE SLIS_SELFIELD.
CASE S_UCOMM.
WHEN 'NEW1'.
LOOP AT T_MAT INTO WA_MAT.
WRITE:/ WA_MAT-MATNR, 20 WA_MAT-MAKTX.
ENDLOOP.
ENDCASE.
ENDFORM.
Thanx in Advance,
Regards,
Sangeeta.
Hi All,
I am displaying matnr and maktx using ALV grid display. MAKTX is an editable field. On changing the material description on the screen and then clicking the button 'NEW' on the Application Toolbar, will let me display the modified description alongwith the material number in the next screen.
I have written the following code. This code enables me to edit but the required functionality is not getting performed on clicking the NEW button. What to do next?
How to capture the modified data from the screen to the internal table T_MAT?
&----
*& Report ZEDITABLE_MAT_DESCRIPTION *
*& *
&----
*& *
*& *
&----
REPORT Z6PM_EDITABLE_MAT_DESCRIPTION no standard page heading message-id zp.
----
*Purpose: To edit material description on clicking new button on the
application toolbar
----
----
Type Declaration *
----
TYPE-POOLS: SLIS.
TYPES: BEGIN OF TYPE_MAT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
END OF TYPE_MAT.
TYPES: TYPE_T_MAT TYPE STANDARD TABLE OF TYPE_MAT.
----
Internal Table Definition *
----
DATA: T_MAT TYPE TYPE_T_MAT.
----
Work Area *
----
DATA: WA_MAT TYPE TYPE_MAT.
----
Variables *
----
DATA: V_MATNR TYPE MATNR.
DATA: V_MATNR1 TYPE MATNR.
----
Variables used for ALV *
----
*Fieldcat
TYPES: slis_t_fieldcat_alv type slis_fieldcat_alv.
DATA: T_FIELDCAT TYPE STANDARD TABLE OF SLIS_T_FIELDCAT_ALV.
*Layout
DATA: T_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Event
DATA: T_EVENTCAT TYPE SLIS_T_EVENT.
*Progam Name Variable
DATA: V_PROG_NAME LIKE SY-REPID.
----
Selection-Screen *
----
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_MATNR FOR V_MATNR.
SELECTION-SCREEN END OF BLOCK B1.
----
At Selection-Screen *
----
AT SELECTION-SCREEN.
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR INTO V_MATNR1
UP TO 1 ROWS
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E035.
ENDIF.
ENDIF.
----
Start of Selection *
----
START-OF-SELECTION.
Fetching Data from Database
PERFORM Z_FETCH_DATA.
Fieldcatalog.
PERFORM Z_FILL_DATA.
Layout
PERFORM Z_LAYOUT.
Events
PERFORM Z_EVENT CHANGING T_EVENTCAT.
Display Material No. and Description
PERFORM Z_DISPLAY_DATA.
&----
*& Form Z_FETCH_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_FETCH_DATA .
IF NOT S_MATNR[] IS INITIAL.
REFRESH T_MAT.
SELECT PMATNR QMAKTX
FROM MARA AS P
INNER JOIN MAKT AS Q
ON PMATNR = QMATNR
INTO TABLE T_MAT
WHERE P~MATNR IN S_MATNR
AND SPRAS = SY-LANGU.
IF SY-SUBRC <> 0.
MESSAGE E035.
ELSE.
SORT T_MAT BY MATNR.
ENDIF.
ENDIF.
endform. " Z_FETCH_DATA
&----
*& Form Z_DISPLAY_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_DISPLAY_DATA .
V_PROG_NAME = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_PROG_NAME
I_CALLBACK_PF_STATUS_SET = 'ALV_MENU'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = TEXT-004
I_GRID_SETTINGS =
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = T_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENTCAT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = T_MAT
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. " Z_DISPLAY_DATA
&----
*& Form Z_FILL_DATA
&----
text
----
--> p1 text
<-- p2 text
----
form Z_FILL_DATA .
DATA: S_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
REFRESH T_FIELDCAT.
S_FIELDCAT-FIELDNAME = 'MATNR'.
S_FIELDCAT-TABNAME = 'T_MAT'.
S_FIELDCAT-SELTEXT_M = TEXT-002.
S_FIELDCAT-KEY = 'X'.
S_FIELDCAT-COL_POS = 0.
S_FIELDCAT-OUTPUTLEN = 18.
S_FIELDCAT-EMPHASIZE = 'X'.
S_FIELDCAT-REF_FIELDNAME = 'MARA-MATNR'.
S_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
S_FIELDCAT-FIELDNAME = 'MAKTX'.
S_FIELDCAT-TABNAME = 'T_MAT'.
S_FIELDCAT-SELTEXT_M = TEXT-003.
S_FIELDCAT-EDIT = 'X'.
S_FIELDCAT-COL_POS = 1.
S_FIELDCAT-OUTPUTLEN = 18.
S_FIELDCAT-EMPHASIZE = 'X'.
S_FIELDCAT-REF_FIELDNAME = 'MAKT-MAKTX'.
S_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND S_FIELDCAT TO T_FIELDCAT.
CLEAR S_FIELDCAT.
endform. " Z_FILL_DATA
&----
*& Form Z_LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
form Z_LAYOUT .
T_LAYOUT-ZEBRA = 'X'.
endform. " Z_LAYOUT
&----
*& Form Z_EVENT
&----
text
----
<--P_T_EVENTCAT text
----
form Z_EVENT changing p_t_eventcat TYPE SLIS_T_EVENT.
DATA: S_EVENT TYPE SLIS_ALV_EVENT.
Get All Events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_T_EVENTCAT
EXCEPTIONS
LIST_TYPE_WRONG = 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.
CLEAR S_EVENT.
READ TABLE T_EVENTCAT WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO S_EVENT.
IF SY-SUBRC = 0.
MOVE 'ZF_PF_STATUS' TO S_EVENT-FORM.
APPEND S_EVENT TO P_T_EVENTCAT.
ENDIF.
CLEAR S_EVENT.
READ TABLE P_T_EVENTCAT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO S_EVENT.
IF SY-SUBRC = 0.
MOVE 'ZF_USER_COMMAND' TO S_EVENT-FORM.
APPEND S_EVENT TO P_T_EVENTCAT.
ENDIF.
endform. " Z_EVENT
&----
*& Form ZF_PF_STATUS
&----
text
----
form zf_pf_status using p_extab type slis_t_extab.
set pf-status 'ALV_MENU'.
endform. " PF_STATUS_SET
&----
*& Form ZF_USER_COMMAND
&----
text
----
*
----
FORM ZF_USER_COMMAND USING S_UCOMM LIKE SY-UCOMM P_SELFIELD TYPE SLIS_SELFIELD.
CASE S_UCOMM.
WHEN 'NEW1'.
LOOP AT T_MAT INTO WA_MAT.
WRITE:/ WA_MAT-MATNR, 20 WA_MAT-MAKTX.
ENDLOOP.
ENDCASE.
ENDFORM.
Thanx in Advance,
Regards,
Sangeeta.
2006 Apr 24 4:10 PM
Hello,
Take one more table like t_mat1.
t_mat1[] = t_mat[].
After pressing NEW button, compare the description field of the table. If you want to use same alv you can fill the table t_mat again then,
FORM USER_COMMAND USING RS_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
RS_SELFIELD-REFRESH = 'X'.
endform.
Regards,
Naimesh
2006 Apr 24 4:12 PM
Sangeeta,
In your last post for the same question - the suggestion was to have two different fields for the OLD and NEW material descriptions so that the user does NOT have to click NEW every time. And this type of functionality is easy to be implemented using OO ALV rather than REUSE.
Anyways, as soon as you change the field and hit ENTER the table data should be changed to have new description, however the question would be how to identify the new data vs the old data. In OO ALV its easy as there will be a event DATA CHANGED where you can identify the modified fields or as you have a separate field for the new description, you just will have to look at the new field where it is NOT NULL.
In your case the updation should happend automactically.
Regards,
Ravi
Note : Please mark the helpful answers
2006 Jun 26 4:40 PM
Hi Ravi,
Can u pls explain me how to triger as soon as you change the field and hit ENTER key the table data should be changed in ALV List display or
I just want to check my data when i hit ENTER in alv editable mode.
please let me know .
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |