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

re: alv

Former Member
0 Likes
1,053

Hi,

How to add the user command button to the sap alv status. can any body give the code.

rgds

p.kp

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,029

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

<b>I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>

I_GRID_TITLE = ' GE-IS LIBRARY'

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = IT_FIELDCAT_RAMS_SCREEN

IT_EVENTS = IT_EVENTS

TABLES

T_OUTTAB = IT_RAMS_SCR_FLDS

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.

&----


*& Form PF_STATUS

&----


  • to add a new button in the application toolbar of the ALV report

----


  • RT_EXTAB

----


<b>copy the GUI status from any standard program and add ur new button to that and give an FCODE for that.here my FCODE is REQ</b>

FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDARD1' EXCLUDING RT_EXTAB.

ENDFORM. "PF_STATUS

&----


*& Form USER_COMMAND

&----


  • based on user command , corresponding actions are performed

----


FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

DATA : L_REP_MODE. "report mode

CASE P_UCOMM.

*When New request button is selected then report id is set as space

WHEN 'REQ'. "new request

W_REPT_ID = ' '.

AUTHORITY-CHECK OBJECT 'ZRAMSSTAT'

ID 'STATID' FIELD '1'.

IF SY-SUBRC = 0.

AUTHORITY-CHECK OBJECT 'ZRAMS_ACT'

ID 'ACTVT' FIELD '01'. "FOR Create

IF SY-SUBRC = 0.

*sets parameter id for the given field and leaves to the given

*transaction

L_REP_MODE = 'N'.

SET PARAMETER ID 'RAMS_MODE' FIELD L_REP_MODE.

SET PARAMETER ID 'RAMS' FIELD W_REPT_ID.

CALL TRANSACTION 'ZF23'.

ELSE.

message I001(ZZ) WITH TEXT-102.

ENDIF.

ELSE.

message I001(ZZ) WITH TEXT-102.

ENDIF.

  • ENDCASE.

ENDFORM. "USER_COMMAND

Message was edited by: chandrasekhar jagarlamudi

Message was edited by: chandrasekhar jagarlamudi

Hi,

How to add the user command button to the sap alv status. can any body give the code.

rgds

p.kp

8 REPLIES 8
Read only

Former Member
0 Likes
1,029

hi

r u working in grid or list

Read only

Former Member
0 Likes
1,030

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

<b>I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>

I_GRID_TITLE = ' GE-IS LIBRARY'

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = IT_FIELDCAT_RAMS_SCREEN

IT_EVENTS = IT_EVENTS

TABLES

T_OUTTAB = IT_RAMS_SCR_FLDS

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.

&----


*& Form PF_STATUS

&----


  • to add a new button in the application toolbar of the ALV report

----


  • RT_EXTAB

----


<b>copy the GUI status from any standard program and add ur new button to that and give an FCODE for that.here my FCODE is REQ</b>

FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'STANDARD1' EXCLUDING RT_EXTAB.

ENDFORM. "PF_STATUS

&----


*& Form USER_COMMAND

&----


  • based on user command , corresponding actions are performed

----


FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

DATA : L_REP_MODE. "report mode

CASE P_UCOMM.

*When New request button is selected then report id is set as space

WHEN 'REQ'. "new request

W_REPT_ID = ' '.

AUTHORITY-CHECK OBJECT 'ZRAMSSTAT'

ID 'STATID' FIELD '1'.

IF SY-SUBRC = 0.

AUTHORITY-CHECK OBJECT 'ZRAMS_ACT'

ID 'ACTVT' FIELD '01'. "FOR Create

IF SY-SUBRC = 0.

*sets parameter id for the given field and leaves to the given

*transaction

L_REP_MODE = 'N'.

SET PARAMETER ID 'RAMS_MODE' FIELD L_REP_MODE.

SET PARAMETER ID 'RAMS' FIELD W_REPT_ID.

CALL TRANSACTION 'ZF23'.

ELSE.

message I001(ZZ) WITH TEXT-102.

ENDIF.

ELSE.

message I001(ZZ) WITH TEXT-102.

ENDIF.

  • ENDCASE.

ENDFORM. "USER_COMMAND

Message was edited by: chandrasekhar jagarlamudi

Message was edited by: chandrasekhar jagarlamudi

Read only

Former Member
0 Likes
1,029

hello krishna

