2015 Jul 22 11:45 AM
Hi Experts,
I have a requirement to create a Address Number in ADRC table using following function Modules.
I have written following piece of code to test the first two function modules first.
DATA: wa_addr1_data TYPE ADDR1_DATA,
wa_addr_ref TYPE addr_ref,
addr_num TYPE adrc-addrnumber,
addr_data TYPE ADDR1_DATA.
wa_addr1_data-date_from = '01.01.0001'.
wa_addr1_data-title = 'OOO'.
wa_addr1_data-name1 = 'TESTING'.
wa_addr_ref-addr_group = 'CA01'.
*wa_addr_ref-owner = 'X'.
wa_addr_ref-appl_table = 'ADRC'.
wa_addr_ref-appl_field = 'ADDRNUMBER'.
CALL FUNCTION 'ADDR_INSERT'
EXPORTING
address_data = wa_addr1_data
address_group = 'CA01'
address_handle = 'TEST'
* DATE_FROM = '00010101'
* LANGUAGE = SY-LANGU
* CHECK_EMPTY_ADDRESS = 'X'
* CHECK_ADDRESS = 'X'
IMPORTING
ADDRESS_DATA = addr_data
* RETURNCODE =
* TABLES
* ERROR_TABLE =
* EXCEPTIONS
* ADDRESS_EXISTS = 1
* PARAMETER_ERROR = 2
* INTERNAL_ERROR = 3
* OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
COMMIT WORK.
wait UP TO 1 SECONDS.
CALL FUNCTION 'ADDR_NUMBER_GET'
EXPORTING
address_handle = 'TEST'
address_reference = wa_addr_ref
PERSONAL_ADDRESS = ' '
* NUMBERRANGE_NUMBER = '01'
* E071K_WA =
* GENERATE_TRANSPORT_ENTRIES =
* OWNER = 'X'
* TABLE_NAME =
* FIELD_NAME =
* OBJKEY =
IMPORTING
ADDRESS_NUMBER = addr_num
* RETURNCODE_NUMBERRANGE =
* TABLES
* E071K_TAB =
* EXCEPTIONS
* ADDRESS_HANDLE_NOT_EXIST = 1
* INTERNAL_ERROR = 2
* PARAMETER_ERROR = 3
* OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
The Address group is available in TSAD7 table as well.
But when i execute the code i get the Error as "Address handle invalid: TEST "
I would require your expert advice to solve this.
Thanks in advance,
Manjunath
2015 Jul 23 8:57 AM
Hi Manjunath,
Please try the below logic.
*&---------------------------------------------------------------------*
*& Report ZTEST0101
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST0101.
types: t_bool(1) type c.
constants: c_yes type t_bool value 'X'.
data: begin of number_handle_tab occurs 0.
include structure addr1_dia.
data: end of number_handle_tab.
data: begin of comp_address_tab occurs 0.
include structure addr1_data.
data: end of comp_address_tab.
data: ok_code like sy-ucomm.
data: addrref like addr_ref.
data: address_number like adrc-addrnumber.
move 'TEST' to comp_address_tab-name1.
move 'SHANGHAI' to comp_address_tab-city1.
move '200131' to comp_address_tab-post_code1.
move 'RI JING ROAD' to comp_address_tab-street.
move 'NO. 161' to comp_address_tab-house_num1.
move 'CN' to comp_address_tab-country.
append comp_address_tab.
clear number_handle_tab.
refresh number_handle_tab.
move 'TEST' to number_handle_tab-handle.
move 'TEST' to number_handle_tab-name1.
move 'PM01' to number_handle_tab-addr_group.
move 'CREATE' to number_handle_tab-maint_mode.
append number_handle_tab.
call function 'ADDR_INSERT'
exporting
address_data = comp_address_tab
address_group = number_handle_tab-addr_group
address_handle = number_handle_tab-handle
exceptions
address_exists = 1
parameter_error = 2
internal_error = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_exists.
when 2. raise parameter_error.
when 3 or 4. raise internal_error.
endcase.
else.
ok_code = 'CREATE'.
addrref-appl_table = 'ADRC'.
addrref-appl_field = 'ADDRNUMBER'.
addrref-appl_key(3) = sy-mandt.
addrref-appl_key+3(42) = 'TEST'. "*489i
addrref-addr_group = 'PM01'.
call function 'ADDR_NUMBER_GET'
exporting
address_handle = number_handle_tab-handle
address_reference = addrref
importing
address_number = address_number
exceptions
address_handle_not_exist = 1
internal_error = 2
parameter_error = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_handle_not_exist.
when 2 or 4. raise internal_error.
when 3. raise parameter_error.
endcase.
else.
call function 'ADDR_SINGLE_SAVE'
exporting
address_number = address_number
exceptions
address_not_exist = 1
person_not_exist = 2
address_number_missing = 3
reference_missing = 4
internal_error = 5
database_error = 6
parameter_error = 7
others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_not_exist.
when 2. raise person_not_exist.
when 3. raise address_number_missing.
when 4. raise reference_missing.
when 5 or 8. raise internal_error.
when 6. raise database_error.
when 7. raise parameter_error.
endcase.
endif.
endif.
endif.
If you want to pass TITLE also to comp_address_tab, make sure you pass the available TITLEs.
Thanks,
Kiran
Hi Experts,
I have a requirement to create a Address Number in ADRC table using following function Modules.
I have written following piece of code to test the first two function modules first.
DATA: wa_addr1_data TYPE ADDR1_DATA,
wa_addr_ref TYPE addr_ref,
addr_num TYPE adrc-addrnumber,
addr_data TYPE ADDR1_DATA.
wa_addr1_data-date_from = '01.01.0001'.
wa_addr1_data-title = 'OOO'.
wa_addr1_data-name1 = 'TESTING'.
wa_addr_ref-addr_group = 'CA01'.
*wa_addr_ref-owner = 'X'.
wa_addr_ref-appl_table = 'ADRC'.
wa_addr_ref-appl_field = 'ADDRNUMBER'.
CALL FUNCTION 'ADDR_INSERT'
EXPORTING
address_data = wa_addr1_data
address_group = 'CA01'
address_handle = 'TEST'
* DATE_FROM = '00010101'
* LANGUAGE = SY-LANGU
* CHECK_EMPTY_ADDRESS = 'X'
* CHECK_ADDRESS = 'X'
IMPORTING
ADDRESS_DATA = addr_data
* RETURNCODE =
* TABLES
* ERROR_TABLE =
* EXCEPTIONS
* ADDRESS_EXISTS = 1
* PARAMETER_ERROR = 2
* INTERNAL_ERROR = 3
* OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
COMMIT WORK.
wait UP TO 1 SECONDS.
CALL FUNCTION 'ADDR_NUMBER_GET'
EXPORTING
address_handle = 'TEST'
address_reference = wa_addr_ref
PERSONAL_ADDRESS = ' '
* NUMBERRANGE_NUMBER = '01'
* E071K_WA =
* GENERATE_TRANSPORT_ENTRIES =
* OWNER = 'X'
* TABLE_NAME =
* FIELD_NAME =
* OBJKEY =
IMPORTING
ADDRESS_NUMBER = addr_num
* RETURNCODE_NUMBERRANGE =
* TABLES
* E071K_TAB =
* EXCEPTIONS
* ADDRESS_HANDLE_NOT_EXIST = 1
* INTERNAL_ERROR = 2
* PARAMETER_ERROR = 3
* OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
The Address group is available in TSAD7 table as well.
But when i execute the code i get the Error as "Address handle invalid: TEST "
I would require your expert advice to solve this.
Thanks in advance,
Manjunath
2015 Jul 22 7:25 PM
Seems like a handle with this name was not created with 'TEST'
Did you try and debug where is this error getting populated?
Refer to the SAP note 1877560/73.
2015 Jul 23 8:57 AM
Hi Manjunath,
Please try the below logic.
*&---------------------------------------------------------------------*
*& Report ZTEST0101
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST0101.
types: t_bool(1) type c.
constants: c_yes type t_bool value 'X'.
data: begin of number_handle_tab occurs 0.
include structure addr1_dia.
data: end of number_handle_tab.
data: begin of comp_address_tab occurs 0.
include structure addr1_data.
data: end of comp_address_tab.
data: ok_code like sy-ucomm.
data: addrref like addr_ref.
data: address_number like adrc-addrnumber.
move 'TEST' to comp_address_tab-name1.
move 'SHANGHAI' to comp_address_tab-city1.
move '200131' to comp_address_tab-post_code1.
move 'RI JING ROAD' to comp_address_tab-street.
move 'NO. 161' to comp_address_tab-house_num1.
move 'CN' to comp_address_tab-country.
append comp_address_tab.
clear number_handle_tab.
refresh number_handle_tab.
move 'TEST' to number_handle_tab-handle.
move 'TEST' to number_handle_tab-name1.
move 'PM01' to number_handle_tab-addr_group.
move 'CREATE' to number_handle_tab-maint_mode.
append number_handle_tab.
call function 'ADDR_INSERT'
exporting
address_data = comp_address_tab
address_group = number_handle_tab-addr_group
address_handle = number_handle_tab-handle
exceptions
address_exists = 1
parameter_error = 2
internal_error = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_exists.
when 2. raise parameter_error.
when 3 or 4. raise internal_error.
endcase.
else.
ok_code = 'CREATE'.
addrref-appl_table = 'ADRC'.
addrref-appl_field = 'ADDRNUMBER'.
addrref-appl_key(3) = sy-mandt.
addrref-appl_key+3(42) = 'TEST'. "*489i
addrref-addr_group = 'PM01'.
call function 'ADDR_NUMBER_GET'
exporting
address_handle = number_handle_tab-handle
address_reference = addrref
importing
address_number = address_number
exceptions
address_handle_not_exist = 1
internal_error = 2
parameter_error = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_handle_not_exist.
when 2 or 4. raise internal_error.
when 3. raise parameter_error.
endcase.
else.
call function 'ADDR_SINGLE_SAVE'
exporting
address_number = address_number
exceptions
address_not_exist = 1
person_not_exist = 2
address_number_missing = 3
reference_missing = 4
internal_error = 5
database_error = 6
parameter_error = 7
others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
case sy-subrc.
when 1. raise address_not_exist.
when 2. raise person_not_exist.
when 3. raise address_number_missing.
when 4. raise reference_missing.
when 5 or 8. raise internal_error.
when 6. raise database_error.
when 7. raise parameter_error.
endcase.
endif.
endif.
endif.
If you want to pass TITLE also to comp_address_tab, make sure you pass the available TITLEs.
Thanks,
Kiran
2015 Jul 23 9:01 AM
2022 Nov 04 3:10 PM
Update November 2022: It works! One of the best answer founded after days looking for. Thanks!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |