Application Development 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: 

Implement F4 help for AFNAM(Requested By) field of Item Overview for transaction ME51n

Former Member
0 Kudos

Hi Experts,

I need to Implement F4 help for AFNAM(Requested By) field of Item Overview for transaction ME51n - create purchase requisition.

Steps to identify the field:

-> Open T-code - ME51n

-> Expand Item overview

-> One table will be displayed, will see one field Requested By - Technical Name (AFNAM)

-> Requirement is to add F4 help on this.

PFA the screenshot and suggest what should be the approach to do this.

10 REPLIES 10

former_member196331
Active Contributor
0 Kudos

Hi,

You can use below code. Have a look on below attached image

Do Some changes as per your requirement.

May be so many ways are exists like creating search help  by implementing the match code object in your code.

or some other way.  the below is one of the possible way.

TABLES : EBAN.

SELECT-OPTIONS: S_MATNR FOR EBAN-MATNR.

TYPES: BEGIN OF TT,

        BANFN  TYPE EBAN-BANFN,

        AFNAME TYPE EBAN-AFNAM,

        END OF TT.

DATA: IT_TT TYPE TABLE OF TT,

       WA_TT TYPE TT.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR-LOW.

   SELECT BANFN AFNAM  FROM EBAN INTO TABLE IT_TT. "WHERE BDART EQ 'AR' and  BWART IN ('261','262') ORDER BY AUFNR.

   IF SY-SUBRC = 0.

     CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

       EXPORTING

         RETFIELD        = 'AFNAME'

         DYNPPROG        = 'ZPRAC11'

         DYNPNR          = SY-DYNNR

         DYNPROFIELD     = 'S_SCREEN'

         VALUE_ORG       = 'S'  "Mandatory

       TABLES

         VALUE_TAB       = IT_TT

       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.

   ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MATNR-HIGH.

   SELECT BANFN AFNAM  FROM EBAN INTO TABLE IT_TT. "WHERE BDART EQ 'AR' and  BWART IN ('261','262') ORDER BY AUFNR.

   IF SY-SUBRC = 0.

     CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

       EXPORTING

         RETFIELD        = 'AFNAME'

         DYNPPROG        = 'ZPRAC11'

         DYNPNR          = SY-DYNNR

         DYNPROFIELD     = 'S_SCREEN'

         VALUE_ORG       = 'S'  "Mandatory

       TABLES

         VALUE_TAB       = IT_TT

       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.

   ENDIF.

0 Kudos

This is not a correct answer. F4 is required in ME51n transaction not in a customized screen.

shadab_maldar
Active Participant
0 Kudos

Hi Akshay,

I suggest you to go with field exit but only at last option if you are not getting an alternate(because this is absolute Now).

1)   Create a field exit on data element AFNAM.

2)   Use the exit space to fetch F4 possible entries.

2)   Call FM 'F4IF_INIT_TABLE_VALUE_REQUEST'.

Regards,

Shadab.

0 Kudos

Can you elaborate more on how to implement that field exit for this issue?

0 Kudos

Hi Akshay,

1) Goto Trasaction CMOD

2) Type PRFB in command line and enter.

3) Menu bar-> Create -> Give data element(AFNAM)->It will ask to create FM,create it.

4) You can write your code in FM to fetch all the possible entries and call the FM to call F4  

    help (which I hve suggested in my previous post).

5) Activte everything and check.

Note : To activate field exit you have to set the parameter abap/field exit in RZ11.

Regards,

Shadab.

0 Kudos

Hi Akshay,

One more thing I need to add for this, Field exits are created on data element so wherever this data element is used it gets fired there, so don't forget to validate with respect to TCODE inside the function module, or also you can validate it for particular program that you will find it in CMOD->PRFB->MENU BAR->ASSIGN PROGRAM.

Regards,

Shadab.

0 Kudos

I didn't get you but i have achieved the solution from the below code:

Step 1:

  Goto Tcode : SE 38

  Include : LMEGUICJM

***Adding Coding - Before Endmethod ( METHOD get_fields_for_f4  -- ENDMETHOD )

ENHANCEMENT 1  ZME51N_F4_HELP3.

“for making f4 symbol available in the field afnam

if sy-TCODE = 'ME51N' OR SY-TCODE = 'ME52N' OR SY-TCODE = 'ME53N'.

lmac_upd_then_ins 'AFNAM' 'X'.

ENDIF.

ENDENHANCEMENT.

Step 2:

          Goto Tcode : SE 38 - Include : LMEGUICJM

********* Adding Coding - Before Endmethod ( METHOD handle_f4  -- ENDMETHOD )

ENHANCEMENT 1  ZME51N_F4_HELP_V1. "active version

DATA :   l_AFNAM  TYPE mereq3211grid-AFNAM.

CASE e_fieldname.

      WHEN 'AFNAM'.

CALL FUNCTION 'ZHELP_VALUES_AFNAM'

  EXPORTING

