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

Back Problem in ALV

EkanshCapgemini
Active Contributor
0 Likes
3,005

Hi,

I have created an interactive ALV report but there is  a problem that on pressing F3 or ESC key, it shows an error message "choose a valid function". I double click on the customer and get another popup alv report, if i use f3 to get back from this secondary report, it successfully bring me back on primary report but when i press F3 on primary report to get back to the selection screen, it shows the above error message.

Here is my code:

FORM grid_display.

   DATA : p_var LIKE disvariant-variant,
          gs_variant LIKE disvariant.
   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program                 = sy-repid
       i_callback_pf_status_set         = 'STANDARD'
       i_callback_user_command      = 'HANDLE_USER_COMMAND'
       is_layout                                = ls_layout
       it_fieldcat                               = it_fieldcat[]
       it_events                               = gt_events[]
       i_background_id                     = 'ALV_BACKGROUND'
       i_save                                    = 'A'
       i_default                                 = 'X'
     TABLES
       t_outtab                 = it_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.

   CLEAR: it_final,it_bsik_debit,it_bsik_credit. ",IT_KNA1,IT_KNB1.
ENDFORM.                    "GRID_DISPLAY

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM top_of_page.

   CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
     EXPORTING
       i_logo             = 'INDURE_LOGO'
       it_list_commentary = lt_top_of_page.

ENDFORM.                    "TOP_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  STANDARD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM standard USING p_extab TYPE slis_t_extab.

*- Pf status
   SET PF-STATUS 'STANDARD'.

ENDFORM.                 " STANDARD

*&---------------------------------------------------------------------*
*&      Form  handle_user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM handle_user_command USING r_ucomm     LIKE sy-ucomm
                                rs_selfield TYPE slis_selfield.

   CASE r_ucomm.

     WHEN '&IC1'.
       CLEAR it_final2[].
       CLEAR: wa_bsik_credit,
             wa_bsik_debit,
             wa_bsik_credit1,
             wa_bsik_debit1.

       IF rs_selfield-fieldname = 'KUNNR'.
         READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.

         SELECT a~kunnr a~name1 b~dmbtr b~shkzg
           b~belnr
           b~bukrs
           b~gjahr
           b~budat
           b~bldat
           b~zfbdt
           b~blart
           b~xblnr
           b~bschl
           b~umskz
           b~hkont
           b~sgtxt
           INTO CORRESPONDING FIELDS OF TABLE it_bsik_credit1
           FROM kna1 AS a INNER JOIN
                bsid AS b ON a~kunnr = b~kunnr
           WHERE b~bukrs EQ bukrs AND                    "Company Code.
                 b~bupla IN bupla AND                    "Business Place.
                 b~kunnr IN kunnr AND                    "CUSTOMER Code.
                 b~prctr IN prctr AND                    "Profit Center.
                 b~umskz IN umskz AND
                 "B~UMSKZ EQ UMSKZ AND                    "Special G/L ind.
                 b~shkzg EQ 'H' AND b~shkzg NE 'S' AND   "Only Credit Entry (H)
                 b~budat LE budat                    "Posting Date(Benchmark Date).
                 AND b~kunnr EQ wa_final-kunnr
                 ORDER BY a~kunnr.
         LOOP AT it_bsik_credit1 INTO wa_bsik_credit1.
           wa_bsik_credit1-detail = 'Credit (H)'.
           wa_bsik_credit1-dmbtr = 0 - wa_bsik_credit1-dmbtr.
           MODIFY it_bsik_credit1 FROM wa_bsik_credit1 TRANSPORTING detail dmbtr.
         ENDLOOP.


         MOVE it_bsik_credit1 TO it_final2.

         SELECT a~kunnr a~name1 b~dmbtr b~shkzg
           b~belnr
           b~bukrs
           b~gjahr
           b~budat
           b~bldat
           b~zfbdt
           b~blart
           b~xblnr
           b~bschl
           b~umskz
           b~hkont
           b~sgtxt
          INTO CORRESPONDING FIELDS OF TABLE it_bsik_debit1
          FROM kna1 AS a INNER JOIN
               bsid AS b ON a~kunnr = b~kunnr
           WHERE b~bukrs EQ bukrs AND                  "Company Code.
               b~bupla IN bupla AND                  "Business Place.
               b~kunnr IN kunnr AND                  "CUSTOMER Code.
               b~prctr IN prctr AND                  "Profit Center.
               b~umskz IN umskz AND
               "B~UMSKZ EQ UMSKZ AND                  "Special G/L ind.
               b~shkzg EQ 'S' AND b~shkzg NE 'H' AND "Only Debit Entry (S)
               b~budat LE budat                       "Posting Date(Benchmark Date).
           AND b~kunnr EQ wa_final-kunnr
               ORDER BY a~kunnr.
         LOOP AT it_bsik_debit1 INTO wa_bsik_debit1.
           wa_bsik_debit1-detail = 'Debit (S)'.
           MODIFY it_bsik_debit1 FROM wa_bsik_debit1 TRANSPORTING detail.
         ENDLOOP.

         APPEND LINES OF it_bsik_debit1 TO it_final2.

         PERFORM interactive_report.
       ENDIF.
     WHEN 'BACK'.
       LEAVE TO SCREEN 0.
     WHEN 'EXIT'.
       LEAVE TO SCREEN 0.
     WHEN 'CLOSE'.
       CALL TRANSACTION 'SE38'.
   ENDCASE.

