2008 Jul 15 8:00 AM
I am having some problems in using the BAPI bapi_contract_create to create contracts.
send me some code links.
2008 Jul 15 9:50 AM
Hi tapas,
welcome
Code:
wa_meoutvalidity-item_no = wa_meoutitem-item_no.
wa_meoutvalidity-serial_id = '0000024681'.
wa_meoutvalidity-valid_from = sy-datum.
wa_meoutvalidity-valid_to = '99991231'.
append wa_meoutvalidity.
wa_meoutvalidityx-item_no = wa_meoutitem-item_no.
wa_meoutvalidityx-serial_id = '0000024681'.
wa_meoutvalidityx-serial_idx = 'X'.
wa_meoutvalidityx-item_nox = 'X'.
wa_meoutvalidityx-valid_from = 'X'.
wa_meoutvalidityx-valid_to = 'X'.
append wa_meoutvalidityx.
wa_meoutcondition -cond_count = u201801u2019.
wa_meoutcondition-item_no = wa_meoutitem-item_no.
wa_meoutcondition-serial_id = '0000024681'.
wa_meoutcondition-cond_type = 'RA01'.
wa_meoutcondition-cond_value = wa_comc-ra01.
wa_meoutcondition-currency = '%'.
APPEND wa_meoutcondition.
wa_meoutconditionx-cond_count = wa_meoutcondition-cond_count.
wa_meoutconditionx-item_no = wa_meoutcondition-item_no.
wa_meoutconditionx-serial_id = '0000024681'.
wa_meoutconditionx-serial_idx = 'X'.
wa_meoutconditionx-item_nox = 'X'.
wa_meoutconditionx-cond_countx = 'X'.
wa_meoutconditionx-cond_type = 'X'.
wa_meoutconditionx-cond_value = 'X'.
wa_meoutconditionx-currency = 'X'.
APPEND wa_meoutconditionx.
or
report ztest_yangxg16.
data: gs_header type bapimeoutheader,
gs_headerx type bapimeoutheaderx,
gs_purchasingdocument type bapimeoutheader-number.
data: gt_return like bapiret2 occurs 0 with header line,
gt_item like bapimeoutitem occurs 0 with header line,
gt_itemx like bapimeoutitemx occurs 0 with header line,
gt_account like bapimeoutaccount occurs 0 with header line,
gt_accountprofitsegment like bapimeoutprofitsegment occurs 0 with header line,
gt_accountx like bapimeoutaccountx occurs 0 with header line,
gt_delivery_address like bapimeoutaddrdelivery occurs 0 with header line,
gt_item_cond_validity like bapimeoutvalidity occurs 0 with header line,
gt_item_cond_validityx like bapimeoutvalidityx occurs 0 with header line,
gt_item_condition like bapimeoutcondition occurs 0 with header line,
gt_item_conditionx like bapimeoutconditionx occurs 0 with header line,
gt_item_cond_scale_value like bapimeoutitemscaleval occurs 0 with header line,
gt_item_cond_scale_quan like bapimeoutitemscalequan occurs 0 with header line,
gt_item_text like bapimeoutitemtext occurs 0 with header line,
gt_header_text like bapimeouttext occurs 0 with header line,
gt_head_cond_validity like bapimeoutheadvalidity occurs 0 with header line,
gt_head_cond_validityx like bapimeoutheadvalidityx occurs 0 with header line,
gt_head_condition like bapimeoutheadercond occurs 0 with header line,
gt_head_conditionx like bapimeoutheadercondx occurs 0 with header line,
gt_head_cond_scale_val like bapimeoutscalevalue occurs 0 with header line,
gt_head_cond_scale_quan like bapimeoutscale occurs 0 with header line,
gt_partner like bapimeoutpartner occurs 0 with header line,
gt_partnerx like bapimeoutpartnerx occurs 0 with header line,
gt_extensionin like bapiparex occurs 0 with header line,
gt_extensionout like bapiparex occurs 0 with header line.
*header
gs_header-comp_code = '1000'.
gs_header-doc_type = 'ZMK'.
gs_header-vendor = '0000002100'.
gs_header-pmnttrms = '1026'.
gs_header-purch_org = '1000'.
gs_header-pur_group = '177'.
gs_header-currency = 'USD'.
gs_header-vper_start = '20080701'.
gs_header-vper_end = '20080711'.
gs_header-incoterms1 = 'FOB'.
gs_header-incoterms2 = 'dalian'.
gs_header-dscnt1_to = '35'.
gs_headerx-comp_code = 'X'.
gs_headerx-doc_type = 'X'.
gs_headerx-vendor = 'X'.
gs_headerx-pmnttrms = 'X'.
gs_headerx-purch_org = 'X'.
gs_headerx-pur_group = 'X'.
gs_headerx-currency = 'X'.
gs_headerx-vper_start = 'X'.
gs_headerx-vper_end = 'X'.
gs_headerx-incoterms1 = 'X'.
gs_headerx-incoterms2 = 'X'.
gs_headerx-dscnt1_to = 'X'.
*ITEM
gt_item-item_no = 1.
gt_item-material = 'WANGLTEST'.
gt_item-plant = '1001'.
*gt_item-STGE_LOC = ''.
gt_item-matl_group = '111020201'.
gt_item-target_qty = 3.
gt_item-po_unit = 'PC'.
gt_item-po_unit_iso = 'PC'.
gt_item-orderpr_un = 'PC'.
gt_item-orderpr_un_iso = 'PC'.
gt_item-conf_ctrl = '0001'.
gt_item-net_price = '100'.
append gt_item.
clear gt_item.
gt_itemx-item_no = 'X'.
gt_itemx-material = 'X'.
gt_itemx-plant = 'X'.
*gt_itemx-STGE_LOC = 'X'.
gt_itemx-matl_group = 'X'.
gt_itemx-target_qty = 'X'.
gt_itemx-po_unit = 'X'.
gt_itemx-po_unit_iso = 'X'.
gt_itemx-orderpr_un_iso = 'X'.
gt_itemx-orderpr_un = 'X'.
gt_itemx-conf_ctrl = 'X'.
gt_itemx-net_price = 'X'.
append gt_itemx.
clear gt_itemx.
call function 'BAPI_CONTRACT_CREATE'
exporting
header = gs_header
headerx = gs_headerx
VENDOR_ADDRESS =
TESTRUN =
TECHNICAL_DATA =
importing
purchasingdocument = gs_purchasingdocument
EXP_HEADER =
tables
return = gt_return
item = gt_item
itemx = gt_itemx
.
if gs_purchasingdocument is initial.
call function 'BAPI_TRANSACTION_COMMIT'.
write: / gs_purchasingdocument.
else.
call function 'BAPI_TRANSACTION_ROLLBACK'.
write: / ' fail'.
thanks
katrhik
2008 Jul 15 9:50 AM
Hi tapas,
welcome
Code:
wa_meoutvalidity-item_no = wa_meoutitem-item_no.
wa_meoutvalidity-serial_id = '0000024681'.
wa_meoutvalidity-valid_from = sy-datum.
wa_meoutvalidity-valid_to = '99991231'.
append wa_meoutvalidity.
wa_meoutvalidityx-item_no = wa_meoutitem-item_no.
wa_meoutvalidityx-serial_id = '0000024681'.
wa_meoutvalidityx-serial_idx = 'X'.
wa_meoutvalidityx-item_nox = 'X'.
wa_meoutvalidityx-valid_from = 'X'.
wa_meoutvalidityx-valid_to = 'X'.
append wa_meoutvalidityx.
wa_meoutcondition -cond_count = u201801u2019.
wa_meoutcondition-item_no = wa_meoutitem-item_no.
wa_meoutcondition-serial_id = '0000024681'.
wa_meoutcondition-cond_type = 'RA01'.
wa_meoutcondition-cond_value = wa_comc-ra01.
wa_meoutcondition-currency = '%'.
APPEND wa_meoutcondition.
wa_meoutconditionx-cond_count = wa_meoutcondition-cond_count.
wa_meoutconditionx-item_no = wa_meoutcondition-item_no.
wa_meoutconditionx-serial_id = '0000024681'.
wa_meoutconditionx-serial_idx = 'X'.
wa_meoutconditionx-item_nox = 'X'.
wa_meoutconditionx-cond_countx = 'X'.
wa_meoutconditionx-cond_type = 'X'.
wa_meoutconditionx-cond_value = 'X'.
wa_meoutconditionx-currency = 'X'.
APPEND wa_meoutconditionx.
or
report ztest_yangxg16.
data: gs_header type bapimeoutheader,
gs_headerx type bapimeoutheaderx,
gs_purchasingdocument type bapimeoutheader-number.
data: gt_return like bapiret2 occurs 0 with header line,
gt_item like bapimeoutitem occurs 0 with header line,
gt_itemx like bapimeoutitemx occurs 0 with header line,
gt_account like bapimeoutaccount occurs 0 with header line,
gt_accountprofitsegment like bapimeoutprofitsegment occurs 0 with header line,
gt_accountx like bapimeoutaccountx occurs 0 with header line,
gt_delivery_address like bapimeoutaddrdelivery occurs 0 with header line,
gt_item_cond_validity like bapimeoutvalidity occurs 0 with header line,
gt_item_cond_validityx like bapimeoutvalidityx occurs 0 with header line,
gt_item_condition like bapimeoutcondition occurs 0 with header line,
gt_item_conditionx like bapimeoutconditionx occurs 0 with header line,
gt_item_cond_scale_value like bapimeoutitemscaleval occurs 0 with header line,
gt_item_cond_scale_quan like bapimeoutitemscalequan occurs 0 with header line,
gt_item_text like bapimeoutitemtext occurs 0 with header line,
gt_header_text like bapimeouttext occurs 0 with header line,
gt_head_cond_validity like bapimeoutheadvalidity occurs 0 with header line,
gt_head_cond_validityx like bapimeoutheadvalidityx occurs 0 with header line,
gt_head_condition like bapimeoutheadercond occurs 0 with header line,
gt_head_conditionx like bapimeoutheadercondx occurs 0 with header line,
gt_head_cond_scale_val like bapimeoutscalevalue occurs 0 with header line,
gt_head_cond_scale_quan like bapimeoutscale occurs 0 with header line,
gt_partner like bapimeoutpartner occurs 0 with header line,
gt_partnerx like bapimeoutpartnerx occurs 0 with header line,
gt_extensionin like bapiparex occurs 0 with header line,
gt_extensionout like bapiparex occurs 0 with header line.
*header
gs_header-comp_code = '1000'.
gs_header-doc_type = 'ZMK'.
gs_header-vendor = '0000002100'.
gs_header-pmnttrms = '1026'.
gs_header-purch_org = '1000'.
gs_header-pur_group = '177'.
gs_header-currency = 'USD'.
gs_header-vper_start = '20080701'.
gs_header-vper_end = '20080711'.
gs_header-incoterms1 = 'FOB'.
gs_header-incoterms2 = 'dalian'.
gs_header-dscnt1_to = '35'.
gs_headerx-comp_code = 'X'.
gs_headerx-doc_type = 'X'.
gs_headerx-vendor = 'X'.
gs_headerx-pmnttrms = 'X'.
gs_headerx-purch_org = 'X'.
gs_headerx-pur_group = 'X'.
gs_headerx-currency = 'X'.
gs_headerx-vper_start = 'X'.
gs_headerx-vper_end = 'X'.
gs_headerx-incoterms1 = 'X'.
gs_headerx-incoterms2 = 'X'.
gs_headerx-dscnt1_to = 'X'.
*ITEM
gt_item-item_no = 1.
gt_item-material = 'WANGLTEST'.
gt_item-plant = '1001'.
*gt_item-STGE_LOC = ''.
gt_item-matl_group = '111020201'.
gt_item-target_qty = 3.
gt_item-po_unit = 'PC'.
gt_item-po_unit_iso = 'PC'.
gt_item-orderpr_un = 'PC'.
gt_item-orderpr_un_iso = 'PC'.
gt_item-conf_ctrl = '0001'.
gt_item-net_price = '100'.
append gt_item.
clear gt_item.
gt_itemx-item_no = 'X'.
gt_itemx-material = 'X'.
gt_itemx-plant = 'X'.
*gt_itemx-STGE_LOC = 'X'.
gt_itemx-matl_group = 'X'.
gt_itemx-target_qty = 'X'.
gt_itemx-po_unit = 'X'.
gt_itemx-po_unit_iso = 'X'.
gt_itemx-orderpr_un_iso = 'X'.
gt_itemx-orderpr_un = 'X'.
gt_itemx-conf_ctrl = 'X'.
gt_itemx-net_price = 'X'.
append gt_itemx.
clear gt_itemx.
call function 'BAPI_CONTRACT_CREATE'
exporting
header = gs_header
headerx = gs_headerx
VENDOR_ADDRESS =
TESTRUN =
TECHNICAL_DATA =
importing
purchasingdocument = gs_purchasingdocument
EXP_HEADER =
tables
return = gt_return
item = gt_item
itemx = gt_itemx
.
if gs_purchasingdocument is initial.
call function 'BAPI_TRANSACTION_COMMIT'.
write: / gs_purchasingdocument.
else.
call function 'BAPI_TRANSACTION_ROLLBACK'.
write: / ' fail'.
thanks
katrhik
2008 Jul 15 11:08 AM