Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Editable ALV grid

Former Member
0 Likes
1,313

I'm using REUSE_ALV_GRID_DISPLAY to display the report. Iam able to edit the report output on the ALV grid and save the entries in Z table.

But iam not able to edit and sort the fields at the same time .

Both EDIT and SORT fileds are not working at same time, if I do not pass the filed EDIT flag sort function working fine.

Can you please let me know how to use both function at the same time.

here is my code.

DATA:FC TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.

DATA: SORTCAT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.

FC-OUTPUTLEN = 10.

FC-TABNAME = 'OUTPUT_ITAB'.

FC-FIELDNAME = FIELDNAME.

FC-SELTEXT_M = TEXTNAME.

FC-EDIT = 'X'.

APPEND FC.

CLEAR FC.

CLEAR SORTCAT.

REFRESH SORTCAT.

SORTCAT-SPOS = 1.

SORTCAT-FIELDNAME = 'MATNR'.

SORTCAT-TABNAME = 'OUTPUT_ITAB'.

SORTCAT-UP = 'X'.

SORTCAT-GROUP = 'X'.

SORTCAT-SUBTOT = 'X'.

APPEND SORTCAT.

CLEAR SORTCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = PGM

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_GRID_TITLE = OUTPUT_TITLE

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FC[]

IT_SORT = SORTCAT[]

I_DEFAULT = 'X'

I_SAVE = 'A'

TABLES

T_OUTTAB = OUTPUT_ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

Help is really appreciated.

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
1,268

Hi check this code snippet:

REPORT zjay_edit_alv.

*******************************************************************
* TYPE-POOLS *
*******************************************************************
TYPE-POOLS: slis.

*******************************************************************
* INTERNAL TABLES/WORK AREAS/VARIABLES
*******************************************************************
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.

*******************************************************************
* FIELD-SYMBOLS *
*******************************************************************
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.

*******************************************************************
* SELECTION SCREEN *
*******************************************************************
PARAMETERS: tabname(30) TYPE c DEFAULT 'MARA',
lines(5) TYPE n DEFAULT 7.

*******************************************************************
* START-OF-SELECTION *
*******************************************************************
START-OF-SELECTION.

* Storing table name
p_table = tabname.

* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.

LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.

* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.

SORT i_fieldcat BY col_pos.

* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.

REFRESH <dyn_tab_temp>.

* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

*&-----------------------------------------------------------------*
*& Form SET_PF_STATUS
*&-----------------------------------------------------------------*
* Setting custom PF-Status
*------------------------------------------------------------------*
* -->RT_EXTAB Excluding table
*------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'. "copy it from SALV func group standard

ENDFORM. "SET_PF_STATUS

*&----------------------------------------------------------------*
*& 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.

* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.

* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.

* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.

* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.

CASE r_ucomm.

* When a record is selected
WHEN '&IC1'.

* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.

IF sy-subrc = 0.

* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.

* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.

* Make all the fields input enabled except key fields
w_field-input = 'X'.

MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.

ENDIF.

* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc = 0.

* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.

* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.

ENDIF.

* When save button is pressed
WHEN 'SAVE'.

* Sort the index table
SORT i_index.

* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.

LOOP AT i_index.

* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.

ENDLOOP.

* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc = 0.

* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.

REFRESH <dyn_tab_temp>.

* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.

ENDIF.
ENDCASE.

rs_selfield-refresh = 'X'.

ENDFORM. "user_command

Hi check this code snippet:

REPORT zjay_edit_alv.

*******************************************************************
* TYPE-POOLS *
*******************************************************************
TYPE-POOLS: slis.

*******************************************************************
* INTERNAL TABLES/WORK AREAS/VARIABLES
*******************************************************************
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.

*******************************************************************
* FIELD-SYMBOLS *
*******************************************************************
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.

*******************************************************************
* SELECTION SCREEN *
*******************************************************************
PARAMETERS: tabname(30) TYPE c DEFAULT 'MARA',
lines(5) TYPE n DEFAULT 7.

*******************************************************************
* START-OF-SELECTION *
*******************************************************************
START-OF-SELECTION.

