Control de RUT y cédula
Link
https://www.saptutorial.org/business-partner-enhancement-tax-number-validation/
Business Partner Enhancement Tax Number
Validation
/SAP ABAP Enhancement /Business Partner Enhancement Tax Number Validation
Sep 22, 2018
SAP ABAP Enhancement
ABAP Enhancement – You can create Business Partner using BDT. BDT allows
custom code to be written around in BP by way of simple function modules. The call of
the function modules are controlled through customizing.
The relevant functions for BDT customizing can be found using the area menu BUPT.
In this case we have to validate Tax number format when entry Business Partner Data.
1.Run BUPT transaction code to open SAP Area Menu then open menu Business
Partner -> Control -> Screen Layout -> Views.
2.Double click on menu Views. in this screen you need to choose View which it is
appropriate to your need. for this case we choose view BUTX01 Numbers for Taxes and
Reporting, Select it then double click Further Checks.
3. On thats following screen you can select Appl and input the name of function module
contain ABAP Code for validation appropriate data.
4.Create function module to write your ABAP Code, in this function module you must
use function module especially in BP Area to get data from memory during BP Created
or Changed. there are several function module for that purpose.
5.Please check ABAP Code complete for check Tax format during BP Data create or
changed.
1 DATA : lt_but000 TYPE TABLE OF but000,
2 lv_aktyp LIKE tbz0k-aktyp,
3 sy_datlo_timestamp TYPE timestamp,
4 l_but000 LIKE but000,
5 lt_but100 LIKE but100 OCCURS 0 WITH HEADER LINE,
6 lv_std_role_mkk TYPE bu_partnerrole,
7 lt_tax TYPE TABLE OF dfkkbptaxnum,
8 ls_taxnum TYPE dfkkbptaxnum,
9 lw_taxnumold TYPE dfkkbptaxnum.
10
11 FIELD-SYMBOLS <fs_tax> TYPE dfkkbptaxnum.
12
13 CONSTANTS: gc_tzone_utc TYPE tznzone VALUE 'UTC '.
14
15 CALL FUNCTION 'BUS_PARAMETERS_ISSTA_GET'
16 IMPORTING
17 e_aktyp = lv_aktyp.
18
19 IF lv_aktyp = '01' OR lv_aktyp = '02'.
20
21 CALL FUNCTION 'BUP_BUPA_BUT000_GET'
22 TABLES
23 et_but000 = lt_but000.
24
25 CONVERT DATE sy-datlo INTO TIME STAMP sy_datlo_timestamp
26 TIME ZONE gc_tzone_utc.
27
28 LOOP AT lt_but000 INTO l_but000.
29 IF ( l_but000-valid_from LE sy_datlo_timestamp
30 AND l_but000-valid_to GE sy_datlo_timestamp )
31 OR ( l_but000-valid_from IS INITIAL AND
32 l_but000-valid_to IS INITIAL ).
33 EXIT.
34 ENDIF.
35 ENDLOOP.
36
37
38 * get tax numbers
39 CALL FUNCTION 'BUP_BUPA_TAX_GET'
40 TABLES
41 et_tax = lt_tax
42 EXCEPTIONS
43 no_taxnumbers_found = 1
44 OTHERS = 2.
45 IF sy-subrc <> 0.
46 * safety refresh
47 REFRESH lt_tax.
48 ENDIF.
49
50 LOOP AT lt_tax ASSIGNING <fs_tax>.
51 MOVE-CORRESPONDING <fs_tax> TO ls_taxnum.
52
53 IF strlen( ls_taxnum-taxnumxl ) NE 20.
54
55 CALL FUNCTION 'BUS_MESSAGE_STORE'
56 EXPORTING
57 arbgb = 'ZXK01'
58 msgty = 'E'
59 txtnr = 000
60 msgv1 = ls_taxnum-taxnumxl.
61
62 ENDIF.
63
64 IF strlen( ls_taxnum-taxnumxl ) EQ 20.
65
66 IF ls_taxnum-taxnumxl+2(1) NE '.' OR ls_taxnum-taxnumxl+6(1) NE '.' OR ls_taxnum-taxnumxl+10(1) NE
'.'
67
OR ls_taxnum-taxnumxl+12(1) NE '-' OR ls_taxnum-taxnumxl+16(1) NE '.' .
68
CALL FUNCTION 'BUS_MESSAGE_STORE'
69
EXPORTING
70
arbgb = 'ZXK01'
71
msgty = 'E'
72
txtnr = 000
73
msgv1 = ls_taxnum-taxnumxl.
74
75
ELSE.
76
77
SELECT SINGLE * FROM dfkkbptaxnum INTO lw_taxnumold WHERE taxnumxl = ls_taxnum-
78 taxnumxl.
79 IF sy-subrc EQ 0.
80 CALL FUNCTION 'BUS_MESSAGE_STORE'
81 EXPORTING
82 arbgb = 'ZXK01'
83 msgty = 'E'
84 txtnr = 001
85 msgv1 = ls_taxnum-taxnumxl.
86
87 ENDIF.
88
89
90 ENDIF.
91
ENDIF.
92
93
94
ENDLOOP.
95
96
97
ENDIF.
6. You can see there are function module with prefix BUP_BUPA* . those function
module was used to get data BP from memory during Business Partner/ BP Created or
Changed.