Use Of BAPI's

Hi All,
I got a requirement regarding data transfer using bapi's. can anyone please tell me how to create a bapi.
please send me any program to understand better.
Reward points will be given for best answer.
thanx in advance

Hi,
   Welcome to SDN.
Refer https://forums.sdn.sap.com/click.jspa?searchID=5436713&messageID=1715433 why bapi used insted of bdc?
check the below sample program using bapi..
REPORT z_po_create NO STANDARD PAGE HEADING
MESSAGE-ID z0lo_scm
LINE-SIZE 220
LINE-COUNT 65 .
TABLES : ekko,
ekpo.
D A T A D E C L A R A T I O N S
*--Type declaration to store data read from table EKKO.
TYPES : BEGIN OF t_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bsart TYPE ekko-bsart,
aedat TYPE ekko-aedat,
ernam TYPE ekko-ernam,
lifnr TYPE ekko-lifnr,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
spras TYPE ekko-spras,
werks TYPE ekpo-werks,
END OF t_ekko.
*--Type declaration to store data read from table EKPO.
TYPES : BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
menge TYPE ekpo-menge,
knttp TYPE ekpo-knttp,
matkl TYPE ekpo-matkl,
bednr TYPE ekpo-bednr,
afnam TYPE ekpo-afnam,
meins TYPE ekpo-meins,
bpumz TYPE ekpo-bpumz,
bpumn TYPE ekpo-bpumn,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
webaz TYPE ekpo-webaz,
END OF t_ekpo.
TYPES : BEGIN OF t_head_item,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bsart TYPE ekko-bsart,
aedat TYPE ekko-aedat,
ernam TYPE ekko-ernam,
lifnr TYPE ekko-lifnr,
ekorg TYPE ekko-ekorg,
ekgrp TYPE ekko-ekgrp,
spras TYPE ekko-spras,
pincr TYPE ekko-pincr,
zterm TYPE ekko-zterm,
waers TYPE ekko-waers,
inco1 TYPE ekko-inco1,
inco2 TYPE ekko-inco2,
bedat TYPE ekko-bedat,
ebelp TYPE ekpo-ebelp,
txz01 TYPE ekpo-txz01,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
menge TYPE ekpo-menge,
knttp TYPE ekpo-knttp,
matkl TYPE ekpo-matkl,
bednr TYPE ekpo-bednr,
afnam TYPE ekpo-afnam,
meins TYPE ekpo-meins,
bpumz TYPE ekpo-bpumz,
bpumn TYPE ekpo-bpumn,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
webaz TYPE ekpo-webaz,
mwskz TYPE ekpo-mwskz,
adrn2 TYPE ekpo-adrn2,
END OF t_head_item.
TYPES : BEGIN OF t_sucess,
ebeln TYPE ekko-ebeln,
END OF t_sucess.
TYPES : BEGIN OF t_ekko_ekpo,
ebeln TYPE ekko-ebeln,
lifnr TYPE ekko-lifnr,
inco1 TYPE ekko-inco1,
inco2 TYPE ekko-inco2,
zterm TYPE ekko-zterm,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
END OF t_ekko_ekpo.
TYPES: BEGIN OF t_err_log,
ebeln TYPE ebeln, " Purchase order no.
bstpo TYPE bstpo, " Purchase order line item
etenr TYPE etenr, " Schedule line
err_val(20) TYPE c, " Error value
err_msg(100) TYPE c, " Error message
pogr_err(1) TYPE c, " If 'X' indicates PO creation error,
" else, indicates GR creation error
END OF t_err_log.
*-- Variables declarations.
DATA : v_ebeln TYPE ekko-ebeln, "PO Number
v_bsart TYPE ekko-bsart,
v_ekorg TYPE ekko-ekorg, "Purchasing Organization
v_ekgrp TYPE ekko-ekgrp, "Purchasing group
v_lifnr TYPE ekko-lifnr, "Vendor Number
v_werks TYPE ekpo-werks, "Plant
v_matnr TYPE ekpo-matnr, "Material Number
v_infnr TYPE ekpo-infnr. "Agreement
*-- Constants declarations.
CONSTANTS: c_bstyp TYPE ekpo-bstyp VALUE 'K',
c_bstyp1 TYPE ekpo-bstyp VALUE 'F',
c_x VALUE 'X'.
D A T A D E C L A R A T I O N S FOR BAPI
**-BAPI structure for Purchase Order Header Data
DATA : x_poheader TYPE bapimepoheader,
**-BAPI structure for Purchase Order Header Data (Change Toolbar)
x_poheaderx TYPE bapimepoheaderx,
**-BAPI structure for Purchase Order Item Data
x_poitem TYPE bapimepoitem,
**-BAPI structure for Purchase Order Item Data (Change Toolbar)
x_poitemx TYPE bapimepoitemx,
**-BAPI structure for messages
x_return TYPE bapiret2,
**-Structure for the error log
x_err_log TYPE t_err_log,
**-BAPI structure for Purchase Order Account assignment Data
x_poaccount TYPE bapimepoaccount,
**-BAPI structure for Purchase Order Account assignment
**-Data (Change Toolbar)
x_poaccountx TYPE bapimepoaccountx,
*ADDRESS
x_deliveryaddr TYPE bapimepoaddrdelivery.
**-BAPI internal table containing purchase order item
DATA : it_poitem TYPE STANDARD TABLE OF bapimepoitem,
**-BAPI internal table containing PO item data (Change Toolbar)
it_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
**-BAPI Return table containing messages
it_return TYPE STANDARD TABLE OF bapiret2,
**-BAPI internal table containing Account Assignment Fields for PO
it_poaccount TYPE STANDARD TABLE OF bapimepoaccount,
**-BAPI internal table containing Account Assignment Fields
**-in Purchase Order (Change Toolbar)
it_poaccountx TYPE STANDARD TABLE OF bapimepoaccountx,
it_deliveryaddr TYPE STANDARD TABLE OF bapimepoaddrdelivery.
I N T E R N A L T A B L E D E C L E R A T I O N S
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE,
it_ekko_dest TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE,
it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE,
it_head_item TYPE STANDARD TABLE OF t_head_item WITH HEADER LINE,
it_ekko_ekpo TYPE STANDARD TABLE OF t_ekko_ekpo WITH HEADER LINE,
it_sucess TYPE STANDARD TABLE OF t_sucess WITH HEADER LINE,
it_contract TYPE STANDARD TABLE OF t_sucess WITH HEADER LINE,
**-Internal table containing error messages
it_err_log TYPE STANDARD TABLE OF t_err_log.
S E L E C T I O N S C R E E N
*-- Selection criteria
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_ebeln FOR ekko-ebeln, "PO Number
s_bsart FOR ekko-bsart DEFAULT 'ZHBV', "PO Type
s_aedat FOR ekko-aedat DEFAULT sy-datum, "Creation Date
s_ekorg FOR ekko-ekorg, "Purchasing Organization
s_ekgrp FOR ekko-ekgrp, "Purchasing group
s_lifnr FOR ekko-lifnr, "Vendor Number
s_werks FOR ekpo-werks, "Plant
s_matnr FOR ekpo-matnr, "Material Number
s_infnr FOR ekpo-infnr. "Agreement
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS :p_bukrs LIKE ekko-bukrs DEFAULT '9040', "Company Code
p_werks LIKE ekpo-werks DEFAULT '7040', "Plant
p_ekorg LIKE ekko-ekorg DEFAULT '9040', "Purchasing Organization
p_ekgrp LIKE ekko-ekgrp DEFAULT '031', "Purchasing group
p_bsart1 LIKE ekko-bsart DEFAULT 'ZHIH'. "PO Type
SELECTION-SCREEN END OF BLOCK b2.
A T S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN.
*-- Validating the Selection Screen inputs.
PERFORM validate_user_input.
S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
*-- Getting data from table EKKO.
PERFORM get_purchase_order.
*-- Getting data from table EKKO
PERFORM get_po_created.
*-- Getting data from table EKKO & EKPO
PERFORM get_contract_num.
*-- Creating the PO.
PERFORM create_po.
E N D - O F - S E L E C T I O N
END-OF-SELECTION.
*-- Display PO which are already created
PERFORM display_createdpo_rept.
*-- Display PO which doesnt have contract numbers
PERFORM display_contract_rept.
TOP-OF-PAGE.
PERFORM page_heading.
*& Form VALIDATE_USER_INPUT
Form to validate user inputs at Selection Screen.
FORM validate_user_input .
*-- Validating Purchasing Document Number
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln
INTO v_ebeln
FROM ekko
UP TO 1 ROWS
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Document Number'(004).
ENDIF.
ENDIF.
*-- Validating Purchasing Document Type
IF NOT s_bsart[] IS INITIAL.
SELECT bsart
INTO v_bsart
FROM t161
UP TO 1 ROWS
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Document Type'(005).
ENDIF.
ENDIF.
*-- Validating Purchasing org
IF NOT s_ekorg[] IS INITIAL.
SELECT ekorg
INTO v_ekorg
FROM t024e
UP TO 1 ROWS
WHERE ekorg IN s_ekorg.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Organization'(006).
ENDIF.
ENDIF.
*-- Validating Purchasing group
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp
INTO v_ekgrp
FROM t024
UP TO 1 ROWS
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(007).
ENDIF.
ENDIF.
*-- Validating Vendor's account number
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr
INTO v_lifnr
FROM lfa1
UP TO 1 ROWS
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Vendor account number'(008).
ENDIF.
ENDIF.
*-- Validating Plant
IF NOT s_werks[] IS INITIAL.
SELECT werks
INTO v_werks
FROM t001w
UP TO 1 ROWS
WHERE werks IN s_werks.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Plant'(009).
ENDIF.
ENDIF.
*-- Validating Material
IF NOT s_matnr[] IS INITIAL.
SELECT matnr
INTO v_matnr
FROM mara
UP TO 1 ROWS
WHERE matnr IN s_matnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid Material Number'(010).
ENDIF.
ENDIF.
*-- Validating info record(Agreement)
IF NOT s_infnr[] IS INITIAL.
SELECT infnr
INTO v_infnr
FROM eina
UP TO 1 ROWS
WHERE infnr IN s_infnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'Invalid purchasing info record'(011).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_USER_INPUT
*& Form GET_PURCHASE_ORDER
Form to fetch data required from table EKKO & EKPO into internal table.
FORM get_purchase_order.
REFRESH it_head_item.
*-- Getting data from table EKKO & EKPO.
SELECT a~ebeln
a~bukrs
a~bsart
a~aedat
a~ernam
a~lifnr
a~ekorg
a~ekgrp
a~spras
a~pincr
a~zterm
a~waers
a~inco1
a~inco2
a~bedat
b~ebelp
b~txz01
b~matnr
b~werks
b~lgort
b~menge
b~knttp
b~matkl
b~bednr
b~afnam
b~meins
b~bpumz
b~bpumn
b~netpr
b~peinh
b~webaz
b~mwskz
b~adrn2
INTO TABLE it_head_item
FROM ekko AS a
INNER JOIN ekpo AS b
ON aebeln = bebeln
WHERE a~ebeln IN s_ebeln
AND a~bsart IN s_bsart
AND a~aedat IN s_aedat
AND a~ekgrp IN s_ekgrp
AND a~ekorg IN s_ekorg
AND a~lifnr IN s_lifnr
AND a~loekz <> c_x
AND b~werks IN s_werks
AND b~matnr IN s_matnr
AND b~infnr IN s_infnr
AND b~loekz <> c_x.
IF sy-subrc = 0.
SORT it_head_item BY ebeln.
LOOP AT it_head_item.
it_head_item-ebeln+0(1) = 'I'.
MODIFY it_head_item INDEX sy-tabix.
ENDLOOP.
ELSE.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_PURCHASE_ORDER
*& Form GET_PO_CREATED
Form to fetch data required from table EKKO into internal table.
Delete those records which are already created
FORM get_po_created .
*--fetch data from table EKKO into internal table
*--Where Docu type = 'ZHIH'
IF NOT it_head_item[] IS INITIAL.
SELECT a~ebeln
a~bukrs
a~bsart
a~aedat
a~ernam
a~lifnr
a~ekorg
a~ekgrp
a~spras
b~werks
INTO TABLE it_ekko_dest
FROM ekko AS a
INNER JOIN ekpo AS b
ON aebeln = bebeln
FOR ALL ENTRIES IN it_head_item
WHERE a~ebeln = it_head_item-ebeln
AND a~bsart = p_bsart1
AND a~bukrs = p_bukrs
AND b~werks = p_werks
AND b~bstyp = c_bstyp1
AND a~ekorg = p_ekorg
AND a~ekgrp = p_ekgrp.
IF sy-subrc = 0.
SORT it_ekko_dest BY ebeln.
ENDIF.
ENDIF.
*--Move all the PO numbers into sucess internal table
*--if the PO was already created
LOOP AT it_ekko_dest.
MOVE it_ekko_dest-ebeln TO it_sucess-ebeln.
APPEND it_sucess.
CLEAR it_sucess.
DELETE it_head_item WHERE ebeln = it_ekko_dest-ebeln.
ENDLOOP.
CLEAR it_head_item.
IF it_head_item[] IS INITIAL.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_PO_CREATED
*& Form GET_CONTRACT_NUM
text
FORM get_contract_num .
*--Select the data to get contract number
IF NOT it_head_item[] IS INITIAL.
SELECT a~ebeln "contract numbers
a~lifnr
a~inco1 "Incoterm1
a~inco2 "incoterm2
a~zterm
b~ebelp
b~matnr
INTO TABLE it_ekko_ekpo
FROM ekko AS a
INNER JOIN ekpo AS b
ON a~ebeln = b~ebeln
FOR ALL ENTRIES IN it_head_item
WHERE b~matnr = it_head_item-matnr
AND a~bukrs = p_bukrs " Company code
AND a~ekorg = p_ekorg " Purchase org
AND a~loekz <> c_x " Deletion indicator for header data
AND a~kdatb <= sy-datum " Validity period start
AND a~kdate >= sy-datum " Validity period end
AND b~loekz <> c_x " Deletion indicator for item data
AND b~bstyp = c_bstyp. " Purch. doc. category
IF sy-subrc = 0.
SORT it_ekko_ekpo BY matnr.
ENDIF.
LOOP AT it_head_item.
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc <> 0.
*-- move the data to the internal table
*-- which doesnt have contract number
it_contract-ebeln = it_head_item-ebeln.
APPEND it_contract.
CLEAR it_contract.
*-- Deleting the record
*-- which doesnt have any contract number
DELETE it_head_item WHERE ebeln = it_head_item-ebeln.
ENDIF.
ENDLOOP.
CLEAR it_head_item.
ENDIF.
IF it_head_item[] IS INITIAL.
MESSAGE i000 WITH 'No Purchase Order is possible for creation'(003).
STOP.
ENDIF.
ENDFORM. " GET_CONTRACT_NUM
*& Form CREATE_PO
CREATE PURCHASE ORDER
FORM create_po .
DATA: l_ret_msg(1000) TYPE c. " Success/Error message from BAPI
CLEAR: x_poheader, x_poheaderx.
SORT it_head_item BY ebeln.
LOOP AT it_head_item.
AT NEW ebeln.
READ TABLE it_head_item WITH KEY ebeln = it_head_item-ebeln.
IF sy-subrc = 0.
**-Populate PO Header structure
x_poheader-po_number = it_head_item-ebeln. " PO no.
x_poheader-comp_code = p_bukrs. " Company code
x_poheader-doc_type = p_bsart1. " Document type
x_poheader-creat_date = it_head_item-aedat. " Date created
x_poheader-created_by = it_head_item-ernam. " Created by
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc = 0.
x_poheader-vendor = it_ekko_ekpo-lifnr. " Vendor no.
x_poheader-incoterms1 = it_ekko_ekpo-inco1. " Incoterms1
x_poheader-incoterms2 = it_ekko_ekpo-inco2. " Incoterms2
x_poheader-pmnttrms = it_ekko_ekpo-zterm. " Payment terms
ENDIF.
x_poheader-langu = sy-langu. " Language key
x_poheader-langu_iso = sy-langu. " Language key iso
x_poheader-purch_org = p_ekorg. " Purchasing org.
x_poheader-pur_group = p_ekgrp. " Purch. Group
x_poheader-currency = it_head_item-waers. " currency
x_poheader-currency_iso = it_head_item-waers. " currency iso
x_poheader-doc_date = it_head_item-bedat. " Doc date
**-Populate PO Header 'X' structure
x_poheaderx-po_number = c_x.
x_poheaderx-comp_code = c_x.
x_poheaderx-doc_type = c_x.
x_poheaderx-creat_date = c_x.
x_poheaderx-created_by = c_x.
x_poheaderx-vendor = c_x.
x_poheaderx-langu = c_x.
x_poheaderx-langu_iso = c_x.
x_poheaderx-pmnttrms = c_x.
x_poheaderx-purch_org = c_x.
x_poheaderx-pur_group = c_x.
x_poheaderx-currency = c_x.
x_poheaderx-currency_iso = c_x.
x_poheaderx-doc_date = c_x.
x_poheaderx-incoterms1 = c_x.
x_poheaderx-incoterms2 = c_x.
ENDIF.
ENDAT.
READ TABLE it_ekko_ekpo WITH KEY matnr = it_head_item-matnr
BINARY SEARCH.
IF sy-subrc = 0.
x_poitem-po_item = it_ekko_ekpo-ebelp. " PO Item no.
x_poitem-agreement = it_ekko_ekpo-ebeln. " Agreement NO
ENDIF.
x_poitem-short_text = it_head_item-txz01. " Item description
x_poitem-material = it_head_item-matnr. " Material no.
x_poitem-plant = p_werks. " Plant
x_poitem-stge_loc = p_werks. " Storage Loc
x_poitem-matl_group = it_head_item-matkl. " Material group
x_poitem-quantity = it_head_item-menge. " Ordered qty.
x_poitem-po_unit = it_head_item-meins. " Order unit
x_poitem-po_unit_iso = it_head_item-meins. " Order unit
x_poitem-net_price = it_head_item-netpr. " Net price
x_poitem-price_unit = it_head_item-peinh. " price per unit
x_poitem-tax_code = it_head_item-mwskz. " Tax Code
x_poitem-acctasscat = it_head_item-knttp. " Account *** cata
APPEND x_poitem TO it_poitem.
CLEAR x_poitem.
**-Populate PO Item 'X' structure
x_poitemx-po_item = it_ekko_ekpo-ebelp. " PO Item no.
x_poitemx-po_itemx = c_x.
x_poitemx-short_text = c_x.
x_poitemx-material = c_x.
x_poitemx-plant = c_x.
x_poitemx-stge_loc = c_x.
x_poitemx-agreement = c_x.
x_poitemx-matl_group = c_x.
x_poitemx-quantity = c_x.
x_poitemx-po_unit = c_x.
x_poitemx-po_unit_iso = c_x.
x_poitemx-net_price = c_x.
x_poitemx-price_unit = c_x.
x_poitemx-tax_code = c_x.
x_poitemx-acctasscat = c_x.
APPEND x_poitemx TO it_poitemx.
CLEAR x_poitemx.
x_deliveryaddr-po_item = it_ekko_ekpo-ebelp.
x_deliveryaddr-addr_no = it_head_item-adrn2.
APPEND x_deliveryaddr TO it_deliveryaddr.
CLEAR x_deliveryaddr.
AT END OF ebeln.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = x_poheader
poheaderx = x_poheaderx
TABLES
return = it_return
poitem = it_poitem
poitemx = it_poitemx
poaddrdelivery = it_deliveryaddr.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
REFRESH : it_poitemx,it_poitem.
WRITE :/ x_poheader-po_number.
LOOP AT it_return INTO x_return.
WRITE :/ x_return-type,
20 x_return-message.
ENDLOOP.
REFRESH : it_poitemx,it_poitem,it_deliveryaddr,it_return.
CLEAR: x_poheader,x_poheaderx,x_poitem,x_poitemx,x_deliveryaddr.
ENDAT.
ENDLOOP.
ENDFORM. " CREATE_PO
*& Form display_createdpo_rept
text
FORM display_createdpo_rept .
**-Column headings
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
30 'List of PO already created',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
*-- Display PO created sucess report
LOOP AT it_sucess.
WRITE:/1 sy-vline,
15 'Purchase Order NO:',
40 it_sucess-ebeln,
100 sy-vline.
ENDLOOP.
WRITE:/1 sy-vline,
2(99) sy-uline,
100 sy-vline.
ENDFORM. " display_createdpo_rept
*& Form display_contract_rept
text
FORM display_contract_rept .
SKIP 3.
**-Column headings
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
30 'List of Contract Numbers',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
LOOP AT it_contract.
WRITE:/1 sy-vline,
15 'Purchase Order NO:',
40 it_contract-ebeln,
100 sy-vline.
ENDLOOP.
WRITE:/1 sy-vline,
2(99) sy-uline,
100 sy-vline.
ENDFORM. " display_contract_rept
**& Form RETURN_MESSAGES
text
*FORM return_messages .
*ENDFORM. " RETURN_MESSAGES
*& Form PAGE_HEADING
text
FORM page_heading .
**-List heading
FORMAT COLOR COL_HEADING.
WRITE:/1(100) sy-uline.
WRITE:/1 sy-vline,
40 'Summary Report',
100 sy-vline.
FORMAT INTENSIFIED OFF.
FORMAT RESET.
WRITE:/1(100) sy-uline.
SKIP 5.
ENDFORM. " PAGE_HEADING
Regards