* Storing table name
p_table = tabname.

* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.

LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.

* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.

SORT i_fieldcat BY col_pos.

* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.

REFRESH <dyn_tab_temp>.

* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

*&-----------------------------------------------------------------*
*& Form SET_PF_STATUS
*&-----------------------------------------------------------------*
* Setting custom PF-Status
*------------------------------------------------------------------*
* -->RT_EXTAB Excluding table
*------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'. "copy it from SALV func group standard

ENDFORM. "SET_PF_STATUS

*&----------------------------------------------------------------*
*& 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.

* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.

* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.

* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.

* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.

CASE r_ucomm.

* When a record is selected
WHEN '&IC1'.

* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.

IF sy-subrc = 0.

* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.

* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.

* Make all the fields input enabled except key fields
w_field-input = 'X'.

MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.

ENDIF.

* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc = 0.

* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.

* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.

ENDIF.

* When save button is pressed
WHEN 'SAVE'.

* Sort the index table
SORT i_index.

* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.

LOOP AT i_index.

* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.

ENDLOOP.

* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc = 0.

* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.

REFRESH <dyn_tab_temp>.

* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.

ENDIF.
ENDCASE.

rs_selfield-refresh = 'X'.

ENDFORM. "user_command

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
1,269

Hi check this code snippet:

REPORT zjay_edit_alv.

*******************************************************************
* TYPE-POOLS *
*******************************************************************
TYPE-POOLS: slis.

*******************************************************************
* INTERNAL TABLES/WORK AREAS/VARIABLES
*******************************************************************
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.

*******************************************************************
* FIELD-SYMBOLS *
*******************************************************************
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.

*******************************************************************
* SELECTION SCREEN *
*******************************************************************
PARAMETERS: tabname(30) TYPE c DEFAULT 'MARA',
lines(5) TYPE n DEFAULT 7.

*******************************************************************
* START-OF-SELECTION *
*******************************************************************
START-OF-SELECTION.

* Storing table name
p_table = tabname.

* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.

LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.

* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.

SORT i_fieldcat BY col_pos.

* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.

REFRESH <dyn_tab_temp>.

* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

*&-----------------------------------------------------------------*
*& Form SET_PF_STATUS
*&-----------------------------------------------------------------*
* Setting custom PF-Status
*------------------------------------------------------------------*
* -->RT_EXTAB Excluding table
*------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'. "copy it from SALV func group standard

ENDFORM. "SET_PF_STATUS

*&----------------------------------------------------------------*
*& 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.

* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.

* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.

* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.

* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.

CASE r_ucomm.

* When a record is selected
WHEN '&IC1'.

* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.

IF sy-subrc = 0.

* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.

* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.

* Make all the fields input enabled except key fields
w_field-input = 'X'.

MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.

ENDIF.

* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.

IF sy-subrc = 0.

* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.

* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.

ENDIF.

* When save button is pressed
WHEN 'SAVE'.

* Sort the index table
SORT i_index.

* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.

LOOP AT i_index.

* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.

ENDLOOP.

* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.

IF sy-subrc = 0.

* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.

REFRESH <dyn_tab_temp>.

* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.

ENDIF.
ENDCASE.

rs_selfield-refresh = 'X'.

ENDFORM. "user_command

Read only

Former Member
0 Likes
1,268

hi ,

thanks for your help but actual issue i have used below logic before , this when i doubclick on cell a pop-window appeares to edit the cells which we do not want to do.

alv_merge_Catlogue we can not modify the cells on the alv layout itself.

i want to modify the cells on the layout only.

thanks

Read only

0 Likes
1,268
* Make all the fields input enabled except key fields
w_field-input = 'X'.

This makes the field editable... execute and debug the code... to know more....

The forum has loooooooot of code snippets like mine... search well...

Read only

0 Likes
1,268

Thanks for your reply , My issue is different i can not sort and edit the fields on the alv grid at the same time.

IF i pass the EDIT = 'X'' , the sort functionality lost on the output screen. If i dont pass the edit = 'x'' sort function works fine on the key fields.

Read only

0 Likes
1,268

