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

how to fill empty parameter (selection-option)

Former Member
0 Likes
1,803

Hi!

On selection screen I have two parameters (s_egrid and s_empid). If user enter something in first (but not in second) one, second one should be filled from database.

The problem is that I don't know how to fill the empty parameter.

Let's say that i have an internal table i_zemployee with list of all necessary employee Id's (stored in field empid)

if I Ioop like this

loop at i_zemployee into wa_zemployee.
    insert wa_zemployee-empid into s_empid.
  endloop.

... I did something stupid but i hope that you understand what i need:

s_emipd[1] = 'u1'.
s_emipd[2] = 'u7'.
s_emipd[3] = 'u9'.

... like array of user id's.

and this s_empid I need in my next SELECT statement like

SELECT * FROM ...
    ....
    WHERE empid in s_empid.

if someone knows the solution thanks in advance!

T.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,094

All the select-options, e.g. s_empid, are range tables so to fill any of them, I'd suggest something like (not syntax checked):


start-of-selection.
  perform fill_gaps.

form fill_gaps.
*" Provide defaults if empty default
  if s_empid[] is initial. "not filled
    loop at i_zemployee into wa_zemployee.
      clear: s_empid.  "clear header line each loop
      s_empid-option = 'EQ'.  "equals
      s_empid-sign   = 'I'.   "include
      s_empid-low    = wa_zemployee-empid. "set a value
      s_empid-high   = space.  "only used for between-type options
      append s_empid.
    endloop.
  endif.

endform.

Jonathan

5 REPLIES 5
Read only

Former Member
0 Likes
1,094

Hello,

To fill the second when the first one is selected you can use the event AT SELECTION-SCREEN ON <field>.

See this, extracted from SAP BC-ABA material.


REPORT EVENT_DEMO.
  NODES SPFLI.
  AT SELECTION-SCREEN ON CITY_FR.
  IF CARRID-LOW EQ 'AA' AND CITY_FR NE 'NEW YORK'. 
    MESSAGE E010(HB).
  ENDIF.

There are some helpfull samples in transaction ABAPDOCU.

Regards,

Read only

Former Member
0 Likes
1,095

All the select-options, e.g. s_empid, are range tables so to fill any of them, I'd suggest something like (not syntax checked):


start-of-selection.
  perform fill_gaps.

form fill_gaps.
*" Provide defaults if empty default
  if s_empid[] is initial. "not filled
    loop at i_zemployee into wa_zemployee.
      clear: s_empid.  "clear header line each loop
      s_empid-option = 'EQ'.  "equals
      s_empid-sign   = 'I'.   "include
      s_empid-low    = wa_zemployee-empid. "set a value
      s_empid-high   = space.  "only used for between-type options
      append s_empid.
    endloop.
  endif.

endform.

Jonathan

Read only

Former Member
0 Likes
1,094

HI try something like this...

tables: mara, makt.

data: begin of itab occurs 0,

matnr like mara-matnr,

end of itab.

data : begin of btab occurs 0,

maktx like makt-maktx,

end of btab.

ata mak like makt-maktx.

DATA : return like ddshretval occurs 0 with header line.

data: begin of dynpfields occurs 3.

include structure dynpread.

data: end of dynpfields.

select-options: p_matnr for mara-matnr.

select matnr from mara into table itab where matnr IN p_matnr.

loop at itab.

write: / itab-matnr.

endloop.

Initialization.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.

REFRESH ITAB.

SELECT matnr FROM mara INTO TABLE ITAB.

call function 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'MATNR '

dynprofield = 'P_MATNR '

dynpprog = sy-REPID

dynpnr = sy-dynnr

value_org = 'S'

TABLES

value_tab = ITAB

return_tab = return.

select single maktx from makt into mak where matnr = return-fieldval.

p_matnr = return-fieldval.

refresh return.

clear return.

move 'P_MAKTX' to dynpfields-fieldname.

move mak to dynpfields-fieldvalue.

append dynpfields.

CALL FUNCTION 'DYNP_VALUES_UPDATE'

EXPORTING

dyname = 'SY-REPID'

dynumb = '1000'

tables

dynpfields = dynpfields

.

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 return.

clear return.

validate according to ur requirement.

Regards

Syed A

Read only

Former Member
0 Likes
1,094

Hi,

First you have to observe here is, if you want to fill second parameter

by entering first one it is not possible,because when you enter some value in first one some event has to trigger ,under that event we can write code.Simply enter the values,will not trigger.

Read only

0 Likes
1,094

Jonathan provided me a correct answer! Problem solved 100% Thanks man! Your reward: 10 points