Urgent-BAPI

Hi all,
Pls provide me the sample code for uploading purchase order details using BAPI.
Thanks in advance.

Hi
See the sample code and do accordingly
REPORT zpo_bapi_purchord_tej.
DATA DECLARATIONS *
TYPE-POOLS slis.
TYPES: BEGIN OF ty_table,
v_legacy(8),
vendor TYPE bapimepoheader-vendor,
purch_org TYPE bapimepoheader-purch_org,
pur_group TYPE bapimepoheader-pur_group,
material TYPE bapimepoitem-material,
quantity(13),
delivery_date TYPE bapimeposchedule-delivery_date,
net_price(23),
plant TYPE bapimepoitem-plant,
END OF ty_table.
TYPES: BEGIN OF ty_alv,
v_legs(8),
success(10),
v_legf(8),
END OF ty_alv.
TYPES: BEGIN OF ty_alv1,
v_legf1(8),
v_msg(500),
END OF ty_alv1.
*-----Work area declarations.
DATA: x_table TYPE ty_table,
x_header TYPE bapimepoheader,
x_headerx TYPE bapimepoheaderx,
x_item TYPE bapimepoitem,
x_itemx TYPE bapimepoitemx,
x_sched TYPE bapimeposchedule,
x_schedx TYPE bapimeposchedulx,
x_commatable(255),
x_alv TYPE ty_alv,
x_alv1 TYPE ty_alv1,
x_alv2 TYPE ty_alv1.
*-----Internal table declarations.
DATA: it_table TYPE TABLE OF ty_table,
it_commatable LIKE TABLE OF x_commatable,
it_item TYPE TABLE OF bapimepoitem,
it_itemx TYPE TABLE OF bapimepoitemx,
it_sched TYPE TABLE OF bapimeposchedule,
it_schedx TYPE TABLE OF bapimeposchedulx,
it_alv TYPE TABLE OF ty_alv,
it_alv1 TYPE TABLE OF ty_alv1,
it_alv2 TYPE TABLE OF ty_alv1.
DATA: po_number TYPE bapimepoheader-po_number,
x_return TYPE bapiret2,
it_return TYPE TABLE OF bapiret2,
v_file TYPE string,
v_temp(8),
v_succsount TYPE i VALUE 0,
v_failcount TYPE i VALUE 0,
v_total TYPE i.
DATA: v_temp1(5) TYPE n VALUE 0.
DATA: x_event TYPE slis_t_event,
x_fieldcat TYPE slis_t_fieldcat_alv,
x_list_header TYPE slis_t_listheader,
x_event1 LIKE LINE OF x_event,
x_layout1 TYPE slis_layout_alv,
x_variant1 TYPE disvariant,
x_repid2 LIKE sy-repid.
DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
SELECTION-SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
*-----To fetch the flat file.
PARAMETERS: p_file TYPE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK v_b1.
AT SELECTION-SCREEN *
AT SELECTION-SCREEN.
IF p_file IS INITIAL.
MESSAGE text-001 TYPE 'E'.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
*-----To use F4 help to find file path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_file.
v_file = p_file.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM gui_upload.
LOOP AT it_table INTO x_table.
PERFORM header_details.
v_temp = x_table-v_legacy.
LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
PERFORM lineitem.
PERFORM schedule.
ENDLOOP.
DELETE it_table WHERE v_legacy = v_temp.
PERFORM bapicall.
MOVE po_number TO x_alv-success.
APPEND x_alv TO it_alv.
CLEAR x_alv.
*-----To clear the item details in internal table after the operation for a header.
REFRESH: it_item,
it_itemx,
it_sched,
it_schedx.
CLEAR: v_temp1.
ENDLOOP.
v_total = v_succsount + v_failcount.
PERFORM display_alv.
FORM GUI_UPLOAD *
FORM gui_upload .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
filetype = 'ASC'
TABLES
data_tab = it_commatable
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc = 0.
*-----To fetch the comma seperated flat file into an internal table.
LOOP AT it_commatable INTO x_commatable.
IF x_commatable IS NOT INITIAL.
SPLIT x_commatable AT ',' INTO
x_table-v_legacy
x_table-vendor
x_table-purch_org
x_table-pur_group
x_table-material
x_table-quantity
x_table-delivery_date
x_table-net_price
x_table-plant.
APPEND x_table TO it_table.
ENDIF.
CLEAR x_table.
ENDLOOP.
ENDIF.
ENDFORM. " gui_upload
FORM HEADER_DETAILS *
FORM header_details .
MOVE 'NB' TO x_header-doc_type.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-vendor
IMPORTING
output = x_table-vendor
MOVE x_table-vendor TO x_header-vendor.
MOVE x_table-purch_org TO x_header-purch_org.
MOVE x_table-pur_group TO x_header-pur_group.
x_headerx-doc_type = 'X'.
x_headerx-vendor = 'X'.
x_headerx-purch_org = 'X'.
x_headerx-pur_group = 'X'.
ENDFORM. " header_details
FORM LINEITEM *
FORM lineitem .
v_temp1 = v_temp1 + 10.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_temp1
IMPORTING
output = v_temp1.
MOVE v_temp1 TO x_item-po_item.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = x_table-material
IMPORTING
output = x_table-material.
MOVE x_table-material TO x_item-material.
MOVE x_table-quantity TO x_item-quantity.
MOVE x_table-net_price TO x_item-net_price.
MOVE x_table-plant TO x_item-plant.
x_itemx-po_item = v_temp1.
x_itemx-material = 'X'.
x_itemx-quantity = 'X'.
x_itemx-net_price = 'X'.
x_itemx-plant = 'X'.
APPEND x_item TO it_item.
APPEND x_itemx TO it_itemx.
CLEAR: x_item, x_itemx.
ENDFORM. " lineitem1
FORM SCHEDULE *
FORM schedule .
MOVE x_table-delivery_date TO x_sched-delivery_date.
MOVE v_temp1 TO x_sched-po_item.
x_schedx-delivery_date = 'X'.
x_schedx-po_item = v_temp1.
APPEND x_sched TO it_sched.
APPEND x_schedx TO it_schedx.
CLEAR: x_sched, x_schedx.
ENDFORM. " schedule
FORM BAPICALL *
FORM bapicall .
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = x_header
poheaderx = x_headerx
IMPORTING
exppurchaseorder = po_number
TABLES
return = it_return
poitem = it_item
poitemx = it_itemx
poschedule = it_sched
poschedulex = it_schedx.
IF po_number IS NOT INITIAL.
v_succsount = v_succsount + 1.
MOVE x_table-v_legacy TO x_alv-v_legs.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ELSE.
v_failcount = v_failcount + 1.
MOVE x_table-v_legacy TO x_alv-v_legf.
MOVE x_table-v_legacy TO x_alv1-v_legf1.
LOOP AT it_return INTO x_return.
IF x_alv1-v_msg IS INITIAL.
MOVE x_return-message TO x_alv1-v_msg.
ELSE.
CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
ENDIF.
ENDLOOP.
APPEND x_alv1 TO it_alv1.
CLEAR x_alv1.
ENDIF.
ENDFORM. " bapicall
FORM DISPLAY_ALV *
FORM display_alv .
PERFORM x_list_header.
PERFORM build_fieldcat CHANGING x_fieldcat.
x_repid2 = sy-repid.
x_event1-name = 'TOP_OF_PAGE'.
x_event1-form = 'TOP_OF_PAGE'.
APPEND x_event1 TO x_event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = x_fieldcat
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_save = 'A'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv
EXCEPTIONS
program_error = 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.
ENDFORM. " display_master_data
FORM USER_COMMAND *
FORM user_command USING ucomm LIKE sy-ucomm selfield
TYPE slis_selfield.
READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
CLEAR : x_alv2,it_alv2[].
LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
x_alv2 = x_alv1.
APPEND x_alv2 TO it_alv2 .
ENDLOOP.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : x3_fieldcat,it_fieldcat[].
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_LEGF1'.
x3_fieldcat-reptext_ddic = text-111.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
CLEAR x3_fieldcat.
x3_fieldcat-col_pos = '1'.
x3_fieldcat-fieldname = 'V_MSG'.
x3_fieldcat-reptext_ddic = text-112.
x3_fieldcat-ref_tabname = 'IT_ALV2'.
APPEND x3_fieldcat TO it_fieldcat.
CLEAR x3_fieldcat.
x_layout1-colwidth_optimize = 'X'.
x_layout1-zebra = 'X'.
IF it_alv2[] IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = x_repid2
is_layout = x_layout1
it_fieldcat = it_fieldcat
i_save = 'A'
i_callback_top_of_page = 'TOP'
is_variant = x_variant1
it_events = x_event
TABLES
t_outtab = it_alv2
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
ENDFORM.
FORM USER_COMMAND *
FORM top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = 'Commentry'.
ENDFORM.
FORM BUILD_FIELDCAT *
FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
DATA: x1_fieldcat TYPE slis_fieldcat_alv.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '1'.
x1_fieldcat-fieldname = 'V_LEGS'.
x1_fieldcat-reptext_ddic = text-108.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '2'.
x1_fieldcat-fieldname = 'SUCCESS'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-109.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
x1_fieldcat-col_pos = '3'.
x1_fieldcat-fieldname = 'V_LEGF'.
x1_fieldcat-key = 'X'.
x1_fieldcat-reptext_ddic = text-110.
x1_fieldcat-ref_tabname = 'IT_ALV'.
APPEND x1_fieldcat TO et_fieldcat.
CLEAR x1_fieldcat.
ENDFORM. " build_fieldcat
FORM BUILD_LIST_HEADER *
FORM x_list_header.
DATA: x_list_header1 TYPE slis_listheader.
*-----List Header: type H
CLEAR x_list_header1 .
x_list_header1-typ = 'H'.
x_list_header1-info = text-105.
APPEND x_list_header1 TO x_list_header.
*-----List Key: type S
x_list_header1-typ = 'S'.
x_list_header1-key = text-106.
x_list_header1-info = v_total.
APPEND x_list_header1 TO x_list_header.
*-----List Key: Type S
CLEAR x_list_header1 .
x_list_header1-typ = 'S'.
x_list_header1-key = text-107.
x_list_header1-info = v_succsount.
APPEND x_list_header1 TO x_list_header.
ENDFORM. " build_list_header
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = x_list_header.
ENDFORM. " TOP_OF_PAGE
Regards
Kiran

