Skip to Content
author's profile photo Former Member
Former Member

Callback PF_STATUS_SET & USER_COMMAND

Hi guys,

I'm getting a strange bug in my program that seems to related to the ALV callback routines.

I have an editable ALV grid and I'm using FM REUSE_ALV_GRID_DISPLAY_LVC to display the table. I implemented I_CALLBACK_USER_COMMAND and everything was working. Then I added my own GUI Status by copying the STANDARD from SALV and implemented I_CALLBACK_PF_STATUS_SET.

Now the ALV seems to refresh before it gets to my user command subroutine. i.e if I type a new value into an editable field my change is not visible.

Any ideas on how to fix this?

Many Thanks,

Philip Johannesen

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 10:01 AM

    Hi Philip,

    See the code below where i have used I_CALLBACK_PF_STATUS_SET and I_CALLBACK_USER_COMMAND simultaneously.Hope this will help you .

    Reward if useful.

    Thkx.

    FORM SUB_GETDETAILS.

    TYPES:BEGIN OF TY_MAKT,

    MAKTX TYPE MAKTX,

    MATNR TYPE MATNR,

    END OF TY_MAKT.

    TYPES:BEGIN OF TY_MAST,

    MATNR TYPE MATNR,

    WERKS TYPE WERKS,

    STLAL TYPE STLAL,

    STLAN TYPE STLAN,

    END OF TY_MAST.

    DATA: WA_MATNR LIKE LINE OF S_MATNR,

    V_MATNR TYPE MATNR.

    TYPES: TY_T_MAKT TYPE STANDARD TABLE OF TY_MAKT.

    Data: lt_makt type TY_T_MAKT.

    types: ty_t_MAST TYPE STANDARD TABLE OF TY_MAST.

    data: lt_mast type ty_t_mast.

    DATA: ITAB_WULTB TYPE STANDARD TABLE OF STPOV,

    ITAB_WULTB_TEMP TYPE STANDARD TABLE OF STPOV.

    DATA: WA_WULTB TYPE STPOV,

    LT_EQU TYPE STANDARD TABLE OF CSCEQUI,

    LT_KND TYPE STANDARD TABLE OF CSCKND,

    LT_STD TYPE STANDARD TABLE OF CSCSTD,

    LT_MAT TYPE STANDARD TABLE OF CSCMAT,

    LT_TPL TYPE STANDARD TABLE OF CSCTPL,

    LT_PRJ TYPE STANDARD TABLE OF CSCPRJ.

    DATA WA_MAKT TYPE TY_MAKT.

    DATA WA_MAST TYPE TY_MAST.

    LOOP AT S_MATNR INTO WA_MATNR.

    V_MATNR = WA_MATNR-LOW.

    CALL FUNCTION 'CS_WHERE_USED_MAT'

    EXPORTING

    DATUB = '99991231'

    DATUV = P_DATUV

    MATNR = V_MATNR

    • POSTP = ' '

    • RETCODE_ONLY = ' '

    • STLAN = ' '

    WERKS = P_WERKS

    • MCLMT = ' '

    • MNSTL = ' '

    • MXSTL = ' '

    STLTP = 'M'

    • NEWSI = ' '

    • IMPORTING

    • TOPMAT =

    TABLES

    WULTB = ITAB_WULTB_TEMP

    EQUICAT = LT_EQU

    KNDCAT = LT_KND

    MATCAT = LT_MAT

    STDCAT = LT_STD

    TPLCAT = LT_TPL

    PRJCAT = LT_PRJ

    EXCEPTIONS

    CALL_INVALID = 1

    MATERIAL_NOT_FOUND = 2

    • NO_WHERE_USED_REC_FOUND = 3

    • NO_WHERE_USED_REC_SELECTED = 4

    • NO_WHERE_USED_REC_VALID = 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.

    IF SY-SUBRC = 0.

    APPEND LINES OF ITAB_WULTB_TEMP TO ITAB_WULTB.

    ENDIF.

    ENDLOOP.

    SELECT

    MAKTX

    FROM MAKT INTO TABLE LT_MAKT

    WHERE MATNR IN S_MATNR.

    SELECT MATNR

    WERKS

    STLAL

    STLAN

    FROM MAST INTO TABLE LT_MAST

    FOR ALL ENTRIES IN

    ITAB_WULTB

    WHERE MATNR = ITAB_WULTB-MATNR.

    LOOP AT ITAB_WULTB INTO WA_WULTB.

    READ TABLE LT_MAKT into WA_MAKT WITH KEY MATNR = WA_WULTB-MATNR.

    IF SY-SUBRC <> 0.

    WA_ITAB_FINAL-MAKTX = WA_MAKT-MAKTX.

    ENDIF.

    READ TABLE LT_MAST INTO WA_MAST WITH KEY MATNR = WA_WULTB-MATNR.

    WA_ITAB_FINAL-MATNR = WA_MAST-MATNR.

    WA_ITAB_FINAL-WERKS = WA_MAST-WERKS.

    WA_ITAB_FINAL-STLAL = WA_MAST-STLAL.

    WA_ITAB_FINAL-STLAN = WA_MAST-STLAN.

    APPEND WA_ITAB_FINAL TO ITAB_FINAL.

    ENDLOOP.

    ENDFORM. "SUB_GETDETAILS

    &----


    *& Form sub_build_fieldcatalog

    &----


    • text

    ----


    FORM sub_build_fieldcatalog .

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = c_matnr.

    lf_fieldcat-tabname = c_mast.

    lf_fieldcat-hotspot = 'X'.

    lf_fieldcat-seltext_m = text-003.

    lf_fieldcat-outputlen = c_10.

    lf_fieldcat-col_pos = 1.

    lf_fieldcat-emphasize = 'X'.

    APPEND lf_fieldcat TO lt_fieldcat.

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = c_werks.

    lf_fieldcat-tabname = c_mast.

    lf_fieldcat-seltext_m = text-004.

    lf_fieldcat-outputlen = c_10.

    lf_fieldcat-col_pos = 1.

    APPEND lf_fieldcat TO lt_fieldcat.

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = c_maktx.

    lf_fieldcat-tabname = c_makt.

    lf_fieldcat-seltext_m = text-005.

    lf_fieldcat-outputlen = c_10.

    lf_fieldcat-col_pos = 1.

    APPEND lf_fieldcat TO lt_fieldcat.

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = c_stlal.

    lf_fieldcat-tabname = c_mast.

    lf_fieldcat-seltext_m = text-006.

    lf_fieldcat-outputlen = c_10.

    lf_fieldcat-col_pos = 1.

    APPEND lf_fieldcat TO lt_fieldcat.

    CLEAR lf_fieldcat.

    lf_fieldcat-fieldname = c_stlan.

    lf_fieldcat-tabname = c_mast.

    lf_fieldcat-seltext_m = text-007.

    lf_fieldcat-outputlen = c_10.

    lf_fieldcat-col_pos = 1.

    APPEND lf_fieldcat TO lt_fieldcat.

    ENDFORM. "sub_build_fieldcatalog

    &----


    *& Form sub_GET_DETAILS

    &----


    • text

    ----


    Form sub_DISP.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = sy-repid

    I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

    I_CALLBACK_USER_COMMAND = 'VAL'

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

    • I_GRID_SETTINGS =

    IS_LAYOUT = l_layout

    IT_FIELDCAT = lt_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = l_sort

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = 'X '

    • 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

    • I_HTML_HEIGHT_TOP = 0

    • I_HTML_HEIGHT_END = 0

    • IT_ALV_GRAPHICS =

    • IT_HYPERLINK =

    • IT_ADD_FIELDCAT =

    • IT_EXCEPT_QINFO =

    • IR_SALV_FULLSCREEN_ADAPTER =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    T_OUTTAB = ITAB_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. "sub_DISP

    &----


    *& Form VAL

    &----


    • text

    ----


    • -->USER_COMMAND text

    • -->SEL text

    ----


    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.

    DATA: CUS(10) TYPE N,

    SALNO(10) TYPE N,

    MAT(10) TYPE C.

    CASE USER_COMMAND.

    WHEN 'EXIT'.

    LEAVE PROGRAM.

    WHEN 'CREATE'.

    CALL TRANSACTION 'MM01' .

    WHEN 'CHANGE'.

    CALL TRANSACTION 'MM02'.

    ENDCASE.

    IF SEL-FIELDNAME = 'MATNR'.

    MAT = SEL-VALUE.

    SET PARAMETER ID 'MAT' FIELD MAT.

    CALL TRANSACTION 'MM04' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDFORM. "VAL

    *FORM user_command USING r_ucomm LIKE sy-ucomm

    *

    • rs_selfield TYPE slis_selfield.

    *

    *

    *

    *

    • Check function code

    *

    • CASE r_ucomm.

    *

    • WHEN '&IC1'.

    *

    • Check field clicked on within ALVgrid report

    *

    • IF rs_selfield-fieldname = 'MATNR'.

    *

    • Read data table, using index of row user clicked on

    *

    • READ TABLE itab_final INTO WA_ITAB_final INDEX rs_selfield-tabindex.

    *

    • Set parameter ID for transaction screen field

    *

    • SET PARAMETER ID 'MAT' FIELD WA_ITAB_final-matnr.

    *

    • Execute transaction MM04, and skip initial data entry screen

    *

    • CALL TRANSACTION 'MM04' AND SKIP FIRST SCREEN.

    *

    • ENDIF.

    *

    *

    • WHEN 'BACK'.

    • LEAVE PROGRAM.

    *

    • ENDCASE.

    *

    *ENDFORM. "user_command

    FORM PF_STATUS using RT_EXTAB TYPE SLIS_T_EXTAB.

    SET PF-STATUS 'STANDARD1'.

    • SET PF-STATUS 'STANDARD2'.

    ENDFORM. "PF_STATUS

    &----


    *& Form build_layout *

    &----


    FORM build_layout .

    l_layout-colwidth_optimize = 'X'.

    l_layout-zebra = 'X'.

    *l_layout-box_fieldname = 'CHK'.

    *l_layout-box_tabname = 'ITAB_FINAL' .

    *

    ENDFORM. " build_layout

    FORM sort_layout .

    CLEAR w_sort.

    w_sort-fieldname = 'STLAL'.

    w_sort-tabname = 'ITAB_FINAL'.

    w_sort-spos = 1.

    w_sort-up = 'X'.

    w_sort-subtot = 'X'.

    APPEND w_sort TO l_sort.

    ENDFORM. " sort_layout

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 10:18 AM

    Use the following code in User_comman form.

    the changed data automatically reflect to the internal table assinged to ALV.

    DATA: ref_grid TYPE REF TO cl_gui_alv_grid.

    IF ref_grid IS INITIAL.

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

    IMPORTING

    e_grid = ref_grid.

    ENDIF.

    IF NOT ref_grid IS INITIAL.

    CALL METHOD ref_grid->check_changed_data.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi philip,

      1. Not sure whether i understood the problem correctly or not,

      2. but i also faced similar problem.

      3. after entering on any cell, in the alv grid,

      we need to DOUBLE-CLICK on the grid,

      so that the changed value, gets reflected in the internal table of the grid.

      regards,

      amit m.

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 01:17 PM

    It works fine for me, Shall know where you are using this code. why the values are not updating correctly. Could you please explain me .

    Regards,

    Gopi.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.