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

Capture Fcode at selection screen.

Former Member
0 Likes
3,352

hello all,

here is my problem,

i have created a report in which on one parameter i have created custom F4 Help.

code snippet:

SELECTION-SCREEN: BEGIN OF BLOCK B1.

PARAMETERS: P_EXNUM TYPE J_1IEXCHDR-EXNUM  OBLIGATORY.

SELECTION-SCREEN: END  OF BLOCK   B1.

at this parameter p_Exnum F4 help is been assigned.

"most importantly i wanted to restrict the selection so i created a

"selection screen with few parameters & select-options on it.

"selection screen is been called as a pop up window.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EXNUM.

  CALL SELECTION-SCREEN 100 STARTING AT 004 006 ENDING AT 85 014.

  BREAK PPUSER.

  IF S_WERKS[] IS INITIAL AND S_MATNR[] IS INITIAL AND

    S_KUNAG[] IS INITIAL AND S_KUNWE[] IS INITIAL AND

    P_BUDAT[] IS INITIAL AND P_EXYEAR[] IS INITIAL.

    MESSAGE 'Enter Help Parameters' TYPE 'S' DISPLAY LIKE 'E'.

    RETURN.

  ENDIF.

this is how i created the selection-screen:

SELECTION-SCREEN: BEGIN OF SCREEN 100 TITLE TEXT-004.

SELECT-OPTIONS : S_WERKS FOR J_1IEXCHDR-WERKS,

S_MATNR FOR J_1IEXCDTL-MATNR,

P_BUDAT FOR J_1IEXCHDR-EXDAT.

SELECTION-SCREEN: END OF SCREEN 100 .

what i want:

there are few buttons on selection screen. like execute, cancel(cross button), check, save(varient save buttuon).

the problem is after filling pop up selection screen, when i press execute, i debugging, sy-ucomm is empty.

i want to capture the F-Code of the buttons on selection screen and wanted to code accordingly.

say:

if user press execute : and if all selection screen parameters are initial.

"throw error msg.

endif.

plz suggest how the achieve the same.

1 ACCEPTED SOLUTION
Read only

Aashish28
Contributor
0 Likes
1,753

Hiii,

         Just put break point AT SELECTION-SCREEN. than check sy-ucomm and sy-dynnr value you will find value

CRET - Execute

NONE - Check

SPOS - Save


10 REPLIES 10
Read only

Former Member
0 Likes
1,753

You will get the value of Function code (SY-UCOMM) in the event AT SELECTION-SCREEN, where you are supposed to do the validation.  Since you are using two selection screens, you have to check the screen number (SY-DYNNR) for carrying out appropriate validation according to the screen.

Regards, Vinod

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,753

By default if you call it with CALL SELECTION SCREEN, only foru buttons gets displayed like "execute" , "variant", "Check syntax", "cancel". Try to create a function module which internally calls the selection screen, it will be better.Create separate includes for selection screen declaration and selection screen events.

After the call just check sy-subrc = 0 , then its execute button clicked.

at selection-screen on value-request for p_exnum.

  call function 'CALL_F4'

       importing

         result = it_result.

Function CALL_F4.

CALL SELECTION-SCREEN 100 STARTING AT 004 006 ENDING AT 85 014.

if sy-subrc <> 0.

MESSAGE i112 RAISING cancelled.

else.

....................................

endif.

endfunction

Read only

0 Likes
1,753

Kesav,

If I am not mistaken, OP want to capture the function code selected in the selection screen(popup) which is called from ON-VALUE request event.  I think, that is possible only from the event AT SELECTION-SCREEN.

For example, if save button is selected then SY-UCOMM will hold the value 'SPOS'.

AT SELECTION-SCREEN.

   IF sy-dynnr = '0100'.   "Selection screen in popup"

      IF sy-ucomm = 'CRET'   "Execute Button"

         ..... validations.

      ENDIF.

   ENDIF.

Regards, Vinod


Read only

0 Likes
1,753

Vinod,

You got it correct and I got it wrong ...

Read only

Aashish28
Contributor
0 Likes
1,754

Hiii,

         Just put break point AT SELECTION-SCREEN. than check sy-ucomm and sy-dynnr value you will find value

CRET - Execute

NONE - Check

SPOS - Save


Read only

Former Member
0 Likes
1,753

