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

pf-status ....help

Former Member
0 Likes
683

hi,

Can you please tell me how to set PF status in ALV Grid Display.

my code is:

TABLES: vbak,vbap.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_final,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

matnr LIKE vbap-matnr,

posnr LIKE vbap-posnr,

END OF t_final.

DATA: i_final TYPE STANDARD TABLE OF t_final INITIAL SIZE 0,

wa_final TYPE t_final.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

  • rt_extab TYPE slis_t_extab,

  • u_comm LIKE sy-ucomm." selfield TYPE slis_selfield.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

PERFORM status.

PERFORM user_command.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'sales order'.

fieldcatalog-col_pos = 0.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'ERDAT'.

fieldcatalog-seltext_m = 'date'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'material no.'.

fieldcatalog-col_pos = 2.

fieldcatalog-edit = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'POSNR'.

fieldcatalog-seltext_m = 'line item no.'.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


FORM display_alv_report.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

  • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_PF_STATUS'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

TABLES

t_outtab = i_final

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE i_final WHERE avbeln = bvbeln.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form status

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM status USING pfstat TYPE slis_t_extab.

SET PF-STATUS 'UPDATE' EXCLUDING pfstat.

ENDFORM. " set_stat

&----


*& Form user_command

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM user_command USING okcode like sy-ucomm

wa_selfield TYPE slis_selfield.

CASE okcode.

WHEN 'UPDATE'.

LOOP AT i_final INTO wa_final.

wa_final-matnr = vbap-matnr.

ENDLOOP.

INSERT INTO vbap VALUES wa_final.

ENDCASE.

ENDFORM. " user_command

my error is in code saying that:

different number of parameters in form and perform(routine:status

formal parameters:1,actual parameters:0).

can anyone tell me what the problem is?????

points will be rewarded.

hi sravan,

thank u so much for the response.

i have a requirement to create a alv grid report and in the output one column should be editable.(till here every thing is correct what i did)

i have to create a 'update' button to the tool bar of alv output screen so that if i enter my own data in the editable screen,and press 'update' button then my database table should be updated..

can anyone tell me how to create 'update' button and write code for that.

as u said to add in previous reply,i did that then it is going to dump.

my code is as below:

TABLES: vbak,vbap.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_final,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

matnr LIKE vbap-matnr,

posnr LIKE vbap-posnr,

END OF t_final.

DATA: i_final TYPE STANDARD TABLE OF t_final with header line,

wa_final TYPE t_final.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

  • rt_extab TYPE slis_t_extab,

  • u_comm LIKE sy-ucomm." selfield TYPE slis_selfield.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

PERFORM set_stat.

PERFORM user_command.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'sales order'.

fieldcatalog-col_pos = 0.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'ERDAT'.

fieldcatalog-seltext_m = 'date'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'material no.'.

fieldcatalog-col_pos = 2.

fieldcatalog-edit = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'POSNR'.

fieldcatalog-seltext_m = 'line item no.'.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


FORM display_alv_report.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

  • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_STAT'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

TABLES

t_outtab = i_final

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE i_final WHERE avbeln = bvbeln.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form set_stat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM set_stat." USING rt_extab type slis_t_extab.

SET PF-STATUS 'UPDATE'." EXCLUDING rt_extab.

ENDFORM. " set_stat

&----


*& Form user_command

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM user_command." USING u_comm LIKE sy-ucomm

*selfield TYPE slis_selfield.

CASE sy-ucomm.

WHEN 'UPDATE'.

LOOP AT i_final ."INTO wa_final.

i_final-matnr = vbap-matnr.

ENDLOOP.

update (vbap) from table i_final.

ENDCASE.

ENDFORM. " user_command

can u plz suggest me idea?

points will be rewarded.

5 REPLIES 5
Read only

Former Member
0 Likes
653

Hello ,

Copy the standard pf status of the ALV in SE41 and do the following.

DATA: IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS LIKE LINE OF IT_EVENTS.
REFRESH: IT_EVENTS.
CLEAR: WA_EVENTS,IT_EVENTS.
WA_EVENTS-NAME = 'PF_STATUS_SET'.
WA_EVENTS-FORM = 'STATUS'.
APPEND WA_EVENTS TO IT_EVENTS .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = G_T_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
---------------------------------------------------------------------

FORM status * 
---------------------------------------------------------------------

........ * 
---------------------------------------------------------------------
FORM STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING RT_EXTAB.
ENDFORM.

If useful reward.

Vasanth
Read only

Former Member
0 Likes
653

