‎2008 Jun 04 4:52 AM
Dear All
I am try to create one Ztable in which I want help(F4) option ( Field name "Company code") in table creation only. What I should do. Please advise.
Thanks
Sureshkumar
‎2008 Jun 04 5:03 AM
Hai,
Link foreign key your Ztable (BUKRS) and T001(BUKRS) table.
That time automatically F4 available.
Thanks,
Durai.V
‎2008 Jun 04 5:03 AM
Let's say the selection screen has two input fields. One is plant i.e., PA_WERKS and other one is object(PA_OBJ). While executing the report, User will first enter the plant name in the WERKS field. Then, he will press F4 at the PA_OBJ field. It should dynamically take the value from PA_WERKS and display the possible values on F4 dialog box by searching in the table ZAIS_MMG.
Solution is written below and all the comments were provided at necessary places. Table need not be necessarily ZAIS_MMG. This logic is used for any table where you just need to change the table name.
Below is the subroutine that needs to be called at seelction screenAT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_obj.
&----
*& Form object_f4help
&----
Provides the possible values for pa_obj
----
--> p1 text
<-- p2 text
----
FORM object_f4help.
Refresh the internal table. This helps in reusing these tables and variables in * other subroutines.
CLEAR: tb_dynpfields,
tb_object_range.
REFRESH: tb_dynpfields,
tb_object_range.
Define Internal tables.
DATA: tb_dynpfields LIKE dynpread OCCURS 0 WITH HEADER LINE.
Define constants.
CONSTANTS: co_retfield TYPE dfies-fieldname VALUE 'OBJECT',
co_dynprog LIKE sy-repid
VALUE '/DCSEA/Z_AIS_NUM_RESET_PAJERO',
co_s TYPE c VALUE 'S',
co_field(27) TYPE c VALUE 'PA_OBJ'.
Assigning the values of program name and screen to the variables.
wf_dyname = sy-repid. " PROGRAM NAME
wf_dynumb = sy-dynnr. " SCREEN NUMBER
wf_dynpro = co_field.
Move the field name to tb_dynpfields.
MOVE 'PA_WERKS' TO
tb_dynpfields-fieldname.
APPEND tb_dynpfields.
Read screen field values before PAI field transport. This FM is used for dynamically * reading a value from the selection screen field .
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = wf_dyname
dynumb = wf_dynumb
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 the tbale tb_dynpfields to read the dynamic value of pa_werks
READ TABLE tb_dynpfields INDEX 1.
IF sy-subrc = 0.
wf_werks = tb_dynpfields-fieldvalue.
ENDIF.
Populate the table tb_object_range. Make sure that we filter out null values as it * might appear on the screen.
SELECT werks object
INTO TABLE tb_object_range
FROM zais_mmg
WHERE werks EQ wf_werks
and object NE ' '.
Sorting is always done before dlete adjacent duplicate.
sort tb_object_range.
This will delete all duplicate entries. Or else when you press F4, it will display * the duplicates also.
delete adjacent duplicates from tb_object_range comparing object.
F4 help also returning the value to be displayed in internal table. If the internal table is empty, it will display the message saying 'Values are not found'.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = co_retfield
dynpprog = co_dynprog
dynpnr = sy-dynnr
dynprofield = wf_dynpro
value_org = co_s
TABLES
value_tab = tb_object_range
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. " object_f4help
PS: Do award points if Helps
‎2008 Jun 04 5:04 AM
Use the data element 'BUKRS' for that field when creating your Ztable.
This will automatically provide F4 help for ur field.
‎2008 Jun 04 6:44 AM
Dear All
Thanks For Your Reply
come code f4 help values will come
how will find in this data element
i need the following fields want f4 help
sale order(jobno)
Ship to Party
CURRENCY
PAYMENTTEAMS
Fiscal Year
Country
Thanks
Suresh
‎2008 Jun 04 6:48 AM
Hi,
Use the foll data elements :
sale order(jobno) : VBELN
Ship to Party : KUNAG
CURRENCY : WERKS
Fiscal Year : GJAHR
Country : LAND1
Thanks
Nayan
‎2008 Jun 04 7:33 AM
hi Nayan
Thanks for your reply
i will give same data element
sale order(jobno) : VBELN
Ship to Party : KUNAG
CURRENCY : WERKS
Fiscal Year : GJAHR
Country : LAND1
but didnot come f4 help
thanks Suresh
‎2008 Jun 04 7:38 AM
Hi Suresh,
Just use the same Data Elements, You will get the defauld F4 help.
For Currency use 'WAERS'.
Regards,
Viji