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: 

How to read material number from the screen in ME21n

hamid_moinuddin
Explorer
0 Kudos

I've used the exit MM06E005 for adding custom fields at header and item levels on the purchase order screens. I want to populate certain custom fields at item level based on the material number entered by the user. I tried using DYNP_READ_VALUES but the FM is giving an error all the time even when I tried passing different values for DYNAME and DYNUMB. The FM is called from different screens in different situations, so i'm not sure what value to pass for DYNNR. Once i get the value of material number entered by the user at the current line item i want to read a z-table to populate the custom fields i've added. Below is my code written in the Items PAI function module EXIT_SAPMM06E_017:

data: scr_fields type table of dynpread WITH HEADER LINE.

scr_fields-fieldname = 'EMATN'.

append scr_fields.



CALL FUNCTION 'DYNP_VALUES_READ'

   EXPORTING

     DYNAME                               = 'SAPLXM06'

     DYNUMB                               = '0014'

*   TRANSLATE_TO_UPPER                   = ' '

*   REQUEST                              = ' '

*   PERFORM_CONVERSION_EXITS             = ' '

*   PERFORM_INPUT_CONVERSION             = ' '

*   DETERMINE_LOOP_INDEX                 = ' '

*   START_SEARCH_IN_CURRENT_SCREEN       = ' '

*   START_SEARCH_IN_MAIN_SCREEN          = ' '

*   START_SEARCH_IN_STACKED_SCREEN       = ' '

*   START_SEARCH_ON_SCR_STACKPOS         = ' '

*   SEARCH_OWN_SUBSCREENS_FIRST          = ' '

*   SEARCHPATH_OF_SUBSCREEN_AREAS        = ' '

 

TABLES

     DYNPFIELDS                           = scr_fields

   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.


Any valuable leads will be greatly appreciated.

1 ACCEPTED SOLUTION

thanga_prakash
Active Contributor
0 Kudos

Hello Hamid,

What are the structures or tables which you enhanced with your Z-fields?

Table parameter TEKPO in EXIT_SAPMM06E_017 holds ITEM data.

Enhance table EKPO and structure BEKPO with your Z-fields and pass value to those Z-fields in the exit EXIT_SAPMM06E_017 like below.

LOOP AT tekpo INTO wa.

wa-zfield1 = 'XYZ'.

MODIFY tekpo FROM wa.

ENDLOOP.

Regards,

TP

7 REPLIES 7

thanga_prakash
Active Contributor
0 Kudos

Hello Hamid,

What are the structures or tables which you enhanced with your Z-fields?

Table parameter TEKPO in EXIT_SAPMM06E_017 holds ITEM data.

Enhance table EKPO and structure BEKPO with your Z-fields and pass value to those Z-fields in the exit EXIT_SAPMM06E_017 like below.

LOOP AT tekpo INTO wa.

wa-zfield1 = 'XYZ'.

MODIFY tekpo FROM wa.

ENDLOOP.

Regards,

TP

0 Kudos

Hi Thanga

Thanks for your suggestion. To implement your idea, I put a break-point in the exit 017 to see how i can use the data in TEKPO. The table contains the item data but the problem is that when i am creating a PO and entering items one by one its not showing the most recent item i entered. For example, when i enter item 20, TEKPO contains only item 10... and then when i enter item 30, it has items 10 & 20 only. My requirement is to read the material number for the current item entered and fetch its related values. I'm unable to do that as the values desired are not appearing until the next item is entered. Please help.

Thanks

Hamid

0 Kudos

Hello Hamid,

Is there any header line available for table TEKPO. Recent data might be available in header line.

Regards,

TP

0 Kudos

Hi Thanga

TEKPO is a header line table but during the execution the header line is empty. the entries in the table control show up directly in the table after the iteration is completed.

0 Kudos

Hi Thanga,

I just checked... the data of the table control is present in TEKET, including the current item entered by the user. now I will develop the logic to read the last row of the ITAB TEKET so as to populate other fields based on material number. Thanks for your advice.

atul_mohanty
Active Contributor
0 Kudos

Hi

For material entered for current line , did you check the   I_EKPO-MATNR of EXIT_SAPMM06E_016, EXIT_SAPMM06E_017 ?

0 Kudos

Yes, I did. the control stops at Exit 017 twice. the first time it holds the previous item and then the second time it holds the current item. I need to use some technique to find out if the structure  has previous data or current. I also tried pushing the fetched data to the screen structures EKPO_CI-'ABCDE' but its not showing the data on the screen.