12-24-2007 2:52 AM
Hi folks,
I need to get ALV grid display in my list report when selected the interval values from the selection screen. If I change the values in list of ALV grid it needs to be updated when I press UPDATE pushbutton. The output of list should be in ALV grid display.I need sorting ,flitering,totaling functionality in the list output.
For example if I selected BUKRS = 100 and 200 in the selection screen ,I need to display the ALV grid list in below the selection screen as ALV grid display...
Its urgent as I am new to ALV grid functionality...
Thanks in advance..
12-24-2007 9:12 AM
hi raja,
check with the folllowing code.
REPORT zca0m_zca0fcstftop NO STANDARD PAGE HEADING
MESSAGE-ID zcsv_usrtbl_maintain.
************************************************************************
Type pools *
************************************************************************
TYPE-POOLS : slis. " Used for ALV display
************************************************************************
Tables
************************************************************************
TABLES: zca0fcstftop,
dd04t, "R/3 DD: Data element texts
tactt. "Activities that can be protected
************************************************************************
internal tables
************************************************************************
DATA: BEGIN OF wa_zca0fcstftop .
INCLUDE STRUCTURE zca0fcstftop.
DATA: END OF wa_zca0fcstftop.
DATA: t_zca0fcstftop LIKE STANDARD TABLE OF wa_zca0fcstftop.
DATA: BEGIN OF i_fcode OCCURS 0,
fcode LIKE sy-ucomm,
END OF i_fcode.
*Record for variant selection
DATA : BEGIN OF ws_variant,
selected TYPE c,
variant LIKE ltdx-variant, "Variant name
text LIKE ltdxt-text, "Variant description
END OF ws_variant.
*Table for variant selection
data : itab_variant LIKE STANDARD TABLE OF ws_variant WITH HEADER LINE.
Variant selection pop-up global variables
DECLARATION OF TABLECONTROL 'VARIANT_CNTL' ITSELF
CONTROLS: variant_cntl TYPE TABLEVIEW USING SCREEN 0200.
LINES OF TABLECONTROL 'VARIANT_CNTL'
DATA: g_variant_cntl_lines LIKE sy-loopc.
DATA:grid1 TYPE REF TO cl_gui_alv_grid ,
g_custom_container TYPE REF TO cl_gui_custom_container.
************************************************************************
Work fields
************************************************************************
DATA: table_name LIKE dd02l-tabname, "To store table name
field_name LIKE dd03l-fieldname, "To Store Field Name
act_auth LIKE tactz-actvt, "To pass Activity ID
tab_maint LIKE dd02l-tabname, "To pass Table Name to be Maintd.
wg_confirm_ind, "To trap User responses
flag, "To trap changes made to an entry
f_copy, "To Identify 'COPY' Command Use
f_select, "To decide between Select-options
" and Internal Table
l_transaction_code LIKE tstc-tcode,
v_langu LIKE sy-langu,
v_repid LIKE sy-repid,
s_variant TYPE disvariant.
DATA: ok_code LIKE sy-ucomm.
DATA:selected_rows TYPE lvc_t_row ,
sel_rows TYPE lvc_t_row WITH HEADER LINE.
DATA:t_lines TYPE i.
************************************************************************
Constants *
************************************************************************
CONSTANTS :
c_x TYPE c VALUE 'X', " Constant 'X'.
c_f TYPE c VALUE 'F'. " Constant 'F'.
************************************************************************
Parameters and Selection Options
************************************************************************
*Selection Screen for table maintenance
*Selection option for Plant
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-b01.
PARAMETERS: p_werks LIKE zca0fcstftop-werks OBLIGATORY.
SELECT-OPTIONS: s_prdfml FOR zca0fcstftop-product_family,
s_bmach FOR zca0fcstftop-base_machine,
s_factop FOR zca0fcstftop-factory_top,
s_optval FOR zca0fcstftop-option_value,
s_week FOR zca0fcstftop-week.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-b02.
PARAMETERS : p_varant LIKE ltdx-variant. " ALV variant
SELECTION-SCREEN END OF BLOCK block2.
************************************************************************
At selection screen *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varant.
PERFORM alv_variant_f4 CHANGING p_varant.
AT SELECTION-SCREEN ON p_werks .
Validating Plant on the selection screen
PERFORM validate_plant.
************************************************************************
Initialization
************************************************************************
INITIALIZATION.
************************************************************************
Check Authorization for the Transaction
************************************************************************
Authorization Check For T Code
SELECT tcode
INTO l_transaction_code
FROM tstc UP TO 1 ROWS
WHERE pgmna = sy-repid.
ENDSELECT.
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD l_transaction_code.
IF sy-subrc NE 0.
MESSAGE e001 WITH l_transaction_code.
ENDIF.
v_langu = sy-langu. " language
v_repid = sy-repid . " abap Program name
************************************************************************
Start Of Selection
************************************************************************
START-OF-SELECTION.
CALL SCREEN 0050.
&----
*& Form validate_plant *
&----
Validating Plant on the selection screen *
----
FORM validate_plant .
DATA : l_werks LIKE t001w-werks. " Plant
IF p_werks IS NOT INITIAL.
SELECT SINGLE werks
FROM t001w
INTO l_werks
WHERE werks EQ p_werks.
IF sy-subrc NE 0.
MESSAGE e100(ra) WITH text-001 .
ENDIF.
ENDIF.
AUTHORITY-CHECK OBJECT 'Z_PP_PLANT'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD p_werks
ID 'TCD' FIELD l_transaction_code.
IF sy-subrc NE 0.
MESSAGE e000(oo) WITH 'No authorization for plant:'(e80) p_werks.
ENDIF.
ENDFORM. " validate_plant
&----
*& Form get_data *
&----
Get data *
----
FORM get_data .
SELECT * FROM zca0fcstftop
INTO TABLE t_zca0fcstftop
WHERE werks = p_werks
AND product_family IN s_prdfml
AND base_machine IN s_bmach
AND factory_top IN s_factop
AND option_value IN s_optval
AND week IN s_week.
ENDFORM. " get_data
&----
*& Form fill_fcode
&----
FORM fill_fcode USING value(p_0029).
i_fcode-fcode = p_0029.
APPEND i_fcode.
CLEAR i_fcode.
ENDFORM. " fill_fcode
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'UPDATE'.
CLEAR flag.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module MODIFY_0100 OUTPUT
&----
MODULE modify_0100 OUTPUT.
IF sy-ucomm = 'CHNG' OR
sy-ucomm = 'PICK'.
LOOP AT SCREEN.
CHECK screen-group1 = 'CHG'.
screen-required = '0'.
screen-output = '1'.
screen-input = '0'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
Check if you are in create mode & if yes then set the screen elements
as mandatory
IF ok_code = 'CREA'.
LOOP AT SCREEN.
CHECK screen-group1 = 'CHG'.
screen-required = '1'.
screen-output = '1'.
screen-input = '1'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDMODULE. " MODIFY_0100 OUTPUT
&----
*& Module Check_Exit INPUT
&----
text
----
MODULE check_exit INPUT.
IF ( sy-ucomm = 'BACK' OR sy-ucomm = 'CANC' OR sy-ucomm = 'EXIT' ) AND
( flag = 'Y' ).
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'Y'
textline1 = text-008
textline2 = text-009
titel = text-004
cancel_display = ' '
IMPORTING
answer = wg_confirm_ind.
CASE wg_confirm_ind.
WHEN 'J'. "Yes
sy-ucomm = 'SAVE'.
CLEAR flag.
WHEN 'N'. "No
sy-ucomm = 'BACK'.
CLEAR flag.
ENDCASE.
ENDIF.
ENDMODULE. " Check_Exit INPUT
&----
*& Module Exit_0100 INPUT
&----
text
----
MODULE exit_0100 INPUT.
SET SCREEN 0. LEAVE SCREEN.
ENDMODULE. " Exit_0100 INPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'. "Save
Check to see if the user has the appropriate authorization
IF p_werks NE zca0fcstftop-werks.
could not update - not in selection
MESSAGE e000(oo) WITH 'Entry not within selection'.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ENDIF.
IF f_copy = 'X'.
INSERT zca0fcstftop.
IF sy-subrc = 0.
MESSAGE s004.
PERFORM initialize.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ELSE.
MESSAGE w005.
ENDIF.
ELSE.
MODIFY zca0fcstftop.
IF sy-subrc = 0.
MESSAGE s004.
PERFORM initialize.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ELSE.
MESSAGE w005.
ENDIF.
ENDIF.
PERFORM get_data.
WHEN 'BACK'. "Back
SET SCREEN 0. LEAVE SCREEN.
WHEN 'CANC'. "Cancel
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
COMMIT WORK.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form Initialize
&----
FORM initialize.
CLEAR : table_name,
field_name,
wg_confirm_ind,
f_copy,
flag,
t_zca0fcstftop,
zca0fcstftop,
wa_zca0fcstftop,
i_fcode.
REFRESH: t_zca0fcstftop.
ENDFORM. " Initialize
&----
*& Form alv_variant_f4
&----
text
----
<--P_VARIANT text
----
FORM alv_variant_f4 CHANGING variant.
DATA: rs_variant LIKE disvariant.
DATA nof4 TYPE c.
CLEAR nof4.
LOOP AT SCREEN.
IF screen-name = 'VARIANT'.
IF screen-input = 0.
nof4 = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
rs_variant-report = sy-repid.
rs_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = rs_variant
i_save = 'A'
IMPORTING
es_variant = rs_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0 AND nof4 EQ space.
variant = rs_variant-variant.
ENDIF.
ENDFORM. " ALV_VARIANT_F4
&----
*& Module STATUS_0050 OUTPUT
&----
text
----
MODULE status_0050 OUTPUT.
In this module Initialize the container and put the grid in it
DATA:grid_layout TYPE lvc_s_layo,
fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF fieldcat.
PERFORM set_auth.
SET PF-STATUS 'UPD_0050' EXCLUDING i_fcode.
SET TITLEBAR 'UPD_0050'.
IF g_custom_container IS INITIAL .
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'FTDATA'.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
ELSE.
CALL METHOD grid1->free.
CALL METHOD g_custom_container->free.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'FTDATA'.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
ENDIF.
Every time refresh The variables
PERFORM initialize.
PERFORM get_data.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZCA0FCSTFTOP'
CHANGING
ct_fieldcat = fieldcat.
grid_layout-grid_title = text-t01.
grid_layout-sel_mode = 'A'.
grid_layout-stylefname = 'CT'.
s_variant-report = sy-repid.
s_variant-username = sy-uname.
s_variant-variant = p_varant.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'ZCA0FCSTFTOP'
is_layout = grid_layout
is_variant = s_variant
i_save = 'A'
CHANGING
it_outtab = t_zca0fcstftop
it_fieldcatalog = fieldcat.
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_button_click FOR grid1.
ENDMODULE. " STATUS_0050 OUTPUT
&----
*& Module USER_COMMAND_0050 INPUT
&----
MODULE user_command_0050 INPUT.
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = selected_rows.
DESCRIBE TABLE selected_rows LINES t_lines.
IF t_lines > 1 .
MESSAGE e048(zcsv_sfdr).
ENDIF.
Clear Header
CLEAR wa_zca0fcstftop.
sel_rows[] = selected_rows .
READ TABLE sel_rows INDEX 1.
READ TABLE t_zca0fcstftop INTO wa_zca0fcstftop INDEX sel_rows-index.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'CREA'.
CLEAR zca0fcstftop.
ok_code = sy-ucomm.
zca0fcstftop-werks = p_werks.
CALL SCREEN 100.
WHEN 'COPY'.
MOVE wa_zca0fcstftop TO zca0fcstftop .
CLEAR wa_zca0fcstftop.
f_copy = 'X'.
CALL SCREEN 100.
WHEN 'CHNG'.
CHECK NOT wa_zca0fcstftop IS INITIAL.
MOVE wa_zca0fcstftop TO zca0fcstftop .
CLEAR wa_zca0fcstftop.
ok_code = sy-ucomm.
CALL SCREEN 100.
WHEN 'DELE'.
CHECK NOT wa_zca0fcstftop IS INITIAL.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = text-005
textline2 = text-006
titel = text-007
cancel_display = ' '
IMPORTING
answer = wg_confirm_ind.
IF wg_confirm_ind EQ 'J'.
DELETE zca0fcstftop FROM wa_zca0fcstftop .
IF sy-subrc EQ 0.
MESSAGE s004.
ELSE.
MESSAGE e005.
ENDIF.
ELSEIF wg_confirm_ind EQ 'N'.
ENDIF.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_0050 INPUT
&----
*& Form exit_program
&----
FORM exit_program .
CALL METHOD g_custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
SET SCREEN 0.
LEAVE SCREEN.
ENDFORM. " exit_program
&----
*& Form set_auth
&----
FORM set_auth.
REFRESH: i_fcode.
Check authorization for change
MOVE '02' TO act_auth. "02 --> Change
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'CHNG'.
ENDIF.
Check for authorization for create
MOVE '01' TO act_auth. "01 --> Create
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'CREA'.
PERFORM fill_fcode USING 'COPY'.
ENDIF.
Check for authorization for delete
MOVE '06' TO act_auth. "06 --> Delete
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'DELE'.
ENDIF.
ENDFORM. " set_auth
&----
*& Module check_change INPUT
&----
MODULE check_change INPUT.
flag = 'Y'.
ENDMODULE. " check_change INPUT
***************************
regards,
vikas.
plz reward if helpful
12-24-2007 9:12 AM
hi raja,
check with the folllowing code.
REPORT zca0m_zca0fcstftop NO STANDARD PAGE HEADING
MESSAGE-ID zcsv_usrtbl_maintain.
************************************************************************
Type pools *
************************************************************************
TYPE-POOLS : slis. " Used for ALV display
************************************************************************
Tables
************************************************************************
TABLES: zca0fcstftop,
dd04t, "R/3 DD: Data element texts
tactt. "Activities that can be protected
************************************************************************
internal tables
************************************************************************
DATA: BEGIN OF wa_zca0fcstftop .
INCLUDE STRUCTURE zca0fcstftop.
DATA: END OF wa_zca0fcstftop.
DATA: t_zca0fcstftop LIKE STANDARD TABLE OF wa_zca0fcstftop.
DATA: BEGIN OF i_fcode OCCURS 0,
fcode LIKE sy-ucomm,
END OF i_fcode.
*Record for variant selection
DATA : BEGIN OF ws_variant,
selected TYPE c,
variant LIKE ltdx-variant, "Variant name
text LIKE ltdxt-text, "Variant description
END OF ws_variant.
*Table for variant selection
data : itab_variant LIKE STANDARD TABLE OF ws_variant WITH HEADER LINE.
Variant selection pop-up global variables
DECLARATION OF TABLECONTROL 'VARIANT_CNTL' ITSELF
CONTROLS: variant_cntl TYPE TABLEVIEW USING SCREEN 0200.
LINES OF TABLECONTROL 'VARIANT_CNTL'
DATA: g_variant_cntl_lines LIKE sy-loopc.
DATA:grid1 TYPE REF TO cl_gui_alv_grid ,
g_custom_container TYPE REF TO cl_gui_custom_container.
************************************************************************
Work fields
************************************************************************
DATA: table_name LIKE dd02l-tabname, "To store table name
field_name LIKE dd03l-fieldname, "To Store Field Name
act_auth LIKE tactz-actvt, "To pass Activity ID
tab_maint LIKE dd02l-tabname, "To pass Table Name to be Maintd.
wg_confirm_ind, "To trap User responses
flag, "To trap changes made to an entry
f_copy, "To Identify 'COPY' Command Use
f_select, "To decide between Select-options
" and Internal Table
l_transaction_code LIKE tstc-tcode,
v_langu LIKE sy-langu,
v_repid LIKE sy-repid,
s_variant TYPE disvariant.
DATA: ok_code LIKE sy-ucomm.
DATA:selected_rows TYPE lvc_t_row ,
sel_rows TYPE lvc_t_row WITH HEADER LINE.
DATA:t_lines TYPE i.
************************************************************************
Constants *
************************************************************************
CONSTANTS :
c_x TYPE c VALUE 'X', " Constant 'X'.
c_f TYPE c VALUE 'F'. " Constant 'F'.
************************************************************************
Parameters and Selection Options
************************************************************************
*Selection Screen for table maintenance
*Selection option for Plant
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-b01.
PARAMETERS: p_werks LIKE zca0fcstftop-werks OBLIGATORY.
SELECT-OPTIONS: s_prdfml FOR zca0fcstftop-product_family,
s_bmach FOR zca0fcstftop-base_machine,
s_factop FOR zca0fcstftop-factory_top,
s_optval FOR zca0fcstftop-option_value,
s_week FOR zca0fcstftop-week.
SELECTION-SCREEN END OF BLOCK block1.
SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME TITLE text-b02.
PARAMETERS : p_varant LIKE ltdx-variant. " ALV variant
SELECTION-SCREEN END OF BLOCK block2.
************************************************************************
At selection screen *
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varant.
PERFORM alv_variant_f4 CHANGING p_varant.
AT SELECTION-SCREEN ON p_werks .
Validating Plant on the selection screen
PERFORM validate_plant.
************************************************************************
Initialization
************************************************************************
INITIALIZATION.
************************************************************************
Check Authorization for the Transaction
************************************************************************
Authorization Check For T Code
SELECT tcode
INTO l_transaction_code
FROM tstc UP TO 1 ROWS
WHERE pgmna = sy-repid.
ENDSELECT.
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD l_transaction_code.
IF sy-subrc NE 0.
MESSAGE e001 WITH l_transaction_code.
ENDIF.
v_langu = sy-langu. " language
v_repid = sy-repid . " abap Program name
************************************************************************
Start Of Selection
************************************************************************
START-OF-SELECTION.
CALL SCREEN 0050.
&----
*& Form validate_plant *
&----
Validating Plant on the selection screen *
----
FORM validate_plant .
DATA : l_werks LIKE t001w-werks. " Plant
IF p_werks IS NOT INITIAL.
SELECT SINGLE werks
FROM t001w
INTO l_werks
WHERE werks EQ p_werks.
IF sy-subrc NE 0.
MESSAGE e100(ra) WITH text-001 .
ENDIF.
ENDIF.
AUTHORITY-CHECK OBJECT 'Z_PP_PLANT'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD p_werks
ID 'TCD' FIELD l_transaction_code.
IF sy-subrc NE 0.
MESSAGE e000(oo) WITH 'No authorization for plant:'(e80) p_werks.
ENDIF.
ENDFORM. " validate_plant
&----
*& Form get_data *
&----
Get data *
----
FORM get_data .
SELECT * FROM zca0fcstftop
INTO TABLE t_zca0fcstftop
WHERE werks = p_werks
AND product_family IN s_prdfml
AND base_machine IN s_bmach
AND factory_top IN s_factop
AND option_value IN s_optval
AND week IN s_week.
ENDFORM. " get_data
&----
*& Form fill_fcode
&----
FORM fill_fcode USING value(p_0029).
i_fcode-fcode = p_0029.
APPEND i_fcode.
CLEAR i_fcode.
ENDFORM. " fill_fcode
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'UPDATE'.
CLEAR flag.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module MODIFY_0100 OUTPUT
&----
MODULE modify_0100 OUTPUT.
IF sy-ucomm = 'CHNG' OR
sy-ucomm = 'PICK'.
LOOP AT SCREEN.
CHECK screen-group1 = 'CHG'.
screen-required = '0'.
screen-output = '1'.
screen-input = '0'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
Check if you are in create mode & if yes then set the screen elements
as mandatory
IF ok_code = 'CREA'.
LOOP AT SCREEN.
CHECK screen-group1 = 'CHG'.
screen-required = '1'.
screen-output = '1'.
screen-input = '1'.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
ENDMODULE. " MODIFY_0100 OUTPUT
&----
*& Module Check_Exit INPUT
&----
text
----
MODULE check_exit INPUT.
IF ( sy-ucomm = 'BACK' OR sy-ucomm = 'CANC' OR sy-ucomm = 'EXIT' ) AND
( flag = 'Y' ).
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'Y'
textline1 = text-008
textline2 = text-009
titel = text-004
cancel_display = ' '
IMPORTING
answer = wg_confirm_ind.
CASE wg_confirm_ind.
WHEN 'J'. "Yes
sy-ucomm = 'SAVE'.
CLEAR flag.
WHEN 'N'. "No
sy-ucomm = 'BACK'.
CLEAR flag.
ENDCASE.
ENDIF.
ENDMODULE. " Check_Exit INPUT
&----
*& Module Exit_0100 INPUT
&----
text
----
MODULE exit_0100 INPUT.
SET SCREEN 0. LEAVE SCREEN.
ENDMODULE. " Exit_0100 INPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'SAVE'. "Save
Check to see if the user has the appropriate authorization
IF p_werks NE zca0fcstftop-werks.
could not update - not in selection
MESSAGE e000(oo) WITH 'Entry not within selection'.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ENDIF.
IF f_copy = 'X'.
INSERT zca0fcstftop.
IF sy-subrc = 0.
MESSAGE s004.
PERFORM initialize.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ELSE.
MESSAGE w005.
ENDIF.
ELSE.
MODIFY zca0fcstftop.
IF sy-subrc = 0.
MESSAGE s004.
PERFORM initialize.
SET SCREEN 0. LEAVE SCREEN.
PERFORM get_data.
ELSE.
MESSAGE w005.
ENDIF.
ENDIF.
PERFORM get_data.
WHEN 'BACK'. "Back
SET SCREEN 0. LEAVE SCREEN.
WHEN 'CANC'. "Cancel
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
COMMIT WORK.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form Initialize
&----
FORM initialize.
CLEAR : table_name,
field_name,
wg_confirm_ind,
f_copy,
flag,
t_zca0fcstftop,
zca0fcstftop,
wa_zca0fcstftop,
i_fcode.
REFRESH: t_zca0fcstftop.
ENDFORM. " Initialize
&----
*& Form alv_variant_f4
&----
text
----
<--P_VARIANT text
----
FORM alv_variant_f4 CHANGING variant.
DATA: rs_variant LIKE disvariant.
DATA nof4 TYPE c.
CLEAR nof4.
LOOP AT SCREEN.
IF screen-name = 'VARIANT'.
IF screen-input = 0.
nof4 = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
rs_variant-report = sy-repid.
rs_variant-username = sy-uname.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = rs_variant
i_save = 'A'
IMPORTING
es_variant = rs_variant
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 0 AND nof4 EQ space.
variant = rs_variant-variant.
ENDIF.
ENDFORM. " ALV_VARIANT_F4
&----
*& Module STATUS_0050 OUTPUT
&----
text
----
MODULE status_0050 OUTPUT.
In this module Initialize the container and put the grid in it
DATA:grid_layout TYPE lvc_s_layo,
fieldcat TYPE lvc_t_fcat,
wa_fieldcat LIKE LINE OF fieldcat.
PERFORM set_auth.
SET PF-STATUS 'UPD_0050' EXCLUDING i_fcode.
SET TITLEBAR 'UPD_0050'.
IF g_custom_container IS INITIAL .
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'FTDATA'.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
ELSE.
CALL METHOD grid1->free.
CALL METHOD g_custom_container->free.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'FTDATA'.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
ENDIF.
Every time refresh The variables
PERFORM initialize.
PERFORM get_data.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZCA0FCSTFTOP'
CHANGING
ct_fieldcat = fieldcat.
grid_layout-grid_title = text-t01.
grid_layout-sel_mode = 'A'.
grid_layout-stylefname = 'CT'.
s_variant-report = sy-repid.
s_variant-username = sy-uname.
s_variant-variant = p_varant.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'ZCA0FCSTFTOP'
is_layout = grid_layout
is_variant = s_variant
i_save = 'A'
CHANGING
it_outtab = t_zca0fcstftop
it_fieldcatalog = fieldcat.
Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_button_click FOR grid1.
ENDMODULE. " STATUS_0050 OUTPUT
&----
*& Module USER_COMMAND_0050 INPUT
&----
MODULE user_command_0050 INPUT.
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = selected_rows.
DESCRIBE TABLE selected_rows LINES t_lines.
IF t_lines > 1 .
MESSAGE e048(zcsv_sfdr).
ENDIF.
Clear Header
CLEAR wa_zca0fcstftop.
sel_rows[] = selected_rows .
READ TABLE sel_rows INDEX 1.
READ TABLE t_zca0fcstftop INTO wa_zca0fcstftop INDEX sel_rows-index.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'CREA'.
CLEAR zca0fcstftop.
ok_code = sy-ucomm.
zca0fcstftop-werks = p_werks.
CALL SCREEN 100.
WHEN 'COPY'.
MOVE wa_zca0fcstftop TO zca0fcstftop .
CLEAR wa_zca0fcstftop.
f_copy = 'X'.
CALL SCREEN 100.
WHEN 'CHNG'.
CHECK NOT wa_zca0fcstftop IS INITIAL.
MOVE wa_zca0fcstftop TO zca0fcstftop .
CLEAR wa_zca0fcstftop.
ok_code = sy-ucomm.
CALL SCREEN 100.
WHEN 'DELE'.
CHECK NOT wa_zca0fcstftop IS INITIAL.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
defaultoption = 'N'
textline1 = text-005
textline2 = text-006
titel = text-007
cancel_display = ' '
IMPORTING
answer = wg_confirm_ind.
IF wg_confirm_ind EQ 'J'.
DELETE zca0fcstftop FROM wa_zca0fcstftop .
IF sy-subrc EQ 0.
MESSAGE s004.
ELSE.
MESSAGE e005.
ENDIF.
ELSEIF wg_confirm_ind EQ 'N'.
ENDIF.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_0050 INPUT
&----
*& Form exit_program
&----
FORM exit_program .
CALL METHOD g_custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
SET SCREEN 0.
LEAVE SCREEN.
ENDFORM. " exit_program
&----
*& Form set_auth
&----
FORM set_auth.
REFRESH: i_fcode.
Check authorization for change
MOVE '02' TO act_auth. "02 --> Change
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'CHNG'.
ENDIF.
Check for authorization for create
MOVE '01' TO act_auth. "01 --> Create
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'CREA'.
PERFORM fill_fcode USING 'COPY'.
ENDIF.
Check for authorization for delete
MOVE '06' TO act_auth. "06 --> Delete
MOVE 'ZCA0FCSTFTOP' TO tab_maint.
AUTHORITY-CHECK OBJECT 'ZZ:TABLMNP'
ID 'ACTVT' FIELD act_auth
ID 'TABLE' FIELD tab_maint.
IF sy-subrc NE 0.
PERFORM fill_fcode USING 'DELE'.
ENDIF.
ENDFORM. " set_auth
&----
*& Module check_change INPUT
&----
MODULE check_change INPUT.
flag = 'Y'.
ENDMODULE. " check_change INPUT
***************************
regards,
vikas.
plz reward if helpful
12-24-2007 3:47 PM
Hi Vikas,
I am not familiar with OOPS concept. Whether I need to design a dialog programming for selection screens and for ALV grid display in my list output ?
The scenario is when I selected the range of values in selection screen I need to get the ALV grid display output below the selection screen. If I need to change the range of values I can do it by selecting range of values in the select-options...
If I need to change the field values in the ALV grid display I need to update the information when I press update button ....
Finally all I need to see in the ALV grid display.I need some functionality in the list display so I need in ALV Grid as output ...
Thanks in Advance....
12-25-2007 5:44 AM
Hello Raja
A very simple yet straightforward function module for displaying ALV lists is REUSE_ALV_GRID_DISPLAY_LVC.
You cannot display ALV lists below a standard selection screen.
If you require both the select-options and the ALV list on the same screen you have to your own dynpro having these options. However, in this case you have to go for OO-based ALV lists because you cannot display fm-based ALV lists in subscreens. They will always cover the entire screen.
Regards,
Uwe
12-25-2007 7:32 PM
Hi Uwe,
Thanks for throwing some light to my query.Could you be elaborate for showing the select-options and the ALV grid display output in the same screen.How I need to follow the steps in dialog programming.
For select-options I will design by doing text -box and list box but for designing the output of ALV grid display what I need to take steps for that.
Could you throw some light to design the dynpro in OOPs concept as an example.
Thanks in Advance
12-26-2007 4:55 PM
Raja,
For a example see the reports that start with BCALV, like BCALV_GRID_VERIFY
There are many examples, I bet one of them is similar with your needs.