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

DOUBT IN OOPS ALV LIST

Former Member
0 Likes
954

Hi friends

I have one doubt,

Can any one tell me how to reduce ALV list application toolbar items?

i mean ALV using oops in the output list custom container app- tool bar I want to display only the below five

1. Details

2. Sort in ascend order

3. Sort in descend order

4. Find

5. filter

If you illustrate with an coding example that would be helpful.

thanks in advance

Regards,

kannan

Hi friends

I have one doubt,

Can any one tell me how to reduce ALV list application toolbar items?

i mean ALV using oops in the output list custom container app- tool bar I want to display only the below five

1. Details

2. Sort in ascend order

3. Sort in descend order

4. Find

5. filter

If you illustrate with an coding example that would be helpful.

thanks in advance

Regards,

kannan

5 REPLIES 5
Read only

Former Member
0 Likes
853

chk this program <b>BCALV_EDIT_05</b>

and chk how the table <b>it_toolbar_excluding = lt_exclude</b> is populated and passed to SET_TABLE_FOR_FIRST_DISPLAY

Read only

amit_khare
Active Contributor
0 Likes
853

Check this - BCALV_TEST_FUNCTIONS

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
853

Refer the example:

BCALV_GRID_05

You have to refresh the e_object->mt_toolbar to remove al the standard buttons on the grid.

Regards,

Ravi

Read only

Former Member
0 Likes
853

Hi,

Below is a code using OOPS concept in HR ABAP.

jus try it out. may b it wil resolve ur problem.

REPORT zpyr_076_serv_chg NO STANDARD PAGE HEADING .

--


>TABLES<--

----


TABLES : pernr.

--


>INFOTYPES<--

----


INFOTYPES : 0000, "Action

0001, "Org. Assignment

2001, "Absences

9995. "HR Master record

--


>NODES<--

----


NODES : peras.

--


>TYPES - TY_<--

----


*---> Structure to display the fields in ALV format.

TYPES : BEGIN OF ty_srv_chg ,

pernr TYPE p0001-pernr ,"Personnel number

name TYPE emnam ,"Employee Name

zsrchrgp TYPE zzsrchrgp ,"Service Charge %

zesrchrg TYPE zzamnt ,"Eligible Service Charge

nopdays TYPE p DECIMALS 2,"No pay days

dayswrk TYPE p DECIMALS 2,"Days worked

epoints TYPE p DECIMALS 2,"Service charge

END OF ty_srv_chg .

--


>CONSTANTS - C_<--

----


CONSTANTS : c_date TYPE sy-datum VALUE '99991231' ,"End date

c_0 TYPE i VALUE 0 ,"Sy-subrc

c_1 TYPE i VALUE 1 ,"Record found

c_3 TYPE i VALUE 3 ,"Active Employee

c_40 TYPE i VALUE 40 ,"Output Type

c_1640 TYPE i VALUE 1640 ,"Sub type

c_0016(4) TYPE c VALUE '0016' ,"Sub type

c_0015(4) TYPE c VALUE '0015' ,"IT 0015

c_i TYPE c VALUE 'I' ,"Defaulting value

c_eq(2) TYPE c VALUE 'EQ' ,"Equal

c_tahl(4) TYPE c VALUE 'TAHL' ,"Default value TAHL

c_pnpwerks(12) TYPE c VALUE 'PNPWERKS-LOW',"Screen field

c_j1(2) TYPE c VALUE 'J1' ,

c_j9(2) TYPE c VALUE 'J9' ,

c_x TYPE c VALUE 'X' ."Value to Check IT 0015

--


>INTERNAL TABLE - IT_<--

----


DATA : it_srv_chg TYPE TABLE OF ty_srv_chg,"ALV display

it_fieldcatalog TYPE lvc_t_fcat ,"Field Catalog

it_index TYPE lvc_t_row ,"For selected rows

it_0015 TYPE TABLE OF p0015 ,"Infotype 0015

it_error TYPE TABLE OF hrerror ,"Dispaly Error

--


>WORK AREA - WA_<--

----


wa_srv_chg TYPE ty_srv_chg ,"Work area for Service Charge

wa_fieldcatalog TYPE lvc_s_fcat ,"Work area for Fieldcatalog

wa_index TYPE lvc_s_row ,"Work area for selected rows

wa_0015 TYPE p0015 ,"Work area for Infotype 0015

