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

Popup to modify fields

Former Member
0 Likes
2,180

Currently in the selection screen there is a select-option for date that user can enter values in.

Now i am using a function module POPUP_GET_VALUES_USER_CHECKED to dynamically build a popup to allow user to enter new "from" and "to" dates that will modify the same date field so that the records will be reflected in the alv. They will have to be 2 separate fields for input in the popup (not a select-option).

How do i achieve this?

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,134

Hello Jason

Have a look at the sample report <b>ZUS_SDN_POPUP_GET_VAL_USER_CHK</b>. I think it should be quite easy to adapt this for your ALV list. Of course you have to do a somewhat more elaborate error handling.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_POPUP_GET_VAL_USER_CHK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_popup_get_val_user_chk.


TABLES:  knb1.

DATA:
  gd_repid    TYPE syst-repid,
  gt_fields   TYPE STANDARD TABLE OF sval,
  gs_field    TYPE sval.


SELECT-OPTIONS:
  o_erdat    FOR knb1-erdat  DEFAULT '20070101' TO '20070331'
                             OPTION bt
                             SIGN   i.

START-OF-SELECTION.

  REFRESH: gt_fields.

  CLEAR: gs_field.
  gs_field-tabname   = 'PA0000'.
  gs_field-fieldname = 'BEGDA'.
  gs_field-value     = o_erdat-low.
  APPEND gs_field TO gt_fields.
*
  CLEAR: gs_field.
  gs_field-tabname   = 'PA0000'.
  gs_field-fieldname = 'ENDDA'.
  gs_field-value     = o_erdat-high.
  APPEND gs_field TO gt_fields.


  gd_repid = syst-repid.
  CALL FUNCTION 'POPUP_GET_VALUES_USER_CHECKED'
    EXPORTING
      formname                        = 'GET_NEW_DATE'
      popup_title                     = 'Change Date Range'
      programname                     = gd_repid
*     START_COLUMN                    = '5'
*     START_ROW                       = '5'
*     NO_CHECK_FOR_FIXED_VALUES       = ' '
*   IMPORTING
*     RETURNCODE                      =
    TABLES
      fields                          = gt_fields
    EXCEPTIONS
      error_in_fields                 = 1
      OTHERS                          = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  READ TABLE gt_fields INTO gs_field
       WITH KEY fieldname = 'BEGDA'.
  o_erdat-low = gs_field-value.

  READ TABLE gt_fields INTO gs_field
       WITH KEY fieldname = 'ENDDA'.
  o_erdat-high = gs_field-value.

  write: / 'New Range =',
           o_erdat-low  DD/MM/YYYY,
           'to',
           o_erdat-high DD/MM/YYYY.

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  get_new_date
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_new_date TABLES   ut_fields   STRUCTURE sval
                    CHANGING cs_error  STRUCTURE svale.
* define local data
  DATA:
    ls_field_low    TYPE sval,
    ls_field_high   TYPE sval.

  READ TABLE ut_fields INTO ls_field_low
       WITH KEY fieldname = 'BEGDA'.
  READ TABLE ut_fields INTO ls_field_high
       WITH KEY fieldname = 'ENDDA'.

  IF ( ls_field_low-value  IS INITIAL   OR
       ls_field_high-value IS INITIAL ).
  ELSE.
    IF ( ls_field_low-value > ls_field_high-value ).
      MESSAGE 'Begin date > End date' TYPE 'I'.
    ENDIF.
  ENDIF.

ENDFORM.                    "get_new_date

Regards

Uwe

2 REPLIES 2
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,135

Hello Jason

Have a look at the sample report <b>ZUS_SDN_POPUP_GET_VAL_USER_CHK</b>. I think it should be quite easy to adapt this for your ALV list. Of course you have to do a somewhat more elaborate error handling.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_POPUP_GET_VAL_USER_CHK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_popup_get_val_user_chk.


TABLES:  knb1.

DATA:
  gd_repid    TYPE syst-repid,
  gt_fields   TYPE STANDARD TABLE OF sval,
  gs_field    TYPE sval.


SELECT-OPTIONS:
  o_erdat    FOR knb1-erdat  DEFAULT '20070101' TO '20070331'
                             OPTION bt
                             SIGN   i.

START-OF-SELECTION.

  REFRESH: gt_fields.

  CLEAR: gs_field.
  gs_field-tabname   = 'PA0000'.
  gs_field-fieldname = 'BEGDA'.
  gs_field-value     = o_erdat-low.
  APPEND gs_field TO gt_fields.
*
  CLEAR: gs_field.
  gs_field-tabname   = 'PA0000'.
  gs_field-fieldname = 'ENDDA'.
  gs_field-value     = o_erdat-high.
  APPEND gs_field TO gt_fields.


  gd_repid = syst-repid.
  CALL FUNCTION 'POPUP_GET_VALUES_USER_CHECKED'
    EXPORTING
      formname                        = 'GET_NEW_DATE'
      popup_title                     = 'Change Date Range'
      programname                     = gd_repid
*     START_COLUMN                    = '5'
*     START_ROW                       = '5'
*     NO_CHECK_FOR_FIXED_VALUES       = ' '
*   IMPORTING
*     RETURNCODE                      =
    TABLES
      fields                          = gt_fields
    EXCEPTIONS
      error_in_fields                 = 1
      OTHERS                          = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  READ TABLE gt_fields INTO gs_field
       WITH KEY fieldname = 'BEGDA'.
  o_erdat-low = gs_field-value.

  READ TABLE gt_fields INTO gs_field
       WITH KEY fieldname = 'ENDDA'.
  o_erdat-high = gs_field-value.

  write: / 'New Range =',
           o_erdat-low  DD/MM/YYYY,
           'to',
           o_erdat-high DD/MM/YYYY.

END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  get_new_date
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM get_new_date TABLES   ut_fields   STRUCTURE sval
                    CHANGING cs_error  STRUCTURE svale.
* define local data
  DATA:
    ls_field_low    TYPE sval,
    ls_field_high   TYPE sval.

  READ TABLE ut_fields INTO ls_field_low
       WITH KEY fieldname = 'BEGDA'.
  READ TABLE ut_fields INTO ls_field_high
       WITH KEY fieldname = 'ENDDA'.

  IF ( ls_field_low-value  IS INITIAL   OR
       ls_field_high-value IS INITIAL ).
  ELSE.
    IF ( ls_field_low-value > ls_field_high-value ).
      MESSAGE 'Begin date > End date' TYPE 'I'.
    ENDIF.
  ENDIF.

ENDFORM.                    "get_new_date

Regards

Uwe

Read only

0 Likes
1,134

Thanks Uwe. That solution is exactly what i was looking for.