‎2008 Nov 04 9:31 AM
Hi Experts,
I am facing this issue.
I have two fields - Catgory ID and Category Description.
I have created a search help whihc returns both the parameters.
Now how do i access the two parameters inside my report in SE38.
I need to show the Description to the User and use the ID for Programming.
‎2008 Nov 04 9:34 AM
‎2008 Nov 04 9:34 AM
‎2008 Nov 04 9:38 AM
Hi,
Let me be more clear.
I have a field on my screen - CAT Description.
Now there is a field CAT GUID which is the unique key in a DB table.
I have a F4 help on CAT Description which exports back two parameters - GUID and Description.
Now i need to access both these parameters in my report.
I have to show Description in the input field on the selectionscreen.
and i need to use the ID field to process furthut data.
‎2008 Nov 04 9:46 AM
Hi Gaurav,
After getting the description value from selection screen you can use SELECT SINGLE statement to get GUID from DB table into one variable, as description is the only key it will get the associated GUID only.
You can use this value further to your processing.
Regards,
Vikas.
‎2008 Nov 04 9:49 AM
Hi Vikas,
I have the GUID as the key field and not the description.
I need the GUID for the description.
If i do select single, the GUID selected may not be correct as i can have multiple GUID with same description.
‎2008 Nov 04 9:50 AM
Hi ,
Instead of using serch help try using fm 'F4IF_INT_TABLE_VALUE_REQUEST'
and pass only the deciption field value..
as u r getting both id and description in the above fm pass only description and then in ur program already u have id...
now u can read what is the description that the user has selected in the selection screen,get the corresponding id and then process ur program...
the same thingu can do for ur search help,though it shows both on the screen, the description field will be filled by description only and then u can read it in ur program..
Regards,
Nagaraj
‎2008 Nov 04 9:58 AM
Ok, so in this case you need to use FM 'F4IF_INT_TABLE_VALUE_REQUEST'.
Fill up the dynpfld_mapping table by passing field name and dyn field name for both the fields. Pass this table to above FM. You will get the selected values into table return_tab for both the fields.
Take a look into debug how the values are populated into the return table.
Here is one sample code for you.
******************************************************
REFRESH: i_dyn, i_ret.
MOVE:
'FIELD1' TO wa_dyn-fldname,
pv_dynfld_1 TO wa_dyn-dyfldname.
APPEND wa_dyn TO i_dyn.
CLEAR: wa_dyn.
MOVE:
'FIELD2' TO wa_dyn-fldname,
pv_dynfld_2 TO wa_dyn-dyfldname.
APPEND wa_dyn TO i_dyn.
CLEAR: wa_dyn.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CODEGRUPPE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = pv_dynfld_1
value_org = c_s
TABLES
value_tab = i_qpgrk
field_tab = i_field
return_tab = i_ret
dynpfld_mapping = i_dyn
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
No Values Found
MESSAGE text-s01 TYPE c_s.
ENDIF. " IF sy-subrc NE 0
****************************************************
Regards,
Vikas.
‎2008 Nov 04 10:03 AM
Hi Vikas,
So do i need to update the description field on teh selection screen manually or the field will be filled automaticallly???
Regards
Gaurav Raghav
‎2008 Nov 04 10:05 AM
As you select the values from F4 popup these values will be filled automatic into the return table.
Regards,
Vikas.
‎2008 Nov 04 10:08 AM
yes vikas.
what i mean is that since i am going to provide F4 help for field Description and use this Fm to get the data.
When the user selects an entry, i will get both entries in th ret_tab.
but will the selection-screen field 'description' will be filled or i need to do that m,yself.
‎2008 Nov 04 10:10 AM
ya..the selection screen field value will be filled automatic..no need to enter again manually..
‎2008 Nov 04 10:28 AM
Hi Vikas,
Where do i specify the Search Help i am using to get the values in the F4.
‎2008 Nov 04 10:44 AM
You need not to specify the search help in this case. Just write one perform as below.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_field.
PERFORM provide_f4 USING 'P_FIELD'.
and write the code to call the FM into this form.
Regards,
Vikas.
‎2008 Nov 04 10:48 AM
Hi Vikas,
I need to show the user a F4 Help for the Screen field 'Description' and then the search help will return both Description and GUID.
Now i need to fill the Description field in the selection screen and somehow be able to access the GUID for furthur processing.
‎2008 Nov 04 10:53 AM
Gaurav, try to debug the code. After the user selects any value from F4 popup both the GUID and description will be filled into return table. After you function call you just need to READ this internal table to get the GUID.
For more information about this you can go through the documentation avilable for that function module.
Regards,
Vikas.
‎2008 Nov 04 10:57 AM
Hi Vikas,
Then i need to write the code to get the values in the F4 help in the program itself and also how do i know which entry the user has selected????
‎2008 Nov 04 11:08 AM
Yes, you need to write the explicit code to get F4 values in your report and as I said the selected values will be populated into RETURN table. You have to just need to READ this table to get those values.
Go to your Report. Write the perform as I already sent. Get the F4 help value table. Put your code to call that function module. Read the table after this FM call and finaly put a BREAK-POINT on this read statement and see what all values are there.
Regards,
Vikas.
‎2008 Nov 05 12:27 PM
Hi Vikas,
I am able to see only one value in the return table i.e the description.
I have added the code to get the F4 value table in lt_cat_label.
but the lt_return is onlt getting one value.
here is the code.
IF sy-subrc EQ 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'P_RES1'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_RES1'
value_org = 'S'
TABLES
value_tab = lt_cat_label
return_tab = lt_ret_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc EQ 0.
READ TABLE lt_ret_tab INTO ls_ret_tab INDEX 1.
ENDIF.
ENDIF.
Please let me know what is the mistake i am doing??
Regards
Gaurav
‎2008 Nov 05 1:00 PM
As I said you need to first fill up the dyn table for both the fields. Here is sample code again.
******************************************************
REFRESH: i_dyn, i_ret.
MOVE:
'FIELD1' TO wa_dyn-fldname,
pv_dynfld_1 TO wa_dyn-dyfldname.
APPEND wa_dyn TO i_dyn.
CLEAR: wa_dyn.
MOVE:
'FIELD2' TO wa_dyn-fldname,
pv_dynfld_2 TO wa_dyn-dyfldname.
APPEND wa_dyn TO i_dyn.
CLEAR: wa_dyn.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CODEGRUPPE'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = pv_dynfld_1
value_org = c_s
TABLES
value_tab = i_qpgrk
field_tab = i_field
return_tab = i_ret
dynpfld_mapping = i_dyn
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
No Values Found
MESSAGE text-s01 TYPE c_s.
ENDIF. " IF sy-subrc NE 0
****************************************************
Map your code to this, pass the GUID and description field to dyn table and then see the return table.
Regards,
Vikas.
‎2008 Nov 05 1:04 PM
Hi Vikas,
Thats the whole problem Vikas.
I have a search help returning me two parameters.
But i have to show the description on the selection screen while i need the GUID to process data in my report.
How can i go about resolving this???
Regards
Gaurav raghav
‎2008 Nov 05 1:45 PM
Hi Gaurav,
Please follow this sample code below, this code returns the description of the material
to the screen field(parameter) "p_maktx" and the material selected is captured in the variable w_matnr
REPORT zytest.
PARAMETERS:
p_matnr TYPE mara-matnr,
p_maktx TYPE makt-maktx.
DATA:
BEGIN OF itab OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF itab,
t_dynptab TYPE TABLE OF dselc,
t_rettab TYPE TABLE OF ddshretval,
fs_rettab TYPE ddshretval,
fs_dynptab TYPE dselc,
w_matnr TYPE mara-matnr.
INITIALIZATION.
SELECT matnr
maktx
FROM makt
INTO TABLE itab
UP TO 20 ROWS
WHERE spras = sy-langu.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'P_MAKTX'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
fs_dynptab-fldname = 'F0001'.
fs_dynptab-dyfldname = 'P_MATNR'.
APPEND fs_dynptab TO t_dynptab.
fs_dynptab-fldname = 'F0002'.
fs_dynptab-dyfldname = 'P_MAKTX'.
APPEND fs_dynptab TO t_dynptab.
fs_rettab-fieldname = 'P_MATNR'.
APPEND fs_rettab TO t_rettab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = 'ZYTEST'
dynpnr = sy-dynnr
dynprofield = 'P_MATNR'
value_org = 'S'
TABLES
value_tab = itab
return_tab = t_rettab
dynpfld_mapping = t_dynptab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc EQ 0.
READ TABLE t_rettab INTO fs_rettab WITH KEY fieldname = 'F0001'.
IF sy-subrc EQ 0.
w_matnr = fs_rettab-fieldval.
ENDIF.
ENDIF.
CLEAR w_matNr.
START-OF-SELECTION.
‎2008 Nov 06 4:35 AM
Hi Rajesh,
Can i achieve the same functionality for a Select-option also????
Regards
Gaurav Kumar Raghav
‎2008 Nov 06 4:50 AM
>
> Can i achieve the same functionality for a Select-option also????
Yes, that can be achieved, please look into the code below
REPORT zytest.
TABLES:
mara.
SELECT-OPTIONS:
s_matnr FOR mara-matnr. " <- Change
PARAMETERS:
p_maktx TYPE makt-maktx.
DATA:
BEGIN OF itab OCCURS 0,
matnr LIKE makt-matnr,
maktx LIKE makt-maktx,
END OF itab,
t_dynptab TYPE TABLE OF dselc,
t_rettab TYPE TABLE OF ddshretval,
fs_rettab TYPE ddshretval,
fs_dynptab TYPE dselc,
w_matnr TYPE mara-matnr.
INITIALIZATION.
SELECT matnr
maktx
FROM makt
INTO TABLE itab
UP TO 20 ROWS
WHERE spras = sy-langu.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'P_MAKTX'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_matnr-low. " <- Change
fs_dynptab-fldname = 'F0001'.
fs_dynptab-dyfldname = 'S_MATNR-LOW'. " <- Change
APPEND fs_dynptab TO t_dynptab.
fs_dynptab-fldname = 'F0002'.
fs_dynptab-dyfldname = 'P_MAKTX'.
APPEND fs_dynptab TO t_dynptab.
fs_rettab-fieldname = 'P_MATNR'.
APPEND fs_rettab TO t_rettab.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = 'ZYTEST'
dynpnr = sy-dynnr
dynprofield = 'S_MATNR-LOW' " <- Change
value_org = 'S'
TABLES
value_tab = itab
return_tab = t_rettab
dynpfld_mapping = t_dynptab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc EQ 0.
CLEAR w_matnr.
READ TABLE t_rettab INTO fs_rettab WITH KEY fieldname = 'F0001'.
IF sy-subrc EQ 0.
w_matnr = fs_rettab-fieldval.
ENDIF.
ENDIF.
START-OF-SELECTION.
‎2008 Nov 04 9:49 AM
You must be using F4_IF_INT_TABLE...fm to generate the F4.
After user selects the value, you can read the table (which you are passing to F4) and get the description
‎2008 Nov 04 9:52 AM
Hi Swastik,
Can u tell me how to pass the data into the FM F4_IF_INT_TABLE and retrieve the data in my report program.
‎2008 Nov 05 2:33 PM
Hi Rajesh,
Thanks for the code sample.
That really worked out.
I was just messing up in passing the right structure to the dynprotab.
Thanks and Regards
Gaurav Raghav