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: 

ME21 Purchase order number.

Former Member
0 Kudos
278

hi friends,

i am in the process of writing a BDC program for transaction ME21 to create P.O, to run in Background via JOB through Batch input session method.

The purchase order number is generated internally, that means until P.O is created and saved, we don't know the P.O number, after only we save the P.O. the number is generated and shown to us as Information message.

so i want to catch these numbers and push them into the presentation server as flat file. How do i catch these messages after the batch input, so that i can collect them in an internal table. or is there any other way to do it.

My ultimate aim is to catch the purchase order numbers created in that batch input session.

thanks and regards,

sharon

7 REPLIES 7

Former Member
0 Kudos
87

Hi Sharone,

In this case i will suggest you to create the PO using the function module 'BAPI_PO_CREATE'. This FM will capture all messages triggered during creation of PO and will return it in an internal table. And then you can download the internal table to a flat file on presentation server using FM 'GUI_DOWNLOAD'.

Hope this solves your problem.

Regards

PRAFUL

Former Member
0 Kudos
87

I think you must be knowing that it can be easily done in case of BAPI or CALL Transaction BDC..

Using the message variable1 msgv1 of success message that says ..Purchase Order &1 created.

But since you want this for the batch sessions...

I think you need to read the batch session log ( How ? )and then search for the message id msg-no that correspond to the success message.

How to read the message log ..I need to check ...may be, there will be any FM available ..

I'll check..

Cheers,

Ram

Former Member
0 Kudos
87

hello ram and prafulla,

Thanks to both of u, for ur time.

Ram's is a brilliant idea to read the logs, but for it to succeed i need ur help.. i just found out these things,

program rsbdc_protocol is responsible for transaction SM35 which shows the message logs, it uses a structure called bdc_protocol on the screen to display the messages, which inturn incldes a structure called bdclm, i went through the code, but could not find out the DB table from which ultimately the messages are coming, this program uses some function modules, may be they get the information i think, could u or any body else give me an idea, how to capture these messages..

On the other hand when i gave a thought, after th batch has been processed, the P.O. created will have information stored in table EKKO and EKPO, from there also i cud get the P.O numbers, but what should be my search criteria, to get the correct P.O number created in that batch....

thanks

nivin

0 Kudos
87

Hi Sharon,

I saw the RSBDC* programs but could not get much time to look into details..I'll see if I can find something..

It seems to be possible though ..

Another option that you suggested, that was my first idea actually but the problem is that in that case you need to populate the reference number field with some identification ...

May be the batch session id can be used ..

But then generally PO reference numbers are used for other purpose.

If you can populate the reference number then further you can easily get the created POs..

Also you can use creation date & time to restrict the selection...

Cheers,

Ram

krzysztof_konitz4
Contributor
0 Kudos
87

Hi,

You can read SM35 logs using FM:

RSTS_OPEN_RLC, RSTS_READ, RSTS_CLOSE.

But I think that it's better to use FM BAPI_PO_CREATE instead of BDC...

Krzys

0 Kudos
87

I think you must have seen this perform routine ..

see the first perform of include program - RSBDC*1 and F4 to find the exact name ..

You can directly call this routines rather than calling the FMs.

Even I would have suggested that you should use BAPI except for the fact that error handling is not that good in case of BAPIs. Like say if there is some problem with account assignment data of PO line item number 8 but the error that you received only say 'Problem in G/L account assinment ' then you need to check all the items to find the error while it can easily be found in case of session BDC.

Cheers,

Ram

Former Member
0 Kudos
87

Hi,

try this...

After a call transaction is made to ME23 when u do check for sy-subrc to find out whether the purchase order was created or not, you can put the fallowing code when sy-subrc eq 0 ( or when purchase order was successfully created )

l_ebeln type ekpo-ebeln.

GET PARAMETER ID 'BES' field l_ebeln.

Now the l_ebeln will have the po number created.