The following is the sample code and ignore the uploading part of data from excel sheet into the internal table.

REPORT zexcel01 .

TYPE-POOLS : slis.

DATA : itab LIKE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE.

DATA : s_repid LIKE syst-repid.

s_repid = syst-repid.

DATA : tbl_fcat TYPE slis_fieldcat_alv OCCURS 0 WITH HEADER LINE.

DATA : g_layout TYPE slis_layout_alv.

DATA : tbl_bdc TYPE bdcdata OCCURS 0 WITH HEADER LINE.

DATA : tbl_msg TYPE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

DATA : tbl_bdc1 TYPE bdcdata OCCURS 0 WITH HEADER LINE.

DATA : tbl_msg1 TYPE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = 'C:\Documents and Settings\sree Jagannathan\Desktop\vj.xls'

i_begin_col = 1

i_begin_row = 1

i_end_col = 11

i_end_row = 2

TABLES

intern = itab

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DATA : BEGIN OF itab1 OCCURS 0,

c1(10),

c2(10),

c3(10),

c4(10),

c5(10),

c6(10),

c7(10),

c8(10),

c9(10),

c10(10),

c11(10),

END OF itab1.

DATA : BEGIN OF itab2 OCCURS 0,

otype TYPE pphdr-otype,

seark TYPE pm0d1-seark,

infty TYPE pphdr-infty,

istat TYPE pphdr-istat,

short TYPE p1000-short,

stext TYPE p1000-stext,

infty1 TYPE pphdr-infty,

rsign TYPE p1001-rsign,

relat TYPE p1001-relat,

sclas TYPE p1001-sclas,

sobid TYPE p1001-sobid,

END OF itab2.

LOOP AT itab.

CASE itab-col.

WHEN '1'.

MOVE : itab-value TO itab1-c1.

WHEN '2'.

MOVE itab-value TO itab1-c2.

WHEN '3'.

MOVE itab-value TO itab1-c3.

WHEN '4'.

MOVE itab-value TO itab1-c4.

WHEN '5'.

MOVE itab-value TO itab1-c5.

WHEN '6'.

MOVE itab-value TO itab1-c6.

WHEN '7'.

MOVE itab-value TO itab1-c7.

WHEN '8'.

MOVE itab-value TO itab1-c8.

WHEN '9'.

MOVE itab-value TO itab1-c9.

WHEN '10'.

MOVE itab-value TO itab1-c10.

WHEN '11'.

MOVE itab-value TO itab1-c11.

APPEND itab1.

CLEAR itab1.

WHEN OTHERS.

ENDCASE.

ENDLOOP.

*loop at itab1.

*

  • write 😕 itab1-otype,

  • itab1-obdij,

  • itab1-infty,

  • itab1-istat.

*

*endloop.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = s_repid

i_internal_tabname = 'ITAB1'

  • I_STRUCTURE_NAME =

  • i_client_never_display = 'X'

i_inclname = s_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

ct_fieldcat = tbl_fcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3

.

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 FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = s_repid

i_callback_pf_status_set = 'SET_PF_STATUS'(002)

i_callback_user_command = '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 = 'DATA FROM THE EXCEL'

  • I_GRID_SETTINGS =

is_layout = g_layout

it_fieldcat = tbl_fcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'X'

i_save = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • 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 = itab1

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.

&----


*& Form set_pf_status

&----


  • text

----


  • -->RT_EXTAB text

----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'NEWALVSTATUS'.

ENDFORM. "set_pf_status

DATA : r_ucomm LIKE sy-ucomm,

rs_selfield TYPE slis_selfield.

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM user_command USING r_ucomm rs_selfield.

IF syst-ucomm = 'SHUSH'.

HERE THE CORRESPONDING BDC CODE IS WRITTEN.

Hope this helps u.

Thanking you

Regards

vj

Read only

Former Member
0 Likes
1,029

if you are using ALV GRid control then Please have a look at this steps..


*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS LCL_EVENT_HANDLER DEFINITION .
  PUBLIC SECTION .
    METHODS:
    HANDLE_TOOLBAR
        FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
            IMPORTING E_OBJECT E_INTERACTIVE.
ENDCLASS.                    "lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
  METHOD HANDLE_TOOLBAR.
    DATA: LS_TOOLBAR  TYPE STB_BUTTON.