wa_rtab LIKE bapireturn1,"Work area results

wa_0000 TYPE p0000 ,"Work area for infotype 0000

wa_error TYPE hrerror ."Work area to display errors

--


>DATA - W_<--

----


DATA : w_grid TYPE REF TO cl_gui_alv_grid ,"Ref. Obj. for ALV grid

w_custc TYPE REF TO cl_gui_custom_container,"Ref. Obj. for Custom Container

w_scra TYPE scrfname VALUE 'CONTROL' ,"Custom Contaner name

w_layout TYPE lvc_s_layo ,"Layout

w_ct0015 TYPE i ,"count of records inserted

w_abrtg TYPE p2001-abrtg ,"Stores Total no pay days

w_no_pay_days1 TYPE p DECIMALS 2 ,"Stores no pay days

w_no_pay_days2 TYPE p DECIMALS 2 ,"Stores no pay days

w_no_pay_days3 TYPE p DECIMALS 2 ,"Stores no pay days

w_no_pay_days TYPE p DECIMALS 2 ,"Stores no pay days

w_days_worked TYPE p DECIMALS 2 ,"Stores worked days

w_elig_points TYPE p DECIMALS 2 ,"Service Charge

ok_code TYPE sy-ucomm ."User Command

--


>SELECTION-SCREEN<--

----


SELECTION-SCREEN BEGIN OF BLOCK scp WITH FRAME TITLE text-z00."Service Charge Payment

--


>PARAMETER - PR_<--

----


SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(31) text-z05 FOR FIELD pr_date1.

PARAMETERS : pr_date1 TYPE sy-datum OBLIGATORY ."Calc.Period

SELECTION-SCREEN COMMENT 45(5) text-z06 FOR FIELD pr_date2.

PARAMETERS : pr_date2 TYPE sy-datum OBLIGATORY ."Calc.Period

SELECTION-SCREEN END OF LINE.

PARAMETERS : pr_mserc TYPE zzamnt OBLIGATORY ,"Monthly Service Charge

pr_payda TYPE sy-datum OBLIGATORY ."Payment Date

SELECTION-SCREEN END OF BLOCK scp.

--


>INITIALIZATION<--

----


INITIALIZATION.

*--> For the value to appear defaultly in the selection screen

pnpwerks-sign = c_i ."I

pnpwerks-option = c_eq ."EQ

pnpwerks-low = c_tahl."TAHL

APPEND pnpwerks TO pnpwerks.

----


>AT SELECTION-SCREEN -

----


*--> For the Personnel area to be display only field

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF screen-name = c_pnpwerks."PNPWERKS-LOW

screen-input = c_0 ."0

screen-invisible = c_0 ."0

MODIFY SCREEN.

ENDIF.

IF screen-name = 'PR_DATE2'.

screen-input = c_0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

*--> To fill the date2 parameter.

AT SELECTION-SCREEN ON pr_date1.

CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'

EXPORTING

day_in = pr_date1

IMPORTING

last_day_of_month = pr_date2

EXCEPTIONS

day_in_no_date = 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.

--


>START-OF-SELECTION<--

----


START-OF-SELECTION.

GET peras.

CLEAR : wa_srv_chg , wa_0015 , w_no_pay_days , w_days_worked , w_elig_points , w_abrtg.

*--> Select employee falling in the payment date and personnel area

rp_provide_from_last p0001 space pr_date1 pr_date2.

*--> Select the employee in active catagory

rp_provide_from_last p0000 space pr_date1 pr_date2.

IF p0000-stat2 = c_3. "3 - Active

*--> Select the employee having the value 'X' in the field service charge

rp_provide_from_last p9995 space pr_date1 pr_date2.

IF p9995-zsvrchrg = c_x "X

AND p9995-begda <= pr_date2

AND p9995-endda >= pr_date2.

wa_srv_chg-pernr = p0001-pernr ."Personnel number

wa_srv_chg-name = p0001-ename ."Employee name

wa_srv_chg-zsrchrgp = p9995-zsrchrgp ."Service Charge %

wa_srv_chg-zesrchrg = pr_mserc * ( p9995-zsrchrgp / 100 ) ."Eligible Service Charge

*--> Calculate the no pay days

PERFORM f12_no_pay_days.

w_elig_points = ( wa_srv_chg-zesrchrg / 30 )

  • w_days_worked ."Service charge

