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: 

i have a problem in select-options

aarif_baig
Active Participant
0 Kudos

hi frns,

i am facing a big problem in select-options

the requirement is such that

i have 2 select-options

one for matnr and the other for maktx

so wen the clent select matnr with f4

in the maktx the similar description should come by using f4

pls help me out

7 REPLIES 7

Former Member
0 Kudos

Hi Aarif,

Please clarify if what you want is if the f4 is done on matnr the maktx field should automatically get populated?

if so, create a search help on the matnr field and pass these two fields (matnr & maktx) as export parameters. Using this if the f4 is done on matnr the maktx will also get populated.

Please reward points and close this thread if the solution was helpful.

0 Kudos

when f4 is used on matnr

and once the matnr is selected

after that wen f4 is used on maktx only the above selected matnr description should come

Former Member
0 Kudos

hi,

can u send d code or ur report so dat i can help u out.

regards,

ric.s

Former Member
0 Kudos

hi,

***********************************************************************

  • TYPES DECLARATION

***********************************************************************

types: begin of tp_marc,

matnr type marc-matnr,

werks type marc-werks,

end of tp_marc.

***********************************************************************

  • INTERNAL TABLE AND WORK AREA DECLARATION

***********************************************************************

data: t_marc type standard table of tp_marc,

wa_marc type tp_marc.

*----


data : dd like table of dselc with header line. "*--- IMPORTANT

data : ft like table of dfies with header line.

data : t_makt like table of makt with header line.

*----


parameters : matnr like makt-matnr .

parameters : maktx like makt-maktx.

at selection-screen output.

loop at screen.

if screen-name = 'MAKTX'.

screen-input = 0.

modify screen.

endif.

endloop.

*----


at selection-screen on value-request for matnr.

  • SELECT matnr maktx FROM makt INTO TABLE makt up to 500 rows.

select *

from makt

up to 500 rows

into table t_makt

where spras = syst-langu.

if sy-subrc <> 0.

message 'INVALID MATERIAL NUMBER' type 'E'.

endif.

*----


IMPORTANT

refresh dd.

dd-fldname = 'MATNR'.

dd-dyfldname = 'MATNR'.

append dd.

dd-fldname = 'MAKTX'.

dd-dyfldname = 'MAKTX'.

append dd.

*------- IMPORTANT

refresh ft.

ft-tabname = 'MAKT'.

ft-fieldname = 'MATNR'.

append ft.

ft-tabname = 'MAKT'.

ft-fieldname = 'MAKTX'.

append ft.

*----


call function 'F4IF_INT_TABLE_VALUE_REQUEST'

exporting

  • ddic_structure = 'T001' "*----- IMPORTANT IF STANDARD STRUCT

retfield = 'MATNR'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'MATNR'

value_org = 'S'

tables

field_tab = ft "*---- IMPORTANT

value_tab = t_makt

dynpfld_mapping = dd "* IMPORTANT

exceptions

parameter_error = 1

no_values_found = 2

others = 3.

start-of-selection.

select matnr

werks

from marc

into table t_marc

where matnr = matnr.

if sy-subrc <> 0.

message :'no results IN MARC' type 'E'.

endif.

write: at 1(36) sy-uline.

format intensified on color = 7.

new-line.

write :sy-vline,at 10 'MATERIAL NUMBER',at 29 sy-vline, at 30 'PLANT',sy-vline.

new-line.

write: at 1(36) sy-uline.

format intensified off color = 4.

loop at t_marc into wa_marc.

new-line.

write :sy-vline,at 10 wa_marc-matnr ,sy-vline, at 30 wa_marc-werks, at 36 sy-vline.

endloop.

new-line.

write: at 1(36) sy-uline.

******************************************************************************

reward points if useful.

regards,

Vinod Samuel.

Former Member
0 Kudos

Hi Aarif,

u can use following code.it is F4 help for storage location based on the value of plant. Reward points if usefull.

&----


& Form F4_Help_For_Stoloc----


&----


  • F4 help for storage location based on the value --*

of plant----


----


FORM f4_help_for_stoloc .

DATA: dynfields TYPE TABLE OF dynpread WITH HEADER LINE.

  • Get the value for the field based on which f4 should be populated---*

dynfields-fieldname = 'P_PLANT'.

APPEND dynfields.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-cprog

dynumb = sy-dynnr

translate_to_upper = 'X'

TABLES

dynpfields = dynfields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

stepl_not_found = 10

OTHERS = 11.

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 dynfields WITH KEY fieldname = 'S_PLANT'.

  • select query to get the required values from database to populate f4 *

SELECT lgort

INTO TABLE itab_lgort

FROM mard

WHERE werks = dynfields-fieldvalue.

IF sy-subrc <> 0.

MESSAGE 'No Values Found !!!!!!!' TYPE 'I' .

ENDIF.

SORT itab_lgort BY lgort .

DELETE ADJACENT DUPLICATES FROM itab_lgort .

FM to display the f4 based on input selection----


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = 'LGORT'

  • PVALKEY = ' '

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'S_STOLOC'

  • STEPL = 0

  • WINDOW_TITLE = WINDOW_TITLE

  • VALUE = ' '

value_org = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB = MARK_TAB

  • IMPORTING

  • USER_RESET = USER_RESET

TABLES

value_tab = itab_lgort

  • FIELD_TAB = FIELD_TAB

  • RETURN_TAB = RETURN_TAB

  • DYNPFLD_MAPPING = DYNPFLD_MAPPING

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

REFRESH dynfields .

ENDFORM. " F4_Help_For_Stoloc

harimanjesh_an
Active Participant
0 Kudos

hi Aarif,

According to u, Once F4 is pressed on Matnr and u select some Material No.

And again if u press F4 on Maktx then Material description should be populated for the above selected Matnr. Right?

Just do like this.

<b>Code:</b>

Parameters : p_matnr type mara-matnr,

p_maktx type makt-maktx.

Data : w_matnr type mara-matnr.

*----


At selection-screen on value-request for p_matnr.

SELECT single matnr FROM mara into w_matnr.

if sy-subrc <> 0.

Message 'Invalid MAterial Number' type 'I'.

endif.

At selection-screen on value-request for p_maktx.

if p_matnr is not initial.

Select maktx into p_maktx from Makt where matnr = p_matnr.

endif.

<b>If u want to auto populate MAKTX when u press F4 on MATNR then u have to create search help...</b>..

i.e, when u press F4 on MATNR then MAKTX will be auto populated for the selected MATNR.

<b>To create Search Help, check this link....</b>

http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm

Reward me if useful....

Harimanjesh AN

Former Member
0 Kudos

Hi,

parameters: p_matnr type makt-matnr,

p_maktx type makt-maktx.

at selection-screen on value-request for p_maktx.

data: begin of help_item occurs 0,

matnr type makt-matnr,

maktx type makt-maktx,

end of help_item.

data: dynfields type table of dynpread with header line.

dynfields-fieldname = 'P_MATNR'.

append dynfields.

call function 'DYNP_VALUES_READ'

exporting

dyname = sy-cprog

dynumb = sy-dynnr

translate_to_upper = 'X'

tables

dynpfields = dynfields.

read table dynfields with key fieldname = 'P_matnr'.

p_vbeln = dynfields-fieldvalue.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = p_matnr

importing

output = p_matnr.

select posnr matnr arktx into table help_item

from makt where matnr = p_ matnr.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'

exporting

retfield = 'MAKTX'

dynprofield = 'P_MAKTX'

dynpprog = sy-cprog

dynpnr = sy-dynnr

value_org = 'S'

tables

value_tab = help_item.

NOTE:-same code with replacing Parameters with select-options and

at selection-screen on value-request for p_maktx-LOW.

at selection-screen on value-request for p_maktx-High.

Regards,

Vijay Mekala