sap f11labz

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  ZSR_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*REPORT  zsr_test.

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

*---------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:

Sandip Roy

Sandip Roy

Sandip is SAP ABAP consultant at Ericsson. When He is not working he can be found taking snaps @ the Himlayas

More Posts - Website

Add a Comment

HTML Snippets Powered By : XYZScripts.com