did you try using IT_SORT type SLIS_T_SORTINFO_ALV in REUSE_ALV_GRID_DISPLAY

Read only

0 Likes
1,268

Hi ,

I have an ALV implemented using ABAP object , but i dont face the said problem , can you please paste your entire code here so that we can checj why that is happening.

Regards

Arun

Read only

0 Likes
1,268

yes i have used SLIS_T_SORTINFO_ALV for declaring SORT

Read only

0 Likes
1,268

I Drafted the program into a sample format ..

Please comment the code FC-EDIT = 'X' and also try the code with out comment.

you will notice the difference on the output.

if you comment the MATNR is sorted and grouped , i have to use only alv_grid_display.

&----


*& Report ZTEST_ALV_EDIT *

*& *

&----


*& *

*& *

&----


REPORT ZTEST_ALV_EDIT .

TABLES: VBAK.

.

TYPE-POOLS:SLIS.

DATA:BEGIN OF FC_STRUCT,

OUTPUTLEN(5) TYPE N,

TABNAME(13),

FIELDNAME(10),

KEY(2),

DO_SUM(2),

EDIT(2),

SELTEXT_M LIKE DD03P-SCRTEXT_M,

END OF FC_STRUCT.

DATA:FC TYPE SLIS_FIELDCAT_ALV OCCURS 0 WITH HEADER LINE.

DATA:EVENTS TYPE SLIS_ALV_EVENT OCCURS 0 WITH HEADER LINE.

DATA:I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA:W_FIELD TYPE SLIS_FIELDCAT_ALV.

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE VBAP-MATNR,

KWMENG LIKE VBAP-KWMENG,

LGORT LIKE VBAP-LGORT,

END OF ITAB.

SELECT-OPTIONS : S_DATE FOR VBAK-ERDAT.

START-OF-SELECTION.

SELECT BMATNR BKWMENG B~LGORT

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM VBAK AS A INNER JOIN VBAP AS B

ON AVBELN EQ BVBELN

WHERE A~ERDAT IN S_DATE .

IF SY-SUBRC EQ 0.

SORT ITAB.

ENDIF.

CLEAR: FC, FC[].

FC-OUTPUTLEN = 12.

FC-TABNAME = 'ITA'.

FC-FIELDNAME = 'MATNR'.

FC-SELTEXT_M = 'Model'.

FC-KEY = 'X'.

APPEND FC.

CLEAR FC.

FC-OUTPUTLEN = 18.

FC-TABNAME = 'ITAB'.

FC-FIELDNAME = 'KWMENG'.

FC-SELTEXT_M = 'QTY'.

FC-KEY = 'X'.

  • FC-EDIT = 'X'.

APPEND FC.

CLEAR FC.

FC-OUTPUTLEN = 5.

FC-TABNAME = 'ITAB'.

FC-FIELDNAME = 'LGORT'.

FC-SELTEXT_M = 'SL'.

FC-KEY = 'X'.

APPEND FC.

CLEAR FC.

DATA: PGM LIKE SY-REPID.

PGM = SY-REPID.

DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.

LAYOUT-INFO_FIELDNAME = 'COLOR'.

LAYOUT-NO_SCROLLING = 'X'.

LAYOUT-CELL_MERGE = 'X'.

DATA: SORTCAT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.

CLEAR SORTCAT.

REFRESH SORTCAT.

SORTCAT-SPOS = 1.

SORTCAT-FIELDNAME = 'MATNR'.

SORTCAT-TABNAME = 'ITAB'.

SORTCAT-UP = 'X'.

SORTCAT-GROUP = 'X'.

SORTCAT-SUBTOT = 'X'.

APPEND SORTCAT.

CLEAR SORTCAT.

SORT I_FIELDCAT BY COL_POS.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = PGM

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = FC[]

IT_SORT = SORTCAT[]

I_DEFAULT = 'X'

I_SAVE = 'A'

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

ENDIF.

END-OF-SELECTION.

Edited by: madhu reddy on Jan 22, 2009 11:32 PM

Edited by: madhu reddy on Jan 22, 2009 11:37 PM