Similar Messages

  • Open Purchase Order UPload Using the BAPI 's

    i need to upload the open Purchase Order using the BAPI function BAPI_PO_CREATE1., below is the given fileds blod are for Header, header will Repeat for the line items,can any one help me out  using the BAIP's for upload the PO, i need sample code for this ........
    Thanks & Regards
    Raghu
    <u>Field Name     Field Description                              Type     Length</u>
    <b>EBELN             Purchasing Document Number                         CHAR     010          X
    BUKRS             Company Code                                                     CHAR    004     MN10     C
    EKORG             Purchasing Organization                              CHAR     004     MN00     C
    EKGRP             Purchasing group                              CHAR     003          X
    BSART             Order type (Purchasing)                              CHAR     004          X
    LIFNR             Account Number of Vendor or Creditor                    CHAR     010          X
    BEDAT             Purchase Order Date                              DATS     010          X
    ZTERM             Terms of payment key                              CHAR     004          X
    WAERS             Currency Key                                   CUKY     005          X
    INCO1             Incoterms (part 1)                              CHAR     003          X
    INCO2             Incoterms (part 2)                              CHAR     028          X</b>
    EBELP             Item Number of Purchasing Document                    NUMC     005          X
    EMATN             Material number                                   CHAR     018          X
    WERKS             Plant                                        CHAR     004          X
    LGORT             Storage location                              CHAR     004          X
    EPSTP             Item category in purchasing document                    CHAR     001          X
    KNTTP             Account assignment category                         CHAR     001          X
    EINDT             Item delivery date                              DATS     010          X
    MENGE            "Purchase order quantity (direct input, transfer of POs)"     CHAR     013          X
    MEINS            Order unit                                   UNIT     003          X
    NETPR            "Net price: Document currency (direct input, transfer of"     CHAR     011          X
    PEINH            "Price unit (direct input, transfer of POs)"               CHAR     005          X
    BPRME            Order Price Unit (Purchasing)                         UNIT     003          X
    BPUMZ            Numerator: Conversion OPUn into OUn (direct input of POs          CHAR     005          X
    BPUMN            Denominator: Conversion OPUn into OUn (direct input of P          CHAR     005          X
    SAKTO            Cost element                                   CHAR     010          X
    KOSTL              Cost Center                                   CHAR     010          X
    VBELN          Sales and Distribution Document Number                    CHAR     010          X
    VBELP          Sales document item                              NUMC     006          X
    WEMPF          Goods recipient                                   CHAR     012          X
    WEBTH          "Amount in local currency (direct input, transfer of POs)"     CHAR     013          X
    WEBTF          "Amount in document currency (direct input, transfer of P"     CHAR     013          X
    WEREF          Flag for treatment of GR/IR (direct input of POs)          CHAR     001          X
    SPINF          Indicator: Update info record                         CHAR     001          X
    WEPOS          Goods Receipt Indicator                              CHAR     001          X
    REPOS          Invoice receipt indicator                         CHAR     001          X

    i need to upload the open Purchase Order using the BAPI function BAPI_PO_CREATE1., below is the given fileds blod are for Header, header will Repeat for the line items,can any one help me out  using the BAIP's for upload the PO, i need sample code for this ........
    Thanks & Regards
    Raghu
    <u>Field Name     Field Description                              Type     Length</u>
    <b>EBELN             Purchasing Document Number                         CHAR     010          X
    BUKRS             Company Code                                                     CHAR    004     MN10     C
    EKORG             Purchasing Organization                              CHAR     004     MN00     C
    EKGRP             Purchasing group                              CHAR     003          X
    BSART             Order type (Purchasing)                              CHAR     004          X
    LIFNR             Account Number of Vendor or Creditor                    CHAR     010          X
    BEDAT             Purchase Order Date                              DATS     010          X
    ZTERM             Terms of payment key                              CHAR     004          X
    WAERS             Currency Key                                   CUKY     005          X
    INCO1             Incoterms (part 1)                              CHAR     003          X
    INCO2             Incoterms (part 2)                              CHAR     028          X</b>
    EBELP             Item Number of Purchasing Document                    NUMC     005          X
    EMATN             Material number                                   CHAR     018          X
    WERKS             Plant                                        CHAR     004          X
    LGORT             Storage location                              CHAR     004          X
    EPSTP             Item category in purchasing document                    CHAR     001          X
    KNTTP             Account assignment category                         CHAR     001          X
    EINDT             Item delivery date                              DATS     010          X
    MENGE            "Purchase order quantity (direct input, transfer of POs)"     CHAR     013          X
    MEINS            Order unit                                   UNIT     003          X
    NETPR            "Net price: Document currency (direct input, transfer of"     CHAR     011          X
    PEINH            "Price unit (direct input, transfer of POs)"               CHAR     005          X
    BPRME            Order Price Unit (Purchasing)                         UNIT     003          X
    BPUMZ            Numerator: Conversion OPUn into OUn (direct input of POs          CHAR     005          X
    BPUMN            Denominator: Conversion OPUn into OUn (direct input of P          CHAR     005          X
    SAKTO            Cost element                                   CHAR     010          X
    KOSTL              Cost Center                                   CHAR     010          X
    VBELN          Sales and Distribution Document Number                    CHAR     010          X
    VBELP          Sales document item                              NUMC     006          X
    WEMPF          Goods recipient                                   CHAR     012          X
    WEBTH          "Amount in local currency (direct input, transfer of POs)"     CHAR     013          X
    WEBTF          "Amount in document currency (direct input, transfer of P"     CHAR     013          X
    WEREF          Flag for treatment of GR/IR (direct input of POs)          CHAR     001          X
    SPINF          Indicator: Update info record                         CHAR     001          X
    WEPOS          Goods Receipt Indicator                              CHAR     001          X
    REPOS          Invoice receipt indicator                         CHAR     001          X

  • Assignment on Sales Order creation using a BAPI

    hi,
    i m new 2 bapi,so i usually knw how 2 create BAPI
    1.     Create a sales order using BAPI with the header details from selection screen and item details from the file.
    2.     Have the minimum required header fields for a sales order  – Sales order type, sales org, distribution channel, division, customer, purchase order type, purchase order number as the selection screen parameters.
    3.     Have a field to enter the presentation server path on the selection screen where the file with item details is stored. File will have material, size and quantity required.
    4.     Validate all the relevant selection screen entries.
    5.     Create a sales order with the obtained details using the BAPI
          BAPI_SALESORDER_CREATEFROMDAT2
    6.     Catch all the BAPI errors and display a report. If the BAPI call was successful display the sales order document number and the items. If the call fails, display all the error message encountered.

    Hi Priya,
    Here is the sample program , it may helpful check,
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Data declarations.
    DATA: v_vbeln LIKE vbak-vbeln.
    DATA: header LIKE bapisdhead1.
    DATA: headerx LIKE bapisdhead1x.
    DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
    DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
    WITH HEADER LINE.
    DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
    WITH HEADER LINE.
    Initialization.
    INITIALIZATION.
    v_text = 'Order type'.
    v_text1 = 'Sales Org'.
    v_text2 = 'Distribution channel'.
    v_text3 = 'Division'.
    v_text4 = 'Sold-to'.
    v_text5 = 'Ship-to'.
    v_text6 = 'Material'.
    v_text7 = 'Quantity'.
    v_text9 = 'Plant'.
    Start-of-selection.
    START-OF-SELECTION.
    Header data
    Sales document type
    header-doc_type = p_auart.
    headerx-doc_type = 'X'.
    Sales organization
    header-sales_org = p_vkorg.
    headerx-sales_org = 'X'.
    Distribution channel
    header-distr_chan = p_vtweg.
    headerx-distr_chan = 'X'.
    Division
    header-division = p_spart.
    headerx-division = 'X'.
    headerx-updateflag = 'I'.
    Partner data
    Sold to
    partner-partn_role = 'AG'.
    partner-partn_numb = p_sold.
    APPEND partner.
    Ship to
    partner-partn_role = 'WE'.
    partner-partn_numb = p_ship.
    APPEND partner.
    ITEM DATA
    itemx-updateflag = 'I'.
    Line item number.
    item-itm_number = '000010'.
    itemx-itm_number = 'X'.
    Material
    item-material = p_matnr.
    itemx-material = 'X'.
    Plant
    item-plant = p_plant.
    itemx-plant = 'X'.
    Quantity
    item-target_qty = p_menge.
    itemx-target_qty = 'X'.
    APPEND item.
    APPEND itemx.
    Fill schedule lines
    lt_schedules_in-itm_number = '000010'.
    lt_schedules_in-sched_line = '0001'.
    lt_schedules_in-req_qty = p_menge.
    APPEND lt_schedules_in.
    Fill schedule line flags
    lt_schedules_inx-itm_number = '000010'.
    lt_schedules_inx-sched_line = '0001'.
    lt_schedules_inx-updateflag = 'X'.
    lt_schedules_inx-req_qty = 'X'.
    APPEND lt_schedules_inx.
    Call the BAPI to create the sales order.
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
    EXPORTING
    sales_header_in = header
    sales_header_inx = headerx
    IMPORTING
    salesdocument_ex = v_vbeln
    TABLES
    return = return
    sales_items_in = item
    sales_items_inx = itemx
    sales_schedules_in = lt_schedules_in
    sales_schedules_inx = lt_schedules_inx
    sales_partners = partner.
    Check the return table.
    LOOP AT return WHERE type = 'E' OR type = 'A'.
    EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
    WRITE: / 'Error in creating document'.
    ELSE.
    Commit the work.
    COMMIT WORK AND WAIT.
    WRITE: / 'Document ', v_vbeln, ' created'.
    ENDIF.

  • Need to upload mass excel sheet using the bapi bapi_acc_document_post.

    I am assigned with an object, where I need to post the records from a mass excel sheet in to ECC or/and BW basing the dimensions using the bapi bapi_acc_document_post.the excel sheet has header and Item data. I am pretty much new to this bapi's
    please do the need ful

    Check report "ACC_BAPI_TEST_INVOICE_RECEIPT",
    this report calls BAPI "BAPI_ACC_INVOICE_RECEIPT_POST",
    but the parameters are nearly the same.
    Best Regards, Dirk

  • Create a Purchase order using the BAPI using the data in the XML file.

    Hello Gurus,
    here is the scenario can anyone help me how to proceed explaining the procedure?
    Create a Purchase order using the BAPI using the data in the XML file.
    comprehensive explanations are appreciated.
    thanks in advance.

    hi,
      first use fm "bapi_po_create".
      then use fm "BAPI_ACC_GL_POSTING_POST"
    The demo environment was made with real business scenario in mind, but following subjects need to be addressed in a live implementation:
    •     No exceptions and error handling is implemented, except the order rejection (e.g. partly delivery);
    •     In Navision both XML Ports and the XML DOM has been used to integrate with SAP XI, because XML ports has some drawbacks regarding to Namespaces in XML Documents (mandatory in SAP XI);
    •     A minimum of SAP and Navision customization is required to implement this solution. (e.g. user exit in SAP, Navision XML DOM).

  • Need Help ! PO using a BAPI -  BAPI_PO_CREATE1

    Hi friends,
    Need some help. I am trying to create a PO using a BAPI - BAPI_PO_CREATE1
    <i><b>I want the new PO to have all the characteristics of an existing PO. which is stored in wa_order_split_create-docnr and for the new PO, i want the quantity from wa_order_split_create-qty_acptd and the delivery data to be wa_order_split_create-dly_date. But this process and code below gives a short dump in  the std FM  - MEPO_DOC_ITEM_GET . It raises an exception of failure.</b></i>
    Am i making any mistake while filling the header or item or schedule lines before BAPI_PO_CREATE1 ?
    MOVE: wa_order_split_create-docnr TO i_ebeln,
    wa_order_split_create-docitm TO i_ebelp .
    CALL FUNCTION 'ME_EKKO_SINGLE_READ'
    EXPORTING
    pi_ebeln = i_ebeln
    IMPORTING
    po_ekko = i_ekko
    EXCEPTIONS
    no_records_found = 1
    OTHERS = 2.
    IF sy-subrc <> 0 .
    ENDIF .
    Fill PO Header
    i_bpoh-comp_code = i_ekko-bukrs .
    i_bpoh-doc_type = i_ekko-bsart .
    i_bpoh-vendor = i_ekko-lifnr .
    i_bpoh-langu = i_ekko-spras .
    i_bpoh-pmnttrms = i_ekko-zterm .
    i_bpoh-purch_org = i_ekko-ekorg .
    i_bpoh-pur_group = i_ekko-ekgrp .
    i_bpoh-currency = i_ekko-waers .
    i_bpoh-agreement = i_ekko-konnr .
    i_bpoh-incoterms1 = i_ekko-inco1 .
    i_bpoh-incoterms2 = i_ekko-inco2 .
    Fill PO update indicator 'X'
    i_bpohx-comp_code = c_char_x .
    i_bpohx-doc_type = c_char_x .
    i_bpohx-vendor = c_char_x .
    i_bpohx-langu = c_char_x .
    i_bpohx-pmnttrms = c_char_x .
    i_bpohx-purch_org = c_char_x .
    i_bpohx-pur_group = c_char_x .
    i_bpohx-currency = c_char_x .
    i_bpohx-agreement = c_char_x .
    i_bpohx-incoterms1 = c_char_x .
    i_bpohx-incoterms2 = c_char_x .
    CALL FUNCTION 'ME_EKPO_SINGLE_READ'
    EXPORTING
    pi_ebeln = i_ebeln
    pi_ebelp = i_ebelp
    IMPORTING
    po_ekpo = i_ekpo
    EXCEPTIONS
    no_records_found = 1
    OTHERS = 2.
    IF sy-subrc <> 0 .
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF .
    Fill PO Item
    i_wa_bpoi-po_item = i_ekpo-ebelp .
    i_wa_bpoi-material = i_ekpo-matnr .
    i_wa_bpoi-plant = i_ekpo-werks .
    i_wa_bpoi-stge_loc = i_ekpo-lgort .
    i_wa_bpoi-quantity = wa_order_split_create-qty_acptd .
    i_wa_bpoi-po_unit = i_ekpo-meins .
    i_wa_bpoi-tax_code = i_ekpo-mwskz .
    i_wa_bpoi-val_type = i_ekpo-bwtar .
    i_wa_bpoi-item_cat = i_ekpo-pstyp .
    i_wa_bpoi-acctasscat = i_ekpo-knttp .
    i_wa_bpoi-agreement = i_ekpo-konnr .
    i_wa_bpoi-agmt_item = i_ekpo-ktpnr .
    APPEND i_wa_bpoi TO i_bpoi .
    Fill PO Item update indicator 'X'
    i_wa_bpoix-po_item = i_ekpo-ebelp .
    i_wa_bpoix-po_itemx = c_char_x .
    i_wa_bpoix-material = c_char_x .
    i_wa_bpoix-plant = c_char_x .
    i_wa_bpoix-stge_loc = c_char_x .
    i_wa_bpoix-quantity = c_char_x .
    i_wa_bpoix-po_unit = c_char_x .
    i_wa_bpoix-tax_code = c_char_x .
    i_wa_bpoix-val_type = c_char_x .
    i_wa_bpoix-item_cat = c_char_x .
    i_wa_bpoix-acctasscat = c_char_x .
    i_wa_bpoix-agreement = c_char_x .
    i_wa_bpoix-agmt_item = c_char_x .
    APPEND i_wa_bpoix TO i_bpoix .
    Fill PO Item Schedule
    i_wa_bpos-po_item = i_ekpo-ebelp .
    i_wa_bpos-sched_line = '0001' .
    i_wa_bpos-delivery_date = wa_order_split_create-dly_date .
    i_wa_bpos-quantity = wa_order_split_create-qty_acptd .
    APPEND i_wa_bpos TO i_bpos .
    Fill PO Item schedule update indicator 'X'
    i_wa_bposx-po_item = i_ekpo-ebelp .
    i_wa_bposx-sched_line = '0001' .
    i_wa_bposx-delivery_date = c_char_x .
    i_wa_bposx-quantity = c_char_x .
    APPEND i_wa_bposx TO i_bposx .
    CLEAR: i_pargr .
    SELECT SINGLE pargr
    INTO i_pargr
    FROM t161
    WHERE bstyp = i_ekko-bstyp
    AND bsart = i_ekko-bsart .
    CLEAR i_ekpa[].
    CALL FUNCTION 'MM_READ_PARTNERS'
    EXPORTING
    application = c_char_p
    ebeln = i_ebeln
    bstyp = i_ekko-bstyp
    pargr = i_pargr
    TABLES
    x_ekpa = i_ekpa[].
    LOOP AT i_ekpa INTO i_wa_ekpa .
    i_wa_bpop-partnerdesc = i_wa_ekpa-parvw .
    i_wa_bpop-langu = sy-langu .
    IF NOT i_wa_ekpa-lifn2 IS INITIAL .
    i_wa_bpop-buspartno = i_wa_ekpa-lifn2 .
    ELSE .
    i_wa_bpop-buspartno = i_wa_ekpa-parnr .
    ENDIF .
    APPEND i_wa_bpop TO i_bpop .
    CLEAR: i_wa_ekpa, i_wa_bpop .
    ENDLOOP .
    CALL FUNCTION 'DIALOG_SET_NO_DIALOG'.
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = i_bpoh
    poheaderx = i_bpohx
    IMPORTING
    exppurchaseorder = i_new_ebeln
    TABLES
    return = i_bapiret2
    poitem = i_bpoi[]
    poitemx = i_bpoix[]
    poschedule = i_bpos[]
    poschedulex = i_bposx[].
    i_order = i_new_ebeln .
    SHIFT i_order LEFT DELETING LEADING '0' .
    i_return-errortype = c_char_i .
    i_return-workarea = c_zsw .
    i_return-message = '064' .
    i_return-variable1 = i_order .
    loop at i_bapiret2 into i_bapiretn where type ca 'EAX' .
    append i_bapiretn to t_bapi_return .
    endloop .
    if t_bapi_return[] is initial .
    i_create_order = c_char_x .
    CALL FUNCTION 'SWD_POPUP_MESSAGE_SEND'
    EXPORTING
    act_return = i_return.

    Hi,
    Make the required settings to trigger an idoc during the creation of a PO in Me21N with multiple line items, check how the idoc is being created, This should be starting point to know how to create idoc with multiple line items.
    Hope this works for you.
    Rajeev

  • How to get custom field value in vbkd table using "SD_SALESDOCUMENT_CREATE" bapi

    Hi Experts,
    Need your help . In one program Iam using SD_SALESDOCUMENT_CREATE bapi .
    i/p for my report is am excel.
    excel is having  below formatt.
    To create salesdoc we are using SD_SALESDOC_CREATE bapi.
    but After execution of the program we are unable to find the ZZFV_SBCNT (which is custom  field) in VBKD w.r.t salesdocument.
    Need your help what we need to do to reflect the value in vbkd table.
    Here temp will contains the data from excel
    1)
    FORM f_move_header_data .
       wg_header-doc_type            = wg_temp-auart .                   "Order type
       wg_header-sales_org           = wg_temp-vkorg .                   "Sales Organization
       wg_header-distr_chan          = wg_temp-vtweg .                   "Distribution Channel
       wg_header-division            = wg_temp-spart.                    "Division
       wg_header-sales_off           = wg_temp-vkbur .                   "Sales Office
       wg_header-sales_grp           = wg_temp-vkgrp .                   "Sales Group
       wg_header-purch_no_c          = wg_temp-bstnk .                   "Customer purchase order number
       wg_header-pymt_meth           = wg_temp-zlsch  .                  "Payment Method
       wg_header-zzychan_role        = wg_temp-zzychan_role_i.           "Channel Role
       wg_header-zzysub_role         = wg_temp-zzysub_role  .            "Submitter Role
       wg_header-zzy_inv_for_opt     = wg_temp-zzinv_format  .           "Invoice Format Optio
       wg_header-ord_reason          = wg_temp-augru  .                  "Order Reason Code
       wg_header-bill_block          = wg_temp-faksp.                    "Billing Block
       wg_headerx-doc_type            = c_set .                   "Order type
       wg_headerx-sales_org           = c_set .                   "Sales Organization
       wg_headerx-distr_chan          = c_set .                   "Distribution Channel
       wg_headerx-division            = c_set.                    "Division
       wg_headerx-sales_off           = c_set .                   "Sales Office
       wg_headerx-sales_grp           = c_set .                   "Sales Group
       wg_headerx-purch_no_c          = c_set .                   "Customer purchase order number
       wg_headerx-pymt_meth           = c_set  .                  "Payment Method
       wg_headerx-zzychan_role        = c_set.                    "Channel Role
       wg_headerx-zzysub_role         = c_set .                   "Submitter Role
       wg_headerx-zzy_inv_for_opt     = c_set .                   "Invoice Format Option
       wg_headerx-ord_reason          = c_set .                   "Order Reason Code
       wg_headerx-bill_block           = c_set.                    "Billing Block
    ENDFORM.                    " F_MOVE_HEADER_DATA
    2)
    FORM f_move_item_data .
       wg_item-itm_number          =   g_itmnumber.                              "Item number
       wg_item-material            =   wg_process-matnr .                        "Material
       wg_item-target_qty          =   wg_process-target_qty.                    "Targeted Qty
       wg_item-item_categ          =   wg_process-pstyv.                         "Sales document item category
       wg_item-zzylegal_i          =   wg_process-zzlegal.                       "Legal Contract
    **********Added this line for vbkd-ZZFV_SBCNT****************************
       wg_item-zzfv_sbcnt          = wg_process-zzfv_sbcnt.      
    APPEND wg_item TO i_item.
    wg_itemx-material            =   c_set .                        "Material
       wg_itemx-target_qty          =   c_set.                         "Targeted Qty
       wg_itemx-item_categ          =   c_set.                         "Sales document item category
       wg_itemx-zzylegal_i          =   c_set.                         "Legal Contract
       wg_itemx-zzsteady_date       =   c_set .                        "Amortization Start Date
       wg_itemx-zzsteady_end_dat    =   c_set.                         "Amortization Stop Date
    **********Added this line for vbkd-ZZFV_SBCNT****************************
       wg_itemx-ZZFV_SBCNt     =   c_set.   "
       APPEND wg_itemx TO i_itemx.
       CLEAR : wg_itemx. 
    endform. 
    3)           
    FORM f_move_head_ext
    wg_extension-structure   = c_ext_vbak.
       wg_ext_vbak-zzinv_format = wg_temp-zzinv_format.
    wg_ext_vbak-zzychan_role = wg_temp-zzychan_role_i.
       wg_ext_vbak-zzysub_role  = wg_temp-zzysub_role.
       wg_extension+30 = wg_ext_vbak.
    APPEND wg_extension to i_extension.
    CLEAR wg_extension.
       wg_extensionx-structure =  c_ext_vbakx.
       wg_ext_vbakx-zzinv_format = c_set.
      wg_ext_vbakx-zzlegal      = c_set.
       wg_ext_vbakx-zzychan_role = c_set.
       wg_ext_vbakx-zzysub_role  = c_set.
       wg_extensionx+30 = wg_ext_vbakx.
       APPEND wg_extensionx TO i_extensionx.
       CLEAR wg_extensionx.
    ENDFORM.                    " F_MOVE_HEAD_EXT
    *&      Form  F_MOVE_ITEM_EXT
    *       Item Extension
    4)
    FORM f_move_item_ext .
    * Structure for BAPI parameter Extension
       wg_extension-structure = c_ext_vbap.
       wg_ext_vbap-posnr      = g_itmnumber.
       wg_ext_vbap-zzsteady_date       =   wg_process-zzsteady_date .                 "Amortization Start Date
       wg_ext_vbap-zzsteady_end_dat    =   wg_process-zzsteady_end_dat.               "Amortization Stop Date
       wg_ext_vbap-zzlegal             =   wg_process-zzlegal.                        "Legal Contract
       wg_extension+30 = wg_ext_vbap.
    APPEND wg_extension to i_extension.
    * Structure for BAPI parameter Extension - Update Indicator Fields
       wg_extensionx-structure =  c_ext_vbapx.
       wg_ext_vbapx-posnr = g_itmnumber.
       wg_ext_vbapx-zzsteady_date       =   c_set .
       wg_ext_vbapx-zzsteady_end_dat    =   c_set.
    *  wg_ext_vbapx-zzlegal             =   c_set.
    *wg_process-zzfv_sbcnt = c_set.
       wg_extensionx+30 = wg_ext_vbapx.
       APPEND wg_extensionx TO i_extensionx.
       CLEAR wg_extensionx.
    and bapi calling is like below.
    CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
         EXPORTING
           sales_header_in       = wg_header
           sales_header_inx      = wg_headerx
           logic_switch          = wg_logic_switch
           business_object       = fp_bus_obj
           status_buffer_refresh = 'X'
         IMPORTING
           salesdocument_ex      = g_sorder
         TABLES
          return                = i_return
           sales_items_in        = i_item
           sales_items_inx       = i_itemx
           sales_partners        = i_partner
           sales_conditions_in   = i_cond
           sales_conditions_inx  = i_condx
           sales_text            = i_text
           extensionin           = i_extension
         extensionex           = i_extensionx.
    still we are not getting ZZFV_SBCNT value in VBKD table w.r.t created salesdoc(g_sorder)
    Please help me from this issue.
    Thank You..

    Hi,
    Please let me know how to add custom fields in the characteristic list, My clients wants department and profit center grouping.
    Please tell me how to solve it..
    Thanks & Regards,
    Reena..

  • Netprice Picked up from last document-Open PO load using LSMW BAPI method.

    Hi Experts,
    I m doing Open PO load using LSMW BAPI method...(BAPI_PO_CREAT1).
    Inside the LSMW BAPI picks up the NETPR value from the last document and doesnt consider the value from load file...
    Please advice me how to handle this issue...
    I tried giving values to field CALCTYPE at item level or POCOND table with with carry out new pricing options....but nothig works for me...
    PLease give your valuable inputs to achieve the requirement....
    Bharathi.J

    read OSS Note 580225 - Purchasing BAPIs: Conditions and pricing

  • How to Use PM BAPI for equipment Master upload : BAPI_EQUIPMENT_SAVEREPLICA

    Hi ,
      How to use PM BAPI for equipment Master upload : BAPI_EQUIPMENT_SAVEREPLICA.
      May i know what are the input parameters & fields mandatory
      for each Table structures ct_data , ct_datax , it_descript , it_longtext.
      Can any one explain me Step by Step Process.
      B'cos i tried with below code. Equipment is not getting created.
      wa_itab-equipment_ext = '000000000100000001'.
      wa_itab-descript      = 'Test 2 -> Lube Oil Pump'.
      wa_itab-text_language = 'EN'.
      wa_itab-sdescript     = 'Short Description'.
      APPEND wa_itab TO it_itab.
      CLEAR  wa_itab.
      LOOP AT it_itab INTO wa_itab.
        ct_data-ta_guid       = '000000000000000001'.
        ct_data-equipment_ext = wa_itab-equipment_ext.
        ct_data-descript      = wa_itab-descript     .
        ct_data-valid_date    = sy-datum.
        ct_data-equicatgry    = 'M'.
        APPEND ct_data.
        CLEAR  ct_data.
        ct_datax-ta_guid       = '000000000000000001'.
        ct_datax-equipment_ext = 'X'.
        ct_datax-equipment     = 'X'.
        APPEND ct_datax.
        CLEAR  ct_datax.
        it_descript-ta_guid       = '000000000000000001'.
        it_descript-text_language = wa_itab-text_language.
        it_descript-descript      = wa_itab-sdescript    .
        APPEND it_descript.
        CLEAR  it_descript.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'LTXT'.
        it_longtext-text_line      = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'aaaaaaaaaaaaaaa'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'bbbbbbbbbbbb'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'cccccccccccccccc'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      call BAPI-function in this system
        CALL FUNCTION 'BAPI_EQUIPMENT_SAVEREPLICA'
          TABLES
            ct_data     = ct_data
            ct_datax    = ct_datax
            it_descript = it_descript
            it_longtext = it_longtext
            return      = return
          EXCEPTIONS
            OTHERS      = 1.
        IF sy-subrc = 0.
          CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          WRITE : 'Successful'.
        ENDIF.
        IF NOT return IS INITIAL.
          LOOP AT return.
            IF return-type = 'A' OR return-type = 'E'.
              WRITE : 'Error'.
            ENDIF.
          ENDLOOP.
        ENDIF.
        REFRESH  return.
      ENDLOOP.
    Regards
    SUrendar

    Hi ,
      How to use PM BAPI for equipment Master upload : BAPI_EQUIPMENT_SAVEREPLICA.
      May i know what are the input parameters & fields mandatory
      for each Table structures ct_data , ct_datax , it_descript , it_longtext.
      Can any one explain me Step by Step Process.
      B'cos i tried with below code. Equipment is not getting created.
      wa_itab-equipment_ext = '000000000100000001'.
      wa_itab-descript      = 'Test 2 -> Lube Oil Pump'.
      wa_itab-text_language = 'EN'.
      wa_itab-sdescript     = 'Short Description'.
      APPEND wa_itab TO it_itab.
      CLEAR  wa_itab.
      LOOP AT it_itab INTO wa_itab.
        ct_data-ta_guid       = '000000000000000001'.
        ct_data-equipment_ext = wa_itab-equipment_ext.
        ct_data-descript      = wa_itab-descript     .
        ct_data-valid_date    = sy-datum.
        ct_data-equicatgry    = 'M'.
        APPEND ct_data.
        CLEAR  ct_data.
        ct_datax-ta_guid       = '000000000000000001'.
        ct_datax-equipment_ext = 'X'.
        ct_datax-equipment     = 'X'.
        APPEND ct_datax.
        CLEAR  ct_datax.
        it_descript-ta_guid       = '000000000000000001'.
        it_descript-text_language = wa_itab-text_language.
        it_descript-descript      = wa_itab-sdescript    .
        APPEND it_descript.
        CLEAR  it_descript.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'LTXT'.
        it_longtext-text_line      = 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'aaaaaaaaaaaaaaa'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'bbbbbbbbbbbb'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        it_longtext-ta_guid        = '000000000000000001'.
        it_longtext-text_language  = wa_itab-text_language.
        it_longtext-text_id        = 'INTV'.
        it_longtext-text_line      = 'cccccccccccccccc'.
        APPEND it_longtext.
        CLEAR  it_longtext.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      call BAPI-function in this system
        CALL FUNCTION 'BAPI_EQUIPMENT_SAVEREPLICA'
          TABLES
            ct_data     = ct_data
            ct_datax    = ct_datax
            it_descript = it_descript
            it_longtext = it_longtext
            return      = return
          EXCEPTIONS
            OTHERS      = 1.
        IF sy-subrc = 0.
          CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
          WRITE : 'Successful'.
        ENDIF.
        IF NOT return IS INITIAL.
          LOOP AT return.
            IF return-type = 'A' OR return-type = 'E'.
              WRITE : 'Error'.
            ENDIF.
          ENDLOOP.
        ENDIF.
        REFRESH  return.
      ENDLOOP.
    Regards
    SUrendar

  • Issue with posting G/L using the BAPI " BAPI_ACC_DOCUMENT_POST"

    Hi all,
    I am trying to create a G/L document using the BAPI "BAPI_ACC_DOCUMENT_POST". The Bapi is returning me a success message, but i am not able to see the document in BKPF/BSEG.
    Can somebody please let me know if there is any customization that needs to be done to get the document number reflected in the corresponding tables after i execute this BAPI.
    Here is the part of the code that i am using to fill the header structure:
      docheader-obj_type = 'REACI'.
        docheader-obj_key = 'TEST'.
        docheader-obj_sys = 'ECSCLNT010'.
        docheader-bus_act = 'RFBU'.
        docheader-username = sy-uname.
        docheader-header_txt = 'HDR TEXT'.
        docheader-comp_code = 'SC01'.
        docheader-doc_date = sy-datum.
        docheader-pstng_date = sy-datum.
        CASE wa_input_tmp-batch_type .
          WHEN '0'.
            docheader-doc_type = 'SA'.
          WHEN '1'.
            docheader-doc_type = 'RA'.
        ENDCASE.
    Any help is much appreciated.
    Thanks in Advance,
    Suresh

    See the below code :
    I have tested program in my system :
    *&---HEADER DECLARATION
    DATA: HEADER TYPE BAPIACHE09.                " HEADER DATA
                 INTERNAL TABLE DECLARATION
    *&----G/L ACCOUNT ITEM
    DATA: ACCOUNTGL TYPE STANDARD TABLE OF BAPIACGL09.
    *&---CURRENCY ITEMS
    DATA: CURRENCY_AMOUNT TYPE STANDARD TABLE OF BAPIACCR09.
    *&----RETURN PARAMETER
    DATA: RETURN  TYPE STANDARD TABLE OF BAPIRET2 with header line.
                         WORK-AREA DECLARATION
    *&----WORKAREA FOR G/L ACCOUNT ITEM
    DATA: WA_ACCOUNTGL TYPE BAPIACGL09.
    *&---WORKAREA FOR CURRENCY ITEMS
    DATA: WA_CURRENCY_AMOUNT TYPE BAPIACCR09.
                        INITIALIZATION
    HEADER-HEADER_TXT  = 'TEST HEADER'.
    HEADER-USERNAME    = 'DEVELOPER'.
    HEADER-COMP_CODE   = '0002'.
    HEADER-FISC_YEAR   = '2007'.
    HEADER-DOC_DATE    = '20070502'.
    HEADER-PSTNG_DATE  = '20070502'.
    HEADER-TRANS_DATE  = '20070502'.
    HEADER-DOC_TYPE    = 'SA'.
    HEADER-BUS_ACT     = 'RFBU'.
    WA_ACCOUNTGL-ITEMNO_ACC  = '0000000010'.
    WA_ACCOUNTGL-GL_ACCOUNT = '0000113020'.
    WA_ACCOUNTGL-ITEM_TEXT  = 'SO_DOC'.
    WA_ACCOUNTGL-DE_CRE_IND = 'S'.
    APPEND WA_ACCOUNTGL TO ACCOUNTGL.
    CLEAR WA_ACCOUNTGL.
    WA_ACCOUNTGL-ITEMNO_ACC  = '0000000020'.
    WA_ACCOUNTGL-GL_ACCOUNT = '0000113020'.
    WA_ACCOUNTGL-ITEM_TEXT  = 'SO_DOC'.
    WA_ACCOUNTGL-DE_CRE_IND = 'H'.
    APPEND WA_ACCOUNTGL TO ACCOUNTGL.
    CLEAR WA_ACCOUNTGL.
    WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000010'.
    WA_CURRENCY_AMOUNT-AMT_DOCCUR = '500'.
    WA_CURRENCY_AMOUNT-CURRENCY   = 'INR'.
    APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
    CLEAR WA_CURRENCY_AMOUNT.
    WA_CURRENCY_AMOUNT-ITEMNO_ACC = '0000000020'.
    WA_CURRENCY_AMOUNT-AMT_DOCCUR = '-500'.
    WA_CURRENCY_AMOUNT-CURRENCY   = 'INR'.
    APPEND WA_CURRENCY_AMOUNT TO CURRENCY_AMOUNT.
    CLEAR WA_CURRENCY_AMOUNT.
                    START-OF-SELECTION
    START-OF-SELECTION.
    CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
      EXPORTING
        documentheader          = HEADER
      CUSTOMERCPD             =
      CONTRACTHEADER          =
    IMPORTING
      OBJ_TYPE                =
      OBJ_KEY                 =
      OBJ_SYS                 =
      tables
       ACCOUNTGL               =   ACCOUNTGL
      ACCOUNTRECEIVABLE       =
      ACCOUNTPAYABLE          =
      ACCOUNTTAX              =
        currencyamount          = CURRENCY_AMOUNT
      CRITERIA                =
      VALUEFIELD              =
      EXTENSION1              =
        return                  = RETURN
      PAYMENTCARD             =
      CONTRACTITEM            =
      EXTENSION2              =
      REALESTATE              =
    IF return-type NA 'EA'.
    call function 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = 'X'.
    IMPORTING
      RETURN        = RETURN.
      write:/ return-message.
    else.
      write:/ return-message.
    ENDIF.
    Reward Points if it is helpful
    Thanks
    Seshu

  • Error while using the Bapi   BAPI_GOODSMVT_CREATE

    Hi all,
    I am using the BAPI     BAPI_GOODSMVT_CREATE to Upload the Data in MB01 and for creating the MATERIAL DOCUMENT  for Multiple Lineitems at a time.
    But i am getting the error as  * NO ITEMS WERE TRANSFERRED*
    I am using two separate intenal tables One for Header records and One for Line item records
    and passing the tables in the BAPI.
    Please Solve my issue and if possible please send me the sample code along with the flatfile or excel sheet.
    Thanks and Regards
    ajay

    Check the below link for a sample code.
    [http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm|http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm]
    Hope this helps.
    Thanks,
    Balaji

  • Creation of Vendor using a BAPI

    I need to create a vendor in SAP system from a non-SAP system. I thought to use a BAPI. But the BAPI available, BAPI_VENDOR_CREATE is not suitable as it is dialog oriented.
    Could anyone suggest me a better method of achieving this.
    Raja

    Refer the following links:
    Create Vendor Master Data
    Searching for a Bapi or Function to create Creditor / Vendor
    Regards,
    Ravi

  • Problem in creating and updating of  material by the use of bapi and bdc

    Hello All,
    I am using bapi (BAPI_MATERIAL_SAVEDATA ) and than bdc to create and update classification data of material.
    I am facing a problem.
    1) firstly I am creating material by the use of bapi and than after creation i want to update classification data for taht perticular material .
    2) To update classification data i am using bdc . while at the time of updating material through bdc system showing me error that material is currently locked by user (my login name ).
    Please suggest what to do.
    Tkank you
    With Regards
    Shantanu Modi

    When u update/create data it takes sometime to commit. So after using BAPI
    give 10 minutes wait in ur program before updating classification data.
    you can write like
    wait up to 20 seconds.
    and update the classification.

  • Uploading subcontracting PO using LSMW-BAPI method

    I am trying to upload the subcontracting Purchase order using LSMW-BAPI .
    Bapi name -Create from Data1
    Business Object  -    BUS2012                             Purchase Order
    Method               -    CREATEFROMDATA1          Create Enjoy Purchase Ord
    Message Type     -    PORDCR1                           Create Purchase Order
    Basic Type          -    PORDCR102                        Create Purchase Order
    In this BAPI - for subcontracting material (component), required quantity & plant values are provided in a input file .
    When I trying to upload this PO, PO gets created but component data not getting uploaded.
    In documentation of BAPI -under restriction section -there is a restriction for subcontracting.
    So can we create Subcontracting PO using this PO.
    any solution on same.
    Because most of the conversion part is done. Only for subcontracting PO this bapi is not working.
    Please anybody know about the solution guide me ASAP.
    Thanks

    Hi Vikram,
    I am also having same scenario , I m using BAPI - BAPI_GOODSMVT_CREATE To create GR  for Subcontracting PO
    Can u please tell me how can solve this problem.
    Normal GR its working but for Subcontracting PO its not working.
    Regards,
    Sanket

  • Using the bapi BAPI_INSPECTIONPLAN_CREATE

    Hi ,
      I am using the bapi BAPI_INSPECTIONPLAN_CREATE to create inspection plans.
      Here I am facing one issue, as a part of this creation in inspection characteristics, I am not able to
      handle all the control indicators.
      In this control indicators under Results confirmation block I dont see fields in the BAPI to handle   
      radiobuttons for 1. Required Char  2. Optional Char 3. After Accep. 4 After Rejection
    If anybody is familiar with this BAPI, please help me.
    Thanks,
    Ravi

    Hi Neha,
       Sorry to say this, It does not answers my question. I am having the program created by someone else. The issue is the program is not able to populate the control indicators as specified in the file. Because the programmer has not populated those values in the BAPI, even the program you had given is not having those fields. Also I am not able to find the correct fields to populate the values into the BAPI. If you know this specific thing please help me out.
    Thanks,
    Ravi.
    Edited by: ravi itekala on Dec 4, 2008 1:51 PM

  • How to delete an operation from order using the bapi

    Can somebody please tell me how to delete an operation from order using the bapi
    BAPI_ALM_ORDER_MAINTAIN.
    Following was the test data for the BAPI.
    000000 OPERATION DELETE 0000040052810070
    000000 SAVE 0000040052810070
    Even I tried entering the operation table. The BAPI control ends fine, but when I check the order using IW32, the operation still exists.
    So, can you please tell me where Iam going wrong.

    Hi Subash Mohanvel,
    Check bapireturn parameter of the bapi BAPI_ALM_ORDER_MAINTAIN after execution of the code , and if there is no error message in the return table then call bapi_Transaction_commit.
    Unless you call this database saving of the records/values will not get reflected in the system.
    Hope that helps.
    Regards
    Kapadia
    ***Assigning points is the way to say thanks in SDN.***

