SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software




F4 Search Help on Screen Painter Date Element


Assign Search Help for Date Field on Screen Painter

The easiest method to assign search help for date type fields on Screen Painter is using the standard search help BU_DATE_CHAR (Search Help for Date in Character Format)

Double click on the screen to launch Screen Painter. When screen elements are displayed on Element list tab, switch to References titled sub-tab as seen in below screenshot.

ABAP

Enter the BU_DATE_CHAR search help name as the Search Help attribute of the related date element in its References tab


Call F4_Date Function Module on Value-Request Process

An other method for displaying calendar search help for date elements on a Dynpro screen for ABAP programs is using F4_Date function module. This method requires some coding in ABAP but can also be used as an alternative to assigning BU_DATE_CHAR elemantary search help.

Here is the Layout view of a sample Dynpro screen with some elements as well as two date input elements for VBAK-ERDAT field. One field will be used for the minimum date and the other date element will be used for the maximum date for filtering sales orders using the date range object.

ABAP

When I clicked on the date elements, you will see I named first one as S_ERDAT_LOW.
In Attributes section, I set format as DATS
The second date field is configured similar.

ABAP

I defined the below data types in the TOP include of the ABAP program where I defined all global variables of the report.

DATA: s_erdat TYPE RANGE OF vbak-erdat,
 rs_erdat LIKE LINE OF s_erdat,
 s_erdat_low TYPE vbak-erdat,
 s_erdat_high TYPE vbak-erdat.

ABAP

And in the Flow Logic of the ABAP program screen, I added below code fragment.

PROCESS ON VALUE-REQUEST.
 FIELD s_erdat_low MODULE f4_date_low.
 FIELD s_erdat_high MODULE f4_date_high.

ABAP

Here is the source codes of the ABAP module f4_date_low. The second module is similar to this one but for the s_erdat_high date element.

MODULE f4_date_low INPUT.

CALL FUNCTION 'F4_DATE'
 EXPORTING
  date_for_first_month = s_erdat_low
  display = ' '
* FACTORY_CALENDAR_ID = ' '
* GREGORIAN_CALENDAR_FLAG = ' '
* HOLIDAY_CALENDAR_ID = ' '
* PROGNAME_FOR_FIRST_MONTH = ' '
* DATE_POSITION = ' '
 IMPORTING
  select_date = s_erdat_low
* SELECT_WEEK =
* SELECT_WEEK_BEGIN =
* SELECT_WEEK_END =
 EXCEPTIONS
* CALENDAR_BUFFER_NOT_LOADABLE = 1
* DATE_AFTER_RANGE = 2
* DATE_BEFORE_RANGE = 3
* DATE_INVALID = 4
* FACTORY_CALENDAR_NOT_FOUND = 5
* HOLIDAY_CALENDAR_NOT_FOUND = 6
* PARAMETER_CONFLICT = 7
  OTHERS = 8.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

ENDMODULE.

ABAP

Now ABAP programmer can activate all ABAP codes and run the report.
When you click on one of the date controls and press F4 for search help, following calendar will be displayed to pick a date.

ABAP

Later in the "process after input", I use below ABAP code to build the date range object to use in data selection for filtering sales orders.

REFRESH s_erdat.
CLEAR rs_erdat.
IF s_erdat_low IS NOT INITIAL OR s_erdat_high IS NOT INITIAL.
 rs_erdat-sign = 'I'.
 IF s_erdat_low IS INITIAL OR s_erdat_high IS INITIAL.
  rs_erdat-option = 'EQ'.
  IF s_erdat_low IS INITIAL.
   rs_erdat-low = s_erdat_high.
  ELSE.
   rs_erdat-low = s_erdat_low.
  ENDIF.
 ELSE.
  rs_erdat-sign = 'I'.
  rs_erdat-option = 'BT'.
  rs_erdat-low = s_erdat_low.
  rs_erdat-high = s_erdat_high.
 ENDIF.
 APPEND rs_erdat TO s_erdat.
ENDIF.





SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table








Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems