2014 Jul 22 2:09 PM
2014 Jul 22 3:09 PM
RESOLVED:
CODE FROM SWO1 METHOD DEFINITION:
BEGIN_METHOD CREATE_BP_FROM_CIC CHANGING CONTAINER.
DATA: db_update TYPE REGEN-DB_UPDATE,
EXIT_TYPE TYPE REGEN-EXIT_TYPE,
muster_kun TYPE EKUND-MUSTER_KUN,
TYPE TYPE BUS000FLDS-TYPE,
bpkind TYPE BUS000FLDS-BPKIND,
GROUP TYPE TB001-BU_GROUP,
PARTNER TYPE BUT000-PARTNER,
ROLETYPE TYPE TBZ0-RLTYP OCCURS 0,
upd_onl TYPE REGEN-KENNZX,
no_xinit TYPE REGEN-KENNZX,
xinit type regen-kennzx,
p type isu01_partner_data,
NAME_FIRST TYPE BUT000-NAME_FIRST,
NAME_LAST TYPE BUT000-NAME_LAST,
TEL_NUMBER TYPE ADR2-TEL_NUMBER,
EMAIL TYPE ADR6-SMTP_ADDR,
SOC_SECURE TYPE EKUN-SOC_SECURE,
rec_partner type bapiisubpd,
rec_partner_x type bapiisubpdx,
r_partner_new type bapibppara-partner,
rec_return type bapiret2,
rec_address type bapiisubpa,
rec_address_x type bapiisubpax,
rec_adruse type bapiisubpau,
rec_adruse_x type bapiisubpaux,
rec_bank type bapiisubpb,
rec_bank_x type bapiisubpbx,
rec_ccard type bapiisubpc,
rec_ccard_x type bapiisubpcx,
rec_email_on_a type bapiadsmtp,
rec_extension type bapiparex,
rec_rltypes type bapiisubpr,
rec_tel_on_a type bapiadtel,
rec_tax type bapibus1006tax,
tab_adruse like rec_adruse occurs 0 with header line,
tab_adruse_x like rec_adruse_x occurs 0 with header line,
tab_address like rec_address occurs 0 with header line,
tab_address_TMP like rec_address occurs 0 with header line,
tab_address_x like rec_address_x occurs 0 with header line,
tab_bank like rec_bank occurs 0 with header line,
tab_bank_x like rec_bank_x occurs 0 with header line,
tab_ccard like rec_ccard occurs 0 with header line,
tab_ccard_x like rec_ccard_x occurs 0 with header line,
tab_email_on_a like rec_email_on_a occurs 0 with header line,
tab_extension like rec_extension occurs 0 with header line,
tab_rltypes like rec_rltypes occurs 0 with header line,
tab_tax like bapibus1006tax occurs 0 with header line,
tab_tel_on_a like rec_tel_on_a occurs 0 with header line,
ls_auto type isu01_partner_auto,
LS_ADDRESS LIKE LINE OF LS_AUTO-T_ADDRESS,
rltypes like bup_partnerroles occurs 0 with header line,
t_rltyp like tbz0-rltyp occurs 0 with header line.
************************************************************************
SWC_GET_ELEMENT CONTAINER 'ReferenceCustomer' muster_kun.
SWC_GET_ELEMENT CONTAINER 'Type' TYPE.
SWC_GET_ELEMENT CONTAINER 'BusinessPartnerKind' bpkind.
SWC_GET_ELEMENT CONTAINER 'Group' GROUP.
SWC_GET_ELEMENT CONTAINER 'Partner' PARTNER.
SWC_GET_ELEMENT CONTAINER 'FirstName' NAME_FIRST.
SWC_GET_ELEMENT CONTAINER 'LastName' NAME_LAST.
SWC_GET_ELEMENT CONTAINER 'EMailAddress' email.
SWC_GET_ELEMENT CONTAINER 'Telephone' tel_number.
SWC_GET_TABLE CONTAINER 'RoleType' t_rltyp[].
SWC_GET_ELEMENT CONTAINER 'UpdateOnline' upd_onl.
SWC_GET_ELEMENT CONTAINER 'NoFirstScreen' no_xinit.
SWC_GET_ELEMENT CONTAINER 'SS' soc_secure.
if no_xinit = 'X'.
clear xinit.
else.
xinit = 'X'.
endif.
refresh rltypes.
loop at t_rltyp.
rltypes-rolecategory = t_rltyp.
append rltypes.
endloop.
* provide business partner data
CLEAR: LS_aUTO, rec_partner, rec_partner_X.
call function 'ISU_S_PARTNER_PROVIDE'
exporting
x_partner = PARTNER
x_wmode = '1'
x_no_dialog = 'X'
importing
y_auto = ls_auto
exceptions
not_found = 1
partner_in_role_not_found = 2
foreign_lock = 3
not_authorized = 4
invalid_wmode = 5
different_type = 6
general_fault = 7
others = 8.
if sy-subrc = 0 and not ls_auto is initial.
rec_partner-bpkind = LS_AUTO-ACT-BPKIND.
rec_partner_x-bpkind = 'X'.
rec_partner-name_first = NAME_FIRST.
rec_partner_x-name_first = 'X'.
rec_partner-name_last = NAME_last.
rec_partner_x-name_last = 'X'.
rec_partner-soc_secure = soc_secure.
rec_partner_x-soc_secure = 'X'.
CLEAR: TAB_ADDRESS_TMP, TAB_ADDRESS, TAB_ADDRESS_X.
REFRESH: TAB_ADDRESS_TMP, TAB_ADDRESS, TAB_ADDRESS_X.
*APPEND LINES OF LS_AUTO-T_ADDRESS TO TAB_ADDRESS_TMP.
LOOP AT LS_AUTO-T_ADDRESS INTO LS_ADDRESS.
tab_address_x-XDFADR = 'X'.
tab_address-XDFADR = 'X'.
tab_address_x-CITY1 = 'X'.
tab_address-CITY1 = LS_ADDRESS-CITY1.
tab_address_x-POST_CODE1 = 'X'.
tab_address-POST_CODE1 = LS_ADDRESS-POST_CODE1.
tab_address_x-STREET = 'X'.
tab_address-STREET = LS_ADDRESS-STREET.
tab_address_x-HOUSE_NUM1 = 'X'.
tab_address-HOUSE_NUM1 = LS_ADDRESS-HOUSE_NUM1.
tab_address_x-COUNTRY = 'X'.
tab_address-COUNTRY = LS_ADDRESS-COUNTRY.
tab_address_x-TEL_NUMBER = 'X'.
tab_address-TEL_NUMBER = tel_number.
tab_address_x-E_MAIL = 'X'.
tab_address-E_MAIL = EMAIL.
APPEND TAB_ADDRESS.
APPEND tab_address_x.
CLEAR: LS_ADDRESS, TAB_ADDRESS, TAB_ADDRESS_X.
ENDLOOP.
endif.
*upd_onl = 'X'.
type = '1'.
group = '0001'.
* ==============================================
call function 'BAPI_ISUPARTNER_CREATEFROMDATA'
* ==============================================
exporting
* PARTNER =
type = type
group = group
refcustomer = 'SDKUNDE'
partnerdata = rec_partner
partnerdatax = rec_partner_x
* TESTRUN =
accept_error = 'X'
importing return = rec_return
new_partner = r_partner_new
tables taddress = tab_address
taddressx = tab_address_x
tbankdata = tab_bank
tbankdatax = tab_bank_x
tccarddata = tab_ccard
tccarddatax = tab_ccard_x
rltypes = tab_rltypes
extensionin = tab_extension
ttaxdata = tab_tax
telefondatanonaddress = tab_tel_on_a
e_maildatanonaddress = tab_email_on_a
tadruse = tab_adruse
tadrusex = tab_adruse_x.
if not rec_return-type = 'E'.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
CALL FUNCTION ' BAPI_BUPR_RELATIONSHIP_CREATE'
EXPORTING
businesspartner1 = partner
businesspartner2 = r_partner_new
relationshipcategory = 'ZDISP2'
* RELATIONSHIPTYPE =
* VALIDFROMDATE = SY-DATLO
* VALIDUNTILDATE = '99991231'
* DIFFERENTIATIONTYPEVALUE =
* XDFREL =
* TABLES
* RETURN =
.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
call function 'ISU_S_PARTNER_CHANGE'
exporting
x_partner = r_partner_new
* X_VALDT =
x_upd_online = 'X'
* X_NO_DIALOG =
* X_AUTO =
* X_OBJ =
* X_NO_OTHER =
* X_REL_KZ = 'X'
* X_MUSTER_KUN =
* X_TESTRUN =
* IMPORTING
* Y_DB_UPDATE =
* Y_EXIT_TYPE =
* Y_NEW_PARTNER =
* TABLES
* XT_RLTYPES =
* EXCEPTIONS
* NOT_FOUND = 1
* FOREIGN_LOCK = 2
* NOT_AUTHORIZED = 3
* CANCELLED = 4
* INPUT_ERROR = 5
* GENERAL_FAULT = 6
* OTHERS = 7
.
commit work and wait.
else.
endif.
** call change service function (no commit)
*call function 'ISU_S_PARTNER_CREATE'
* exporting
** x_partner = partner
** x_upd_online = upd_onl
* x_upd_online = SPACE
* x_type = type
* x_group = group
** x_first_screen = xinit
* x_muster_kun = muster_kun
* x_bpkind = bpkind
** X_NO_DIALOG =
* X_AUTO = ls_auto
** X_WINDOW =
* x_rel_kz = 'X'
* importing
** y_db_update = db_update
* y_exit_type = exit_type
* y_new_partner = p
** tables
** xt_rltypes = rltypes
* exceptions
* existing = 1
* foreign_lock = 2
* not_authorized = 3
* input_error = 5
* general_fault = 6
* others = 7.
*
*if sy-subrc <> 0.
* if sy-subrc = 1.
** existing
* exit_return 1000 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* elseif sy-subrc = 2.
** foreign lock
* exit_return 1001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* elseif sy-subrc = 3.
** not authorized
* exit_return 1002 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* else.
** other error
* swc_refresh_object self.
** set initial objectkey
* clear object-key.
* swc_set_objectkey object-key.
* exit_return 1003 text-s00 space space space.
* endif.
*endif.
if exit_type = 'CANC'.
* cacelled
exit_cancelled.
endif.
swc_set_objectkey r_partner_new.
* put export parameters to container
SWC_SET_ELEMENT CONTAINER 'DatabaseUpdate' db_update.
SWC_SET_ELEMENT CONTAINER 'Exit_type' EXIT_TYPE.
SWC_SET_ELEMENT CONTAINER 'Partner' r_partner_new.
* attributes may have changed, force new read from DB
swc_refresh_object self.
END_METHOD.
IF YOU LIKE MY CODE, PLEASE GIVE ME STAR
2014 Jul 22 3:09 PM
RESOLVED:
CODE FROM SWO1 METHOD DEFINITION:
BEGIN_METHOD CREATE_BP_FROM_CIC CHANGING CONTAINER.
DATA: db_update TYPE REGEN-DB_UPDATE,
EXIT_TYPE TYPE REGEN-EXIT_TYPE,
muster_kun TYPE EKUND-MUSTER_KUN,
TYPE TYPE BUS000FLDS-TYPE,
bpkind TYPE BUS000FLDS-BPKIND,
GROUP TYPE TB001-BU_GROUP,
PARTNER TYPE BUT000-PARTNER,
ROLETYPE TYPE TBZ0-RLTYP OCCURS 0,
upd_onl TYPE REGEN-KENNZX,
no_xinit TYPE REGEN-KENNZX,
xinit type regen-kennzx,
p type isu01_partner_data,
NAME_FIRST TYPE BUT000-NAME_FIRST,
NAME_LAST TYPE BUT000-NAME_LAST,
TEL_NUMBER TYPE ADR2-TEL_NUMBER,
EMAIL TYPE ADR6-SMTP_ADDR,
SOC_SECURE TYPE EKUN-SOC_SECURE,
rec_partner type bapiisubpd,
rec_partner_x type bapiisubpdx,
r_partner_new type bapibppara-partner,
rec_return type bapiret2,
rec_address type bapiisubpa,
rec_address_x type bapiisubpax,
rec_adruse type bapiisubpau,
rec_adruse_x type bapiisubpaux,
rec_bank type bapiisubpb,
rec_bank_x type bapiisubpbx,
rec_ccard type bapiisubpc,
rec_ccard_x type bapiisubpcx,
rec_email_on_a type bapiadsmtp,
rec_extension type bapiparex,
rec_rltypes type bapiisubpr,
rec_tel_on_a type bapiadtel,
rec_tax type bapibus1006tax,
tab_adruse like rec_adruse occurs 0 with header line,
tab_adruse_x like rec_adruse_x occurs 0 with header line,
tab_address like rec_address occurs 0 with header line,
tab_address_TMP like rec_address occurs 0 with header line,
tab_address_x like rec_address_x occurs 0 with header line,
tab_bank like rec_bank occurs 0 with header line,
tab_bank_x like rec_bank_x occurs 0 with header line,
tab_ccard like rec_ccard occurs 0 with header line,
tab_ccard_x like rec_ccard_x occurs 0 with header line,
tab_email_on_a like rec_email_on_a occurs 0 with header line,
tab_extension like rec_extension occurs 0 with header line,
tab_rltypes like rec_rltypes occurs 0 with header line,
tab_tax like bapibus1006tax occurs 0 with header line,
tab_tel_on_a like rec_tel_on_a occurs 0 with header line,
ls_auto type isu01_partner_auto,
LS_ADDRESS LIKE LINE OF LS_AUTO-T_ADDRESS,
rltypes like bup_partnerroles occurs 0 with header line,
t_rltyp like tbz0-rltyp occurs 0 with header line.
************************************************************************
SWC_GET_ELEMENT CONTAINER 'ReferenceCustomer' muster_kun.
SWC_GET_ELEMENT CONTAINER 'Type' TYPE.
SWC_GET_ELEMENT CONTAINER 'BusinessPartnerKind' bpkind.
SWC_GET_ELEMENT CONTAINER 'Group' GROUP.
SWC_GET_ELEMENT CONTAINER 'Partner' PARTNER.
SWC_GET_ELEMENT CONTAINER 'FirstName' NAME_FIRST.
SWC_GET_ELEMENT CONTAINER 'LastName' NAME_LAST.
SWC_GET_ELEMENT CONTAINER 'EMailAddress' email.
SWC_GET_ELEMENT CONTAINER 'Telephone' tel_number.
SWC_GET_TABLE CONTAINER 'RoleType' t_rltyp[].
SWC_GET_ELEMENT CONTAINER 'UpdateOnline' upd_onl.
SWC_GET_ELEMENT CONTAINER 'NoFirstScreen' no_xinit.
SWC_GET_ELEMENT CONTAINER 'SS' soc_secure.
if no_xinit = 'X'.
clear xinit.
else.
xinit = 'X'.
endif.
refresh rltypes.
loop at t_rltyp.
rltypes-rolecategory = t_rltyp.
append rltypes.
endloop.
* provide business partner data
CLEAR: LS_aUTO, rec_partner, rec_partner_X.
call function 'ISU_S_PARTNER_PROVIDE'
exporting
x_partner = PARTNER
x_wmode = '1'
x_no_dialog = 'X'
importing
y_auto = ls_auto
exceptions
not_found = 1
partner_in_role_not_found = 2
foreign_lock = 3
not_authorized = 4
invalid_wmode = 5
different_type = 6
general_fault = 7
others = 8.
if sy-subrc = 0 and not ls_auto is initial.
rec_partner-bpkind = LS_AUTO-ACT-BPKIND.
rec_partner_x-bpkind = 'X'.
rec_partner-name_first = NAME_FIRST.
rec_partner_x-name_first = 'X'.
rec_partner-name_last = NAME_last.
rec_partner_x-name_last = 'X'.
rec_partner-soc_secure = soc_secure.
rec_partner_x-soc_secure = 'X'.
CLEAR: TAB_ADDRESS_TMP, TAB_ADDRESS, TAB_ADDRESS_X.
REFRESH: TAB_ADDRESS_TMP, TAB_ADDRESS, TAB_ADDRESS_X.
*APPEND LINES OF LS_AUTO-T_ADDRESS TO TAB_ADDRESS_TMP.
LOOP AT LS_AUTO-T_ADDRESS INTO LS_ADDRESS.
tab_address_x-XDFADR = 'X'.
tab_address-XDFADR = 'X'.
tab_address_x-CITY1 = 'X'.
tab_address-CITY1 = LS_ADDRESS-CITY1.
tab_address_x-POST_CODE1 = 'X'.
tab_address-POST_CODE1 = LS_ADDRESS-POST_CODE1.
tab_address_x-STREET = 'X'.
tab_address-STREET = LS_ADDRESS-STREET.
tab_address_x-HOUSE_NUM1 = 'X'.
tab_address-HOUSE_NUM1 = LS_ADDRESS-HOUSE_NUM1.
tab_address_x-COUNTRY = 'X'.
tab_address-COUNTRY = LS_ADDRESS-COUNTRY.
tab_address_x-TEL_NUMBER = 'X'.
tab_address-TEL_NUMBER = tel_number.
tab_address_x-E_MAIL = 'X'.
tab_address-E_MAIL = EMAIL.
APPEND TAB_ADDRESS.
APPEND tab_address_x.
CLEAR: LS_ADDRESS, TAB_ADDRESS, TAB_ADDRESS_X.
ENDLOOP.
endif.
*upd_onl = 'X'.
type = '1'.
group = '0001'.
* ==============================================
call function 'BAPI_ISUPARTNER_CREATEFROMDATA'
* ==============================================
exporting
* PARTNER =
type = type
group = group
refcustomer = 'SDKUNDE'
partnerdata = rec_partner
partnerdatax = rec_partner_x
* TESTRUN =
accept_error = 'X'
importing return = rec_return
new_partner = r_partner_new
tables taddress = tab_address
taddressx = tab_address_x
tbankdata = tab_bank
tbankdatax = tab_bank_x
tccarddata = tab_ccard
tccarddatax = tab_ccard_x
rltypes = tab_rltypes
extensionin = tab_extension
ttaxdata = tab_tax
telefondatanonaddress = tab_tel_on_a
e_maildatanonaddress = tab_email_on_a
tadruse = tab_adruse
tadrusex = tab_adruse_x.
if not rec_return-type = 'E'.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
CALL FUNCTION ' BAPI_BUPR_RELATIONSHIP_CREATE'
EXPORTING
businesspartner1 = partner
businesspartner2 = r_partner_new
relationshipcategory = 'ZDISP2'
* RELATIONSHIPTYPE =
* VALIDFROMDATE = SY-DATLO
* VALIDUNTILDATE = '99991231'
* DIFFERENTIATIONTYPEVALUE =
* XDFREL =
* TABLES
* RETURN =
.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
call function 'ISU_S_PARTNER_CHANGE'
exporting
x_partner = r_partner_new
* X_VALDT =
x_upd_online = 'X'
* X_NO_DIALOG =
* X_AUTO =
* X_OBJ =
* X_NO_OTHER =
* X_REL_KZ = 'X'
* X_MUSTER_KUN =
* X_TESTRUN =
* IMPORTING
* Y_DB_UPDATE =
* Y_EXIT_TYPE =
* Y_NEW_PARTNER =
* TABLES
* XT_RLTYPES =
* EXCEPTIONS
* NOT_FOUND = 1
* FOREIGN_LOCK = 2
* NOT_AUTHORIZED = 3
* CANCELLED = 4
* INPUT_ERROR = 5
* GENERAL_FAULT = 6
* OTHERS = 7
.
commit work and wait.
else.
endif.
** call change service function (no commit)
*call function 'ISU_S_PARTNER_CREATE'
* exporting
** x_partner = partner
** x_upd_online = upd_onl
* x_upd_online = SPACE
* x_type = type
* x_group = group
** x_first_screen = xinit
* x_muster_kun = muster_kun
* x_bpkind = bpkind
** X_NO_DIALOG =
* X_AUTO = ls_auto
** X_WINDOW =
* x_rel_kz = 'X'
* importing
** y_db_update = db_update
* y_exit_type = exit_type
* y_new_partner = p
** tables
** xt_rltypes = rltypes
* exceptions
* existing = 1
* foreign_lock = 2
* not_authorized = 3
* input_error = 5
* general_fault = 6
* others = 7.
*
*if sy-subrc <> 0.
* if sy-subrc = 1.
** existing
* exit_return 1000 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* elseif sy-subrc = 2.
** foreign lock
* exit_return 1001 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* elseif sy-subrc = 3.
** not authorized
* exit_return 1002 sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
*
* else.
** other error
* swc_refresh_object self.
** set initial objectkey
* clear object-key.
* swc_set_objectkey object-key.
* exit_return 1003 text-s00 space space space.
* endif.
*endif.
if exit_type = 'CANC'.
* cacelled
exit_cancelled.
endif.
swc_set_objectkey r_partner_new.
* put export parameters to container
SWC_SET_ELEMENT CONTAINER 'DatabaseUpdate' db_update.
SWC_SET_ELEMENT CONTAINER 'Exit_type' EXIT_TYPE.
SWC_SET_ELEMENT CONTAINER 'Partner' r_partner_new.
* attributes may have changed, force new read from DB
swc_refresh_object self.
END_METHOD.
IF YOU LIKE MY CODE, PLEASE GIVE ME STAR
2014 Jul 22 4:57 PM
2014 Jul 23 7:50 AM
Hi Lechoo,
Try to fulfill your requirement with using "BAPI_BUPR_RELATIONSHIP_CREATE".
Regards,
Akhil Vaghasiya