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: 

Popup function module to select some fields on popup screen

Former Member
0 Kudos

Hello Gurus,

I want a popup during my program execution. This popup should show the list of fields that I want and a check box in front of those fields. If I select those fields and click ok, then they should be selected and passed tp program as soon as funcion module finsihes execution.

Thanks.

Regards,

Rajesh.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Try this.

TABLES: t001.
DATA: t_fields  LIKE  mcs01 OCCURS 0 WITH HEADER LINE,
      t_marked_fields LIKE  mcs01 OCCURS 0 WITH HEADER LINE.

SELECT * FROM t001 UP TO 5 ROWS.
  t_fields-tabname    = 'T001'.
  t_fields-fieldname  = t001-bukrs.
  t_fields-scrtext_l  = t001-butxt.
  APPEND t_fields.
ENDSELECT.



CALL FUNCTION 'MC_POPUP_TO_MARK_FIELDS'
  EXPORTING
    i_object_name_plural   = 'Test'
    i_object_name_singular = 'Test'
  TABLES
    t_fields               = t_fields
    t_marked_fields        = t_marked_fields
  EXCEPTIONS
    unvalid_text_length    = 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.

LOOP AT t_marked_fields.
  WRITE:/  t_marked_fields-scrtext_l.
ENDLOOP.

6 REPLIES 6

Former Member
0 Kudos

Use this FM MC_POPUP_TO_MARK_FIELDS

Former Member
0 Kudos

U can use FM REUSE_ALV_POPUP_TO_SELECT

Sample code:


Report ztests. 

TYPE-POOLS SLIS. 

DATA: BEGIN OF itab OCCURS 0,
        BUKRS LIKE T001-BUKRS,
        BUTXT LIKE T001-BUTXT,
      END   OF itab. 

PARAMETERS: P_BUKRS TYPE BUKRS. 

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS. 

  PERFORM F4_FOR_BUKRS.
*&---------------------------------------------------------------------*
*&      Form  F4_FOR_BUKRS
*----------------------------------------------------------------------*
FORM F4_FOR_BUKRS. 

  DATA: IT_FIELDCAT TYPE  SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
        ES_SELFIELD TYPE  SLIS_SELFIELD. 

* Get data
  SELECT BUKRS
         BUTXT
         FROM T001
         INTO TABLE itab
         up to 10 rows .
* Get field
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            I_PROGRAM_NAME     = SY-REPID
            I_INTERNAL_TABNAME = 'ITAB'
       CHANGING
            CT_FIELDCAT        = IT_FIELDCAT[]. 

  LOOP AT IT_FIELDCAT.
    IT_FIELDCAT-KEY = SPACE.
    IF IT_FIELDCAT-FIELDNAME = 'BUTXT'.
      IT_FIELDCAT-EMPHASIZE  = 'C710'.
    ENDIF.
    IF IT_FIELDCAT-FIELDNAME = 'BUKRS'.
      IT_FIELDCAT-EMPHASIZE  = 'C610'.
    ENDIF. 

    MODIFY IT_FIELDCAT.
  ENDLOOP. 

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
 I_TITLE                       = 'THIS IS FOR F4 IN COLOR'
      I_TABNAME                     = 'ITAB'
      IT_FIELDCAT                   = IT_FIELDCAT[]
    IMPORTING
      ES_SELFIELD                   = ES_SELFIELD
    TABLES
      T_OUTTAB                      = ITAB . 

ENDFORM.                    " F4_FOR_BUKRS

Former Member
0 Kudos

Try this.

TABLES: t001.
DATA: t_fields  LIKE  mcs01 OCCURS 0 WITH HEADER LINE,
      t_marked_fields LIKE  mcs01 OCCURS 0 WITH HEADER LINE.

SELECT * FROM t001 UP TO 5 ROWS.
  t_fields-tabname    = 'T001'.
  t_fields-fieldname  = t001-bukrs.
  t_fields-scrtext_l  = t001-butxt.
  APPEND t_fields.
ENDSELECT.



CALL FUNCTION 'MC_POPUP_TO_MARK_FIELDS'
  EXPORTING
    i_object_name_plural   = 'Test'
    i_object_name_singular = 'Test'
  TABLES
    t_fields               = t_fields
    t_marked_fields        = t_marked_fields
  EXCEPTIONS
    unvalid_text_length    = 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.

LOOP AT t_marked_fields.
  WRITE:/  t_marked_fields-scrtext_l.
ENDLOOP.

0 Kudos

Thanks Amardeep. If I want all the fields on the screen to be selectd by default, what do I do, as if now none of these are selected by default.

Regards,

Rajesh

0 Kudos

Set the Parameter I_FIELDS_MARKED = 'X' for the FM MC_POPUP_TO_MARK_FIELDS.

0 Kudos

Is it possible I don't have the MC_POPUP_TO_MARK_FIELDS function module in an SRM system?