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: 

Number Range for Purchase Requistion in ME51N

Former Member
0 Kudos

Dear All,

How can I get the item details (e.g., Plant )using the function module EXIT_SAPLMEREQ_009 in userexit MEREQ001 for number ranges.

Have tried to access the item data with:

DATA: REQ_ITEM TYPE MEREQ_ITEM.

DATA: LS_MEREQ_ITEM TYPE REF TO IF_PURCHASE_REQUISITION_ITEM.

CALL METHOD LS_MEREQ_ITEM->GET_DATA RECEIVING RE_DATA = REQ_ITEM.

I have the dump error: "OBJECTS_OBJREF_NOT_ASSIGNED".

Anyone can help me in this issue?

Thanks in advance for your help.

Regards

Prakash

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Its difficult to read data from call stack in OO concept.

Why dont you export to ABAP memeory in exit EXIT_SAPLMEREQ_001 which is called before EXIT_SAPLMEREQ_009 and plant is available here .

Later in EXIT_SAPLMEREQ_009 you can import from memeory.

Cheers

4 REPLIES 4

Former Member
0 Kudos

Hi

Its difficult to read data from call stack in OO concept.

Why dont you export to ABAP memeory in exit EXIT_SAPLMEREQ_001 which is called before EXIT_SAPLMEREQ_009 and plant is available here .

Later in EXIT_SAPLMEREQ_009 you can import from memeory.

Cheers

christian_wohlfahrt
Active Contributor
0 Kudos

Hi!

A few lines above exit EXIT_SAPLMEREQ_008 is called. There you have importing parameter for EBAN and EBKN.

Either make your task in this exit - or write interesting information into memory and read this again in exit EXIT_SAPLMEREQ_009.

Regards,

Christian

Former Member
0 Kudos

Dear friends,

This is my first reply to ths community. I found that each & every tip given here is useful in one or other way. But we have to combined those tips to get a complete solution.

My problem was that my client needed a different Number Range at Purchase Order level as well as at Purchase Requisition Level.

Purchase Order Number Range Exit :

Enhancement : M06B0003

Exit : EXIT_SAPMM06B_001

INCLUDE : ZXM06U18

ZTABLE : ZPONR

STRUCTURE OF ZPONR :

***************************************************

FIELD DATA ELEMENT

MANDT MANDT

WERKS WERKS_D

BSART ESART

BSTYP BSTYP

NUMKI NUMKI

***************************************************

CODE :

if sy-tcode = 'ME51N' or sy-tcode = 'ME51'.

tables : EBAN.

select single * from ZPONR into ZPONR

where werks = NEBAN-WERKS

AND BSART = NEBAN-BSART

AND BSTYP = NEBAN-BSTYP.

if sy-subrc = '0'.

RANGE = zponr-NUMKI.

endif.

endif.

************************************************************************************

Purchase Requisition Number Range Exit :

This is the real problematic thing for those who don't know how to work with BADI (as I don't know) ...

Enhancement : MEREQ001

First Exit : EXIT_SAPLMEREQ_005

Include : ZXM02U05

Second Exit : EXIT_SAPLMEREQ_009

INCLUDE : ZXM02U09

ZTABLE : ZPONR

STRUCTURE OF ZPONR :

***************************************************

FIELD DATA ELEMENT

MANDT MANDT

WERKS WERKS_D

BSART ESART

BSTYP BSTYP

NUMKI NUMKI

***************************************************

In the first exit, I pick the values of Plant(WERKS), Purchasing Document Type(BSART) & Purchasing Document Category(BSTYP) & put them to SAP SHARED BUFFER because in the main exit i.e., the second exit, where I have to assign the number range, the Values of Item level data i.e. WERKS, BSART & BSTYP are in the form of Object Oriented Objects in BADI, & we can't fetch the single value, so here in the first exit , I took their values & export them to shared memory & in that main exit, I'll fetch them from the shared memory, in that case I don't have to go through the complex BADI operations.

CODE FOR First Exit : EXIT_SAPLMEREQ_005

Include : ZXM02U05

DATA : variable1 TYPE mereq_item-werks.

DATA : variable2 TYPE mereq_item-bsart.

DATA : variable3 TYPE mereq_item-bstyp.

variable1 = im_data_new-werks.

variable2 = im_data_new-bsart.

variable3 = im_data_new-bstyp.

EXPORT variable1 TO SHARED BUFFER indx(st) ID 'ZMOHIT1'.

EXPORT variable2 TO SHARED BUFFER indx(st) ID 'ZMOHIT2'.

EXPORT variable3 TO SHARED BUFFER indx(st) ID 'ZMOHIT3'.

Code for Second Exit : EXIT_SAPLMEREQ_009

INCLUDE : ZXM02U09

IF sy-tcode = 'ME51N' OR sy-tcode = 'ME51'.

TABLES : eban, zponr.

DATA : variable1 TYPE mereq_item-werks.

DATA : variable2 TYPE mereq_item-bsart.

DATA : variable3 TYPE mereq_item-bstyp.

IMPORT variable1 FROM SHARED BUFFER indx(st) ID 'ZMOHIT1'.

IMPORT variable2 FROM SHARED BUFFER indx(st) ID 'ZMOHIT2'.

IMPORT variable3 FROM SHARED BUFFER indx(st) ID 'ZMOHIT3'.

select single * from ZPONR into ZPONR

where werks = VARIABLE1

AND BSART = VARIABLE2

AND BSTYP = VARIABLE3.

if sy-subrc = '0'.

EX_RANGE = zponr-NUMKI.

endif.

endif.

          • IF YOU NEED HELP REGARDING THIS, YOU CAN SEND ME A MAIL AT MY ID, i.e., MOHITGROVER.MCA@GMAIL.COM.

0 Kudos

I need help for changing purchase requisition number range during third party sales order where the PR gets generated automatically on saving of sales order.

Can you please help