thats my reply to all of u.

infact its a question.

at selection-screen on value request for p_exnum.

after pressing F4 at paramter p_exnum , only the entire code in above event is calling.

as soon as system detects the end of code in the event :

at selection-screen on value request for p_exnum.

Control flow exits i.e. comes back to initial selection-screen of Report.

in short Event At selection screen is not getting triggered!

and i guess u all are saying to capture the F- Codes at this event.

for the convenience i am posting my entire code just before the event START-OF-SELECTION.

Take a look. (Actually this report finally calls a Smartform).

TABLES :J_1IEXCHDR,J_1IEXCDTL,LFA1.

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

*& Constant Decleration

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

CONSTANTS:

       C_FORMNAME    TYPE TDSFNAME VALUE 'ZSD_INVOICE_FORM_N1'.

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

*& Selection Screen "of main report (need not to pay attention)

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

SELECTION-SCREEN: BEGIN OF BLOCK B1.

PARAMETERS: P_EXNUM TYPE J_1IEXCHDR-EXNUM  OBLIGATORY,

                

             P_YEAR TYPE J_1IEXCHDR-DOCYR OBLIGATORY,

             P_PRNT  TYPE CHAR1 DEFAULT '1' NO-DISPLAY.

PARAMETERS PDF AS CHECKBOX.

SELECTION-SCREEN: END  OF BLOCK   B1.

SELECTION-SCREEN: BEGIN OF SCREEN 100 TITLE TEXT-004.

SELECT-OPTIONS : S_WERKS FOR J_1IEXCHDR-WERKS,

S_MATNR FOR J_1IEXCDTL-MATNR,

P_BUDAT FOR J_1IEXCHDR-EXDAT ,

P_EXYEAR FOR J_1IEXCHDR-EXYEAR,

S_KUNWE FOR J_1IEXCHDR-KUNWE,

S_KUNAG FOR J_1IEXCHDR-KUNAG.

SELECTION-SCREEN: END OF SCREEN 100 .

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

*& At Selection Screen

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

AT SELECTION-SCREEN." while pressing F4 this event is not getting triggered

   SELECT * UP TO 1 ROWS

       INTO TABLE LT_J_1IEXCHDR

     FROM J_1IEXCHDR

       WHERE EXNUM = P_EXNUM

*Ins By Madhur 01.04.2011

         AND EXYEAR = P_YEAR.

*End of Ins By Madhur 01.04.2011

   IF SY-SUBRC NE 0.

     MESSAGE E000(ZMSG) WITH TEXT-001.

   ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EXNUM.

"this is the point from where control flow starts after pressing F4 at P_EXNUM.

   CALL SELECTION-SCREEN 100 STARTING AT 004 006 ENDING AT 85 014.

   BREAK PPUSER.

   IF S_WERKS[] IS INITIAL AND S_MATNR[] IS INITIAL AND

     S_KUNAG[] IS INITIAL AND S_KUNWE[] IS INITIAL AND

     P_BUDAT[] IS INITIAL AND P_EXYEAR[] IS INITIAL.

     MESSAGE 'Enter Help Parameters' TYPE 'S' DISPLAY LIKE 'E'.

     RETURN.

   ENDIF.

   REFRESH IT_HELP[].

   SELECT J_1IEXCHDR~WERKS

     J_1IEXCHDR~EXNUM

     J_1IEXCHDR~EXYEAR

     J_1IEXCHDR~EXDAT

     J_1IEXCDTL~MATNR

     J_1IEXCHDR~KUNAG

     J_1IEXCHDR~KUNWE

     FROM J_1IEXCHDR

     INNER JOIN J_1IEXCDTL

     ON J_1IEXCHDR~TRNTYP EQ J_1IEXCDTL~TRNTYP

     AND J_1IEXCHDR~DOCNO EQ  J_1IEXCDTL~DOCNO

     AND J_1IEXCHDR~DOCYR EQ J_1IEXCDTL~DOCYR

*    INNER JOIN LFA1

*    ON J_1IEXCHDR~KUNAG EQ LFA1~LIFNR

