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

FREE_SELECTIONS_DIALOG with Field names

mucsiattila
Explorer
0 Kudos
393

Hi!

I have a program I have to modify. The program uses FM 'FREE_SELECTIONS_INIT' and FM 'FREE_SELECTIONS_DIALOG' to display the fields of the previously given SAP table (eg. ERDK), to add select options for filtering data.

I have to add field names near the field labels as shown on the image below, but I cant figure out how.
Can you help me please?

 FREE_SELECTIONS_DIALOG.jpg

In this case:
GT_ROWTAB-PRIM_TAB = 'ERDK'
GT_FREE is initial
GV_SELID = 'DS000001'

TYPES: BEGIN OF ty_free_selection,
        expr    TYPE rsds_texpr,
        where   TYPE rsds_twhere,
        fields  TYPE rsdsfields_t,
        field_r TYPE rsds_trange,
       END OF   ty_free_selection.

DATA: gt_rowtab TYPE rsdstabs_t.
DATA: gt_free   TYPE ty_free_selection. 
DATA: gv_selid  TYPE dynselid.

  CALL FUNCTION 'FREE_SELECTIONS_INIT'
    EXPORTING
      kind                  = 'T'
      expressions           = gt_free-expr
    IMPORTING
      selection_id          = gv_selid
      where_clauses         = gt_free-where
      expressions           = gt_free-expr
      field_ranges          = gt_free-field_r
    TABLES
      tables_tab            = gt_rowtab
      fields_tab            = gt_free-fields.

  CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
    EXPORTING
      selection_id  = gv_selid
      as_window     = 'X'
      start_row     = 3
      start_col     = 8
    IMPORTING
      where_clauses = gt_free-where
      expressions   = gt_free-expr
      field_ranges  = gt_free-field_r
    TABLES
      fields_tab    = gt_free-fields.  
5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
0 Kudos
348

Look at the documentation. It says to use FIELD_TEXTS.

Read only

0 Kudos
270

Thank you for the answer!
I tried to use FIELD_TEXTS filled it with data, but I cant use it in FM FREE_SELECTIONS_DIALOG. There is no parameter for it.

DATA: gs_field_texts TYPE rsdstexts,
			gt_field_texts TYPE TABLE OF rsdstexts.

LOOP AT gt_rowtab INTO gs_rowtab.
	SELECT  dd03l~tabname
					dd03l~fieldname
					dd04t~scrtext_m
		INTO  gs_field_texts
		FROM  dd03l
		INNER JOIN dd04t
			ON  dd03l~rollname    =   dd04t~rollname
			AND dd04t~ddlanguage  =   sy-langu
			AND dd04t~as4local    =   'A'
		WHERE dd03l~tabname     =   gs_rowtab-prim_tab
			AND dd03l~as4local    =   'A'
			AND dd03l~fieldname   <> 'MANDT'.
		APPEND gs_field_texts TO gt_field_texts.
	ENDSELECT.
ENDLOOP.

CALL FUNCTION 'FREE_SELECTIONS_INIT'
	EXPORTING
		kind          = 'T'
		expressions   = gt_free-expr
	IMPORTING
		selection_id  = gv_selid
		where_clauses = gt_free-where
		expressions   = gt_free-expr
		field_ranges  = gt_free-field_r
	TABLES
		tables_tab    = gt_rowtab
		fields_tab    = gt_free-fields
		field_texts   = gt_field_texts.

Pattern for dialog on my system:

CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
  EXPORTING
    selection_id                  = 
*   TITLE                         = ' '
*   FRAME_TEXT                    = ' '
*   STATUS                        =
*   AS_WINDOW                     = ' '
*   START_ROW                     = 2
*   START_COL                     = 2
*   NO_INTERVALS                  = ' '
*   JUST_DISPLAY                  = ' '
*   PFKEY                         =
*   ALV                           = ' '
*   TREE_VISIBLE                  = 'X'
*   DIAG_TEXT_1                   =
*   DIAG_TEXT_2                   =
*   WARNING_TITLE                 =
*   AS_SUBSCREEN                  = ' '
*   NO_FRAME                      =
* IMPORTING
*   WHERE_CLAUSES                 =
*   EXPRESSIONS                   =
*   FIELD_RANGES                  =
*   NUMBER_OF_ACTIVE_FIELDS       =
  TABLES
    fields_tab                    =
*   FCODE_TAB                     =
*   FIELDS_NOT_SELECTED           =
* EXCEPTIONS
*   INTERNAL_ERROR                = 1
*   NO_ACTION                     = 2
*   SELID_NOT_FOUND               = 3
*   ILLEGAL_STATUS                = 4
*   OTHERS                        = 5
          .
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 only

0 Kudos
254

It's the one in FREE_SELECTIONS_INIT.

Read only

0 Kudos
163

Thanks I have a small step foreward.

I modified gs_field_texts-text in the select, before FREE_SELECTIONS_INIT.
I checked it in debug mode, and it was okay, but in display it stayed default in the red (tree) area, and changed only in the slect options section marked with yellow. ☹️

CONCATENATE gs_field_texts-text '(' gs_field_texts-fieldname ')' INTO gs_field_texts-text.
APPEND gs_field_texts TO gt_field_texts.

mucsiattila_0-1749543228152.png

mucsiattila_1-1749543543890.png

 

Read only

138

As there's no other solution proposed in the documentation, I guess it's a limit of the tool...