Application Development 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: 

How to get PAI triggered on date field of selection screen?

Former Member
0 Kudos

Hi Gurus,

I need to get the PAI triggered on date field of selection screen when user select date from drop down selection.

It does got triggered when user select date from drop down selection AND hit Enter or Any Key.

My requirement it to have it triggered even the user does not hit any key on keyboard, only by selecting date from DDL. As we use in Radio Button or Check Box of command USER-COMMAND.

Your help will be appreciated?

Edited by: sap_learner on Jun 5, 2008 3:14 PM

16 REPLIES 16

Former Member
0 Kudos

I just went through this same issue in this thread

There is not a solution.

0 Kudos

Hi,

maybe this FM can help you: SAPGUI_SET_FUNCTIONCODE


DATA gv_date TYPE rschavl.
* [...]
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_date.

  CALL FUNCTION 'RSEC_F4HELP_DATE'
    EXPORTING
      sy_datum = sy-datum
    CHANGING
      l_date   = gv_date.

  pa_date = gv_date(8).
  CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
    EXPORTING
      functioncode           = 'ENTR'
    EXCEPTIONS
      function_not_supported = 0
      OTHERS                 = 0.

I did not check out if this will work, but it is an idea.

Regards Rudi

0 Kudos

Rudi's suggestion worked perfectly.

I used


  CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
    EXPORTING
      functioncode           = 'ENTR'
    EXCEPTIONS
      function_not_supported = 0
      OTHERS                 = 0.

In my F4 routine as the last action.

former_member598013
Active Contributor
0 Kudos

Hi ,

I think what you need to do is select the data once the user enter the data.. Change the OK-CODE to 'ENTER' or something which is required.

Former Member
0 Kudos

Thanks for all to bring their thoughts and suggestion.

My question is not been solved yet.

The following code will explain my process.

PARAMETERS: p_date LIKE p0000-begda.

AT SELECTION-SCREEN OUTPUT.

note I try to use AT SELECTION-SCREEN ON p_date. which does not help me.

PERFORM selection_screen_output.

INITIALIZATION.

p_date = sy-datum.

If I hit the enter key it will then go into this perform (selection_screen_output) and make my other fields of selection screen populated with correct data.

I can not use this AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date. Because it will take off the option of selecting date from Drop Down Selection.

I try to use the following FM but does not get the desired result.

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'

EXPORTING

functioncode = 'ENTR'

EXCEPTIONS

function_not_supported = 0

OTHERS = 0.

0 Kudos

How did you create the DDL for date?

0 Kudos

It is not Drop Down List, it is selecting date from the Drop Down selection which you get by defining the parameter like I did in my code.

0 Kudos

Only other thing I can think of is to hide all field except the date field.

You would also need to EXCLUDE the F8/PROCESS from the PFSTATUS.

The user would be forced to hit enter to continue where you would, in your AT SELECTION-SCREEN OUTPUT, open them up and not exclude the F8/PROCESS.

After you produce the output, and the user hits F3/BACK to continue, reset some switch to again hide all fields except the date again.

0 Kudos

Hi,

as I understand you want to select a date from the date popup and after that other selection-screen fields will be filled automatically. Is this right? If so than you can use the solution mentioned above. Otherwise please go more into details.

Usually the AT SELECTION-SCREEN ON field statement is for varifying and validating entered values. From my point of view it is not a good idea to select further data.

1. the user press F4 for date

2. the ON VALUE-REQUEST will be processed

3. FM SAPGUI_SET_FUNCTIONCODE will raise a fcode

4. Selection-Screen processing will go on into AT SELECTION-SCREEN (ON)

5. in SELECTION-SCREEN OUTPUT you can select further data and pass it to the fields

I think you can not declare any other fields as obligatory. But this can also be checked in AT SELECTION-SCREEN or in START-OF-SELECTION.

Regards Rudi

0 Kudos

Hi Rudi,

What you have written in first paragraph is exactly what I want to do.

I eliminate the unnecessary stuff to cut down the size of program for better understanding.

If you or any one else think they have solution for it let me know?

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

REPORT z_test_1 NO STANDARD PAGE HEADING.

*I N F O T Y P E S

INFOTYPES: 0000, 0001, 0002, 0006, 0656, 9003.

*D A T A

DATA:i_t549q TYPE t549q,

t_vabrp TYPE t549q-vabrp,

t_vabrj TYPE t549q-vabrj.

  • P A R A M E T E R S

SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME TITLE text-004.

PARAMETERS: p_date LIKE p0000-begda.

SELECTION-SCREEN END OF BLOCK main.

SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.

PARAMETERS: p_abkrs LIKE pernr-abkrs DEFAULT 'Z1' NO-DISPLAY,

p_vabrp LIKE t549q-vabrp,

p_pabrj LIKE t549q-pabrj,

p_begda LIKE t549q-begda,

p_endda LIKE t549q-begda.

SELECTION-SCREEN END OF BLOCK 001.

SELECTION-SCREEN BEGIN OF BLOCK 003 WITH FRAME TITLE text-003.

SELECTION-SCREEN COMMENT /2(65) text-c04.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETER: p_proxy AS CHECKBOX DEFAULT 'X' USER-COMMAND trig.

SELECTION-SCREEN COMMENT 4(48) text-s50 FOR FIELD p_proxy.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK 003.

  • INITIALIZATION EVENT

INITIALIZATION.

p_date = sy-datum.

  • A T S E L E C T I O N S C R E E N

AT SELECTION-SCREEN ON p_date.

*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date.

PERFORM selection_screen_output.

AT SELECTION-SCREEN OUTPUT.

PERFORM selection_screen_output.

  • S T A R T O F S E L E C T I O N

START-OF-SELECTION.

WRITE: i_t549q-permo, i_t549q-pabrp, i_t549q-vabrj ,i_t549q-vabrp.

END-OF-SELECTION.

FORM selection_screen_output.

CLEAR: i_t549q, t_vabrp, t_vabrj.

  • Get previous Payroll Period from todays date or date entered by user

SELECT SINGLE vabrp vabrj FROM t549q INTO

(t_vabrp,t_vabrj)

WHERE permo EQ '95' AND

begda LE p_date AND

endda GE p_date.

  • Get begin and end date for previous Payroll Period.

SELECT SINGLE * FROM t549q INTO

i_t549q WHERE permo EQ '95' AND

pabrp EQ t_vabrp AND

pabrj EQ t_vabrj.

p_vabrp = i_t549q-pabrp.

p_pabrj = i_t549q-pabrj.

p_begda = i_t549q-begda.

p_endda = i_t549q-endda.

LOOP AT SCREEN.

IF screen-name = '%_P_DATE_%_APP_%-TEXT'

or screen-name = 'P_ABKRS'

or screen-name = 'P_VABRP'

or screen-name = 'P_PABRJ'

or screen-name = 'P_BEGDA'

or screen-name = 'P_ENDDA'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " selection_screen_output

0 Kudos

Ok... I've found a solution.

First let me tell you how I did this so that you can verify information on your side.

Before any modifications were made to the code you sent, I ran it. Once the selection screen was up, I use "/H" to put me in debug mode. I hit the matchcode button for the date and found that it was simply calling the FM HELP_START. In another screen I used SE37 to open that FM to find out what paramaters were needed. The important infomation is sent in a structure called HELP_INFOS that used the structure HELP_INFO. Back to the debug screen, I used the Table button with the name HELP_INFOS and it listed all the values that were passed to the FM. I created code that built this structure and then imbeded this and other paramaters in your code under an AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date..

All of the parameters I could provide with 2 exceptions; curow and cucol, but in the display of the structure, they contained 3 and 35 respectivily. The FM documentation explained these as Column and Row having to do with something when it returned. I left these values in my structure to pass, and everything worked ok. I never tried changing the values nor the position of the date field on the screen. If you have issues with my code working, this may be the issue.

Anyway, here's the code and this is ALL that I modified/added to your code (other then commenting out the INFOTYPES line).


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_date.
  DATA:    help_infos LIKE help_info,
           selection  TYPE c,
           select_value TYPE text132.
  DATA:    dselc TYPE dselc,
           dynpselect LIKE STANDARD TABLE OF dselc,
           dval  TYPE dval,
           dynpvaluetab LIKE STANDARD TABLE OF dval.

  help_infos-call         = 'V'.
  help_infos-object       = 'F'.
  help_infos-program      = 'RSSYSTDB'.
  help_infos-dynpro       = '1000'.
  help_infos-tabname      = 'P0000'.
  help_infos-fieldname    = 'BEGDA'.
  help_infos-fieldtype    = 'DATE'.
*  help_infos-KEYWORD      = *Skip
  help_infos-fieldlng     = '10'.
  help_infos-fldvalue     = p_date.
* help_infos-MCOBJ         = *Skip
  help_infos-spras        = sy-langu.
  help_infos-menufunct    = 'HC'.
*  help_infos-MESSAGEID    = *Skip
*  help_infos-MESSAGENR    = *Skip
*  help_infos-MESSAGE      = *Skip
  help_infos-title         = sy-repid.
  help_infos-dynprofld     = 'P_DATE'.
*  help_infos-DYNPROFLAG    = *Skip
*  help_infos-CHECKTABLE    = *Skip
*  help_infos-CHECKFIELD    = *Skip
*  help_infos-VALEXIST      = *Skip
  help_infos-tcode         = sy-tcode.
  help_infos-pfkey         = '%_00'.
*  help_infos-DOCUKEY       = *Skip
  help_infos-report        = sy-repid.
  help_infos-docuid        = 'FE'.
*  help_infos-DOCUOBJECT    = *Skip
*  help_infos-HEADERTEXT    = *Skip
*  help_infos-F1SYSHEL      = *Skip
*  help_infos-MSGV1         = *Skip
*  help_infos-MSGV2         = *Skip
*  help_infos-MSGV3         = *Skip
*  help_infos-MSGV4         = *Skip
*  help_infos-SHOW          = *Skip
  help_infos-pov           = 'V'.
  help_infos-curow         = '3'.
  help_infos-cucol         = '35'.
  help_infos-sy_dyn        = 'S'.
  help_infos-dynpprog      = sy-repid.
  help_infos-stepl         = '0'.
*  help_infos-SELECTART = *Skip

  CALL FUNCTION 'HELP_START'
    EXPORTING
      help_infos = help_infos
    IMPORTING
      selection          = selection
      select_value       = select_value
*      RSMDY_RET          =
    TABLES
      dynpselect         = dynpselect
      dynpvaluetab       = dynpvaluetab.

  IF selection = 'X'.
    p_date+0(4) = select_value+6(4).
    p_date+4(2) = select_value+0(2).
    p_date+6(2) = select_value+3(2).
    CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
         EXPORTING
              functioncode           = 'ENTR'
         EXCEPTIONS
              function_not_supported = 0
              OTHERS                 = 0.
  ENDIF.

0 Kudos

Hi Paul,

the only difference I see to my posting above is, that you check if the user selected a date. If so then you will raise the FCODE, otherwise you will not raise the FCODE. Can you tell me were the benefit is when using your suggestion instead of mine, please? Cause I don't see it.

Regards

Rudi

0 Kudos

Only issue I had after applying your concept was the Calendar help did not pop up.

I had to find a way to initiate it, therefore the addition of the CALL FUNCTION 'HELP_START'

only change I made to your suggestion

0 Kudos

Hello Paul,

As I tested the example the calendar popup worked well.... And if not, there are several other F4 date FM (i.e. F4_DATE). I think it could be easier to use such a FM instead of building up complicated structures. But maybe this is just my point of view

Regards Rudi

0 Kudos

LOL.. point of view perhaps.. more likely.. I was unaware of the other functions available.

Also could be SAP version. We're still on 4.6c here.

in fact.. I just looked for FM 'RSEC_F4HELP_DATE'. Nor do we have F4_DATE

we don't have it in 4.6c

Edited by: Paul Chapman on Jun 6, 2008 10:55 AM

0 Kudos

Sorry, I didn't check if RSEC_F4HELP_DATE is available in lower versions. F4_DATE is available in our 4.6C. It is part of development class SZC - R/3 central Basis development: Factory calendar. Or is this part of a special industry solution e.g. DI ?

Regards Rudi