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: 

Populate description in seacrh help

Former Member
0 Kudos

Hi All,

I have a requirement wherein i have 2 parameter fields on the selection screen, Matnr and Maktx.

Both these fields have search help attached to it.

I have to select a value through a search help for Matnr field, which i have completed.

Now in the secrh help of Maktx i should get the Matnr value selected and its corresponding Desciption only. The search help of Maktx should not show any other values and descriptions at all except for the Value selected in Matnr.

The Database table and the search help used is of Z type.

How do i go about doing this? I am posting how much of the code i have written.

******Data Declaration

DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.

******Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE text-000.

PARAMETERS: v_matnr TYPE matnr.

PARAMETERS: v_maktx TYPE maktx.

SELECTION-SCREEN END OF BLOCK block0.

******At Selection-screen on value-request.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_matnr.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

tabname = 'ZMAT_DESC'

fieldname = 'MATNR'

searchhelp = 'ZDESC1'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'V_MATNR'

callback_program = sy-repid

TABLES

return_tab = return

EXCEPTIONS

field_not_found = 1

no_help_for_field = 2

inconsistent_help = 3

no_values_found = 4

OTHERS = 5.

Regards,

Darpana.

1 ACCEPTED SOLUTION

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Test the following Sample Code hope will Solve out your problem,

******Data Declaration
DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.

******Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE text-000.
PARAMETERS: v_matnr TYPE makt-matnr.
PARAMETERS: v_maktx TYPE makt-maktx.
SELECTION-SCREEN END OF BLOCK block0.

******At Selection-screen on value-request.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_maktx.

data: BEGIN OF it OCCURS 10,
  matnr like makt-matnr,
  maktx like makt-maktx,
  END OF it.

SELECT matnr maktx from makt
  into CORRESPONDING FIELDS OF TABLE it
  where matnr = v_matnr.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
     retfield               = 'MAKTX'
     dynpprog               = sy-repid
     dynpnr                 = sy-dynnr
     dynprofield            = 'v_maktx'
     value_org              = 'S'
    tables
     value_tab              = it.

and also don't forget to press enter key after enter the v_matnr in the parameter

Kind Regards,

Faisal

Edited by: Faisal Altaf on Feb 19, 2009 12:06 PM

13 REPLIES 13

Former Member
0 Kudos

Hi Darpana ,

First create the search help using selection method ztable and give the matnr field as IMP (import parameter) and matkx as Export parameter.

Then change the code like ---

PARAMETERS: v_maktx TYPE maktx   MATCHCODE OBJECT  search_help_name.

regards

Pinaki

Former Member
0 Kudos

Hi,

Use At selection-screen for value-request for matnr.

parameters:
    matnr type makt-matnr as listbox visible lenght 10. ,
    maktx type makt-maktx.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR name1.
CALL SCREEN 100 STARTING AT 10 5
ENDING AT 50 10.

MODULE value_list OUTPUT.
SUPPRESS DIALOG.
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
SET PF-STATUS space.
NEW-PAGE NO-TITLE.

select single maktx from <Databasetable> into matkx.
where matnr = matnr.

Write : / maktx.
hide maktx.
Endselect.
ENDMODULE.

AT LINE-SELECTION.
CHECK NOT name1 IS INITIAL.
LEAVE TO SCREEN 0.

Former Member
0 Kudos

Hi Darpana,

Also add the selection screen value request for v_maktx also.

Call FM "F4IF_INT_TABLE_VALUE_REQUEST" in which u can populate the Internal table with only selected material (v_matnr) and it's description accordingly. This FM is will only show the selected matnr description as F4 help for v_maktx.

Let me know for any clarifications.

From

Reddy

Former Member
0 Kudos

tables: makt.

******Data Declaration

DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.

******Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE text-000.

PARAMETERS: v_matnr like makt-matnr.

PARAMETERS: v_maktx like makt-maktx.

SELECTION-SCREEN END OF BLOCK block0.

******At Selection-screen on value-request.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_matnr.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

