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 Validate Address Fields of Vendor Master XK01/XK02

0 Kudos

Can Anyone help me to validate Address Fields (Street, Street 2, Street 3, Street 4, Name 1 , Name 2 ) of Vendor Master -XK01/XK02.

I have a requirement to add field length restriction for specific companies.

I've found BADI - ADDRESS_UPDATE but it's not suitable as company field is not available.

Thanks in Advance.

12 REPLIES 12

NTeunckens
Active Contributor

See if you can use the UserExit "EXIT_SAPMF02K_001" for this (Prgr. "ZXF05U01") as the Address-Handle is provided ...

0 Kudos

Thanks Nic .

can't use this Exit as Address data not available in Address Handle.

The "I_LFA1" Structure provides the Address-Number ("I_LFA1-ADRNR") that allows you to fetch the Address, then include your intended validation ... You could use FunctionModule "ADDR_GET" to read Address-data based upon the AddressNumber (or directly from "ADRC"-table Selection).

I see that these Structures are also provided in the "VENDOR_ADD_DATA" BAdI, see Methods such as "CHECK_ALL_DATA" where you could do the same ...


Hope this helps

Nic T.

0 Kudos

Thanks a lot.

But Through ADRC can not get live data.

I need to restrict fields once user entered the value & click on save (Means before save the transaction)

Though Address number i_lfa1-adrnr, can get existing old data instead of updated data.

0 Kudos

Either through the mentioned UserExit or Badi, you could read the Address-Data from Memory.

Go into Debugging, put BREAK and check "(SAPMF02K)ADDR_COMPLETE-ADDR1_TAB[1]-DATA" ...

That should offer you the Data as is it Put on the Screen Fields of the transaction.

Using this construct in your Code in the UExit or the BAdI will provide your with the Address that is entered on the Screen.

raymond_giuseppi
Active Contributor
0 Kudos

You could try BAdI ADDRESS_CHECK method ADDRESS_POSTAL_CHECK. Don't use BAdI ADDRESS_UPDATE which is not suitable to perform some custom check.

To get the company code value, you could either use memory-id BUK or export the field (and others if required) to memory in a vendor master data exit such as BAdI VENDOR_ADD_DATA[_CS] or exit SAPMF02K/EXIT_SAPMF02K_001 and read them in the address BAdI.

Question: But the address (LFA1-ADRNR) is not dependent on the company code, so check exact requirement with functional? What should be done for vendor defined for multiple companies, should you also look for other LFB1 records in database to get the more restrictive rule?

0 Kudos

Thanks a lot, Raymond

BADI ADDRESS_CHECK does not have Fields Name 1 & Name 2

I've a requirement to restrict fields Name 1, Name 2 , Street, Street 2, Street 3, Street 4 if user entered value greater than 35 Chars for specific companies & Account Group


For the fields that are not part of the 'postal address' you could use VENDOR_ADD_DATA method CHECK_ALL_DATA. In this BAdI, also export company code and account group to memory so ADDRESS_CHECK will be able to read those?

Summary:

VENDOR_ADD_DATA - CHECK_ALL_DATA

  • (Export I_LFB1-BUKRS and I_LFA1-KTOKK to memory) optional
  • Check length of I_LFA1-NAME1, I_LFA1-NAME2

VENDOR_ADD_DATA - SET_USER_INPUTS

  • Export I_BUKRS and I_KTOKK to memory

ADDRESS_CHECK

  • Import BUKRS and KTOKK from memory
  • Check length of CH_ADRC_STRUC-STREET, STR_SPPL1, STR_SPPL2, STR_SPPL3 (you are also allowed to change their values)

0 Kudos

Same thing I've done.

But Problem is,

VENDOR_ADD_DATA - CHECK_ALL_DATA

when user entered more than 35 chars, not coming full value in I_LFA1-NAME1, I_LFA1-NAME2 fields as both have Data type - Char35 .

And I need to add length validation for more than 35 chars.

0 Kudos

You should look in the PAI of the dynpro (in address management function group) for available BAdI (such as duplicate check, etc.) or implicit enhancement spots.

0 Kudos

No I didn't check.

Can you please help me to find out appropriate enhancement spot for program SAPMF02K

0 Kudos

The enhancement you look for should be in an address function group, so in some SAPLSZA1 main program. Navigate from a test session to dynpro field, F1, tech info, double-click on dy npro Nr to PAI logic and from MODULE to FORM statement.