I_PROGRAM       = PROG

I_DYNNR         = DYNPRO

IMPORTING

E_AFNAM         = L_AFNAM           .

        IF sy-subrc IS INITIAL AND l_ch EQ mmpur_yes.

ls_modi-value  = l_AFNAM.

        ENDIF.

    IF NOT ls_modi IS INITIAL.

      ASSIGN er_event_data->m_data->* TO <fs_t_modi>.

ls_modi-row_id    = es_row_no-row_id.

      ls_modi-fieldname = e_fieldname.

      APPEND ls_modi TO <fs_t_modi>.

    ENDIF.

ENDCASE.

ENDENHANCEMENT.

Step 3:

Goto Tcode : SE 37 - Create Zfunction module ZHELP_VALUES_AFNAM

Source Code

************* Source Code for Function module - ZHELP_VALUES_AFNAM *******

FUNCTION ZHELP_VALUES_AFNAM.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(I_PROGRAM) LIKE SY-CPROG

*"     VALUE(I_DYNNR) LIKE SY-DYNNR

*"     VALUE(I_AFNAM) LIKE EBAN-AFNAM OPTIONAL

*"  EXPORTING

*"     VALUE(E_AFNAM) LIKE EBAN-AFNAM

*"----------------------------------------------------------------------

  TABLES: T024W.

  DATA: LV_VALUE TYPE CHAR10.

  DATA : LV_FLAG(1).

  DATA: BEGIN OF I_DYNPREAD OCCURS 10.

INCLUDE STRUCTURE DYNPREAD.

  DATA: END OF I_DYNPREAD.

  DATA: BEGIN OF FULL_TABLE_WERKS OCCURS 0,

AFNAM TYPE ZAFNAM_F4-AFNAM,

          TEXT TYPE ZAFNAM_F4-TEXT,

        END OF FULL_TABLE_WERKS.

  DATA: T_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.

  CLEAR : LV_FLAG.

  IF I_AFNAM IS INITIAL.

    REFRESH I_DYNPREAD.

    CLEAR I_DYNPREAD.

    I_DYNPREAD-FIELDNAME = 'MEREQ3211GRID-AFNAM'.

    APPEND I_DYNPREAD.

    CALL FUNCTION 'DYNP_VALUES_READ'

      EXPORTING

DYNAME     = I_PROGRAM

DYNUMB     = I_DYNNR

      TABLES

        DYNPFIELDS = I_DYNPREAD

      EXCEPTIONS

OTHERS     = 1.

    IF SY-SUBRC EQ 0.

      READ TABLE I_DYNPREAD INDEX 1.

      LV_VALUE = I_DYNPREAD-FIELDVALUE.

    ELSE.

      LV_FLAG = 'X'.

    ENDIF.

  ENDIF.

  IF LV_FLAG = 'X'.

SELECT ABTNR VTEXT           FROM TSABT

          INTO TABLE FULL_TABLE_WERKS

          WHERE SPRAS = 'EN'.

    SORT FULL_TABLE_WERKS.

    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

      EXPORTING

RETFIELD = 'AFNAM'

VALUE_ORG = 'S'

      TABLES

VALUE_TAB = FULL_TABLE_WERKS

RETURN_TAB = T_RETURN[]

      EXCEPTIONS

OTHERS = 1.

    READ TABLE T_RETURN INDEX 1.

    IF SY-SUBRC = 0.

      READ TABLE FULL_TABLE_WERKS WITH KEY AFNAM

= T_RETURN-FIELDVAL BINARY SEARCH.

      E_AFNAM = FULL_TABLE_WERKS-AFNAM.

    ENDIF.

  ENDIF.

ENDFUNCTION.

Step 4:

          Goto Tcode : SE 37 - F4IF_FIELD_VALUE_REQUEST

****** Add coding - Function Module - F4IF_FIELD_VALUE_REQUEST *********

********** First line of Source code **********

ENHANCEMENT 1  ZF4_FUN_MOD_CS. "active version

DATA : LV_SEARCH_NAME TYPE CHAR25.

BREAK ABAP.

IF SY-TCODE = 'ME51N' OR SY-TCODE = 'ME52N' OR SY-TCODE = 'ME53N'.

  CLEAR : LV_SEARCH_NAME.

  IF fieldname = 'AFNAM'.

  LV_SEARCH_NAME = 'TSABT'.

  searchhelp = LV_SEARCH_NAME.

  ENDIF.

ENDIF.

ENDENHANCEMENT.

But only problem i am facing is that the F4 pop up is coming 2 times

0 Kudos

Hi,

Try to check implementing using field exits, you will get lots of document's in SCN, I think this will make the solution short and simple.

Regards,

Shadab.

former_member196331
Active Contributor
0 Kudos

hi,

Have a look on below thread.

http://scn.sap.com/message/1023951#1023951

0 Kudos

Changing data element of Table - EBAN field AFNAM require access key to implement and that i know how to do that. But is there any other alternative way ??