tabname = 'ZMAT_DESC'

fieldname = 'MATNR'

searchhelp = 'ZDESC1'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'V_MATNR'

callback_program = sy-repid

TABLES

return_tab = return

EXCEPTIONS

field_not_found = 1

no_help_for_field = 2

inconsistent_help = 3

no_values_found = 4

OTHERS = 5.

 " Just add these lines of code
AT SELECTION-SCREEN OUTPUT. 
  select maktx from makt into v_maktx where matnr = v_matnr.
    ENDSELECT.
when u select the value of matnr and press the enter u will get the description of that matnr in matkx filed

Edited by: tahir naqqash on Feb 19, 2009 12:03 PM

0 Kudos

Hi,

I do not want the description to come in the Maktx field automatically on press of enter.

I want a search help attached to field Maktx which gives only the value of the selected Matnr, and then i select that value from its search help.

Regards,

Darpana

0 Kudos

Hi.

then code Posted By faisal is working according to ur need. check that code.

but search help attached with maktx is showing matnr and its description. 
and when u select the matnr in search help, it will put the descrition in maktx field.
 but u are saying that search help aatached on it should display only matnr and 
on selecting it matnr should go in maktx field. is it

Edited by: tahir naqqash on Feb 19, 2009 12:21 PM

Former Member
0 Kudos

hi,

see following example it will help you

If requirement in selection screen is:

There are 2parameters in selection screen. For e.g. matnr and werks

If I am giving matnr then respect to that matnr i should get only those plant in F4 help.

Solution:

AT SELECTION-SCREEN ON VALUE-REQUEST FOR werks.

select the werks based on plant in internal.table 
use f.m

F4IF_INT_TABLE_VALUE_REQUEST.
and pass the i.tab here in 

tables
value_t = i.tab

Or

Follow the psudo code below.

Note: it_matnr has only single field MATNR.

**--- Return table to handle selected field in F4 help ---**

data: it_return like ddshretval occurs 0 with header line.
 
parameters: p_matnr type marc-matnr,
                  p_werks type marc-werks.
 
at selection-screen on value-request for p_repnam.
 
  select matnr
         from marc
         into table it_matnr
         where werks eq p_werks.
 
  call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
      retfield         = 'OBJ_NAME'
      dynpprog         = sy-cprog
      dynpnr           = sy-dynnr
      value_org        = 'S'
      callback_program = sy-cprog
    tables
      value_tab        = it_matnr
      return_tab       = it_return
    exceptions
      parameter_error  = 1
      no_values_found  = 2.
 
  if sy-subrc eq 0.
    loop at it_return.
      clear p_repnam.
      p_repnam = it_return-fieldval.
    endloop.
 
  endif.

hope it will help u

regards

rahul

0 Kudos

Hi,

What is p_repnam used here for?

Regards,

Darpana

0 Kudos

hi,

here p_renam is used for p_werks

rahul

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Test the following Sample Code hope will Solve out your problem,

******Data Declaration
DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.

******Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE text-000.
PARAMETERS: v_matnr TYPE makt-matnr.
PARAMETERS: v_maktx TYPE makt-maktx.
SELECTION-SCREEN END OF BLOCK block0.

******At Selection-screen on value-request.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_maktx.

data: BEGIN OF it OCCURS 10,
  matnr like makt-matnr,
  maktx like makt-maktx,
  END OF it.

SELECT matnr maktx from makt
  into CORRESPONDING FIELDS OF TABLE it
  where matnr = v_matnr.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
     retfield               = 'MAKTX'
     dynpprog               = sy-repid
     dynpnr                 = sy-dynnr
     dynprofield            = 'v_maktx'
     value_org              = 'S'
    tables
     value_tab              = it.

and also don't forget to press enter key after enter the v_matnr in the parameter

Kind Regards,

Faisal

Edited by: Faisal Altaf on Feb 19, 2009 12:06 PM

kamesh_g
Contributor
0 Kudos

hi

try this