ENDFORM.                    "HANDLE_USER_COMMAND

Hi,

I have created an interactive ALV report but there is  a problem that on pressing F3 or ESC key, it shows an error message "choose a valid function". I double click on the customer and get another popup alv report, if i use f3 to get back from this secondary report, it successfully bring me back on primary report but when i press F3 on primary report to get back to the selection screen, it shows the above error message.

Here is my code:

FORM grid_display.

   DATA : p_var LIKE disvariant-variant,
          gs_variant LIKE disvariant.
   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program                 = sy-repid
       i_callback_pf_status_set         = 'STANDARD'
       i_callback_user_command      = 'HANDLE_USER_COMMAND'
       is_layout                                = ls_layout
       it_fieldcat                               = it_fieldcat[]
       it_events                               = gt_events[]
       i_background_id                     = 'ALV_BACKGROUND'
       i_save                                    = 'A'
       i_default                                 = 'X'
     TABLES
       t_outtab                 = it_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.

   CLEAR: it_final,it_bsik_debit,it_bsik_credit. ",IT_KNA1,IT_KNB1.
ENDFORM.                    "GRID_DISPLAY

*&---------------------------------------------------------------------*
*&      Form  TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM top_of_page.

   CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
     EXPORTING
       i_logo             = 'INDURE_LOGO'
       it_list_commentary = lt_top_of_page.

ENDFORM.                    "TOP_OF_PAGE

*&---------------------------------------------------------------------*
*&      Form  STANDARD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_EXTAB    text
*----------------------------------------------------------------------*
FORM standard USING p_extab TYPE slis_t_extab.

*- Pf status
   SET PF-STATUS 'STANDARD'.

ENDFORM.                 " STANDARD