wa_srv_chg-nopdays = w_no_pay_days ."Number of no pay days

wa_srv_chg-dayswrk = w_days_worked ."Number of working days

wa_srv_chg-epoints = w_elig_points ."Service charge

wa_0015-pernr = p0001-pernr ."Personnel number

wa_0015-infty = c_0015 ."IT 0015

wa_0015-begda = pr_payda ."Payment Date

wa_0015-endda = c_date ."defaulting (31.12.9999)

wa_0015-subty = c_1640 ."defaulting Subtype 1640

wa_0015-betrg = w_elig_points ."Service Charge

APPEND wa_srv_chg TO it_srv_chg.

APPEND wa_0015 TO it_0015.

ENDIF.

ENDIF.

--


>END-OF-SELECTION<--

----


END-OF-SELECTION.

*--> Fill the fieldcatalog

PERFORM f001_fill_fieldcatalog USING 'PERNR'

text-z01 "Personnel No.

text-z01."Personnel No.

PERFORM f001_fill_fieldcatalog USING 'NAME'

text-z02 "Name

text-z02."Name

PERFORM f001_fill_fieldcatalog USING 'ZSRCHRGP'

text-z03 "Service Charge %

text-z03."Service Charge %

PERFORM f001_fill_fieldcatalog USING 'ZESRCHRG'

text-z04 "Eligible Serv. Chrg

text-z04."Eligible Serv. Chrg

PERFORM f001_fill_fieldcatalog USING 'NOPDAYS'

text-z07 "No pays days

text-z07."No pays days

PERFORM f001_fill_fieldcatalog USING 'DAYSWRK'

text-z08 "Days Worked

text-z08."Days Worked

PERFORM f001_fill_fieldcatalog USING 'EPOINTS'

text-z09 "Service Charge

text-z09."Service Charge

*--> Fill the Layout

PERFORM f002_fill_layout.

*--> Create object for Custm container

PERFORM f003_obj_custcnt.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

*--> Status for the screen 100.

SET PF-STATUS 'ZBONUS'.

*--> Titlebar for the screen 100.

SET TITLEBAR 'ZSRCHG'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


*

----


MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'UPDINFTY'.

*--> Infotype 0015 Updation

PERFORM f006_infoty_updation.

WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.

*--> Leave to selection screen when it is any one of the user command

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form f001_FILL_FIELDCATALOG

&----


  • Fill the fieldcatalog

----


FORM f001_fill_fieldcatalog USING value(p_field) TYPE any

value(p_seltext) TYPE any

value(p_coltext) TYPE any.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = p_field . "Field name

wa_fieldcatalog-seltext = p_seltext. "Selection text

wa_fieldcatalog-coltext = p_coltext. "Column text

IF p_field = 'NAME'.

wa_fieldcatalog-outputlen = c_40.

ENDIF.

APPEND wa_fieldcatalog TO it_fieldcatalog.

CLEAR wa_fieldcatalog.

ENDFORM. "f001_FILL_FIELDCATALOG

&----


*& Form f002_Fill_LAYOUT

&----


  • Fill the Layout

----


FORM f002_fill_layout.

CONSTANTS : lc_x TYPE c VALUE 'X',

lc_a TYPE c VALUE 'A'.

CLEAR w_layout.

*--> Select rows to update in the IT 0015.

w_layout-zebra = lc_x.

w_layout-sel_mode = lc_a.

ENDFORM. "f002_Fill_LAYOUT

&----


*& Form F003_OBJ_CUSTCNT

&----


  • Create object for custom container

----


FORM f003_obj_custcnt.

CLEAR w_custc.

*--> Create custom container

CREATE OBJECT w_custc

EXPORTING

container_name = w_scra

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--> Create object for Alv grid

PERFORM f004_obj_alv_grid.

ENDFORM. "F003_OBJ_CUSTCNT

&----


*& Form F004_OBJ_ALV_GRID

&----


  • Create object for Alv grid

----


FORM f004_obj_alv_grid.

CLEAR w_grid.

*--> Create ALV GRID object

CREATE OBJECT w_grid

EXPORTING

i_parent = w_custc

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--> Call method SET_TABLE FOR_FIRST_DISPLAY

PERFORM f005_grid_display.

ENDFORM. "F004_OBJ_ALV_GRID

&----


*& Form F005_GRID_DISPLAY

&----


  • Call method SET_TABLE FOR_FIRST_DISPLAY