*    AND J_1IEXCHDR~KUNWE EQ LFA1~LIFNR

     INTO CORRESPONDING FIELDS OF TABLE IT_HELP

     WHERE J_1IEXCHDR~EXDAT IN P_BUDAT

     AND J_1IEXCHDR~EXYEAR IN P_EXYEAR

     AND J_1IEXCHDR~WERKS IN S_WERKS

     AND KUNAG IN S_KUNAG

     AND KUNWE IN S_KUNWE.

   IF IT_HELP[] IS NOT INITIAL.

     CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

       EXPORTING

*     DDIC_STRUCTURE         = ' '

         RETFIELD               = 'P_EXNUM'

*     PVALKEY                = ' '

*     DYNPPROG               =

*     DYNPNR                 = SY-REPID

      DYNPROFIELD            = 'P_EXNUM'

*     STEPL                  = 0

      WINDOW_TITLE           = 'Search Results'

*     VALUE                  = ' '

      VALUE_ORG              = 'S'

*     MULTIPLE_CHOICE        = ' '

*     DISPLAY                = ' '

*     CALLBACK_PROGRAM       = ' '

*     CALLBACK_FORM          = ' '

*     MARK_TAB               =

*   IMPORTING

*     USER_RESET             =

       TABLES

         VALUE_TAB              = IT_HELP[]

*     FIELD_TAB              =

*     RETURN_TAB             =

*     DYNPFLD_MAPPING        =

      EXCEPTIONS

        PARAMETER_ERROR        = 1

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

   ENDIF.

"This is from where control flow exits.

i stronly want to these F-Codes at this event.

the code which is to be written is for this event only(F4 Help).

to be honest i am also in dilemma that why AT SELECTION SCREEN IS is not getting triggered?


Read only

0 Likes
1,753

AT SELECTION-SCREEN." while pressing F4 this event is not getting triggered"

It will not trigger on F4, it will trigger on "Execute" or "Enter".

Read only

0 Likes
1,753

Hiii,

AT SELECTION-SCREEN." while pressing F4 this event is not getting triggered : - Yes when you press execute or enter - at selection-screen will trigger .otherwise write code on -

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EXNUM.

Just Try this -


TABLES :J_1IEXCHDR,mara.


     SELECTION-SCREEN: BEGIN OF BLOCK B1.

     PARAMETERS: P_EXNUM TYPE J_1IEXCHDR-EXNUM  OBLIGATORY.

     SELECTION-SCREEN: END  OF BLOCK   B1.


     SELECTION-SCREEN: BEGIN OF SCREEN 100 TITLE TEXT-004.

     SELECT-OPTIONS : S_WERKS FOR J_1IEXCHDR-WERKS,

     S_MATNR FOR mara-MATNR,

     P_BUDAT FOR J_1IEXCHDR-EXDAT.

     SELECTION-SCREEN: END OF SCREEN 100 .

     AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EXNUM.

      CALL SELECTION-SCREEN 100 STARTING AT 004 006 ENDING AT 85 014.
     AT SELECTION-SCREEN.

       if sy-ucomm = 'CRET'.

       IF S_WERKS[] IS INITIAL AND S_MATNR[] IS INITIAL.

*        S_KUNAG[] IS INITIAL AND S_KUNWE[] IS INITIAL AND
*
*        P_BUDAT[] IS INITIAL AND P_EXYEAR[] IS INITIAL.

         MESSAGE 'Enter Help Parameters' TYPE 'E' .

         RETURN.

       ENDIF.

       elseif sy-ucomm = 'ONLI' .

          MESSAGE 'First Screen message' TYPE 'E' . " Write your logic here
      

      else.

          MESSAGE 'First Screen message' TYPE 'E' . " Write your logic here
      

       endif.


Read only

Former Member
0 Likes
1,753

Yes, Kesav is right.  AT-SELECTION screen will be executed only if you select the function codes CRET (Execute) & NONE (Check) in the selection screen (POPUP).  Ideally, your validations should be in AT-SELECTION SCREEN, as there any many restrictions/limitations in using MESSAGE statement in event POV.  http://help.sap.com/abapdocu_731/en/abenabap_message_dialog.htm

Only when user select close button on selection-screen (POPUP), AT-SELECTION screen event will not be triggered. For this scenario, you may have to do appropriate validations in AT SELECTION-SCREEN event of default selection screen.

Regards, Vinod

Read only

bharat_rathod2
Active Participant
0 Likes
1,753

Dear,

Please give fcode to screen PB and in screen user command save it to variable and use it to your selection screen validation part if needed use import export.