*&---------------------------------------------------------------------*
*&      Form  handle_user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM handle_user_command USING r_ucomm     LIKE sy-ucomm
                                rs_selfield TYPE slis_selfield.

   CASE r_ucomm.

     WHEN '&IC1'.
       CLEAR it_final2[].
       CLEAR: wa_bsik_credit,
             wa_bsik_debit,
             wa_bsik_credit1,
             wa_bsik_debit1.

       IF rs_selfield-fieldname = 'KUNNR'.
         READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.

         SELECT a~kunnr a~name1 b~dmbtr b~shkzg
           b~belnr
           b~bukrs
           b~gjahr
           b~budat
           b~bldat
           b~zfbdt
           b~blart
           b~xblnr
           b~bschl
           b~umskz
           b~hkont
           b~sgtxt
           INTO CORRESPONDING FIELDS OF TABLE it_bsik_credit1
           FROM kna1 AS a INNER JOIN
                bsid AS b ON a~kunnr = b~kunnr
           WHERE b~bukrs EQ bukrs AND                    "Company Code.
                 b~bupla IN bupla AND                    "Business Place.
                 b~kunnr IN kunnr AND                    "CUSTOMER Code.
                 b~prctr IN prctr AND                    "Profit Center.
                 b~umskz IN umskz AND
                 "B~UMSKZ EQ UMSKZ AND                    "Special G/L ind.
                 b~shkzg EQ 'H' AND b~shkzg NE 'S' AND   "Only Credit Entry (H)
                 b~budat LE budat                    "Posting Date(Benchmark Date).
                 AND b~kunnr EQ wa_final-kunnr
                 ORDER BY a~kunnr.
         LOOP AT it_bsik_credit1 INTO wa_bsik_credit1.
           wa_bsik_credit1-detail = 'Credit (H)'.
           wa_bsik_credit1-dmbtr = 0 - wa_bsik_credit1-dmbtr.
           MODIFY it_bsik_credit1 FROM wa_bsik_credit1 TRANSPORTING detail dmbtr.
         ENDLOOP.


         MOVE it_bsik_credit1 TO it_final2.

         SELECT a~kunnr a~name1 b~dmbtr b~shkzg
           b~belnr
           b~bukrs
           b~gjahr
           b~budat
           b~bldat
           b~zfbdt
           b~blart
           b~xblnr
           b~bschl
           b~umskz
           b~hkont
           b~sgtxt
          INTO CORRESPONDING FIELDS OF TABLE it_bsik_debit1
          FROM kna1 AS a INNER JOIN
               bsid AS b ON a~kunnr = b~kunnr
           WHERE b~bukrs EQ bukrs AND                  "Company Code.
               b~bupla IN bupla AND                  "Business Place.
               b~kunnr IN kunnr AND                  "CUSTOMER Code.
               b~prctr IN prctr AND                  "Profit Center.
               b~umskz IN umskz AND
               "B~UMSKZ EQ UMSKZ AND                  "Special G/L ind.
               b~shkzg EQ 'S' AND b~shkzg NE 'H' AND "Only Debit Entry (S)
               b~budat LE budat                       "Posting Date(Benchmark Date).
           AND b~kunnr EQ wa_final-kunnr
               ORDER BY a~kunnr.
         LOOP AT it_bsik_debit1 INTO wa_bsik_debit1.
           wa_bsik_debit1-detail = 'Debit (S)'.
           MODIFY it_bsik_debit1 FROM wa_bsik_debit1 TRANSPORTING detail.
         ENDLOOP.

         APPEND LINES OF it_bsik_debit1 TO it_final2.

         PERFORM interactive_report.
       ENDIF.
     WHEN 'BACK'.
       LEAVE TO SCREEN 0.
     WHEN 'EXIT'.
       LEAVE TO SCREEN 0.
     WHEN 'CLOSE'.
       CALL TRANSACTION 'SE38'.
   ENDCASE.

ENDFORM.                    "HANDLE_USER_COMMAND

6 REPLIES 6
Read only

gouravkumar64
Active Contributor
0 Likes
2,032

Hi,

DID U DECLARED ur PF Status properly & activate that?

*- Pf status
   SET PF-STATUS 'STANDARD'.

Thanks

Gourav.


Read only

0 Likes
2,032

actually it is not  clear what u want to ask?  the way i have declared is in my code that is posted.

btw the problem got solved when i commented the pf-status line in reuse_alv... FM call. Can u please explain me what is the actual meaning and use of pf-status? it would be very helpful.

Read only

0 Likes
2,030

HI,

Pf or gui stuatus is function key,gui(graphical user interface) (like back,cancel,save) to enhancing the menu,application bar functionality.

In time of PF status creation,u have to assign some key like ctrl+s for save icon.

Otherwise ur all pf icon will not work.

So hope u r trying like this.

see also in Website for details.

In this image,hope u r trying to assign the all thing.

See other's reply also,

Hope it helps.

Thanks

Gourav.

Read only

Former Member
0 Likes
2,030

Hi Ekansh,

check user command inside the pf status form. check this below code.

*&---------------------------------------------------------------------*

*&      Form  STANDARD

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_EXTAB    text

*----------------------------------------------------------------------*

FORM standard USING p_extab TYPE slis_t_extab.

*- Pf status

   SET PF-STATUS 'STANDARD'.

   CASE  p_extab-fcode.

     WHEN 'BACK'.

       LEAVE TO SCREEN 0.

     WHEN 'EXIT'.

       LEAVE TO SCREEN 0.

     WHEN 'CLOSE'.

       CALL TRANSACTION 'SE38'.

   ENDCASE.

ENDFORM.                 " STANDARD

Read only

former_member491621
Contributor
0 Likes
2,030

Hi Ekansh,

Try using

WHEN 'BACK'. 

       LEAVE LIST PROCESSING.

Also, wanted to ask if you have given proper function code for back in SE41 for back button.

Try giving a function code(eg. BACK1) and activate.(BACK must also work but did you assign it so??)

Hope this helps

Read only

gouravkumar64
Active Contributor
0 Likes
2,030

HI ekasnh,

Time of PF Status creation,assign some KEYBOARD or Shortcurt key also.

Thanks

Gourav.