----


FORM f005_grid_display.

SORT it_srv_chg BY pernr.

SORT it_0015 BY pernr.

*--> Use the class SET_TABLE FORFIRST_DISPLAY to display the ALV grid.

CALL METHOD w_grid->set_table_for_first_display

EXPORTING

is_layout = w_layout

CHANGING

it_outtab = it_srv_chg

it_fieldcatalog = it_fieldcatalog

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*--> Call the screen 100 to display the ALV grid.

CALL SCREEN 100.

ENDFORM. "F005_GRID_DISPLAY

&----


*& Form F006_INFOTY_UPDATION

&----


  • Infotype 0015 Updation

----


FORM f006_infoty_updation.

REFRESH it_index.

*--> Function to get the index of the selected rows in ALV grid

CALL METHOD w_grid->get_selected_rows

IMPORTING

et_index_rows = it_index.

*--> If no rows are selected display a Information message to select rows

IF it_index IS INITIAL.

MESSAGE text-i00 TYPE 'I'.

LEAVE TO SCREEN 0.

*--> Function to refresh to ALV gird

CALL METHOD w_grid->refresh_table_display.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSE.

*--> Fetch the Employee number from the given index value

LOOP AT it_index INTO wa_index.

READ TABLE it_srv_chg INTO wa_srv_chg INDEX wa_index.

IF sy-subrc = c_0.

*--> IT 0015 to insert the Eligible Service Charge.

READ TABLE it_0015 INTO wa_0015 WITH KEY pernr = wa_srv_chg-pernr.

IF sy-subrc = c_0.

*-->Insert Record to infotype 0015

PERFORM f007_insert_it0015.

ENDIF.

ENDIF.

CLEAR wa_0015.

ENDLOOP.

MESSAGE i012(zpy) WITH w_ct0015.

LEAVE TO SCREEN 0.

CALL METHOD w_grid->refresh_table_display.

IF sy-subrc <> 0.

ENDIF.

ENDIF.

ENDFORM. "F006_INFOTY_UPDATION

&----


*& Form F007_INSERT_IT0015

&----


  • Insert Record to infotype 0015

----


FORM f007_insert_it0015.

*--> Lock the recorrd to be updated

PERFORM f008_lock_empno.

*--> Insert the record in the infotype

PERFORM f009_insert_empdet.

*--> Unlock the Record

PERFORM f010_unlock_empno.

ENDFORM. "F007_INSERT_IT0015

&----


*& Form F008_LOCK_EMPNO

&----


  • Lock the recorrd to be updated

----


FORM f008_lock_empno.

*--> Function to lock the employee to insert the record

CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'

EXPORTING

number = wa_0015-pernr

IMPORTING

return = wa_rtab.

CLEAR wa_error.

*--> Error in locking the employee

IF NOT wa_rtab IS INITIAL.

wa_error-pernr = wa_srv_chg-pernr.

wa_error-arbgb = wa_rtab-id.

wa_error-msgty = wa_rtab-type.

wa_error-msgno = wa_rtab-number.

wa_error-msgv1 = wa_rtab-message_v1.

wa_error-msgv2 = wa_rtab-message_v2.

wa_error-msgv3 = wa_rtab-message_v3.

wa_error-msgv4 = wa_rtab-message_v4.

APPEND wa_error TO it_error.

CLEAR wa_error.

ENDIF.

IF NOT it_error IS INITIAL.

*--> Display errors if any during locking the record

PERFORM f011_display_error.

LEAVE PROGRAM.

ENDIF.

ENDFORM. "F008_LOCK_EMPNO

&----


*& Form F009_INSERT_EMPDET

&----


  • Insert the record in the infotype

----


FORM f009_insert_empdet.

*--> Function to insert the reocrd in IT 0015

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = wa_0015-infty

number = wa_0015-pernr

record = wa_0015

operation = 'INS'

IMPORTING

return = wa_rtab.

CLEAR wa_error.

*--> Error in inserting the record

IF NOT wa_rtab IS INITIAL.

wa_error-pernr = wa_0015-pernr.

wa_error-arbgb = wa_rtab-id.

wa_error-msgty = wa_rtab-type.

wa_error-msgno = wa_rtab-number.

wa_error-msgv1 = wa_rtab-message_v1.

wa_error-msgv2 = wa_rtab-message_v2.

wa_error-msgv3 = wa_rtab-message_v3.

