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

Modulepool screen Problem

Former Member
0 Likes
1,110

Hi Abap gurus,

I created a screen at Modulepool wiht 10 fields on it. user will enter the data on these fields.

Here i need to capture the fileds values dynamically at runtime because based on first field i need to write the logic for 2field like all the fields.

Is there any FM available for capture the data which is there at screen.

Thanks in Advance.

Helpful answer will be rewarded.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,080

Hi friend,

In u r case u just declare a internal table like this.

<b>DATA : BEGIN OF tb_dyn_fields OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA : END OF tb_dyn_fields.</b>

<b>DATA: dyname LIKE d020s-prog VALUE 'PROGRAM NAME',

dynumb LIKE d020s-dnum VALUE 'SCREEN NO'.</b>

In PBO in Module request do the code like this.

MOVE '1 FIELD' TO tb_dyn_fields-fieldname.

APPEND tb_dyn_fields.

<b>CALL FUNCTION 'DYNP_VALUES_READ'</b>

EXPORTING

dyname = dyname

dynumb = dynumb

translate_to_upper = 'X'

TABLES

dynpfields = tb_dyn_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.

CASE sy-subrc.

WHEN 0.

    • IMIDIATELY U CALL THE FM

<b> CALL FUNCTION 'DYNP_VALUES_UPDATE'</b>

EXPORTING

dyname = dyname

dynumb = dynumb

TABLES

dynpfields = tb_dyn_fields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

undefind_error = 7

OTHERS = 8.

CLEAR : 'I FIELD'.

READ TABLE tb_dyn_fields WITH KEY fieldname ='I FIELD'.

<b> 'I FIELD' = tb_dyn_fields-fieldvalue.</b>

WHEN OTHERS.

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

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

ENDCASE.

Use CALL FUNCTION <b>'F4IF_INT_TABLE_VALUE_REQUEST'</b> to get f4 functionality.

Now the screen value is available at 'I FIELD'.

    • Reward if Helpfull

Thanks,

Anil.

8 REPLIES 8
Read only

Former Member
0 Likes
1,080

hi,

check outh the FM DYNP_VALUES_READ

regards,

Navneeth.K

Read only

Former Member
0 Likes
1,080

hi,

Check this code sample.

Here also, values of other parameters on selection-screen are determined based on the value given to the first parameter..

Similar logic can also be applied to module pool.

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abapProgramtoReadorPopulateSelectionScreenParameters+Dynamically&

Regards

Sailaja.

Read only

Former Member
0 Likes
1,080

Hi,

Please look at this sample code

*This function module gets the values on screen.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = l_program_name

dynumb = l_dynpro_number

TABLES

dynpfields = l_dynp_value_tab

EXCEPTIONS

invalid_abapworkarea = 04

invalid_dynprofield = 08

invalid_dynproname = 12

invalid_dynpronummer = 16

invalid_request = 20

no_fielddescription = 24

undefind_error = 28.

READ TABLE l_dynp_value_tab INDEX 1.

l_functd1_value = l_dynp_value_tab-fieldvalue.

The table l_dynp_value_tab will contain the value.

Kindly reward points if helpful.

Thanks

Pranati

Read only

former_member491305
Active Contributor
0 Likes
1,080

Hi,

Are you trying to give search help for all the other field based on first filed.

If so then you can use 'DYNP_VALUES_READ' in the MODULE of Procees on value-request event.Otherwise then there is no need for funtion module to read the

screen data.It will be available automatically in PAI event and PBO Event.

Read only

Former Member
0 Likes
1,080

Hi,

Here except 1 and 2 all r Zdata elements. So no serchhelps for that.

I use 'DYNP_VALUES_READ' also but it is not fullfilling the requirment.

Please Help me.

Thanks.

Read only

0 Likes
1,080

Hi ,

I think you need to use the FM DYNP_VALUES_READ and then the FM

F4IF_INT_TABLE_VALUE_REQUEST.

first you need to capture the value dynamically using DYNP_VALUES_READ,

then use this to select data from database table into an internal table. Then give this internal table as input to the FM F4IF_INT_TABLE_VALUE_REQUEST for the second field. I had done something in similar fashion. Please see the code below.

