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

Selection screen

Former Member
0 Likes
645

hi,

Inselection screen I have three fields, Plant,Mat and Mat group. If I input Plant how do I get the mat no and mat group based on plant dynamically.

sarath

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
610

Hi ,

at selection-screen output .

select single plant mat matgroup from <table name> into corresponding fields of wtab where plant = p_plant . " p_plant is the parameter .

LOOP AT SCREEN.

p_mat = wt_mat .

p_matgroup = wt_matgroup .

MODIFY SCREEN.

ENDLOOP.

Hope this helps you .

7 REPLIES 7
Read only

gopi_narendra
Active Contributor
0 Likes
610

write it in the <b>at selection-screen output</b> event

Regards

- Gopi

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
610

Hi,

Check whether this sample code helps you.

&----


*& Report ZGK_TEST *

*& *

&----


*& *

*& *

&----


REPORT ZGK_TEST

message-id zsd

line-count 16(1)

no standard page heading .

----


  • Tables Declaration

----


tables : vbap. " Sales Document: Item Data

----


  • Constant Declaration *

----


CONSTANTS:

C_X TYPE C VALUE 'X'. " Translate to Uppercase

----


  • Variable Declaration *

----


  • Variable for Table index

data v_sytabix like sy-tabix.

  • Variable for Program name

data L_NAME LIKE SYST-REPID.

----


  • Ranges Declaration *

----


  • Range for getting values form selection screen

DATA: BEGIN OF range1 OCCURS 0,

SIGN(1),

OPTION(2),

LOW LIKE vbap-vbeln,

high like vbap-vbeln,

END OF range1.

----


  • Structure Declaration *

----


----


  • Internal table Declaration *

----


  • Internal table for Report output

data: begin of i_vbap occurs 0,

vbeln like vbap-vbeln, " Sales Document

posnr like vbap-posnr, " Sales Document item

end of i_vbap.

  • Internal table for output to the F4 help

data: begin of I_DISPLAY occurs 0,

vbeln like vbap-vbeln, " Sales Document

posnr like vbap-posnr, " Sales Document item

end of I_DISPLAY.

  • Internal table for return value form function module

DATA: BEGIN OF I_RETURNVAL OCCURS 0.

INCLUDE STRUCTURE DDSHRETVAL. " Interface Structure Search

DATA: END OF I_RETURNVAL.

  • Internal table for F4 help field heading

DATA: I_FIELDTAB LIKE DFIES OCCURS 0 WITH HEADER LINE.

  • Internal table for getting screen values from selection screen

data L_SCR_FIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.

----


  • Field-Symbols *

----


----


  • Selection-screen *

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME title text-001.

select-options:

S_VBELN for vbap-vbeln no intervals,

S_POSNR for vbap-posnr no intervals.

SELECTION-SCREEN end OF BLOCK B1.

----


  • AT SELECTION-SCREEN ON VALUE-REQUEST *

----


at selection-screen on value-request for s_posnr-low.

clear: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.

refresh: L_SCR_FIELDS, I_FIELDTAB, i_display, I_RETURNVAL.

L_NAME = SYST-REPID.

MOVE 'S_VBELN-LOW' TO L_SCR_FIELDS-FIELDNAME.

APPEND L_SCR_FIELDS.

  • Call the Function module DYNP_VALUES_READ to get the values form

  • selection screen

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = L_NAME

DYNUMB = SYST-DYNNR

TRANSLATE_TO_UPPER = C_X " X

TABLES

DYNPFIELDS = L_SCR_FIELDS

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 eq 0.

LOOP AT L_SCR_FIELDS.

range1-sign = 'I'.

range1-option = 'EQ'.

range1-low = L_SCR_FIELDS-FIELDVALUE.

range1-high = space.

append range1.

ENDLOOP.

ENDIF.

  • F4 help Field headings

I_FIELDTAB-TABNAME = 'I_DISPLAY'.

I_FIELDTAB-FIELDNAME = 'VBELN'.

I_FIELDTAB-POSITION = '1'.

