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

F4 entry issue

Former Member
0 Likes
533

I have a requirement like:

I have two fields in selection screen.If I will do F4 at field1, a set of values will come.If I will click on one entry, that will come to Field1 and when I press F4 at field2 the corresponding value for field1 should populate here.

I have coded as follows,but the value is not coming.Aslo if I wont select any value for field1,then also one value is populating at field1.

Please help.

FORM f4_F1.

SELECT aa bb FROM T1 CLIENT SPECIFIED INTO TABLE gt_T1

WHERE client = sy-mandt AND aa NE space.

IF sy-subrc = 0.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = text-007

dynpprog = sy-repid

dynpnr = sy-dynnr

  • dynprofield = 'F1'

dynprofield = TEXT-013

value_org = c_s

display = space

callback_program = sy-repid

TABLES

value_tab = gt_T1.

ENDIF.

data:l_counter type I.

DESCRIBE TABLE gt_T1 LINES l_counter.

IF l_counter > 0.

READ TABLE gt_T1 index sy-index into gw_t1.

if sy-subrc = 0

F1 = gw_t1-aa.

endif.

ELSE.

MESSAGE text-019 TYPE c_i.

ENDIF.

ENDFORM. " F4_F1

FORM f4_F2 .

IF F1 is initial.

SELECT aa cc dd FROM T2 INTO TABLE gt_f21

FOR ALL ENTRIES IN gt_t1

WHERE aa = gt_t1-aa.

IF sy-subrc = 0.

LOOP AT gt_f21 INTO gw_f21.

gw_f2-cc = gw_f21-cc.

gw_f2-dd = gw_f21-dd.

APPEND gw_f2 TO gt_f2.

ENDLOOP.

ENDIF.

IF sy-subrc = 0.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = text-008

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'F2'

value_org = c_s

display = space

callback_program = sy-repid

TABLES

value_tab = gt_f2.

ENDIF.

ENDIF.

IF f1 is not initial.

SELECT aa cc dd FROM t2 INTO TABLE gt_f21

WHERE aa = f1.

IF sy-subrc = 0.

LOOP AT gt_f21 INTO gw_f21.

gw_f2-cc = gw_f21-cc.

gw_f2-dd = gw_f21-dd.

APPEND gw_f2 TO gt_f2.

ENDLOOP.

ENDIF.

ENDIF.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = text-008

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'F2'

value_org = c_s

display = space

callback_program = sy-repid

TABLES

value_tab = gt_f2.

SORT gt_f2 BY cc.

READ TABLE gt_project index sy-index.

psproj = gt_subproj-subproj.

Edited by: Jjammy on Jun 16, 2009 8:46 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
486

Check the below code.

tables: t001k.

  • For Identification Number

DATA: BEGIN OF it_bwkey OCCURS 0,

bwkey LIKE t001k-bwkey,

END OF it_bwkey.

data: v_bukrs(4).

  • For Run date

DATA: BEGIN OF it_bukrs OCCURS 0,

bukrs LIKE t001k-bukrs,

END OF it_bukrs.

DATA it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN: BEGIN OF BLOCK main WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP.

PARAMETERS: p_bukrs(4) TYPE c.

SELECT-OPTIONS s_bwkey FOR t001k-bwkey NO INTERVALS.

SELECTION-SCREEN END OF BLOCK main.

INITIALIZATION.

SELECT DISTINCT bukrs FROM t001k INTO TABLE it_bukrs.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING retfield = 'BUKRS'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_BUKRS'

value_org = 'S'

TABLES value_tab = it_bukrs

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.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bwkey-low.

TABLES: t130r.

DATA: BEGIN OF dynpfields OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA: END OF dynpfields.

DATA : sy_repid LIKE sy-repid,

sy_dynnr LIKE sy-dynnr.

CLEAR dynpfields.

REFRESH dynpfields.

dynpfields-fieldname = 'P_BUKRS'.

APPEND dynpfields.

sy_repid = sy-repid.

sy_dynnr = sy-dynnr.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy_repid

dynumb = sy_dynnr

TABLES

dynpfields = dynpfields

EXCEPTIONS

OTHERS = 01.

IF sy-subrc = 0.

READ TABLE dynpfields WITH KEY fieldname = 'P_BUKRS'.

IF sy-subrc = 0.

v_bukrs = dynpfields-fieldvalue.

ENDIF.

ENDIF.