Code:

PARAMETERS: p_ccgrp LIKE rkpln-ksgru. "Cost Center Group

*Input help for Cost Center Group

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ccgrp.

TYPES: BEGIN OF ty_ccenter_group,

setname TYPE setnamenew,

descript TYPE settext,

END OF ty_ccenter_group.

DATA: it_ccenter_group TYPE TABLE OF ty_ccenter_group.

CLEAR it_ccenter_group.

SELECT a~setname

b~descript

INTO TABLE it_ccenter_group

FROM setheader AS a INNER JOIN

setheadert AS b ON

asubclass EQ bsubclass AND

asetname EQ bsetname

WHERE a~setclass EQ '0101' AND

b~langu EQ sy-langu.

CALL FUNCTION

'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

ret field = 'SETNAME'

dynpprog = v_repid

dynpnr = SY-DYNR

dynprofield = 'P_CCGRP'

value_org = 'S'

TABLES

value_tab = it_ccenter_group.

F4IF_FIELD_VALUE_REQUEST:

This FM is used to display value help or input from ABAP dictionary. We have to pass the name of the structure or table (TABNAME) along with the field name (FIELDNAME). The selection can be returned to the specified screen field if three

parameters DYNPNR, DYNPPROG, DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

TABNAME = table/structure

FIELDNAME = 'field name'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNR

DYNPROFIELD = 'screen field'

IMPORTING

RETURN_TAB = table of type DYNPREAD

Getting F4 help based on other field .

Suppose if there are 2 fields on selection screen user name and Purchasing Document and the case is getting values of Purchasing Document Number based on user name

Code:

TYPES: BEGIN OF ty_match_nast,

objky TYPE na_objkey,

END OF ty_match_nast.

Data: it_match_nast TYPE STANDARD TABLE OF ty_match_nast.

Data: it_dypr_val TYPE STANDARD TABLE OF dynpread.

DATA: wa_dypr_val TYPE dynpread.

DATA: it_return TYPE STANDARD TABLE OF ddshretval.

Case when only username value is entered.

SELECT objky

FROM nast

INTO TABLE it_match_nast

WHERE kappl = c_ef

AND kschl = c_neu

AND usnam = wa_dypr_val-fieldvalue.

ENDIF.

*Read User name on selection screen field value

CLEAR wa_dypr_val.

REFRESH it_dypr_val.

wa_dypr_val-fieldname = 'P_UNAME'. "User name

APPEND wa_dypr_val TO it_dypr_val.

*FM to get the value

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-repid

dynumb = sy-dynnr

translate_to_upper = 'X'

TABLES

dynpfields = it_dypr_val_h.

*Pass the values to f4 table

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = u2018OBJKY'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_EBELN'

value_org = 'P'

TABLES

value_tab = it_match_nast

return_tab = it_return.

former_member222860
Active Contributor
0 Kudos

Hi,

Check this code, it works:

tables: makt.

DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK block0 WITH FRAME TITLE text-000.
PARAMETERS: v_matnr TYPE makt-matnr.
PARAMETERS: v_maktx TYPE makt-maktx VALUE CHECK.      " keep VALUE CHECK
SELECTION-SCREEN END OF BLOCK block0.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_maktx.

data: BEGIN OF itab OCCURS 10,
  matnr like makt-matnr,
  maktx like makt-maktx,
  END OF itab.

SELECT matnr maktx from makt
  into CORRESPONDING FIELDS OF TABLE itab
  where matnr = v_matnr.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    exporting
     retfield               = 'MAKTX'
     dynpprog               = sy-repid
     dynpnr                 = sy-dynnr
     dynprofield            = 'v_maktx'
     value_org              = 'S'
    tables
     value_tab              = itab.

regards|

Mahesh

Former Member
0 Kudos

you can create a search help in se11. Give selection method as ztable (used in the program) .

You can use the search help like,

PARAMETERS: v_maktx TYPE maktx MATCHCODE OBJECT search_help.

Regards,

Joan