wa_error-msgv4 = wa_rtab-message_v4.

APPEND wa_error TO it_error.

CLEAR wa_error.

ELSE.

w_ct0015 = w_ct0015 + c_1.

ENDIF.

IF NOT it_error IS INITIAL.

*--> Display Error if any during updation

PERFORM f011_display_error.

ENDIF.

ENDFORM. "F009_INSERT_EMPDET

&----


*& Form F010_UNLOCK_EMPNO

&----


  • Unlock the Record

----


FORM f010_unlock_empno.

*--> Function to unlock the employee after insertion in IT 0015

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

EXPORTING

number = wa_0015-pernr.

ENDFORM. "F010_UNLOCK_EMPNO

&----


*& Form F11_ERROR_DISPLAY

&----


  • Display errors

----


FORM f011_display_error.

*--> Function to display error if any found

CALL FUNCTION 'HR_DISPLAY_ERROR_LIST'

TABLES

error = it_error

EXCEPTIONS

invalid_linesize = 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.

REFRESH it_error.

ENDFORM. "F11_ERROR_DISPLAY

&----


*& Form f12_no_pay_days

&----


  • Calculate the no pay days

----


FORM f12_no_pay_days.

DATA: it_2001 TYPE TABLE OF p2001,

wa_2001 LIKE LINE OF it_2001.

rp_read_all_time_ity pr_payda c_date.

PROVIDE * FROM p2001

BETWEEN pr_date1 AND pr_date2.

it_2001[] = p2001[].

ENDPROVIDE.

CLEAR wa_2001.

LOOP AT it_2001 INTO wa_2001 WHERE subty = c_0016 AND

( ( begda >= pr_date1 AND begda <= pr_date2 ) OR

( endda >= pr_date1 AND endda <= pr_date2 ) ).

*--> Infotype 2001 begda and endda outside No pay Period

IF wa_2001-begda <= pr_date1 OR wa_2001-endda >= pr_date2.

*--> Begda not within no pay period

IF wa_2001-begda <= pr_date1.

wa_2001-begda = pr_date1.

ENDIF.

*--> Endda not within no pay period

IF wa_2001-endda >= pr_date2.

wa_2001-endda = pr_date2.

ENDIF.

w_abrtg = w_abrtg + ( wa_2001-endda - wa_2001-begda ) + 1.

ELSE.

w_abrtg = w_abrtg + wa_2001-abrtg.

ENDIF.

ENDLOOP.

w_no_pay_days1 = w_abrtg.

*--> If Employee Joined In Period Pr_date1 And Pr_date2, No Pay Days = Joining Date - Pr_date1

READ TABLE p0000 INTO wa_0000 WITH KEY massn = c_j1.

IF sy-subrc = 0.

IF wa_0000-begda > pr_date1 AND wa_0000-begda < pr_date2.

w_no_pay_days2 = wa_0000-begda - pr_date1.

ENDIF.

ENDIF.

*--> If Employee Leaves In Period Pr_date1 AND Pr_date2, NO PAY DAYS = pr_date2 - LEAVING DATE

READ TABLE p0000 INTO wa_0000 WITH KEY massn = c_j9.

IF sy-subrc = 0.

IF wa_0000-endda > pr_date1 AND wa_0000-endda < pr_date2.

w_no_pay_days3 = pr_date2 - wa_0000-endda.

ENDIF.

ENDIF.

w_no_pay_days = w_no_pay_days1 + w_no_pay_days2 + w_no_pay_days3. "TOTAL NO PAY DAYS

w_days_worked = 30 - w_no_pay_days. "DAYS WORKED

ENDFORM. "f12_no_pay_days.

********reward points if useful.

all the best

Read only

Former Member
0 Likes
853

Hi,

DATA : ls_exclude TYPE ui_func,

pt_exclude TYPE ui_functions.

*excluding the toolbar buttons obtained by default to the grid dislaying ztmw_wrkbnch_tab

ls_exclude = cl_gui_alv_grid=>mc_fc_detail.

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_find.

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_filter.

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_filter.

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_filter.

APPEND ls_exclude TO pt_exclude.

*Grid display

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

it_toolbar_excluding = pt_exclude

CHANGING

IT_FIELDCATALOG = FCAT[]

IT_OUTTAB = GT_ZTMW_WRKBNCH_TAB[].

rgds,

bharat.