05-18-2006 3:55 AM
DEar All,
I have a requirement actually I have a field shipping codition on the screen for which I have created the custom F4 help now when I select the the value using the F4 help I want another fields shipping type on the scren to be filled atomatically based on the shipping condition.
Mean to say I will click F4 only on shipping condition field and ressult will be both the fields shipping condition and shipping type would be filled on the screen.
Please suggest,
Thanks,
Anup.
05-18-2006 4:06 AM
Hi,
You need to fill the DYNPFLD_MAPPING of function module F4IF_INT_TABLE_VALUE_REQUEST with the fields to be displayed when F4 is selected. For more clarification refer the function module documentation.
Regards,
Arun.
05-18-2006 4:14 AM
Anup,
You can use AT SELECTION-SCREEN event. Do F1 on this event in ABAP editor you'll get your answer.
Thanks,
Giri.
05-18-2006 4:38 AM
for f4 help on the particular field
AT SELECTION-SCREEN ON VALUE-REQUEST ON <P>.
CALL FUNCTION F4IF_INT_TABLE_VALUE_REQUEST.
for the other field to be populated when the above field is field,
call function DYNP_VALUES_READ
CALL FUNCTION DYNP_VALUES_UPDATE.
05-18-2006 5:14 AM
Hi Anup,
You can use the function module DYNP_VALUES_UPDATE to update the values in another field.
Check this code.
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
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
CLEAR: DYFIELDS[], DYFIELDS.
CALL FUNCTION 'HELP_VALUES_GET'
EXPORTING
fieldname = 'WAERS'
tabname = 'TCURT'
IMPORTING
SELECT_VALUE = P_WAERS.
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 .
In this code, the Function MOdule HELP_VALUES_GET is obsolete.
You can use the Function Module F4IF_FIELD_VALUE_REQUEST to store the value selected in the F4 help..
Hope your query is solved..
Regards,
SP.
05-18-2006 5:45 AM
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'VALUE'
dynpprog = sy-repid
dynpnr = '1'
dynprofield = 'VALUE'
window_title = 'HELP FOR TABLE NAME'
value_org = 'S'
tables
value_tab = t_f4_table
return_tab = t_return
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.
read table t_return index 1.
if sy-subrc = 0.
condense t_return-fieldval no-gaps.
if not t_return-fieldval is initial.
Check for Numeric Value
call function 'CATS_NUMERIC_INPUT_CHECK'
exporting
input = t_return-fieldval
exceptions
no_numeric = 1
others = 2.
if sy-subrc = 0.
read table t_f4_table index t_return-fieldval.
if sy-subrc = 0.
call function 'DYNP_GET_STEPL' importing
povstepl = step_line exceptions
stepl_not_found = 1
others = 2.
clear: ltab_fields.
refresh : ltab_fields.
ltab_fields-fieldname = 'ZMM_TABLE-TABNAME'.
ltab_fields-fieldvalue = t_f4_table-tabname.
ltab_fields-stepl = step_line.
append ltab_fields.
ltab_fields-fieldname = 'ZMM_TABLE-FLDNAME'.
ltab_fields-fieldvalue = t_f4_table-fieldname.
ltab_fields-stepl = step_line.
append ltab_fields.
ltab_fields-fieldname = 'ZMM_TABLE-VALUE'.
ltab_fields-fieldvalue = t_f4_table-fieldtext.
ltab_fields-stepl = step_line.
append ltab_fields.
call function 'DYNP_VALUES_UPDATE' exporting
dyname = lc_dyname
dynumb = lc_dynumb
tables
dynpfields = ltab_fields
exceptions
others = 8.
commit work and wait.
else.
clear : zmm_table-tabname, zmm_table-fldname, zmm_table-value.
endif.
endif.
endif.
endif.
OR
REPORT ZVV.
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.
*----
05-18-2006 7:09 AM
Hai Anup
Check the following code
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ldf_tabname " Structure of VALUE_TAB
RETFIELD = LDF_FLDNAME "Name of return field in FIELD_TAB
PVALKEY = ' '
DYNPPROG = ' '
DYNPNR = ' '
DYNPROFIELD = ' '
STEPL = 0
WINDOW_TITLE =
VALUE = ' '
VALUE_ORG = LCF_VAL "Value return
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
MARK_TAB =
IMPORTING
USER_RESET =
TABLES
VALUE_TAB = TAB_TEMP " Table of Values
FIELD_TAB = LDT_FLDTAB " Fileds of the Hit list
RETURN_TAB = LDT_RETTAB " return the selected value
DYNPFLD_MAPPING =
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.
READ TABLE LDT_RETTAB INDEX 1.
DATA: LDT_DFIES LIKE DFIES OCCURS 0 WITH HEADER LINE.
CLEAR LDT_DFIES.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = LDF_TABNANME
FIELDNAME = LDF_FLDNAME
LANGU = SY-LANGU
LFIELDNAME = ' '
ALL_TYPES = ' '
GROUP_NAMES = ' '
UCLEN =
IMPORTING
X030L_WA =
DDOBJTYPE =
DFIES_WA =
LINES_DESCR =
TABLES
DFIES_TAB = LDT_DFIES " Field List
FIXED_VALUES =
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 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.
Thanks & regards
Sreenivasulu P
05-18-2006 7:48 AM
Check out the below program.It populates multiple fields on pressing F4 for one field.If your query is solved please close this thread.
&----
*& Report Z_POPULATE *
*& *
&----
*& *
*& *
&----
REPORT Z_POPULATE .
*----
DATA : dd LIKE TABLE OF dselc WITH HEADER LINE. "*--- IMPORTANT
DATA : ft LIKE TABLE OF dfies WITH HEADER LINE.
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
*----
PARAMETERS : bukrs LIKE t001-bukrs .
PARAMETERS : butxt LIKE t001-butxt.
PARAMETERS : ort01 LIKE t001-ort01.
PARAMETERS : waers LIKE t001-waers.
*----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR bukrs.
SELECT * FROM t001 INTO TABLE t001.
*----
IMPORTANT
REFRESH dd.
dd-fldname = 'BUTXT'.
dd-dyfldname = 'BUTXT'.
APPEND dd.
dd-fldname = 'ORT01'.
dd-dyfldname = 'ORT01'.
APPEND dd.
dd-fldname = 'WAERS'.
dd-dyfldname = 'WAERS'.
APPEND dd.
*------- IMPORTANT
REFRESH ft.
ft-tabname = 'T001'.
ft-fieldname = 'BUTXT'.
APPEND ft.
ft-tabname = 'T001'.
ft-fieldname = 'WAERS'.
APPEND ft.
ft-tabname = 'T001'.
ft-fieldname = 'ORT01'.
APPEND ft.
*----
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
ddic_structure = 'T001' "*----- IMPORTANT IF STANDARD STRUCT
retfield = 'BUKRS'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'BUKRS'
value_org = 'S'
TABLES
field_tab = ft "*---- IMPORTANT
value_tab = t001
dynpfld_mapping = dd "* IMPORTANT
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
05-18-2006 12:54 PM
Thanks all for replying..
Dear Nishanth,
I tried ur code as it seems the idea one for my problem. Did you run that code before beacuse I'm doing the same but system give some dummy values on click of F4.
05-18-2006 1:47 PM
Hi Anup ,
I executed Nishant's program and from that I suppose your requirement is "When I select a value from a search help , immediately another field should be filled with the corresponding value."
Just check this code..It has the same requirement.
tables TCURT.
DATA: RTAB TYPE TABLE OF DDSHRETVAL WITH HEADER LINE.
DATA DYFIELDS LIKE DYNPREAD OCCURS 1 WITH HEADER LINE.
PARAMETERS: P_WAERS LIKE TCURT-WAERS, "Currency
P_LTEXT LIKE TCURT-LTEXT. "Long Text
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_WAERS.
CLEAR: DYFIELDS[], DYFIELDS.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = 'TCURT'
fieldname = 'WAERS'
SEARCHHELP = ' '
SHLPPARAM = ' '
DYNPPROG = ' '
DYNPNR = ' '
DYNPROFIELD = ' '
STEPL = 0
VALUE = ' '
MULTIPLE_CHOICE = ' '
DISPLAY = ' '
SUPPRESS_RECORDLIST = ' '
CALLBACK_PROGRAM = ' '
CALLBACK_FORM = ' '
TABLES
RETURN_TAB = RTAB[]
EXCEPTIONS
FIELD_NOT_FOUND = 1
NO_HELP_FOR_FIELD = 2
INCONSISTENT_HELP = 3
NO_VALUES_FOUND = 4
OTHERS = 5
.
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 RTAB INDEX SY-TABIX.
P_WAERS = RTAB-FIELDVAL.
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 .
Hope your query will be solved...
Regards,
SP.
Message was edited by: Sylendra Prasad
05-19-2006 2:24 AM
Dear Sylendra,
Thanks for replying..
See I can't even go the way u suggested because the first field which I slect on F4 is not the only key field in the databse table so later if I use "Read return_tab" this will give the value of onl one column and with that value I can't make a queryy in the database ystem will give duplicate entries. In case of single primary key field your method is correct. So is there any way by which i can read the whole row which user selects in the F4 help?
Thanks,
Anup.
05-19-2006 4:21 AM
Hi Anup,
Just populate the table DYNPFLD_MAPPING of function module F4IF_INT_TABLE_VALUE_REQUEST with your fields to be displayed on the screen, which will map the values to the screen fields directly whenever you select the row .
Regards,
Arun.
05-19-2006 4:33 AM
Hi Anup,
Here is another way you can do to retrieve your other fields.
add a count column to your internal table to make it
unique.
here is a sample code.
=====================================================
parameter: p_fname like z340b_md-fname.
tables: z340b.
data: temp_fname like z340b_md.
DATA: BEGIN OF itab_details OCCURS 0,
<b>count type c,</b>
fname like z340b_md-fname,
END OF itab_details.
data: begin of itab_details1 occurs 0,
<b>count1 type c,</b>
include structure z340b_md.
data: end of itab_details1.
DATA it_return LIKE ddshretval OCCURS 0 WITH HEADER LINE.
SELECT * FROM z340b_md INTO CORRESPONDING FIELDS OF
itab_details.
APPEND itab_details.
ENDSELECT.
loop at itab_details.
<b>itab_details-count = sy-tabix.</b>
modify itab_details.
clear itab_details.
endloop.
SELECT * FROM z340b_md INTO CORRESPONDING FIELDS OF
itab_details1.
APPEND itab_details1.
ENDSELECT.
loop at itab_details1.
<b>itab_details-count1 = sy-tabix.</b>
modify itab_details1.
clear itab_details1.
endloop.
SORT itab_details BY count.
CLEAR itab_details.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'count'
window_title = 'Physicians details'
value_org = 'S'
TABLES
value_tab = itab_details
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
CLEAR itab_details.
READ TABLE it_return INDEX 1.
<b>itab_details-count</b> = it_return-fieldval.
READ TABLE itab_details WITH KEY count = itab_details-count.
if sy-subrc eq 0.
temp_fname = itab_details-fname.
endif.
ENDIF.
read table itab_details1 with key count1 = itab_details-count
fname = temp_fname.
if sy-subrc eq 0.
<b>assign your other fields here</b>
end if.
REFRESH itab_details. CLEAR: itab_details.
REFRESH itab_details1. CLEAR: itab_details1.
=======================================================
I will try to explain you as much as what i meant you to do. declare two internal tables by including an extra column by name count and count1. when the user clicks on F4, you will show the data from first internal table <b>itab_details</b> with two columns count and fname (this is your first custom field). when the user selects any one of the record, we will read the fname corresponding to that field and read the second internal table itab_details1 with this count and fname as key fields.
if this condition is satisfied, you will assign the remaining fields from second internal table.
I am damn sure this is what you want. I might not be clear in explaining but you can try with above code and it will work.
Regards,
Vicky
05-19-2006 4:33 AM
Hi Anup,
Here is the code I have tried to copy multiple values, it is working fine, try this program once.
REPORT ZTEST_F4_MULTIPLE_FIELDS .
TYPES: BEGIN OF ad_loc_type,
location_cd TYPE zloc_cd,
location_desc TYPE zloc,
bland TYPE regio,
land1 TYPE land1,
upper TYPE char30,
END OF ad_loc_type.
DATA: w_ad_display TYPE char1,
w_ad_change TYPE char1,
w_ad_progname TYPE sy-repid,
w_ad_dynnum TYPE sy-dynnr ,
t_dselc TYPE STANDARD TABLE OF dselc,
t_ad_loc_mast TYPE STANDARD TABLE OF ad_loc_type
WITH KEY location_cd.
DATA : wa_data TYPE ad_loc_type .
PARAMETERS :
p2 TYPE zloc ,
*data :
p3 TYPE regio ,
p4 TYPE land1 .
CONSTANTS
c_structed TYPE char1 VALUE 'S' .
INITIALIZATION .
w_ad_progname = sy-cprog .
w_ad_dynnum = sy-dynnr .
wa_data-location_desc = 'Desc1'.
wa_data-bland = 'MO'.
wa_data-land1 = 'US'.
APPEND wa_data TO t_ad_loc_mast .
wa_data-location_desc = 'Desc2'.
wa_data-bland = 'WA'.
wa_data-land1 = 'US'.
APPEND wa_data TO t_ad_loc_mast .
wa_data-location_desc = 'Desc3'.
wa_data-bland = 'CA'.
wa_data-land1 = 'US'.
APPEND wa_data TO t_ad_loc_mast .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p2 .
PERFORM f4_help.
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF screen-name = 'P3' OR screen-name = 'P4'.
screen-input = 0.
MODIFY SCREEN .
ENDIF.
ENDLOOP .
START-OF-SELECTION .
WRITE 😕 p2 .
WRITE 😕 p3 .
WRITE 😕 p4 .
delete from ZSERV_CMTMNT_CTR where werks = '03BV' .
COMMIT WORK .
----
FORM F4_HELP *
----
........ *
----
FORM f4_help .
DATA : WA_1 TYPE dselc .
REFRESH t_dselc.
PERFORM fill_dselc USING: 'F0003' 'P3',
'F0004' 'P4'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'LOCATION_DESC'
dynpprog = w_ad_progname
dynpnr = w_ad_dynnum
dynprofield = 'P2'
value_org = c_structed
TABLES
value_tab = t_ad_loc_mast
dynpfld_mapping = t_dselc.
LOOP AT t_dselc INTO WA_1.
WRITE : WA_1 .
ENDLOOP.
ENDFORM .
----
FORM fill_dselc *
----
FORM fill_dselc USING pw_field pw_screen_field.
DATA: wal_dselc TYPE dselc.
wal_dselc-fldname = pw_field.
wal_dselc-dyfldname = pw_screen_field.
APPEND wal_dselc TO t_dselc.
ENDFORM.
Regards,
Arun.
05-18-2006 8:00 AM
Hi,
check this sample code.
REPORT ZTEST_F4HELP .
*---Report with selection screen and to display the list of
* possible entries for field 'B' as per the value in field 'A'.
parameters: p_vbeln type vbak-vbeln,
p_posnr type vbap-posnr.
at selection-screen on value-request for p_posnr.
data: begin of help_item occurs 0,
posnr type vbap-posnr,
matnr type vbap-matnr,
arktx type vbap-arktx,
end of help_item.
data: dynfields type table of dynpread with header line.
dynfields-fieldname = 'P_VBELN'.
append dynfields.
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-cprog
dynumb = sy-dynnr
translate_to_upper = 'X'
tables
dynpfields = dynfields
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.
read table dynfields with key fieldname = 'P_VBELN'.
p_vbeln = dynfields-fieldvalue.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = p_vbeln
importing
output = p_vbeln.
select posnr matnr arktx into table help_item
from vbap
where vbeln = p_vbeln.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'POSNR'
dynprofield = 'P_POSNR'
dynpprog = sy-cprog
dynpnr = sy-dynnr
value_org = 'S'
tables
value_tab = help_item.
Regards
vijay
05-18-2006 2:36 PM
Hi Anup,
Try this way.
=======================================================
parameter: p_fname like z340b_md-fname.
tables: z340b.
DATA: BEGIN OF itab_details OCCURS 0,
ID like z340b_md-id,
fname like z340b_md-fname,
lname like z340b_md-lname.
DATA: END OF itab_details.
DATA it_return LIKE ddshretval OCCURS 0 WITH HEADER LINE.
SELECT * FROM z340b_md INTO CORRESPONDING FIELDS OF
itab_details WHERE fname eq p_fname.
APPEND itab_details.
ENDSELECT.
SORT itab_details BY ID.
CLEAR itab_details.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ID'
window_title = 'Physicians details'
value_org = 'S'
TABLES
value_tab = itab_details
return_tab = it_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
CLEAR itab_details.
READ TABLE it_return INDEX 1.
itab_details-ID = it_return-fieldval.
READ TABLE itab_details WITH KEY ID = itab_details-ID.
if sy-subrc eq 0.
write: / 'id:', itab_details-id.
write: / 'firstname:' , itab_details-fname.
write: / 'lastname:' , itab_details-lname.
endif.
ENDIF.
REFRESH itab_details. CLEAR: itab_details.
======================================================
In this case, i am writing to the screen, but you need to assign values to your screen fields.
Hope this will help you out.
Regards,
vicky
PS: Award points if helpful