This function module gets the values on screen.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = l_program_name

dynumb = l_dynpro_number

TABLES

dynpfields = l_dynp_value_tab

EXCEPTIONS

invalid_abapworkarea = 04

invalid_dynprofield = 08

invalid_dynproname = 12

invalid_dynpronummer = 16

invalid_request = 20

no_fielddescription = 24

undefind_error = 28.

READ TABLE l_dynp_value_tab INDEX 1.

l_functd1_value = l_dynp_value_tab-fieldvalue.

SELECT subdiscipline subdescr INTO TABLE l_ivalue_subd_tab

FROM zphu_pdc

WHERE pdc = l_functd1_value .

*Gives the search help on the screen using values in l_ivalue_subd_tab

*and returns the selected value in l_ireturn_tab.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'ZZSUBDISCPL'

value_org = 'S'

TABLES

value_tab = l_ivalue_subd_tab[]

return_tab = l_ireturn_tab[]

EXCEPTIONS

parameter_error = 1

no_values_found = 2

OTHERS = 3.

Here, the field with name ZZSUBDISCPL is similar to your 2nd field.

Please reward points if helpful.

Thanks

Pranati

Read only

Former Member
0 Likes
1,081

Hi friend,

In u r case u just declare a internal table like this.

<b>DATA : BEGIN OF tb_dyn_fields OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA : END OF tb_dyn_fields.</b>

<b>DATA: dyname LIKE d020s-prog VALUE 'PROGRAM NAME',

dynumb LIKE d020s-dnum VALUE 'SCREEN NO'.</b>

In PBO in Module request do the code like this.

MOVE '1 FIELD' TO tb_dyn_fields-fieldname.

APPEND tb_dyn_fields.

<b>CALL FUNCTION 'DYNP_VALUES_READ'</b>

EXPORTING

dyname = dyname

dynumb = dynumb

translate_to_upper = 'X'

TABLES

dynpfields = tb_dyn_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.

CASE sy-subrc.

WHEN 0.

    • IMIDIATELY U CALL THE FM

<b> CALL FUNCTION 'DYNP_VALUES_UPDATE'</b>

EXPORTING

dyname = dyname

dynumb = dynumb

TABLES

dynpfields = tb_dyn_fields

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

undefind_error = 7

OTHERS = 8.

CLEAR : 'I FIELD'.

READ TABLE tb_dyn_fields WITH KEY fieldname ='I FIELD'.

<b> 'I FIELD' = tb_dyn_fields-fieldvalue.</b>

WHEN OTHERS.

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

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

ENDCASE.

Use CALL FUNCTION <b>'F4IF_INT_TABLE_VALUE_REQUEST'</b> to get f4 functionality.

Now the screen value is available at 'I FIELD'.

    • Reward if Helpfull

Thanks,

Anil.

Read only

Former Member
0 Likes
1,080

hi guys,

Since you are using module pool hence the values entered on the screen will be passed dynamically to the PBO and PAI of the screen.

<b><u>PBO</u></b>

Assign screen field scr_field1 = itab-field1.

Assign screen field scr_field2 = itab-field2.

Assign screen field scr_field3 = itab-field3.

Assign screen field scr_field4 = itab-field4.

<u><b>PAI</b></u>

If not itab-field1 is initial.

Select field2

From xxx

Into corresponding fields of itab

Where field1 = itab-field1.

Endif.

If not itab-field2 is initial.

Select field3

From xxx

Into corresponding fields of itab

Where field2 = itab-field2.

Endif.

If not itab-field3 is initial.

Select field4

From xxx

Into corresponding fields of itab

Where field3 = itab-field3.

Endif.

Once the user enters any value of field1 on screen and presses enter, the PAI of the screen would be called and the field2 value would be fetched. As soon as field2 value is fetched, field3 value is also fetched and subsequently field4 value is also fetched.

All these values will be passes to the screen fields in the PBO of the screen dynamically.

I hope this solves your query.

Do reward points in case you find it useful

Regards,

Mayank Agarwal