You need to add below line to your grid....

" i_callback_user_command = 'STAT' "

See the code below.

*************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ws_repid

i_callback_pf_status_set = 'GUI_STAT'

i_callback_user_command = 'STAT'

is_layout = gs_layout

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = i_zaw_pol_plan.

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 gui_stat USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' EXCLUDING

rt_extab.

SET TITLEBAR text-005.

ENDFORM.

FORM stat USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'your button fcode here'.

Your functionality for that button.

ENDCASE.

ENDFORM.

reward if useful...

Read only

0 Likes
653

hi sravan,

thank u so much for the response.

i have a requirement to create a alv grid report and in the output one column should be editable.(till here every thing is correct what i did)

i have to create a 'update' button to the tool bar of alv output screen so that if i enter my own data in the editable screen,and press 'update' button then my database table should be updated..

can anyone tell me how to create 'update' button and write code for that.

as u said to add in previous reply,i did that then it is going to dump.

my code is as below:

TABLES: vbak,vbap.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_final,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

matnr LIKE vbap-matnr,

posnr LIKE vbap-posnr,

END OF t_final.

DATA: i_final TYPE STANDARD TABLE OF t_final with header line,

wa_final TYPE t_final.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

  • rt_extab TYPE slis_t_extab,

  • u_comm LIKE sy-ucomm." selfield TYPE slis_selfield.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

PERFORM set_stat.

PERFORM user_command.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'sales order'.

fieldcatalog-col_pos = 0.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'ERDAT'.

fieldcatalog-seltext_m = 'date'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'material no.'.

fieldcatalog-col_pos = 2.

fieldcatalog-edit = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'POSNR'.

fieldcatalog-seltext_m = 'line item no.'.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

ENDFORM. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


FORM display_alv_report.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

  • i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

i_callback_pf_status_set = 'SET_STAT'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

TABLES

t_outtab = i_final

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. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE i_final WHERE avbeln = bvbeln.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form set_stat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM set_stat." USING rt_extab type slis_t_extab.

SET PF-STATUS 'UPDATE'." EXCLUDING rt_extab.

ENDFORM. " set_stat

&----


*& Form user_command

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM user_command." USING u_comm LIKE sy-ucomm

*selfield TYPE slis_selfield.

CASE sy-ucomm.

WHEN 'UPDATE'.

LOOP AT i_final ."INTO wa_final.

i_final-matnr = vbap-matnr.

ENDLOOP.

update (vbap) from table i_final.

ENDCASE.

ENDFORM. " user_command

can u plz suggest me idea?

points will be rewarded.

Read only

Former Member
0 Likes
653

hi nani,

here are the steps..

1) OPEN SE41

2) TYPE IN YOUR PROGRAM NAME FOR WHICH YOU NEED ALV MENU

3) on the application tolbar you would see a button named 'STATUS', click it

4) now it would say copy status FROM AND TO....

type:

FROM:

PROGRAM: SAPLSLVC_FULLSCREEN

STATUS: STANDARD_FULLSCREEN

TO

PROGRAM: TYPE YOuR PROGRAM NAME

STATUS : TYPE YOUR CUSTOM MENU NAME

5) PRESS COPY..and again till it says a message 'COPIED SUCCESSFULLY

6)in you ALV PROGRAM IN EVENT SET_PF_STATUS,

TYPE THIS ALV STATUS AND DOUBLE CLICK UR MENU NAME

AND THEN YOU WILL HAVE YOUR ALV STANDARD MENU..AND

YOU CAN HAVE YOUR BUTTON ON IT, BY MAKING YOU OWN COMMAND SAY ''&UP1' name it as update info

6) ACTIVATE IT

AND YOUR ALV MENU IS MADE

reward points if helpful

Rohan malik

Read only

Former Member
0 Likes
653

Hi...

You can go thru this code,...

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = ws_repid

i_callback_pf_status_set = 'GUI_STAT'

i_callback_user_command = 'STAT'

is_layout = gs_layout

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = i_zaw_pol_plan.

FORM gui_stat USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.

SET TITLEBAR text-005.

ENDFORM.

Double click on 'STANDARD' and set the status.

Here you will loose the standard ALV toolbar.

If you want to get STANDARD ALV tool bar...you need to do this navigations.

SE80 ->give Function Group as SALV -> right click on GUI status -> copy STANDARD menu to your program ->go to SE41 -> Activate the menu -> now you will get the menu in your program -> if you want to add any buttons or want to do any changes in the menu, you can do using SE41-> save and activate.

Regards

sandeep.