Foro de programacion ABAP
Código abierto => Bapis => Mensaje iniciado por: Enrique.Borroni en 05 de Diciembre de 2012, 06:14:15 am
-
Aqui les dejo un pequeño ejemplo de como modificar datos de direccion...
REPORT y_test_050.
TYPE-POOLS: szadr.
*
*----------------------------------------------------------------------*
* DECLARACION DE VARIABLES
*----------------------------------------------------------------------*
*
DATA : ld_addnr TYPE ad_addrnum.
*
*----------------------------------------------------------------------*
* DECLARACION DE TABLAS INTERNAS Y ESTRUCTURAS
*----------------------------------------------------------------------*
*
DATA : wx_kna1 TYPE kna1. "
DATA : addr_complete TYPE szadr_addr1_complete.
DATA : adsmtp_line TYPE szadr_adsmtp_line,
addr1_line TYPE szadr_addr1_line,
adtel_line TYPE szadr_adtel_line.
DATA : ld_recode LIKE szad_field-returncode.
DATA : lt_error TYPE STANDARD TABLE OF addr_error.
* ----------------------------------------------------------------*
* EJECUTAR BAPI : ADDR_GET_COMPLETE
* ----------------------------------------------------------------*
*
* Aqui codigo para obtener en WX_KNA1 en Numero de Direccion "ADRNR"
*
*
addr_complete-addrnumber = wx_kna1-adrnr.
*
* Obtener Datos de Direccion Completos
*
CALL FUNCTION 'ADDR_GET_COMPLETE'
EXPORTING
addrnumber = addr_complete-addrnumber
addrhandle = addr_complete-addrhandle
IMPORTING
addr1_complete = addr_complete
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 4
OTHERS = 5.
*
* Aqui codigo de lo que se quiera modificar...
*
*
* Ejemplo : Para Modificar Datos de : addr1_line
*
READ TABLE addr_complete-addr1_tab INTO addr1_line INDEX 1 .
addr1_line-data-extension2 = 'TEST 01'.
addr1_line-data-house_num1 = '1232'.
MODIFY addr_complete-addr1_tab FROM addr1_line
INDEX 1.
*
* Ejemplo : Para Modificar el Telefono 01
*
CLEAR : adtel_line-adtel.
adtel_line-adtel-country = 'CL'. " Pais
adtel_line-adtel-tel_number = '666222666'. " Telefono Fijo - 01
adtel_line-adtel-telnr_long = '666222666'. " Telefono Fijo - 01
adtel_line-adtel-telnr_call = '666222666'. " Telefono Fijo - 01
adtel_line-adtel-home_flag = 'X'. " Dirección destinatario en esta cl.comunicación (vínc.correo)
adtel_line-adtel-r3_user = '1'. " Tipo de Telefono
adtel_line-adtel-updateflag = 'I'.
APPEND adtel_line TO addr_complete-adtel_tab.
*
* ----------------------------------------------------------------*
* EJECUTAR BAPI : ADDR_MAINTAIN_COMPLETE
* ----------------------------------------------------------------*
CALL FUNCTION 'ADDR_MAINTAIN_COMPLETE'
EXPORTING
updateflag = 'U'
addr1_complete = addr_complete
address_group = 'BP'
substitute_all_comm_data = ' '
check_address = ' '
IMPORTING
returncode = ld_recode
TABLES
error_table = lt_error
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
handle_exist = 4
internal_error = 5
OTHERS = 6.
*
IF ( sy-subrc EQ 0 ).
CALL FUNCTION 'ADDR_MEMORY_SAVE'
EXPORTING
execute_in_update_task = 'X'
EXCEPTIONS
address_number_missing = 1
person_number_missing = 2
internal_error = 3
database_error = 4
reference_missing = 5
OTHERS = 6.
*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
*
ENDIF.