* append a separator to normal toolbar
    CLEAR LS_TOOLBAR.
    MOVE 3 TO LS_TOOLBAR-BUTN_TYPE.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
* append SAVE icon
    CLEAR LS_TOOLBAR.
    MOVE 'SAVE' TO LS_TOOLBAR-FUNCTION.
    MOVE ICON_SYSTEM_SAVE TO LS_TOOLBAR-ICON.
    MOVE 'Save' TO LS_TOOLBAR-QUICKINFO.
    MOVE '  Save  '  TO LS_TOOLBAR-TEXT.
    MOVE ' '  TO LS_TOOLBAR-DISABLED.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
    CLEAR LS_TOOLBAR.
* append a separator to normal toolbar
    CLEAR LS_TOOLBAR.
    MOVE 3 TO LS_TOOLBAR-BUTN_TYPE.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
* append BACK icon
    CLEAR LS_TOOLBAR.
    MOVE 'BACK' TO LS_TOOLBAR-FUNCTION.
    MOVE ICON_SYSTEM_BACK TO LS_TOOLBAR-ICON.
    MOVE 'Back' TO LS_TOOLBAR-QUICKINFO.
    MOVE ' Back '  TO LS_TOOLBAR-TEXT.
    MOVE ' '  TO LS_TOOLBAR-DISABLED.
    APPEND LS_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
    CLEAR LS_TOOLBAR.
  ENDMETHOD.                    "handle_toolbar
ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
*&---------------------------------------------------------------------*
*&             Global Definitions
*&---------------------------------------------------------------------*
DATA: "G_GRID TYPE REF TO CL_GUI_ALV_GRID,   "Grid for first report
      G_GRID1 TYPE REF TO CL_GUI_ALV_GRID,  "grid for second report
      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
      G_CUSTOM_CONTAINER1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"container
      G_HANDLER TYPE REF TO LCL_EVENT_HANDLER, "handler
      G_HANDLER1 TYPE REF TO LCL_EVENT_HANDLER1. "handler

DATA: OK_CODE LIKE SY-UCOMM,
      SAVE_OK LIKE SY-UCOMM,
      G_CONTAINER1 TYPE SCRFNAME VALUE 'ZSDR0057_DEL_HOLD_CONT1',
      G_CONTAINER2 TYPE SCRFNAME VALUE 'ZSDR0057_DEL_HOLD_CONT2',
      GS_LAYOUT TYPE LVC_S_LAYO,
      GS_LAYOUT1 TYPE LVC_S_LAYO.

*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
      X_FIELDCAT TYPE LVC_S_FCAT,
      IT_FIELDCAT1  TYPE  LVC_T_FCAT,
      X_FIELDCAT1 TYPE LVC_S_FCAT,
      LS_VARI  TYPE DISVARIANT.


  CREATE OBJECT G_CUSTOM_CONTAINER
         EXPORTING CONTAINER_NAME = G_CONTAINER1.
  CREATE OBJECT G_GRID
         EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
  SET HANDLER G_HANDLER->HANDLE_TOOLBAR FOR G_GRID.

**Calling the Method for ALV output
  CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
      IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
      IS_VARIANT           = LS_VARI
      IS_LAYOUT            = GS_LAYOUT
      I_SAVE               = 'A'
    CHANGING
      IT_FIELDCATALOG      = IT_FIELDCAT
      IT_OUTTAB            = IT_FINAL[].


  CALL METHOD G_GRID->SET_TOOLBAR_INTERACTIVE

Read only

0 Likes
1,029

hi,

when ever i copy the standard one and iam using the copied standard pf status. I could not able to see any pf status. Is there any problem.

rgds

p.kp

Read only

0 Likes
1,029

Try to copy from SE41

by specifying std prg and pf status copy to your prg...

that is good actually

Read only

0 Likes
1,029

And activate the status one you copied and

if it is normal alv then provide the copied one

FORM PF_STATUS_SET USING P_EXTAB TYPE SLIS_T_EXTAB.

SET PF-STATUS 'COPYSTANDARD' EXCLUDING P_EXTAB.

note: give <b>CAPS</b> in the single quotes

ENDFORM. "PF_STATUS_SET

Message was edited by: Vijay Babu Dudla

Read only

0 Likes
1,029

hi

onece u copy pls activate the pf-status and u can add ur new button