SELECT bwkey FROM t001k INTO TABLE it_bwkey WHERE bukrs = v_bukrs.

DELETE ADJACENT DUPLICATES FROM it_bwkey.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'BWKEY'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'S_BWKEY'

value_org = 'S'

TABLES

value_tab = it_bwkey

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.

Regards,

Kumar Bandandham

3 REPLIES 3
Read only

Former Member
0 Likes
486

hi,

refer this :

If requirement in selection screen.

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

then use FM : F4IF_INT_TABLE_VALUE_REQUEST.

and pass the i.tab here in AS

tables

value_t = i.tab

REGARDS

RAHUL

Read only

GauthamV
Active Contributor
0 Likes
486

Plz SEARCH in SCN before posting, and use while posting.

Use this.


REPORT Z_TEST.

tables tcurt.
DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency
P_LTEXT LIKE TCURT-LTEXT, "Long Text
P_KTEXT LIKE TCURT-KTEXT. "Short Text

*Example of updating value of another field on the screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
CLEAR: DYFIELDS[], DYFIELDS.
*select currency
CALL FUNCTION 'HELP_VALUES_GET'
EXPORTING
fieldname = 'WAERS'
tabname = 'TCURT'
IMPORTING
SELECT_VALUE = P_WAERS.

*get long text for the selected currency
SELECT SINGLE LTEXT FROM TCURT
INTO DYFIELDS-FIELDVALUE
WHERE SPRAS = SY-LANGU
AND WAERS = P_WAERS.
IF SY-SUBRC <> 0.
CLEAR DYFIELDS-FIELDVALUE.
ENDIF.

*update another field
DYFIELDS-FIELDNAME = 'P_LTEXT'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
tables
dynpfields = DYFIELDS .

*Example of reading value of another field
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_KTEXT.
*read another field
CLEAR: DYFIELDS[], DYFIELDS.
DYFIELDS-FIELDNAME = 'P_WAERS'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = DYFIELDS .
READ TABLE DYFIELDS INDEX 1.

*get short text and update current field
SELECT SINGLE KTEXT FROM TCURT
INTO P_KTEXT
WHERE SPRAS EQ SY-LANGU
AND WAERS EQ DYFIELDS-FIELDVALUE.

Read only

Former Member
0 Likes
487

Check the below code.

tables: t001k.

  • For Identification Number

DATA: BEGIN OF it_bwkey OCCURS 0,

bwkey LIKE t001k-bwkey,

END OF it_bwkey.

data: v_bukrs(4).

  • For Run date

DATA: BEGIN OF it_bukrs OCCURS 0,

bukrs LIKE t001k-bukrs,

END OF it_bukrs.

DATA it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN: BEGIN OF BLOCK main WITH FRAME TITLE text-001.

SELECTION-SCREEN SKIP.

PARAMETERS: p_bukrs(4) TYPE c.

SELECT-OPTIONS s_bwkey FOR t001k-bwkey NO INTERVALS.

SELECTION-SCREEN END OF BLOCK main.

INITIALIZATION.

SELECT DISTINCT bukrs FROM t001k INTO TABLE it_bukrs.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bukrs.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING retfield = 'BUKRS'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_BUKRS'

value_org = 'S'

TABLES value_tab = it_bukrs

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.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_bwkey-low.

TABLES: t130r.

DATA: BEGIN OF dynpfields OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA: END OF dynpfields.

DATA : sy_repid LIKE sy-repid,

sy_dynnr LIKE sy-dynnr.

CLEAR dynpfields.

REFRESH dynpfields.

dynpfields-fieldname = 'P_BUKRS'.

APPEND dynpfields.

sy_repid = sy-repid.

sy_dynnr = sy-dynnr.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy_repid

dynumb = sy_dynnr

TABLES

dynpfields = dynpfields

EXCEPTIONS

OTHERS = 01.

IF sy-subrc = 0.

READ TABLE dynpfields WITH KEY fieldname = 'P_BUKRS'.

IF sy-subrc = 0.

v_bukrs = dynpfields-fieldvalue.

ENDIF.

ENDIF.

SELECT bwkey FROM t001k INTO TABLE it_bwkey WHERE bukrs = v_bukrs.

DELETE ADJACENT DUPLICATES FROM it_bwkey.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'BWKEY'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'S_BWKEY'

value_org = 'S'

TABLES

value_tab = it_bwkey

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.

Regards,

Kumar Bandandham