Similar Messages

  • Very Urgent : 'BAPI for CK74n in ECC 6.0 for crating the cost estimates'

    Hi guys,
    i am working in the upgradation project from 4.5b to ecc 6.0
    in 4.5b we have the tcode ck71 for cost estimates
    the respective tcode in ecc 6.0 is CK74N
    I want BAPI for tcode CK74N to upload the data
    can you please help me to find out the respective BAPI
    Thanks
    Ramesh

    Hi guys,
    i am working in the upgradation project from 4.5b to ecc 6.0
    in 4.5b we have the tcode ck71 for cost estimates
    the respective tcode in ecc 6.0 is CK74N
    I want BAPI for tcode CK74N to upload the data
    can you please help me to find out the respective BAPI
    Thanks
    Ramesh

  • !!urgent - BAPI ..... pls help!!

    Hi,
    I really need help to be able to save materials made up of several parts with BAPI.
    Let me show you the idea by using the example of car (finished product):
    Car is built from a lot of components, for instance:
    - 1 engine
    - 4 tires
    - 2 front lights
    etc.
    My task is to implement a method responsible for creating a finished product and all necessary semi-finished products which are connected with ready prod and save them in SAP. Furthermore I've got to create a bill of materials.
    Has somebody faced similar problem? How have you solved it? How?
    Below I show what I've found out:
    I've got to create material master record for trading goods(type: HAWA in Headdata) and create Semifinished products (type: HALB) by using BAPI_MATERIAL_SAVEDATA (hopefully I'm right, otherwise pls correct me), but I still don't know how to connect them with each other and then use to create BOM.
    According to my best knowledge there is no BAPI to create BOM...i tried to find without any result.
    Looking forward your answers.
    BR,
    Rafal

    Hi
    This is the documentation for Function module - CSAP_MAT_BOM_CREATE  
    Functionality
    You can use this function module to create simple material BOMs.
    You cannot add alternatives or variants to a BOM, as in transaction CS01.
    Current restrictions:
    You cannot create long texts.
    You cannot create sub-items.
    You cannot classify BOM items for batches.
    You can only save your BOM if no errors occur, because it is not yet possible to change a BOM. Both header data and all item data must be correct.
    Please note:
    Fields where no entry can be made because they were not selected are initialized. The log does not contain information on initialized fields.
    The BOM default values defined in the control data and any user-specific defaults are handled in the same way as in the online transaction.
    Default values that are dependent on BOM usage (for example, indicators for relevancy to production, costing, and so on) are not processed.
    If you create items with object dependencies, the dependency must have basic data, a description, and source code entered.
    The fields OBJECT_ID and IDENTIFIER identify the object to which a dependency belongs.
    (OBJECT_ID = '2'  => BOM item)
    Dependencies are identified by internal or external names. When you create a dependency, you must enter an external name, because an internal name is not assigned until you save.
    Recursiveness in class items is recognized, but no information is available on which objects in the class caused the recursiveness. You cannot define recursiveness as allowed for these objects.
    Example
    *---- Feldleiste Stücklistenkopfdaten
    data: begin of tstko.
              include structure stko_api01.
    data: end of tstko.
    *---- Tabelle Stücklistenpositionen
    data: begin of tstpo occurs 0.
              include structure stpo_api01.
    data: end of tstpo.
    *---- Tabellen für Beziehungswissen:
        Basisdaten
    data: begin of tdep_data occurs 0.
             include structure csdep_dat.
    data: end of tdep_data.
        Beschreibung
    data: begin of tdep_descr occurs 0.
             include structure csdep_desc.
    data: end of tdep_descr.
        Source
    data: begin of tdep_source occurs 0.
             include structure csdep_sorc.
    data: end of tdep_source.
        Reihenfolge
    data: begin of tdep_order occurs 0.
             include structure csdep_ord.
    data: end of tdep_order.
        Dokumentation
    data: begin of tdep_doc occurs 0.
             include structure csdep_doc.
    data: end of tdep_doc.
    data: flg_warning like capiflag-flwarning.
    *- Datenbankprotokoll eröffnen
       call function 'CALO_INIT_API'
            exceptions
                 log_object_not_found     = 1
                 log_sub_object_not_found = 2
                                                                       other_error              = 3
                                                                       others                   = 4.
    *- Kopfdaten füllen
       tstko-base_quan = '1.000'.
       tstko-bom_text = 'Stücklistentext'.
    *- Positionsdaten füllen
    1. Position (Lagerteil)
       clear tstpo.
       tstpo-item_no    = '0010'.
                                                                                    tstpo-item_categ = 'L'.                                                                                "Mußeingabe
                                                                                    tstpo-component  =                                                                                'MAT200'.                                                                                "Mußeingabe
                                                                                    tstpo-comp_qty                                                                                = '1.000'.                                "Mußeingabe
       tstpo-comp_unit  = 'ST'.
       append tstpo.
    2. Position (Rohmaßposition)
       2 Stück a 4 m X 3 m => 2 St a 12 m2
       clear tstpo.
       tstpo-item_no    = '0020'.
                                                                                    tstpo-item_categ = 'R'.                                                                                "Mußeingabe
                                                                                    tstpo-component  =                                                                                'MAT300'.                                                                                "Mußeingabe
                                                                                    tstpo-comp_qty                                                                                = '2.000'.                                "Mußeingabe
                                                                                    tstpo-vsi_size1  =                                                                                '4.000'.                                  "Mußeingabe
       tstpo-vsi_size2  = '3.000'.
       tstpo-vsi_szunit = 'M'.
       tstpo-comp_unit  = 'M2'.
       append tstpo.
    3. Position (Textposition)
       clear tstpo.
       tstpo-item_no    = '0030'.
                                                                                    tstpo-item_categ = 'T'.                                                                                "Mußeingabe
       tstpo-item_text1 = 'Positionstext'.           "Mußeingabe
       append tstpo.
    4. Position (Dokumentposition)
       clear tstpo.
       tstpo-item_no    = '0040'.
                                                                                    tstpo-item_categ = 'D'.                                                                                "Mußeingabe
                                                                                    tstpo-document   = 'DOK1'.                                                                                "Mußeingabe
                                                                                    tstpo-doc_type   =                                                                                'DRW'.                          "Mußeingabe
       tstpo-comp_qty   = '1.000'.
       tstpo-comp_unit  = 'ST'.
    5. Position (Klassenposition)
       clear tstpo.
       tstpo-item_no    = '0050'.
                                                                                    tstpo-item_categ = 'K'.                                                                                "Mußeingabe
       tstpo-res_itm_ct = 'L'.
                                                                                    tstpo-class      = 'CLS1'.                                                                                "Mußeingabe
                                                                                    tstpo-class_type =                                                                                '200'.                          "Mußeingabe
                                                                                    tstpo-comp_qty                                                                                = '1.000'.                                "Mußeingabe
       tstpo-comp_unit  = 'ST'.
    6. Position (Lagerteil) mit Beziehungswissen
       clear tstpo.
       tstpo-item_no    = '0060'.
                                                                                    tstpo-item_categ = 'L'.                                                                                "Mußeingabe
                                                                                    tstpo-component  =                                                                                'MAT200'.                                                                                "Mußeingabe
                                                                                    tstpo-comp_qty                                                                                = '1.000'.                                "Mußeingabe
       tstpo-comp_unit  = 'ST'.
       tstpo-identifier = 'P1'.      "Mußeingabe beim Anlegen von BezWissen
       append tstpo.
    Beziehungswissen zu Position 0060
       clear tdep_data.
       tdep_data-object_id  =  '2'.
       tdep_data-identifier = 'P1'.
       tdep_data-dep_extern = 'B1'.
       tdep_data-dep_type   = '5'.
       tdep_data-status     = '1'.
       append tdep_data.
       clear tdep_source.
       tdep_source-object_id  = '2'.
       tdep_source-identifier = 'P1'.
       tdep_source-dep_extern = 'B1'.
       tdep_source-line_no    = '1'.
       tdep_source-line       = 'Farbe = ''rot'''.
       append tdep_source.
       clear tdep_descr.
       tdep_descr-object_id  = '2'.
       tdep_descr-identifier = 'P1'.
       tdep_descr-dep_extern = 'B1'.
       tdep_descr-language   = 'D'.
       tdep_descr-descript   = 'Beziehung B1 zu Position P1'.
       append tdep_descr.
    7. Position (Lagerteil) mit Beziehungswissen
       clear tstpo.
       tstpo-item_no    = '0070'.
                                                                                    tstpo-item_categ = 'L'.                                                                                "Mußeingabe
                                                                                    tstpo-component  =                                                                                'MAT400'.                                                                                "Mußeingabe
                                                                                    tstpo-comp_qty                                                                                = '1.000'.                                "Mußeingabe
       tstpo-comp_unit  = 'ST'.
       tstpo-identifier = 'P2'.      "Mußeingabe beim Anlegen von BezWissen
       append tstpo.
    Beziehungswissen zu Position 0070
       clear tdep_data.
       tdep_data-object_id  =  '2'.
       tdep_data-identifier = 'P2'.
       tdep_data-dep_extern = 'B2'.
       tdep_data-dep_type   = '5'.
       tdep_data-status     = '1'.
       append tdep_data.
       clear tdep_source.
       tdep_source-object_id  = '2'.
       tdep_source-identifier = 'P2'.
       tdep_source-dep_extern = 'B2'.
       tdep_source-line_no    = '1'.
       tdep_source-line       = 'Farbe = ''rot'''.
       append tdep_source.
       clear tdep_descr.
       tdep_descr-object_id  = '2'.
       tdep_descr-identifier = 'P2'.
       tdep_descr-dep_extern = 'B2'.
       tdep_descr-language   = 'D'.
       tdep_descr-descript   = 'Beziehung B1 zu Position P1'.
       append tdep_descr.
    *- Materialstückliste anlegen
       call function 'CSAP_MAT_BOM_CREATE'
            exporting
                 material   = 'MAT100'
                                                                       plant      = '0001'
                 bom_usage  = '1'
                 valid_from = '01.01.1995'
                 i_stko  = tstko
            importing
                 fl_warning = flg_warning
            tables
                                                                       t_stpo       = tstpo
                 t_dep_data   = tdep_data
                 t_dep_descr  = tdep_descr
                 t_dep_source = tdep_source
                 t_dep_order  = tdep_order
                 t_dep_doc    = tdep_doc
            exceptions
                 error   = 1.
       if sy-subrc eq 1.
    *---- Fehler aufgetreten (Stückliste kann nicht angelegt werden)
        Bitte Protokoll auswerten
       endif.
       if flg_warning eq 'X'.
    *---- Bitte Protokoll auswerten. Dieses enthält Informationen, War-
        nungen und Erfolgsmeldungen
       Endif.
    Parameters
    MATERIAL
    PLANT
    BOM_USAGE
    VALID_FROM
    CHANGE_NO
    REVISION_LEVEL
    I_STKO
    FL_NO_CHANGE_DOC
    FL_COMMIT_AND_WAIT
    FL_CAD
    FL_DEFAULT_VALUES
    FL_WARNING
    BOM_NO
    T_STPO
    T_DEP_DATA
    T_DEP_DESCR
    T_DEP_ORDER
    T_DEP_SOURCE
    T_DEP_DOC
    T_LTX_LINE
    T_STPU
    Exceptions
    ERROR
    Function Group
    CSAP
    Regards
    - Atul

  • Very urgent / BAPI GENERATION

    ZBAPI_Display_Order_Status
    how to do this object.
    Developed a user defined BAPI function modules to display the order status (ZBAPI_Display_Order_Status).

    hi,
    go through this path..
    get order status
    <a href="http://www.erpgenie.com/abap/bapi/example.htm#step1">http://www.erpgenie.com/abap/bapi/example.htm#step1</a>
    rewards if useful
    regards,
    nazeer

  • Urgent- BAPI Code

    Hi all,
    i am using BAPI_FIXEDASSET_CREATE1 to upload asset data. in this function module there is a mandatory parameter that is key regarding this i am getting a dump error. saying that <b>Type is correct but incorrect for key length</b>. here is my declaration .
    data: begin of wa_companycode occurs 0.
          include structure BAPI1022_KEY.
    data  End of WA_Companycode.
    WA_COMPANYCODE-COMPANYCODE = WA_SOURCE-BUKRS.
    CALL FUNCTION 'BAPI_FIXEDASSET_CREATE1'
      EXPORTING
        key                               = WA_COMPANYCODE-COMPANYCODE
       GENERALDATA              = WA_GENERALDATA
    *   GENERALDATAX             =
        POSTINGINFORMATION         = WA_POSTINGINFORMATION
    *   POSTINGINFORMATIONX        =
       TIMEDEPENDENTDATA          = WA_TIMEDEPENDENTDATA
    *   TIMEDEPENDENTDATAX         =
       ALLOCATIONS                = WA_ALLOCATIONS
    *  ALLOCATIONSX               =
    IMPORTING
      ASSETCREATED               = wa_Assetcreated
       RETURN                     = wa_return
    ** TABLES
    **   DEPRECIATIONAREAS          =
    **   DEPRECIATIONAREASX         =
    **   INVESTMENT_SUPPORT         =
    **   EXTENSIONIN                =

    Make the highlighted change:
    WA_COMPANYCODE-COMPANYCODE = WA_SOURCE-BUKRS.
    CALL FUNCTION 'BAPI_FIXEDASSET_CREATE1'
      EXPORTING
    <b>    key                               = WA_COMPANYCODE</b>
       GENERALDATA              = WA_GENERALDATA
      GENERALDATAX             =
        POSTINGINFORMATION         = WA_POSTINGINFORMATION
      POSTINGINFORMATIONX        =
       TIMEDEPENDENTDATA          = WA_TIMEDEPENDENTDATA
      TIMEDEPENDENTDATAX         =
       ALLOCATIONS                = WA_ALLOCATIONS
    ALLOCATIONSX               =
    IMPORTING
      ASSETCREATED               = wa_Assetcreated
       RETURN                     = wa_return
    TABLES
      DEPRECIATIONAREAS          =
      DEPRECIATIONAREASX         =
      INVESTMENT_SUPPORT         =
      EXTENSIONIN                =
    REgards,
    Ravi

  • Error while creating BOM using BAPI (urgent)

    Hi all,
    Thanks for ur help. i am getting some error while creting a BOM using that BAPI
    BAPI_MATERIAL_BOM_GROUP_CREATE.
    errors are
    1) Error/warning when checking the structure of the BOM group with ID =
    2)Alternative does not exist for material assignment to material BAPIBOMFG1
    is it mandatory to pass the bom group id to this bapi?
    In bomgroup structure , i am not passing anything to BOM_GROUP field.
    is it mandatory to pass this data? i am giving my coding below.plz suggest , where i am making mistake. it is urgent.
    regards
    pabitra
    report z_bom_create
    line-size 132
    line-count 65
    no standard page heading.
    *-- DATA DECLARATION--
    include <icon> .
    *---Tables
    tables : s076, t100, marc .
    *---Types
    types : begin of t_upload, " Upload file data
    col1(18),
    col2(10),
    col3(30),
    col4(12),
    col5(50),
    end of t_upload,
    begin of t_split,
    location like stpu-ebort,
    end of t_split.
    data:begin of i_return occurs 10.
    include structure bapiret2.
    data:end of i_return.
    types:begin of t_item."occurs 10.
    include structure BAPI1080_ITM_C.
    types:end of t_item.
    types:begin of t_subitem." occurs 10.
    include structure BAPI1080_SUI_C.
    types:end of t_subitem.
    types:begin of t_header." occurs 10.
    include structure BAPI1080_MBM_C.
    types:end of t_header.
    types:begin of t_bomgroup." occurs 10.
    include structure BAPI1080_BGR_C.
    types:end of t_bomgroup.
    types:begin of t_variant." occurs 10.
    include structure BAPI1080_BOM_C.
    types:end of t_variant.
    *--- Tables
    data: i_upload type standard table of t_upload, " to hold data
    i_upload1 type standard table of t_upload,
    i_split type standard table of t_split,
    i_item type standard table of t_item,
    i_subitem type standard table of t_subitem,
    i_header type standard table of t_header,
    i_bomgroup type standard table of t_bomgroup,
    i_variant type standard table of t_variant.
    data: wa_upload type t_upload, " to hold file data,
    wa_upload1 type t_upload, " to hold plan data,
    wa_split type t_split,
    wa_item type t_item,
    wa_subitem type t_subitem,
    wa_header type t_header,
    wa_bomgroup type t_bomgroup,
    wa_variant type t_variant.
    data:v_matnr like mara-matnr,
    v_start like sy-index,
    v_count(3) type c.
    *--Constants
    data: c_dot type c value '.',
    c_x type c value 'X',
    c_comma type c value ','.
    -------Selection Screen Design -
    *Selection screen for input of upload file address
    selection-screen skip 2.
    selection-screen begin of block blk1 with frame.
    parameters : p_file like rlgrap-filename obligatory .
    parameters : p_matnr like mara-matnr obligatory,
    p_werks like marc-werks obligatory memory id wrk,
    p_stlan like afko-stlan obligatory default '1' .
    selection-screen end of block blk1.
    ---AT SELECTION SCREEN -
    at selection-screen on value-request for p_file.
    *--For popup to select file.
    perform f_give_help.
    at selection-screen on p_matnr.
    perform f_check_matnr.
    -----START OF SELECTION -
    *--Data upload using WS_Upload.
    perform f_get_data.
    perform f_get_bom_data.
    perform f_get_bom_data1.
    perform f_call_bapi.
    *& Form f_give_help
    text
    --> p1 text
    <-- p2 text
    FORM f_give_help.
    call function 'WS_FILENAME_GET'
    exporting
    mask = ',.,..'
    mode = 'O'
    importing
    filename = p_file
    exceptions
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    others = 5.
    if sy-subrc <> 0 and not sy-msgty is initial.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    ENDFORM. " f_give_help
    *& Form f_check_matnr
    text
    --> p1 text
    <-- p2 text
    FORM f_check_matnr.
    CALL FUNCTION 'BAPI_MAT_BOM_EXISTENCE_CHECK'
    EXPORTING
    MATERIAL = p_matnr
    PLANT = p_werks
    BOMUSAGE = '1'
    VALID_FROM_DATE =
    VALID_TO_DATE =
    TABLES
    RETURN = i_return.
    ENDFORM. " f_check_matnr
    *& Form f_get_data
    text
    --> p1 text
    <-- p2 text
    FORM f_get_data.
    call function 'WS_UPLOAD'
    exporting
    CODEPAGE = ' '
    filename = p_file
    filetype = 'DAT'
    tables
    data_tab = i_upload
    exceptions
    conversion_error = 1
    file_open_error = 2
    file_read_error = 3
    invalid_type = 4
    no_batch = 5
    unknown_error = 6
    invalid_table_width = 7
    gui_refuse_filetransfer = 8
    customer_error = 9
    others = 10
    if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    ENDFORM. " f_get_data
    *& Form f_get_bom_data
    text
    --> p1 text
    <-- p2 text
    FORM f_get_bom_data.
    delete i_upload where col1 is initial.
    delete i_upload where col1 cs 'ITEM'.
    read table i_upload into wa_upload with key col1 = 'FINISHED GOOD:'.
    if sy-subrc = 0.
    v_matnr = wa_upload-col2.
    if v_matnr <> p_matnr.
    message e001(zl) with p_matnr.
    endif.
    else.
    message e000(zl).
    endif.
    ENDFORM. " f_get_bom_data
    *& Form f_get_bom_data1
    text
    --> p1 text
    <-- p2 text
    FORM f_get_bom_data1.
    loop at i_upload into wa_upload where col1 CS 'FINISHED GOOD'.
    v_start = sy-tabix + 1.
    loop at i_upload into wa_upload1 from v_start .
    if wa_upload1-col1 cs 'FINISHED GOOD'.
    exit.
    else.
    perform f_split_upload_data.
    endif.
    endloop.
    endloop.
    ENDFORM. " f_get_bom_data1
    *& Form f_split_upload_data
    text
    --> p1 text
    <-- p2 text
    FORM f_split_upload_data.
    if not wa_upload1-col5 is initial.
    if wa_upload1-col5 cs c_comma.
    split wa_upload1-col5 at c_comma into table i_split.
    loop at i_split into wa_split.
    v_count = v_count + 1.
    endloop.
    if wa_upload1-col4 <> v_count.
    wa_upload1-col4 = v_count.
    endif.
    clear wa_upload1-col5.
    clear wa_split.
    loop at i_split into wa_split.
    wa_upload1-col5 = wa_split-location.
    append wa_upload1 to i_upload1.
    endloop.
    else.
    append wa_upload1 to i_upload1.
    endif.
    else.
    append wa_upload1 to i_upload1.
    endif.
    ENDFORM. " f_split_upload_data
    *& Form f_call_bapi
    text
    --> p1 text
    <-- p2 text
    FORM f_call_bapi.
    clear wa_upload1.
    wa_header-material = p_matnr.
    wa_header-plant = p_werks.
    wa_header-bom_usage = p_stlan.
    append wa_header to i_header.
    wa_bomgroup-bom_usage = p_stlan.
    wa_bomgroup-created_in_plant = p_werks.
    append wa_bomgroup to i_bomgroup.
    wa_variant-alternative_bom = 1.
    wa_variant-base_qty = 1.
    wa_variant-valid_from_date = sy-datum.
    append wa_variant to i_variant.
    loop at i_upload1 into wa_upload1.
    wa_item-item_no = wa_upload1-col1.
    wa_item-item_cat = wa_upload1-col2.
    wa_item-component = wa_upload1-col3.
    wa_item-comp_qty = wa_upload1-col4.
    append wa_item to i_item.
    wa_subitem-subitem_qty = '1'.
    wa_subitem-installation_point = wa_upload1-col5.
    append wa_subitem to i_subitem.
    endloop.
    CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
    EXPORTING
    TESTRUN = ' '
    ALL_ERROR = ' '
    TABLES
    BOMGROUP = i_bomgroup
    VARIANTS = i_variant
    ITEMS = i_item
    SUBITEMS = i_subitem
    MATERIALRELATIONS = i_header
    ITEMASSIGNMENTS =
    SUBITEMASSIGNMENTS =
    TEXTS =
    RETURN = i_return.
    if i_return[] is initial.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *write: /'BOM created:', stpo-stlnr.
    else.
    *if not i_return[] is initial.
    loop at i_return.
    IF i_return-TYPE = 'E'.
    errmsg-type = i_return-type.
    errmsg-line = i_return-message.
    append errmsg.
    ULINE /1(108).
    write:/ icon_led_RED as icon, i_return-MESSAGE.
    ULINE /1(108).
    ENDIF.
    IF i_return-TYPE = 'W'.
    errmsg-type = i_return-type.
    errmsg-line = i_return-message.
    append errmsg.
    ULINE /1(108).
    write:/ icon_led_YELLOW as icon, i_return-MESSAGE.
    ULINE /1(108).
    ENDIF.
    ENDLOOP.
    *write: / i_return-id, i_return-number, i_return-message(80).
    *endloop.
    *write: /'Error'.
    endif.
    ENDFORM. " f_call_bapi

    Hi shashi,
    Thanks for ur help.i tried after passing the group but it is giving same error.
    i am getting the error
    "Error/warning when checking the structure of the BOM group with ID= test"
    i am gettig the above error when i put bomgroup-bom_group_identification = 'TEST'.
    whatever i am putting in this field, the same error is comming having different value.
    if i put--- bomgroup-bom_group_identification = ' '. then i will get error
    "Error/warning when checking the structure of the BOM group with ID=
    if i omit that field, then also , i am getting same error.
    plz suggest what r the fields i need to pass for BOMGROUP structure for that bapi?
    regards
    pabitra

  • Very Urgent: Deleting Batch from STO and Goos Issue reversal  Using BAPI

    Hi,
    I want to delete outbound delivery for particular shipment number and this should be done using BAPI or a FM not using the tcode VL02N.
    I wld be very grateful
    Please List out the BAPI 's or FM that can be used for to perform these listed , with using Tcodes:
    1) REVERSE BILLING DOCUMENT(VF11)
    2) GOODS ISSUe REVERSAL (VL09N)
    3) REMOVE DELIVERY FROM SHIPMENT (VT02N)
    4) DELETING DELIVERY(VL02N)
    5) REMOVE BATCH FROM STO (ME22N)
    Its very urgent..
    Thank you in advance....

    1) REVERSE BILLING DOCUMENT(VF11)
    BAPI_BILLINGDOC_CANCEL
    2) GOODS ISSUe REVERSAL (VL09N)
    BAPI_GOODSMVT_CANCEL
    3) REMOVE DELIVERY FROM SHIPMENT (VT02N)
    BAPI_SHIPMENT_CHANGE
    4) DELETING DELIVERY(VL02N)
    5) REMOVE BATCH FROM STO (ME22N)
    BAPI_PO_CHANGE

  • Step by step bapi to convert SAP to XML please its urgent

    step by step bapi to convert SAP to XML please its urgent
    full points if with full example and coding in ABAP,
    Thank you,
    Regards,
    Jagrut Shukla

    yes i want to convert Catsdb table into xml format and safely in server, i.e secured  place

  • BAPI, facing problem(urgent)

    Hi all,
    seagate is our customer & motorola is our end customer. so first, motorola gives PO to seagate. here , seagate is the vendor for motorola. seagate receives that PO & adds some data( like seagate sales order no,seagate material no, seagate item no etc.) to that PO. then seagate passes that modified PO to my company through EDI.
    for this said PO , i have already created sales order in BAPI & now need to crete shipment order.
    To create shipment order,i am using BAPI_SHIPMENT_CREATE. seagate wants my company, to put so many datas into shipment order but i am not finding those fields in that BAPI FM.
    1)i am describing those fields below.plz suggest me if there is corresponding fields in that BAPI_SHIPMENT_CREATE function module.
    i)shipment identification no.
    ii)purchase order no of seagate.
    iii)PO date
    iv)PO type
    v)Transportation method/type.
    vi)shipment method of payment.
    vii)payment terms.
    viii) Hierchical ID no.(To identify a perticular data segment in a hierchical structure)
    ix)Hierchical parent ID no.(identification no. of the next hierchical data segment)
    x)for pallet,
    i) seagate pallet no
    ii)Hierchical ID no
    iii)hierchical parent ID no
    xi) for carton,
    i)seagate carton no
    ii) hierchical ID no
    iii) hierchical parent ID no
    ( FOR ITEM IDENTIFICATION)
    i) seagate's customer's (i.e motorola) PO material no.
    ii)seagate's customer's PO item no.
    iii)seagate's sales order item no.
    iv)seagate's material no.
    v)no. of units shipped(qty in the carton)
    vi)no. of units shipped(qty in the pallet)
    vii)unit/ basis for meas code for this qty.
    (FOR SUBLINE ITEM DATAIL)
    i)seagate's barcoded serial no
    ii)product date of manufacturer
    iii)relationship code(relationship between subline item to baseline item)
    OR is there any other BAPI to create shipment.
    plz suggest me .it is very urgent.
    Thanks & Regards

    Did you read the documentation of the BAPI, most of the input parameters are self-explanatory.  Go to SE37 and enter BAPI_SHIPMENT_CREATE, and go to IMPORT thats where you have the header details and in the TABLES you have all the item details.  Just double click on the type they refer to, am sure its easier for you to find out all your parameters.  Also do a test run using F8 before you code as this would help you in identifying the parameters and speed up your process.  If your test case is successful store it as a variant and refer to it when you are coding.
    hith
    Sunil Achyut

  • BAPI FOR BOM - URGENT

    Could anybody please give me the coding for uploading BOM by BAPI ? Please it is very urgent.
                                                             Regards,
                                                             SAURAV  LAHIRY

    Hi Saurav,
    Try the following Code.
    REPORT  ZTEST_BOM_BAPI.
    DATA:
       it_bomgroup LIKE bapi1080_bgr_c OCCURS 0 WITH HEADER LINE,
       it_variants LIKE bapi1080_bom_c OCCURS 0 WITH HEADER LINE,
       it_items LIKE bapi1080_itm_c OCCURS 0 WITH HEADER LINE,
       it_matrel LIKE bapi1080_mbm_c OCCURS 0 WITH HEADER LINE,
       it_itemas LIKE bapi1080_rel_itm_bom_c OCCURS 0 WITH HEADER LINE,
       it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    * Fill the data
    * Material BoM Group Header Data
    CLEAR it_bomgroup.
    it_bomgroup-bom_group_identification = 'BAPI_SMP_COL1'.
    it_bomgroup-object_type = 'BGR'.
    it_bomgroup-object_id = 'SIMPLE1'.
    it_bomgroup-bom_usage = '1'.  " YOU COULD CHANGE THE BOM USAGE TO YOUR
    *nEEDS
    *it_bomgroup-created_in_plant = '0001'.
    it_bomgroup-ltxt_lang = sy-langu.
    it_bomgroup-technical_type = ' '.
    it_bomgroup-bom_text = 'Simple BoM - FM'.
    APPEND it_bomgroup.
    * Header Details of the different variants
    CLEAR it_variants.
    it_variants-bom_group_identification = 'BAPI_SMP_COL1'.
    it_variants-object_type = 'BOM'.
    it_variants-object_id = 'SIMPLE1'.
    it_variants-alternative_bom = '01'.
    it_variants-bom_status = '01'.
    it_variants-base_qty = '1.000'.
    it_variants-valid_from_date = sy-datum.
    it_variants-function = 'NEW'.
    APPEND it_variants.
    * Details of the items of the variants
    CLEAR it_items.
    it_items-bom_group_identification = 'BAPI_SMP_COL1'.
    it_items-object_type = 'ITM'.
    it_items-object_id = 'SIMPLE1'.
    it_items-item_no = '0010'.
    it_items-item_cat = 'L'.
    it_items-component = '000000000000000078'.
    it_items-comp_qty = '1'.
    it_items-valid_from_date = sy-datum.
    APPEND it_items.
    CLEAR it_items.
    it_items-bom_group_identification = 'BAPI_SMP_COL1'.
    it_items-object_type = 'ITM'.
    it_items-object_id = 'SIMPLE1'.
    it_items-item_no = '0020'.
    it_items-item_cat = 'L'.
    it_items-component = '000000000000000076'.
    it_items-comp_qty = '2'.
    it_items-valid_from_date = sy-datum.
    APPEND it_items.
    * Details of the materials of the different variants
    CLEAR it_matrel.
    it_matrel-bom_group_identification = 'BAPI_SMP_COL1'.
    it_matrel-material = '000000000000000077'.
    *it_matrel-plant = '0001'.
    it_matrel-bom_usage = '1'.
    it_matrel-alternative_bom = '01'.
    APPEND it_matrel.
    * Linking items to the corresponding variants
    CLEAR it_itemas.
    it_itemas-bom_group_identification = 'BAPI_SMP_COL1'.
    it_itemas-sub_object_type = 'ITM'.
    it_itemas-sub_object_id = 'SIMPLE1'.
    it_itemas-super_object_type = 'BOM'.
    it_itemas-super_object_id = 'SIMPLE1'.
    it_itemas-valid_from_date = sy-datum.
    it_itemas-function = 'NEW'.
    APPEND it_itemas.
    * Create variants
    CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
    EXPORTING
       all_error         = 'X'
    TABLES
       bomgroup          = it_bomgroup
       variants          = it_variants
       items             = it_items
       materialrelations = it_matrel
       itemassignments   = it_itemas
       return            = it_return.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    LOOP AT it_return.
    WRITE:/ it_return-type, it_return-id, it_return-number,
             it_return-message.
    ENDLOOP.
    Reward if useful.
    Thanks and Regards,
    Maddineni Bharath.

  • Objects_objref_not_assigned  - error ( while executing the bapi) - urgent

    Hi,
    i designed a bapi  which is internally calling a transaction (i.e. TRIP ), and returning the status.
    when i call this in back end(abap) side it is giving the desired results correctly.  but when i call the bapi from the front end side , i am getting the error : objects_objref_not_assigned.
    what could be the reasons.
    for your information : we have provided the correct user name and password to execute this tcode.
    regards
    giri

    hi,
    thx for your response, but in the front end side they are calling the rfc using the JCO connection.
    for  your information other bapi's are all working the way which we call.
    regards
    giri
    since it's very urgent if you give your phone no or email .id , it would be helpful.
    thx

  • Urgent ! Need to know a FM or a BAPI.

    Hello Peers,
    I have an urgent requirement where I need to get the <b>***.ATP Quantity</b>  which you can find in CO06 or CO09 T.Code  & display in the Report.
    I tried with FM : MD_STOCK_REQUIREMENTS_LIST_API  which will return  material stock details like Required stock, Available Stock , ATP quantity etc.
    But infact this is not returning the ATP quantity .
    The inputs I have given are : Material No & Plant.
    We could not find  the Database table which contains this value.
    Can anybody suggest any other similar function module which will return the ATP Quantity.
    Thank You,
    Daniel.

    Check with BAPI - BAPI_MATERIAL_AVAILABILITY
    I think *** ATP Quantity is Req/Received quantity -  the confirmed issue quantity
    You can calculate as above formula
    also do check with below FM's :
    RV_GET_PLANT_LIST
    MD_PEGGING
    Thanks
    Seshu

  • Need  F.M or BAPI to update the table IFLOT---URGENT

    HI ALL,
    i need  F.M or BAPI to update the table IFLOT
    its urgent ........................

    use the function module
    EXIT_SAPLITO0_001/2
    www.jt77.com/plant-maintenance/quality-management-11667.html - 11k -
    reward if useful

  • To create Multilevel BOM---- BAPI (urgent)

    Hi all,
    i am using BAPI_MATERIAL_BOM_GROUP_CREATE to create a <u><b>MULTI LEVEL</b></u> BOM in sap. but i am not getting any field for <b>LEVEL</b> in this BAPI.so,  can i create a multilevel bom without a level ?
    can u plz suggest, how can i use this BAPI to create a <b>multi level</b> bom?
    is there any field relating to assembly indicator (stlkz) in this BAPI?i am not getting this field.plz suggest.
    any idea will be highly appreaciated.
    Regards
    pabitra

    Hi eswar,
    Thanks for ur help. i am getting some error while creting a BOM using that BAPI.
    errors are
    1) Error/warning when checking the structure of the BOM group with ID =
    2)Alternative  does not exist for material assignment to material BAPIBOMFG1
    is it mandatory to pass the bom group id to this bapi?
    In bomgroup structure , i am not passing anything to BOM_GROUP field.
    is it mandatory to pass this data? i am giving my coding below.plz suggest , where i am making mistake. it is urgent.
    regards
    pabitra
    report z_bom_create
           line-size 132
           line-count 65
           no standard page heading.
    *-- DATA DECLARATION--
    include <icon> .
    *---Tables
    tables : s076, t100, marc .
    *---Types
    types : begin of t_upload,      " Upload file data
             col1(18),
             col2(10),
             col3(30),
             col4(12),
             col5(50),
           end of t_upload,
           begin of t_split,
           location like stpu-ebort,
           end of t_split.
    data:begin of i_return occurs 10.
    include structure bapiret2.
    data:end of i_return.
    types:begin of t_item."occurs 10.
    include structure BAPI1080_ITM_C.
    types:end of t_item.
    types:begin of t_subitem." occurs 10.
    include structure  BAPI1080_SUI_C.
    types:end of t_subitem.
    types:begin of t_header." occurs 10.
    include structure  BAPI1080_MBM_C.
    types:end of t_header.
    types:begin of t_bomgroup." occurs 10.
    include structure  BAPI1080_BGR_C.
    types:end of t_bomgroup.
    types:begin of t_variant." occurs 10.
    include structure  BAPI1080_BOM_C.
    types:end of t_variant.
    *--- Tables
    data: i_upload type standard table of t_upload, " to hold data
          i_upload1 type standard table of t_upload,
          i_split type standard table of t_split,
          i_item type standard table of t_item,
          i_subitem type standard table of t_subitem,
          i_header type standard table of t_header,
          i_bomgroup type standard table of t_bomgroup,
          i_variant type standard table of t_variant.
    data: wa_upload  type t_upload, " to hold file data,
          wa_upload1 type t_upload, " to hold plan data,
          wa_split type t_split,
          wa_item type t_item,
          wa_subitem type t_subitem,
          wa_header type t_header,
          wa_bomgroup type t_bomgroup,
          wa_variant type t_variant.
    data:v_matnr like mara-matnr,
         v_start like sy-index,
         v_count(3) type c.
    *--Constants
    data: c_dot type c value '.',
          c_x type c value 'X',
          c_comma type c value ','.
    -------Selection Screen Design -
    *Selection screen for input of upload file address
    selection-screen skip 2.
    selection-screen begin of block blk1 with frame.
    parameters     : p_file like rlgrap-filename obligatory .
    parameters     : p_matnr like mara-matnr obligatory,
                     p_werks like marc-werks obligatory memory id wrk,
                     p_stlan like afko-stlan obligatory default '1' .
    selection-screen end of block blk1.
    ---AT SELECTION SCREEN -
    at selection-screen on  value-request for p_file.
    *--For popup  to select file.
      perform f_give_help.
    at selection-screen on  p_matnr.
      perform f_check_matnr.
    -----START OF SELECTION -
    *--Data upload using WS_Upload.
    perform f_get_data.
    perform f_get_bom_data.
    perform f_get_bom_data1.
    perform f_call_bapi.
    *&      Form  f_give_help
          text
    -->  p1        text
    <--  p2        text
    FORM f_give_help.
    call function 'WS_FILENAME_GET'
           exporting
                mask             = ',.,..'
                mode             = 'O'
           importing
                filename         = p_file
           exceptions
                inv_winsys       = 1
                no_batch         = 2
                selection_cancel = 3
                selection_error  = 4
                others           = 5.
      if sy-subrc <> 0 and  not sy-msgty is initial.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    ENDFORM.                    " f_give_help
    *&      Form  f_check_matnr
          text
    -->  p1        text
    <--  p2        text
    FORM f_check_matnr.
    CALL FUNCTION 'BAPI_MAT_BOM_EXISTENCE_CHECK'
      EXPORTING
        MATERIAL              = p_matnr
        PLANT                 = p_werks
        BOMUSAGE              = '1'
      VALID_FROM_DATE       =
      VALID_TO_DATE         =
      TABLES
        RETURN                = i_return.
    ENDFORM.                    " f_check_matnr
    *&      Form  f_get_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_get_data.
    call function 'WS_UPLOAD'
       exporting
      CODEPAGE                      = ' '
          filename                      = p_file
          filetype                      = 'DAT'
        tables
          data_tab                      = i_upload
       exceptions
         conversion_error              = 1
         file_open_error               = 2
         file_read_error               = 3
         invalid_type                  = 4
         no_batch                      = 5
         unknown_error                 = 6
         invalid_table_width           = 7
         gui_refuse_filetransfer       = 8
         customer_error                = 9
         others                        = 10
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
    ENDFORM.                    " f_get_data
    *&      Form  f_get_bom_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_get_bom_data.
    delete i_upload where col1 is initial.
    delete i_upload where col1 cs 'ITEM'.
    read table i_upload into wa_upload with key col1 = 'FINISHED GOOD:'.
    if sy-subrc = 0.
    v_matnr = wa_upload-col2.
    if v_matnr <> p_matnr.
    message e001(zl) with p_matnr.
    endif.
    else.
    message e000(zl).
    endif.
    ENDFORM.                    " f_get_bom_data
    *&      Form  f_get_bom_data1
          text
    -->  p1        text
    <--  p2        text
    FORM f_get_bom_data1.
    loop at i_upload into wa_upload where col1 CS 'FINISHED GOOD'.
    v_start = sy-tabix + 1.
    loop at i_upload into wa_upload1 from v_start .
            if wa_upload1-col1 cs 'FINISHED GOOD'.
              exit.
            else.
    perform f_split_upload_data.
         endif.
    endloop.
          endloop.
    ENDFORM.                    " f_get_bom_data1
    *&      Form  f_split_upload_data
          text
    -->  p1        text
    <--  p2        text
    FORM f_split_upload_data.
    if not wa_upload1-col5 is initial.
    if wa_upload1-col5 cs c_comma.
    split wa_upload1-col5 at c_comma into table i_split.
    loop at i_split into wa_split.
    v_count = v_count + 1.
    endloop.
    if wa_upload1-col4 <> v_count.
       wa_upload1-col4 = v_count.
    endif.
    clear wa_upload1-col5.
    clear wa_split.
    loop at i_split into wa_split.
    wa_upload1-col5 = wa_split-location.
    append wa_upload1 to i_upload1.
    endloop.
    else.
    append wa_upload1 to i_upload1.
    endif.
    else.
    append wa_upload1 to i_upload1.
    endif.
    ENDFORM.                    " f_split_upload_data
    *&      Form  f_call_bapi
          text
    -->  p1        text
    <--  p2        text
    FORM f_call_bapi.
    clear wa_upload1.
    wa_header-material = p_matnr.
    wa_header-plant = p_werks.
    wa_header-bom_usage = p_stlan.
    append wa_header to i_header.
    wa_bomgroup-bom_usage = p_stlan.
    wa_bomgroup-created_in_plant = p_werks.
    append wa_bomgroup to i_bomgroup.
    wa_variant-alternative_bom = 1.
    wa_variant-base_qty = 1.
    wa_variant-valid_from_date = sy-datum.
    append wa_variant to i_variant.
    loop at i_upload1 into wa_upload1.
    wa_item-item_no = wa_upload1-col1.
    wa_item-item_cat = wa_upload1-col2.
    wa_item-component = wa_upload1-col3.
    wa_item-comp_qty = wa_upload1-col4.
    append wa_item to i_item.
    wa_subitem-subitem_qty = '1'.
    wa_subitem-installation_point = wa_upload1-col5.
    append wa_subitem to i_subitem.
    endloop.
    CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
    EXPORTING
      TESTRUN                  = ' '
      ALL_ERROR                = ' '
      TABLES
        BOMGROUP                 = i_bomgroup
        VARIANTS                 = i_variant
       ITEMS                    = i_item
       SUBITEMS                 = i_subitem
        MATERIALRELATIONS        = i_header
      ITEMASSIGNMENTS          =
      SUBITEMASSIGNMENTS       =
      TEXTS                    =
        RETURN                   = i_return.
    if  i_return[] is initial.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *write: /'BOM created:', stpo-stlnr.
    else.
    *if not i_return[] is initial.
    loop at i_return.
        IF i_return-TYPE = 'E'.
       errmsg-type = i_return-type.
       errmsg-line = i_return-message.
       append errmsg.
          ULINE /1(108).
          write:/ icon_led_RED as icon, i_return-MESSAGE.
          ULINE /1(108).
        ENDIF.
        IF i_return-TYPE = 'W'.
       errmsg-type = i_return-type.
       errmsg-line = i_return-message.
       append errmsg.
          ULINE /1(108).
          write:/ icon_led_YELLOW as icon, i_return-MESSAGE.
          ULINE /1(108).
        ENDIF.
      ENDLOOP.
    *write: / i_return-id, i_return-number, i_return-message(80).
    *endloop.
    *write: /'Error'.
    endif.
    ENDFORM.                    " f_call_bapi

  • Bapi's to create/Edit Service Process - BUS2000116 - Very Urgent

    Hi Experts,
    I want ot know the BAPI's to create service process - Business Object - BUS2000116.
    Its very urgent. Please help me.
    regards,
    arul jothi a.

    Hi Arul,
    BAPI_BUSPROCESSND_CREATEMULTI:Bapi to create Service Contracts programmatically. Pass the inputfields to be created in the contract.
    Note: BAPI_BUSPROCESSND_SAVE must be called after this function call to save the Service Contract.
    Regards,
    Arjun
    Pl.Reward the points

Maybe you are looking for

  • A Designer with a H/Parallax and a bag of goodies

    Hello, hopefully theres a person who knows the location to these - or can answer them??? Started using EA last week, and from a PS and AI background and I love it. But I have an issue with the concept that is taken shape, and now I cannot complete it

  • Reading text from a text file(what else!!!!!)

    okay to save time here i've managed to read the text from the text file and display in the console my question is - is there a way to read the text a character at a time, at present i read it as a string, the reason i need a character is that i have

  • FONT SYMBOLS?!?!?!?!How come...

    Hi All. Why when i am using a font symbol in my library some characters (or ranges) are not embed in font?But... When Im embeding font through textfield on the stage using predefined glyphRange in UnicodeTable.xml it does work (if I define my range,

  • Service PR form Sale order

    Dear Friends, I have the Requirement Service Purchase Requisation should generate from Sale Order is it possible?? then in that service PR/PO i will maintain the Service Entry Sheet. I understand that In sale Order with out Material system will not a

  • Screen Share-No audio

    I just set up my mac mini snow leopard server. I have an external hard drive connected to mac mini with movies on. When I do a screen share on the mac mini with my macbook air I don't receive audio. Suggestions?