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: 

HELP: EXIT XK01 - CREATING A VENDOR

glauco
Active Contributor
0 Kudos
417

Friends,

I need to get the new LIFNR after user having clicked on SAVE button.

I know the user-exit EXIT_SAPMF02K_001, INCLUDE ZXF05U01. But in this momment the LIFNR is empty.

Anybody has a solution for it ?

A friend gave me the hint that I can use a function that say to sap reexecute this code after commit work have been executed.

8 REPLIES 8

Former Member
0 Kudos
141

Hi glauco,

Please find the below code which will be helpful to get the vendor number after clicking the save button.

data:v_ktokk type ktokk.

get parameter id 'KGK' field v_ktokk.

tables:t077k.

.

data: nrobj like tnro-object value 'KREDITOR',

v_lifnr type lifnr,

v_retcode type INRI-RETURNCODE.

select single numkr from t077k

into t077k-numkr

where ktokk = v_ktokk.

call function 'NUMBER_GET_NEXT'

exporting object = nrobj

nr_range_nr = t077k-numkr

importing number = v_lifnr

returncode = v_retcode

exceptions interval_not_found = 01

number_range_not_intern = 02

object_not_found = 03.

  • U can find the vendor number in the field v_lifnr,which can be used

*for further purposes.

I am still working on this,But an additional number is consumed by using the above FM.

i will certainly let u know any further updates.

Thanks,

Vamsi

0 Kudos
141

Hi Vamsi,

I think it won't work 'cause the system can create a lot of vendors in this same time and the last maybe not the exact lifnr I need.

What do u think about it ?

Former Member
0 Kudos
141

Glauco - you can create a program which calls BAPI_VENDOR_CREATE. This BAPI simply calls XK01, but returns the vendor number. Alternatively, your program can just call XK01 itself and read the vendor number when done.

Or do you need the vendor number during the execution of XK01?

Rob

b_deterd2
Active Contributor
0 Kudos
141

Hi,

Why is it so important to have the vendor number? The exit is used to check the input so it is logical that there is not a vendor number yet because the input can be wrong according to the additional checks in the exit.

Is customizing an option? You probably now have an internal number range for the group. Is it an option to set this to an external number range? You would then have the vendor number in your exit available.

glauco
Active Contributor
0 Kudos
141

Hi everybody,

I used my coleague'r hint. I called a function "in background task", witch I selected my vendor by STCD1 or STCD2 and KTOKK.

This function is executed after XK01 is saved and It worked very well.

thanx everybody!

Former Member
0 Kudos
141

Hi Glauco,

Can you explain further on how you implemented your solution? I have a requirement whereby I need to update the vendor number created in XK01 with a 3 character prefix. What function did you call in background task? And in which user exit/BADI did you implement this function?

Thank you.

glauco
Active Contributor
0 Kudos
141

Hi .

It was a long time ago. But if I remember, at that moment I was developing a workflow that needed to create a vendor in a intermediate step, using a call transaction (BDC table) and using user exit.

So I needed to get at same moment as SAVE, to get the LIFNR, but logically it was empty at this time. So I had the STCD1 in memory and created a Function Module with flag update task checked. So I called this FM ( So, this FM will run after commit work, after saving. ) and did a SELECT by STCD1 to get back the new LIFNR.

Because in Brazil, the STCD1 can be a single record, so I got the correct vendor in table LFA1.

that's it.

good luck.

Glauco

Former Member
0 Kudos
141

Hi Glauco,

Thanks for your reply. Looks like we are doing two different things here. Anyways, I managed to find  way to update the vendor number by using the user exit SAPMF02K and BADI VENDOR_ADD_DATA which get triggered when save button is clicked on XK01. The method IF_EX_VENDOR_ADD_DATA~MODIFY_ACCOUNT_NUMBER in the BADI contains the vendor number and we can add in codes here to update the vendor number.

Regards,

Shalini