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: 

KNB1-ALTKN

Former Member
0 Kudos
1,628

Hi,

My requirement is that whenever a new customer is created, the field KNB1-ALTKN should always be populated. How can I do this?

Thank You,

SB.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
541

Hi

If you want to populate it automatically, you should use an user-exit (EXIT_SAPMF02D_001);

If you want to make sure user fill that field, you should make it mandatary.

Max

20 REPLIES 20

ferry_lianto
Active Contributor
0 Kudos
541

Hi SB,

You can use this FM <b>CUSTOMER_UPDATE</b> to update field KNB1-ALTKN.

Hope this will help.

Regards,

Ferry Lianto

0 Kudos
541

Hi Ferry,

Thanks for your reply... can I know where I should you write this code... a new prg... or a sap-script ... or anything else...

Thank You,

SB.

0 Kudos
541

Requirement -

01. In Create Customer Mode (XD01 & VD01) SAP should check whether the fields are filled in ZZKV_CUSNO & ZZKV_SEQNO are filled in. The expected behaviour is that SAP should not allow to Save a customer master in case the above is not filled.

02. In Change Customer Mode (xd02 & vd02), User exit should first check whether the user has got an authorisation to change this field, only then allow to change.

Former Member
0 Kudos
541

Hi SB,

try this:

take spro

goto define account groups with screen layout

select the group

select company code data

select Account management

set in Previous account number the button

than save

Regards, Dieter

Former Member
0 Kudos
541

Hi,

You need to make the field in traxn XK01->Companycode data->Account management->Reference data->Prev.acct.no mandatory in SPRO settings,then this will make the field mandatory,

Rgds,

Former Member
0 Kudos
542

Hi

If you want to populate it automatically, you should use an user-exit (EXIT_SAPMF02D_001);

If you want to make sure user fill that field, you should make it mandatary.

Max

0 Kudos
541

Hi Max,

Yes this is what I want that once the user creats the customer... the feild ALTKN "Previous Account number" should be populated automatically... Can you please provide me with more guidenace on how to go forward with the exit EXIT_SAPMF02D_001...

Thanks a lot.

SB.

0 Kudos
541

Hi SB

You have to create a project by trx CMOD to active the exit EXIT_SAPMF02D_001:

- Run CMODE

- Create a project

- Assign it the enhancement SAPMF02D

- Active your project and its component

Now you can insert abap code you need in fm EXIT_SAPMF02D_001 (by trx SE37).

For example:

FIELD-SYMBOLS: <FS_KNB1> TYPE KNB1.

DATA: C_KNB1(30) VALUE '(SAPMF02D)KNB1'.

IF SY-TCODE+3(1) = '1'. "It means user's creating a customer

ASSIGN (C_KNB1) TO <FS_KNB1>.

<FS_KNB1>-ALTKN = '......'.

ENDIF.

Here I use field-symbols because the exit doesn't allow to change data of KNB1.

Max

0 Kudos
541

Hi Max,

I was able to find out that in CMOD there already exited a project which had the assingment of SAPMF02D.. & in the componenets it had the user exit EXIT_SAPMF02D_001 ... when I double click EXIT_SAPMF02D_001 ... I get a screen with INCLUDE ZXF04U01... & when I double click INCLUDE ZXF04U01 ... then here is the place where I have to make sure that the field ALTKN is automatically filled...

My query is that here when I see the project attributes the project status is inactive ... but when I see the components screen the function exit EXIT_SAPMF02D_001 ... shows a green check mark saying that it is already implemented... I do not understand this difference...

How can a project be inactive & it's component as implemented at the same time...

Please explain.

0 Kudos
541

Hi

It means the project is inactive, that's all.

The component screen lists the project components and their status: implemented or not implemented.

The status of component is independent from the project status, but only means which components are used in the project.

Now u've to understand why it's inactive in your development system: check if it's active in production.

Perhaps someone is updating that project.

Max

0 Kudos
541

Hi,

I got the right place where I need to write the user exit. Thanks to Max for this ... My requirement is that For feild ALTKN ... it should be automatically populate the last 7 digits of customer number... How should I code for this ... and what else should I keep in mind .. for e.g. is the customer locked by some other user ??... how or what should I code so that I can get the correct results ... and after that how can I test??... Any help please.

Thank You,

SB

0 Kudos
541

Hi,

I am trying to create a customer. But I cannot find in which screen is Previous Account no. feild = ALTKN... can somebody tell me where to find it ??

Thank You,SB.

0 Kudos
541

Hi

It's in the first tab of company data: Account Management, in Reference data section.

Max

0 Kudos
541

Hi Max,

I have coded

i_knb1-altkn = i_kna1-kunnr+3(7).

inside the include ZXF04U01 ... so that whenever a customer is createdd or changed the field ALTKN is populate with the last 7 digit of the customer number ... What I have coded is it right ??... & if yes then how do I test it ??

Thank You,

SB.

0 Kudos
541

Hi

Just as I said in a my previuos answer that exit doesn't allow to change the company data, I_KNB1 is IMPORT PARAMETER and it can't change the value of an import parameter, so you have to use a trick, try this piece of code:

DATA: V_FIELD(30) VALUE '(SAPMF02D)KNB1'.

FIELD-SYMBOLS: <KNB1> TYPE KNB1.

ASSIGN (V_FIELD) TO <KNB1>.

<KNB1>-ALTKN = I_KNA1-KUNNR+3(7).

Anyway remember: if the system assignes the customer number (so you don't use an external range), you can know the number of customer only after saving it, so that exit can work only when user's updating it.

Max

0 Kudos
541

Ok... that means that when I use XD02 for the existing customer only then the last 7 digits of the customer should come up for the field ALTKN... Am I right ... ??

I tried it this way but it doesn't work ... how do I test it ??

0 Kudos
541

Hi

What doesn't work? The abap code?

If it's so, you make sure:

- Project is active;

- Component is active;

- insert a break-point

In XD02 that exit is triggered only if a date is changed and after pressing SAVE.

I tried it in 4.7 and worked fine

Max

0 Kudos
541

Hi Max,

I want the same thing to work once XD01 is saved... so that I can go & see in XD02 and see that ALTKN is correctly populated...

Any responses ... that I want populate the field ALTKN once saved in XD01.... Currently the logic is working.. but only when I save in XD02...

Former Member
0 Kudos
541

You can also change the screen attribute for the field ALTKN via SE51 for ABAP SAPMF02D and screen 210.

In that case you make the particular field as required, thereby the user have to enter the particular information.

Also, in the user_exit for customer you can check for the particular field and if it is blank throw an error message

Regards

Anurag

ferry_lianto
Active Contributor
0 Kudos
541

Hi SB,

It depends on your requirement.

You can create a custom program and call FM CUSTOMER_UPDATE to update field KNB1-ALTKN. This progam can be used to process mass update after customer master created and schedule to run over night.

Also you can use user exit EXIT_SAPMF02D_001 to update automatically as Max mentioned earlier.

Again, hope this will help.

Regards,

Ferry Lianto

Regards,

Ferry Lianto