Maybe you are looking for

  • Transfer photos from iPhone 5 to external drive?

    I have a lot of photos on my iPhone 5 and a MacBook Air with not much space left. Is there a way to transfer photos from my phone directly to an external hard drive? Or must I import them first and then transfer? Thanks

  • How to hide overwrite existing file in rteUploadDialog.aspx in sharepoitn 2010

    I want to uncheck and hide the overwriteexisting file in sharepoint 2010 i am opening the addnew item of a list in a popup and in the rich text editor iam inserting a image which opens a pop up .   where to add the CEWP if i right click on the popup

  • Not able to use Internet from Any App Except Chrome

    I updated to Yosemite from AppStore recently. After the installation, I can open all websites from Google Chrome. However, none of my other Apps can connect to the Internet. For instance, Dropbox, Box, App Store and Safari Itself cannot connect to in

  • Parameter in Select of DB Adapter

    Hi We implement some services with the osb 10gR3. For my specific service the target is an ms sql database (2005). Over jdeveloper I am defining the connection to the server and with the wizard a select statement. Now to my problem - how can I define

  • Reconciliation GL Account

    Hi, I'm trying to test a BAPI "BAPI_ACC_BILLING_POST" to post AR documents in SAP (The billing will be done in a Legacy system) I'm running the BAPI with my own test data to see whether it is posting the AR document. It is giving me an error saying: