Thursday, May 9, 2013

F4 Help for Parameter and Select Option

Here is a Program which defines the F4 help on Selection Screen. On the screen there are two fields 1. Company Code and 2. Project Definition. Here the company code is the Parameter and the project definition is the Select Option. In this program there is no manual entry. Every input will be given by using F4 help. 

The company codes will be coming uniquely by using F4 help. In database one company code contains lot of Projects. Hence unique company code is necessary while pressing the F4 button.

Then the Project Definition Low field will also have to be selected by using F4 help. Here in the value table all project definition will not come. Only the projects which are under selected company code will come for the Low field. Other projects will not come in value table. Similarly the High field will have to be selected by using F4 help. High filed will show the value table data which are greater than the low field and under that selected company. Other projects will not come on this value table. 


REPORT  zabap_gui1.

*---------PROJ & PRPS Tables Declaration-------------------------------*
*----------------------------------------------------------------------*
TABLES: proj, prps.

*---------Structure Declaration for different Internal Tables----------*
*----------------------------------------------------------------------*
TYPES:
       "Structure to create F4 Help for Company Code
       BEGIN OF ty_vbukr,
        vbukr TYPE proj-vbukr, "Company code
       END OF ty_vbukr,

       "Structure to create F4 Help for Project definition
       BEGIN OF ty_pspid,
        pspid TYPE proj-pspid, "Project definition
       END OF ty_pspid.

DATA:
      "Internal Tables of Value Table for F4 Help
      it_vbukr   TYPE STANDARD TABLE OF ty_vbukr,
      it_pspid   TYPE STANDARD TABLE OF ty_pspid,
      it_pspid1  TYPE STANDARD TABLE OF ty_pspid,

      "Internal Tables of Return Table for F4 Help
      wa_return1 TYPE ddshretval,
      wa_return2 TYPE ddshretval,
      wa_return3 TYPE ddshretval,
      it_return1 TYPE STANDARD TABLE OF ddshretval,
      it_return2 TYPE STANDARD TABLE OF ddshretval,
      it_return3 TYPE STANDARD TABLE OF ddshretval.

CONSTANTS:
           "Constants for F4IF_INT_TABLE_VALUE_REQUEST
           c_vbukr     TYPE dfies-fieldname VALUE 'P_VBUKR',
           c_pspid_l   TYPE dfies-fieldname VALUE 'P_PSPID-LOW',
           c_pspid_h   TYPE dfies-fieldname VALUE 'P_PSPID-HIGH',
           c_vorg      TYPE char1  VALUE 'S'.

*---------SELECTION SCREEN---------------------------------------------*
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_vbukr LIKE proj-vbukr.
SELECT-OPTIONS s_pspid FOR proj-pspid.
SELECTION-SCREEN END OF BLOCK b1.

*---------AT SELECTION-SCREEN ON VALUE-REQUEST for COMPANY CODE--------*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vbukr.
  SELECT DISTINCT vbukr FROM proj INTO TABLE it_vbukr.
  IF sy-subrc = 0.
    SORT it_vbukr BY vbukr.
  ENDIF.

  "Function Module to create F4 help
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = c_vbukr
      value_org       = c_vorg
    TABLES
      value_tab       = it_vbukr
      return_tab      = it_return1
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.

  IF it_return1 IS NOT INITIAL.
    LOOP AT it_return1 INTO wa_return1.
      p_vbukr = wa_return1-fieldval.
    ENDLOOP.
    SELECT pspid FROM proj INTO TABLE it_pspid
    WHERE vbukr = p_vbukr.
    IF sy-subrc = 0.
      SORT it_pspid BY pspid.
    ENDIF.
  ENDIF.

*-----AT SELECTION-SCREEN ON VALUE-REQUEST for PROJECT DEFINITION------*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pspid-low.

  "Function Module to create F4 help
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = c_pspid_l
      value_org       = c_vorg
    TABLES
      value_tab       = it_pspid
      return_tab      = it_return2
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.

  IF it_return2 IS NOT INITIAL.
    LOOP AT it_return2 INTO wa_return2.
      s_pspid-low = wa_return2-fieldval.
    ENDLOOP.
    SELECT pspid FROM proj INTO TABLE it_pspid1
      WHERE pspid GT s_pspid-low
        AND vbukr = p_vbukr.
    IF sy-subrc = 0.
      SORT it_pspid1 BY pspid.
    ENDIF.
  ENDIF.

*-----AT SELECTION-SCREEN ON VALUE-REQUEST for PROJECT DEFINITION------*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pspid-high.

  "Function Module to create F4 help
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = c_pspid_h
      value_org       = c_vorg
    TABLES
      value_tab       = it_pspid1
      return_tab      = it_return3
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.

  IF it_return3 IS NOT INITIAL.
    LOOP AT it_return3 INTO wa_return3.
      s_pspid-high = wa_return3-fieldval.
    ENDLOOP.
  ENDIF.


Below is the Output:

1. Selection Screen:




2. F4 on Company Code:




3. F4 on Project Definition Low Field (All projects are coming from company 0142): Total 2598 Entries




4. F4 on Project Definition High Field (All projects will be Greater than Low field with company 0142): Total 2589 Entries



5. Finally Data have been Selected:



13 comments:

yektek training said...

good post really thanks

Bhavya Kumar said...

Best blog.Got to learn new things.Thanks for this Blog SAP Success Factors Training in Chennai

Shalini said...


Hi, This is shalini from Chennai learned SAP Training in Chennai from mr.karthick. The training really was good and i got selected in leading mnc company as SAP Consultant.

You can contact 8122241286 for Best SAP Training in Chennai or reach www.thecreatingexperts.com

sushma said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

sanayamohit said...

Best SAP Success Factor Training in Chennai

http://thecreatingexperts.com/sap-training-in-chennai/
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
http://thecreatingexperts.com/sap-mm-training-in-chennai/
http://thecreatingexperts.com/sap-fico-training-in-chennai/

Priya Kannan said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Unknown said...


Best SAP MM Material Managemnt Real time hands on Training in chennai

http://thecreatingexperts.com/sap-mm-training-in-chennai/

Priyasekar said...

Thanks for your info...Here THE CREATING EXPERTS provide hands on training with real time scenarios

http://thecreatingexperts.com/sap-abap-training-in-chennai/

contact +91-08122241286

Dragos Ionita said...

HI there,

Thank you for this post.I followed your instructions but there is a problem. After i put a value in first parameter ,then i can see the correct list in the select-options. The issue is that my program is continuously loading and doesn`t do anything else. Please see below my code:

Dear Bertrand ,

I did as you advised me and i thank you for this . When i put a value in s_klart , after i can see in s_atinn the list accordingly to what i put in s_klart,which is good.The problem is that immediatly after my report gets blocked,enters in a sort of loop ,it countinuously loading without being able do anything else. Please find below my code:

"Internal Tables of Return Table for F4 Help

wa_return1 TYPE ddshretval,

wa_return2 TYPE ddshretval,

wa_return3 TYPE ddshretval,

it_return1 TYPE STANDARD TABLE OF ddshretval,

it_return2 TYPE STANDARD TABLE OF ddshretval,

it_return3 TYPE STANDARD TABLE OF ddshretval.



CONSTANTS:

"Constants for F4IF_INT_TABLE_VALUE_REQUEST

c_klart TYPE dfies-fieldname VALUE 'S_KLART',

c_pspid_l TYPE dfies-fieldname VALUE 'P_PSPID-LOW',

c_pspid_h TYPE dfies-fieldname VALUE 'P_PSPID-HIGH',

c_vorg TYPE char1 VALUE 'S'.





* ALV data declarations

data: it_sortcat type slis_sortinfo_alv occurs 1,

wa_sort like line of it_sortcat.



DATA: it_filter TYPE slis_t_filter_alv.

Data: ls_filter TYPE slis_filter_alv.



*selection screen

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

PARAMETERS: s_klart LIKE klah-klart. "Tip clasa ,SELECT-OPTIONS: s_klart FOR klah-klart NO INTERVALS NO-EXTENSION.

SELECT-OPTIONS :s_class FOR klah-class OBLIGATORY MATCHCODE OBJECT clas DEFAULT 'Z_MEDIU'."Nume clasa NO INTERVALS NO-EXTENSION



SELECT-OPTIONS: s_matkl FOR mara-matkl. "Grup Material

SELECT-OPTIONS: s_mtart FOR t134t-mtart. "NO INTERVALS NO-EXTENSION DEFAULT '3010'. "Grup Material

SELECT-OPTIONS: s_matnr FOR mara-matnr." NO INTERVALS NO-EXTENSION. "Numar Material

SELECT-OPTIONS: s_atinn FOR cabn-atinn NO INTERVALS NO-EXTENSION. "Caracteristici

SELECTION-SCREEN END OF BLOCK b1.







*SELECTION-SCREEN SKIP 1.



*START-OF-SELECTION.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_klart.

SELECT DISTINCT class klart FROM klah INTO TABLE i_class1.

IF sy-subrc = 0.

SORT i_class1 BY klart.

ENDIF.



"Function Module to create F4 help

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = c_klart

value_org = c_vorg

TABLES

value_tab = i_class1

return_tab = it_return1

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.



IF it_return1 IS NOT INITIAL.

LOOP AT it_return1 INTO wa_return1.

s_klart = wa_return1-fieldval.

ENDLOOP.

SELECT imerk clint klart FROM ksml INTO TABLE i_ksml

WHERE klart = s_klart.

IF sy-subrc = 0.

SORT i_ksml BY imerk.

ENDIF.

ENDIF.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_atinn-low.



"Function Module to create F4 help

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = c_pspid_l

value_org = c_vorg

TABLES

value_tab = i_ksml

return_tab = it_return2

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.



IF it_return2 IS NOT INITIAL.

LOOP AT it_return2 INTO wa_return2.

s_atinn-low = wa_return2-fieldval.

ENDLOOP.

SELECT imerk clint klart FROM ksml INTO TABLE i_ksml

WHERE imerk GT s_atinn-low

AND klart = s_klart.

IF sy-subrc = 0.

SORT i_ksml BY imerk.

ENDIF.

ENDIF.

ragu varan said...

Best SAP HANA Training in Chennai by leading HANA Consultant.
Reach at 9003085882
http://thecreatingexperts.com/category/sap-hana-training-in-chennai/

gilledashivani said...

Great information. the information provided is of great use as i got to learn new things. If you are looking for real time training in SAP ABAP, kindly contact sieve software
Sieve software offers real time training by industry experts with live projects and placement support.
SAP ABAP TRAINING IN HYDERABAD

calfre services said...

wow really superb you had posted one nice information through this. Definitely it will be useful for many people. So please keep update like this.

sap hr abap classes