‎2009 Mar 26 8:32 AM
hi,
I have a table of 2 values ( WBS and project definition code ) , I used this function F4IF_INT_TABLE_VALUE_REQUEST for F4 on the project definition field. After that I want to return both Project definition and WBS that I've selected . I used value_org = 'S" but I can get only 1 record in the return_table ? Could you please help me?
Thanks in advance
‎2009 Mar 26 8:42 AM
Hi,
Check this Code..
F4 help is povided on the P_PLNNR field and if any data is selected then P_PLNNR and P_PLNAL is updated in the screen. Both values are shown in the F4 help(P_PLNNR and P_PLNAL ).
PARAMETES : p_werks type ...
PARAMETES : p_plnnr type ....
PARAMETES : p_plnal type....
AT SELECTION-SCREEN ON P_PLNNR.
data:
lg_condition type string.
data:
lwa_ddshretval type ddshretval,
lwa_dselc type dselc,
lwa_dynpread type dynpread.
data:
li_f4_insp type standard table of t_f4_insp,
li_ddshretval type standard table of ddshretval,
li_dselc type standard table of dselc,
li_dynpread type standard table of dynpread.
lwa_dynpread-fieldname = 'P_WERKS'.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
* Read Screen Field Values.
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = li_dynpread.
* Read the first record as only one record will be present
read table li_dynpread into lwa_dynpread index 1.
p_werks = lwa_dynpread-fieldvalue.
if p_werks is initial.
move 'PLNTY EQ ''Q''' to lg_condition.
else.
move 'WERKS EQ P_WERKS AND PLNTY EQ ''Q''' to lg_condition.
endif.
* Fetch Data
select werks
plnnr
plnal
plnty
ktext
into table li_f4_insp
from plko
where (lg_condition).
lwa_dselc-fldname = 'F0002'.
lwa_dselc-dyfldname = 'PLNNR'.
append lwa_dselc to li_dselc.
clear lwa_dselc.
lwa_dselc-fldname = 'F0003'.
lwa_dselc-dyfldname = 'PLNAL'.
append lwa_dselc to li_dselc.
clear lwa_dselc.
* FM For F4 Help
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'PLNNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'PLNNR'
value_org = 'S'
tables
value_tab = li_f4_insp
return_tab = li_ddshretval
dynpfld_mapping = li_dselc
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc eq 0.
refresh li_dynpread.
read table li_ddshretval into lwa_ddshretval index 1.
if sy-subrc eq 0.
move lwa_ddshretval-fieldval to p_plnnr.
lwa_dynpread-fieldname = 'P_PLNNR'.
lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
endif. " IF sy-subrc EQ 0.
read table li_ddshretval into lwa_ddshretval index 2.
if sy-subrc eq 0.
move lwa_ddshretval-fieldval to p_plnal.
lwa_dynpread-fieldname = 'P_PLNAL'.
lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
endif. " IF sy-subrc EQ 0.
endif. " IF sy-subrc EQ 0.
* Set Screen Field Values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = li_dynpread
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
check sy-subrc eq 0.
‎2009 Mar 26 8:42 AM
Hi,
Check this Code..
F4 help is povided on the P_PLNNR field and if any data is selected then P_PLNNR and P_PLNAL is updated in the screen. Both values are shown in the F4 help(P_PLNNR and P_PLNAL ).
PARAMETES : p_werks type ...
PARAMETES : p_plnnr type ....
PARAMETES : p_plnal type....
AT SELECTION-SCREEN ON P_PLNNR.
data:
lg_condition type string.
data:
lwa_ddshretval type ddshretval,
lwa_dselc type dselc,
lwa_dynpread type dynpread.
data:
li_f4_insp type standard table of t_f4_insp,
li_ddshretval type standard table of ddshretval,
li_dselc type standard table of dselc,
li_dynpread type standard table of dynpread.
lwa_dynpread-fieldname = 'P_WERKS'.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
* Read Screen Field Values.
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = li_dynpread.
* Read the first record as only one record will be present
read table li_dynpread into lwa_dynpread index 1.
p_werks = lwa_dynpread-fieldvalue.
if p_werks is initial.
move 'PLNTY EQ ''Q''' to lg_condition.
else.
move 'WERKS EQ P_WERKS AND PLNTY EQ ''Q''' to lg_condition.
endif.
* Fetch Data
select werks
plnnr
plnal
plnty
ktext
into table li_f4_insp
from plko
where (lg_condition).
lwa_dselc-fldname = 'F0002'.
lwa_dselc-dyfldname = 'PLNNR'.
append lwa_dselc to li_dselc.
clear lwa_dselc.
lwa_dselc-fldname = 'F0003'.
lwa_dselc-dyfldname = 'PLNAL'.
append lwa_dselc to li_dselc.
clear lwa_dselc.
* FM For F4 Help
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'PLNNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = 'PLNNR'
value_org = 'S'
tables
value_tab = li_f4_insp
return_tab = li_ddshretval
dynpfld_mapping = li_dselc
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc eq 0.
refresh li_dynpread.
read table li_ddshretval into lwa_ddshretval index 1.
if sy-subrc eq 0.
move lwa_ddshretval-fieldval to p_plnnr.
lwa_dynpread-fieldname = 'P_PLNNR'.
lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
endif. " IF sy-subrc EQ 0.
read table li_ddshretval into lwa_ddshretval index 2.
if sy-subrc eq 0.
move lwa_ddshretval-fieldval to p_plnal.
lwa_dynpread-fieldname = 'P_PLNAL'.
lwa_dynpread-fieldvalue = lwa_ddshretval-fieldval.
append lwa_dynpread to li_dynpread.
clear lwa_dynpread.
endif. " IF sy-subrc EQ 0.
endif. " IF sy-subrc EQ 0.
* Set Screen Field Values.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = li_dynpread
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
check sy-subrc eq 0.
‎2009 Mar 26 8:44 AM
Hi,
Refer this demo code to get a S.help for BELNR based on user input for BUKRS:-
PARAMETERS : p_belnr TYPE belnr,
p_bukrs TYPE bukrs.
DATA : BEGIN OF itab OCCURS 0,
belnr TYPE belnr,
END OF itab.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_belnr.
PERFORM f4_belnr_help USING p_belnr.
*&---------------------------------------------------------------------*
*& Form f4_belnr_help
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BELNR text
*----------------------------------------------------------------------*
FORM f4_belnr_help USING p_belnr.
DATA : itab TYPE STANDARD TABLE OF it WITH HEADER LINE,
tb_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE,
v_bukrs TYPE bukrs.
CLEAR: tb_dynpfields.
REFRESH: tb_dynpfields.
MOVE 'P_BUKRS' TO tb_dynpfields-fieldname.
APPEND tb_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = 'Z_F4' "program name
dynumb = '1000' "screen number
TABLES
dynpfields = tb_dynpfields
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 tb_dynpfields INDEX 1.
IF sy-subrc EQ 0.
v_bukrs = tb_dynpfields-fieldvalue.
ENDIF.
SELECT belnr from <db_table> INTO TABLE itab WHERE bukrs = v_bukrs.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR' "internal table field
dynpprog = 'Z_F4' "program name
dynpnr = '1000' "screen number
dynprofield = 'P_BELNR' "screen field name
value_org = 'S'
TABLES
value_tab = itab "internal table
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.
ENDFORM. " f4_belnr_help
Hope this helps you.
Regards,
Tarun
‎2009 Mar 26 8:48 AM