I_FIELDTAB-OUTPUTLEN = '10'.

I_FIELDTAB-INTTYPE = 'C'.

I_FIELDTAB-INTLEN = '10'.

APPEND I_FIELDTAB.

I_FIELDTAB-FIELDNAME = 'POSNR'.

I_FIELDTAB-POSITION = '2'.

I_FIELDTAB-OFFSET = '10'.

I_FIELDTAB-OUTPUTLEN = '6'.

I_FIELDTAB-INTTYPE = 'N'.

I_FIELDTAB-INTLEN = '6'.

APPEND I_FIELDTAB.

  • Retrieve sales document, Sales document item from table Sales

  • Document: Item Data(VBAP).

  • Primary keys used for selection: VBELN

select vbeln posnr from vbap

into table i_display

where vbeln in range1.

  • Call the function module F4IF_INT_TABLE_VALUE_REQUEST for F4 values

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'POSNR'

WINDOW_TITLE = 'Line Item'

VALUE_ORG = 'S'

MULTIPLE_CHOICE = C_X " (for muliple selection)

TABLES

VALUE_TAB = I_DISPLAY

FIELD_TAB = I_FIELDTAB

RETURN_TAB = I_RETURNVAL

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.

ELSE.

  • Star for For single values

  • READ TABLE I_RETURNVAL INDEX 1.

  • S_POSNR-LOW = I_RETURNVAL-FIELDVAL.

  • End for the single values

  • Start For multiple selection

loop at i_returnval.

s_posnr-sign = 'I'.

s_posnr-option = 'EQ'.

s_posnr-low = I_RETURNVAL-FIELDVAL.

append s_posnr.

endloop.

sort s_posnr.

read table s_posnr index 1.

  • End for multiple selection

ENDIF.

----


  • Start-of-selection *

----


start-of-selection.

  • Retrieve sales document, Sales document item from table Sales

  • Document: Item Data(VBAP).

  • Primary keys used for selection: VBELN

select vbeln posnr from vbap

into table i_vbap

where vbeln in s_vbeln

and posnr in s_posnr.

  • if the above selection is successful continue the process else exit *

  • form the report

if sy-subrc ne 0.

  • message e002 with 'No data to display'.

endif.

----


  • End-of-selection *

----


end-of-selection.

if not i_vbap[] is initial.

loop at i_vbap.

write:/ i_vbap-vbeln, i_vbap-posnr.

endloop.

endif.

Read only

Former Member
0 Likes
610

thanks

Read only

Former Member
0 Likes
611

Hi ,

at selection-screen output .

select single plant mat matgroup from <table name> into corresponding fields of wtab where plant = p_plant . " p_plant is the parameter .

LOOP AT SCREEN.

p_mat = wt_mat .

p_matgroup = wt_matgroup .

MODIFY SCREEN.

ENDLOOP.

Hope this helps you .

Read only

Former Member
0 Likes
610

<b>initialization.</b>

parameters: plant type field1,

matno type field2,

matgroup type field3.

data wa type table.

<b>

at selection-screen output.</b>

if plant <>''.

select single field1 field2 from table into corresponding fields of wa where field = plant.

matno = wa-field1.

matgroup = wa-field2.

endif.

Read only

Former Member
0 Likes
610

hi,

parameters : p_plant type marc-werks,

p_matnr type marc-matnr.

data : d_matnr type marc-matnr.

AT SELECTION-SCREEN OUTPUT.

if p_plant is not initial.

select single matnr into (d_matnr) from marc where werks = p_plant.

p_matnr = d_matnr.

else.

Message 'Pls enter plant number' type 'I'.

endif.

Regards

Purshoth

Read only

Former Member
0 Likes
610

HI Sarath

Though the query is already answered, i would like to share the below info with you.

To me the requirement is weird, displaying a material when the plant is in input. I guess all the are parameters in input screen.

Because, within a plant we will have many Materials.

Generally we get this sort of requirement only in one-to-one relation.

As per your selection criteria, we can display the material group when we get the material as input as <b>Material -> Material Group</b>.

Kind Regards

Eswar