Create BOM alternative via BAPI
How can we create a BOM alternative via BAPI?
I now use CSAP_MAT_BOM_MAINTAIN but then I get the following error:
BOM already exists for 1234 W041 9
I do not want to use batch input.
Kind regards,
Lieselot
Hi,
U can use the following BAPI'S
BAPI_MATERIAL_BOM_GROUP_CREAT
BAPI_MAT_BOM_EXISTENCE_CHECK
i hope they solve your purpose!!
thanks
Similar Messages
-
Create Support Message via BAPI with additional partners
Hi all,
i need to create a support message (slfn) via bapi / function module. The basic creation is no problem with BAPI_NOTIFICATION_CREATE.
But i need to set additional partner(functions) like "approved by" in the support message. With this bapi i can only set the processor and creator of the message.
How can i add additional partners via BAPI call?
Any help would be much appreciated.
DanielHi Daniel,
i do not think there is a standard functionality for this.
you can use function module CRM_DNO_UPDATE_PARTNER to set partner functions to a message. You will have to build your own RFC enabled function module around this, though.
Then you can use it to add your partners after the message was created.
Regards,
Christoph -
Document and PS Project - create a link via BAPI?
Hi everybody,
follow problem: I have a document and a project. How can I create a link between both via BAPI?
Means: create a real exsitens document in a project with ...
FB's. What is to do?
Thanks for help.
Regards ThomasHi,
one sol. might be ta <b>OAOH</b> with BUS-object 2001
another <b>OAOR</b>. pls search the corresponding fm's in that transactions
Andreas -
Create PS project via BAPI - using project templates (CJ01)
hi anybody,
if is pos. to create a new project with BAPI* (if yes, which one? and how?) and use a project template (not an existing project).
thanks for help.
regards thomasThanks for welcome.
This BAPI create a new PROJ_DEF, thats clear. But i want to create a new project (with WBS and networks etc.) via BAPI and this with using a existing project template (please look in CJ01), not an existingproject (CJ20N).
You know what I want?
Thomas -
How to create sto po via bapi-BAPI_PO_CREATE1
if create sto po via bapi_po_create1, which fields must be defined? and i want to change sto price.how to define bapi fields? can anyone give me a sample?
hi
check following
BAPI_PO_CREATE1
http://abap.wikiprog.com/wiki/BAPI_PO_CREATE1
hope it helps
regards
kunal
award if helpful -
No Sales BOM explosion via BAPIs
Hi all,
We use BAPI_INQUIRY_CREATEFROMDATA to create inquiries; however this does not explode sales BOM; rather it creates just one line for the main material.
Are there any specific input parameters that need to be modified to trigger BOM explosion in the background.
Alternatively, are there any BAPIs or FMs at least to simulate BOM explosion and return the results so that we can pass them explicitly to the inquiry create BAPI.
Or is there any other way to create sales documents with sales BOM explosion. (we can't change the BAPI as its part of the source code of a 3rd party application; but we have user exits before and after this BAPI call).
Thanks,
KC
SAP SDSolved. Sales BOM does get exploded even in BAPIs. Checked with a different user ID and it worked. The RFC user seemed to have an authorization problem.
-
Problem with creating business partner via BAPI
Hello! I have a simple File-RFC-File scenario:
XML-file with Firstname, Lastname and PartnerCategory. I use BAPI_BUPA_CREATE_FROM_DATA to create a partner with this data.
It works, in target file I have a number of new business partner, but I can't find new partner in the system. Like I only tested BAPI_BUPA_CREATE_FROM_DATA in "bapi" transaction without real effect.Hi,
probably you didn't comit the BAPI
RFC adapter allows to specify comit for BAPI
add this to your RFC channel configuration and you will see the partner
for more info read section:
Commit Control for Single BAPI Calls
from
http://help.sap.com/saphelp_nw04/helpdata/en/c8/e80440a832e369e10000000a155106/content.htm
Regards,
Michal Krawczyk -
Creating Quality Notification via BAPI
I am attempting to create a quality notification using BAPI_QUALNOT_CREATE but am running into an issue. I need the ability to link the inspection lot number to the quality notification but I do not see a field for inspection lot in any of the BAPI segments. When i record results using defect codes in SAP, the quality notification that is created has the inspection lot linked to it (in the reference object tab). As there another field within the BAPI that i can use to pass the inspection lot number??
Thanks in advance...Brock,
Thanks for the response. I have attempted to use the FM you suggested but still am not having much luck. After I feed the required data to the FM, I am prompted with the error message u201CNo quality notification type maintained for inspection lot type.u201D However in SPRO, under Quality Management -> Quality Inspection -> Inspection Lot Creation -> Maintain Inspection Types, the notification type is defined for each of the inspection types I am using. Is there any additional configuration I may be missing? Thanks againu2026
Harm -
Create Contact Person via BAPI / CMD_EI_API (TCode VAP1)
Hi everybody,
I have to develop a function module, which has to be called from an external application (java). This function module should, create contact persons for customers (like Transaction VAP1 does).
I did not find any function module or bapi for this, but I found class CMD_EI_API, which seems to possibly help me. Unfortunately, there is no documentation for this class.
Could anyone help me getting the contact person's addresses into the system? Just hustle me into the right direction and I will walk by myself
Thank you very much
Ralf
Edit: The contact persons addresses have to be maintained for existing customers.
Edited by: Ralf Wenzel on Feb 21, 2012 12:19 PMI have this working. I wrote a wrapper BAPI. If inserting a new contact, you need to get a new partner number otherwise it won't work. There is extra code in this function module that you can remove. I left it as I used the logic for other customer update BAPIs.
FUNCTION Z_CUSTOMER_CONTACT.
*"*"Local Interface:
*" IMPORTING
*" VALUE(CUST) LIKE ZCUSTOMER STRUCTURE ZCUSTOMER
*" VALUE(TESTFLAG) LIKE WDL_FLAG-XFLAG DEFAULT ' '
*" VALUE(FBAPI) TYPE CHAR01 OPTIONAL
*" VALUE(CONTACT) LIKE ZCONTACT STRUCTURE ZCONTACT
*" EXPORTING
*" VALUE(CUSTOMERNO) LIKE BAPIKNA103-CUSTOMER
*" VALUE(RETURN) LIKE BAPIRETURN1 STRUCTURE BAPIRETURN1
*" EXCEPTIONS
*" CLIENT_ERROR
*" KNA1_INCOMPLETE
*" KNB1_INCOMPLETE
*" KNB5_INCOMPLETE
*" KNVV_INCOMPLETE
*" KUNNR_NOT_UNIQUE
*" SALES_AREA_NOT_UNIQUE
*" SALES_AREA_NOT_VALID
*" INSERT_UPDATE_CONFLICT
*" NUMBER_ASSIGNMENT_ERROR
*" NUMBER_NOT_IN_RANGE
*" NUMBER_RANGE_NOT_EXTERN
*" NUMBER_RANGE_NOT_INTERN
*" ACCOUNT_GROUP_NOT_VALID
*" PARNR_INVALID
*" BANK_ADDRESS_INVALID
*" TAX_DATA_NOT_VALID
*" NO_AUTHORITY
*" COMPANY_CODE_NOT_UNIQUE
*" DUNNING_DATA_NOT_VALID
*" KNB1_REFERENCE_INVALID
*" CAM_ERROR
data: wa_header type cmds_ei_header,
wa_central_data type cmds_ei_vmd_central_data,
wa_central_datax type cmds_ei_vmd_central_data_xflag,
wa_address type bapiad1vl,
wa_addressx type bapiad1vlx,
wa_contact_addr type bapiad3vl,
wa_contact_addrx type BAPIAD3VLX,
wa_tax_ind_st type cmds_ei_tax_ind,
wa_tax_ind type cmds_ei_cmd_tax_ind,
wa_bankdetail_st type cvis_ei_cvi_bankdetail,
wa_bankdetail type cvis_ei_bankdetail,
wa_company_code_st type cmds_ei_company,
wa_company_code type cmds_ei_cmd_company,
wa_functions_st type cmds_ei_functions,
wa_functions type cmds_ei_cmd_functions,
wa_tcontact type CVIS_EI_PHONE,
wa_phone_st type CVIS_EI_PHONE_STR,
wa_phone type CVIS_EI_CVI_PHONE,
wa_fcontact type CVIS_EI_FAX,
wa_fax_st type CVIS_EI_FAX_STR,
wa_fax type CVIS_EI_CVI_FAX,
wa_econtact type CVIS_EI_SMTP,
wa_smtp_st type CVIS_EI_SMTP_STR,
wa_smtp type CVIS_EI_CVI_SMTP,
wa_sales_data_st type cmds_ei_sales,
wa_sales_data type cmds_ei_cmd_sales,
wa_customer type cmds_ei_extern,
wa_cust_created type cmds_ei_extern,
is_customers type cmds_ei_main,
es_customers type cmds_ei_main,
wa_correct type cmds_ei_main,
wa_defective type cmds_ei_main,
wa_mes_correct type cvis_message,
wa_mes_error type cvis_message,
it_contacts type cmds_ei_contacts_t,
wa_contacts type CMDS_EI_CONTACTS,
messages type BAPIRET2_T.
FIELD-SYMBOLS: <bapiret2> type BAPIRET2.
DATA: STATUS TYPE CHAR20,
PARNR LIKE KNVK-PARNR.
constants: FILLCHAR VALUE '/',
gc_objtype_customer TYPE mds_ctrl_object VALUE 'CUSTOMER',
gc_insert TYPE c VALUE 'I',
gc_delete TYPE c VALUE 'D',
gc_current_state TYPE c VALUE 'C',
gc_update TYPE c VALUE 'U',
gc_true TYPE c VALUE 'X',
gc_false TYPE c VALUE ' '.
include fbgenmac.
* generate data record
fbgenmac 'Z_CUSTOMER_CONTACT'.
* Clear memory variables - needed if run in Test mode
* Initialization
CALL METHOD cmd_ei_api=>initialize.
wa_customer-header-object_instance-kunnr = cust-kunnr.
wa_customer-header-object_task = gc_update.
append wa_customer to is_customers-customers.
call method CMD_EI_API_EXTRACT=>get_data
EXPORTING
is_master_data = is_customers
IMPORTING
es_master_data = es_customers
es_error = wa_mes_error.
IF wa_mes_error-is_error is initial.
STATUS = 'OK'.
LOOP at es_customers-customers into wa_cust_created.
wa_company_code = wa_cust_created-company_data.
IF STATUS = 'OK' and wa_mes_error-is_error is INITIAL.
* is_customers = es_customers.
free: wa_customer, wa_company_code_st,
wa_company_code, wa_address, wa_sales_data_st,
wa_contacts, wa_contact_addr,
wa_sales_data, wa_tax_ind_st, wa_functions,
wa_functions_st, wa_correct, wa_mes_correct,
wa_defective, wa_mes_error, wa_cust_created,
wa_tcontact, wa_phone_st, wa_phone,
wa_fcontact, wa_fax_st, wa_fax, wa_econtact,
wa_smtp_st, wa_smtp.
FREE: is_customers.
IF CONTACT-FIRSTNAME IS NOT INITIAL.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'AP'
object = 'PARTNER'
QUANTITY = '1'
SUBOBJECT = ' '
* TOYEAR = '0000'
** IGNORE_BUFFER = ' '
IMPORTING
NUMBER = PARNR
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8.
IF SY-SUBRC = 0.
* Add partner type 20
wa_contacts-task = gc_insert.
wa_contacts-data_key-parnr = PARNR.
wa_contacts-data-pafkt = '20'.
wa_contacts-datax-pafkt = 'X'.
* wa_contacts-address_type_1 = ''.
* wa_contacts-address_type_2 = ''.
* wa_contact_addr-fullname = CUST-NAME.
wa_contact_addr-firstname = CONTACT-FIRSTNAME.
wa_contact_addrx-firstname = 'X'.
wa_contact_addr-lastname = CONTACT-LASTNAME.
wa_contact_addrx-lastname = 'X'.
* Assign address data directly
wa_contacts-address_type_3-task = gc_insert.
wa_contacts-address_type_3-postal-data = wa_contact_addr.
wa_contacts-address_type_3-postal-datax = wa_contact_addrx.
* e-mail address
wa_econtact-task = gc_insert.
wa_econtact-data-std_no = 'X'.
wa_econtact-data-e_mail = CONTACT-E_MAIL.
* wa_econtact-datax-std_no = 'X'.
* wa_econtact-datax-e_mail = 'X'.
wa_smtp-current_state = ' '.
wa_smtp_st-contact = wa_econtact.
append wa_smtp_st to wa_smtp-smtp.
wa_contacts-address_type_3-communication-smtp = wa_smtp.
* wa_contacts-contact_texts = ''.
append wa_contacts to it_contacts.
ENDIF.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = 'AP'
object = 'PARTNER'
QUANTITY = '1'
SUBOBJECT = ' '
* TOYEAR = '0000'
** IGNORE_BUFFER = ' '
IMPORTING
NUMBER = PARNR
* QUANTITY =
* RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8.
IF SY-SUBRC = 0.
* Add partner type 30
wa_contacts-data_key-parnr = parnr.
wa_contacts-data-pafkt = '30'.
append wa_contacts to it_contacts.
ENDIF.
* Assign contacts to customer structure
wa_customer-central_data-contact-contacts = it_contacts.
* Set object_task to modify
wa_customer-header-object_instance-kunnr = cust-kunnr.
wa_customer-header-object_task = gc_update.
append wa_customer to is_customers-customers.
IF FBAPI = 'X'.
* MAINTAIN_BAPI seems to now work. Fills in table addr_appl_to_int used in function module
* ADDR_MEMORY_SAVE line 631. It should be blank.
call method cmd_ei_api=>maintain_bapi
EXPORTING
iv_test_run = TESTFLAG
iv_collect_messages = 'X'
is_master_data = is_customers
IMPORTING
es_master_data_correct = wa_correct
es_message_correct = wa_mes_correct
es_master_data_defective = wa_defective
es_message_defective = wa_mes_error.
ELSE.
call method cmd_ei_api=>maintain
EXPORTING
iv_test_run = TESTFLAG
is_master_data = is_customers
IMPORTING
es_error = wa_mes_error.
ENDIF.
IF wa_mes_error-is_error is initial.
if testflag <> 'X'.
commit work and wait.
LOOP at wa_correct-customers into wa_cust_created.
CUSTOMERNO = wa_cust_created-header-object_instance-kunnr.
SY-MSGID = 'F2'.
SY-MSGNO = '056'. " Failure
SY-MSGV1 = ''.
SY-MSGV2 = ''.
SY-MSGV3 = ''.
SY-MSGV4 = ''.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
TYPE = 'E'
CL = SY-MSGID
NUMBER = SY-MSGNO
PAR1 = SY-MSGV1
PAR2 = SY-MSGV2
PAR3 = SY-MSGV3
PAR4 = SY-MSGV4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = RETURN.
ENDLOOP.
CALL FUNCTION 'ADDR_MEMORY_CLEAR'
EXPORTING
force = 'X'
EXCEPTIONS
unsaved_data_exist = 1
internal_error = 2
others = 3.
ELSE.
ROLLBACK WORK.
LOOP at wa_correct-customers into wa_cust_created.
CUSTOMERNO = wa_cust_created-header-object_instance-kunnr.
SY-MSGID = 'F2'.
SY-MSGNO = '035'.
SY-MSGV1 = ''.
SY-MSGV2 = ''.
SY-MSGV3 = ''.
SY-MSGV4 = ''.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
TYPE = 'E'
CL = SY-MSGID
NUMBER = SY-MSGNO
PAR1 = SY-MSGV1
PAR2 = SY-MSGV2
PAR3 = SY-MSGV3
PAR4 = SY-MSGV4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = RETURN.
ENDLOOP.
CALL FUNCTION 'ADDR_MEMORY_CLEAR'
EXPORTING
force = 'X'
EXCEPTIONS
unsaved_data_exist = 1
internal_error = 2
others = 3.
ENDIF.
ELSE.
messages = wa_mes_error-messages.
LOOP at wa_mes_error-messages assigning <bapiret2>.
CUSTOMERNO = CUST-KUNNR.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
TYPE = <bapiret2>-type
CL = <bapiret2>-id
NUMBER = <bapiret2>-number
PAR1 = <bapiret2>-message_v1
PAR2 = <bapiret2>-message_v2
PAR3 = <bapiret2>-message_v3
PAR4 = <bapiret2>-message_v4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = RETURN.
ENDLOOP.
ENDIF.
ELSE.
CUSTOMERNO = CUST-KUNNR.
SY-MSGID = 'F2'.
SY-MSGNO = '152'. " Failure
SY-MSGV1 = CUST-KUNNR.
SY-MSGV2 = CUST-BUKRS.
SY-MSGV3 = ''.
SY-MSGV4 = ''.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
TYPE = 'E'
CL = SY-MSGID
NUMBER = SY-MSGNO
PAR1 = SY-MSGV1
PAR2 = SY-MSGV2
PAR3 = SY-MSGV3
PAR4 = SY-MSGV4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = RETURN.
ENDIF.
ENDIF.
ENDLOOP.
ELSE.
CUSTOMERNO = CUST-KUNNR.
SY-MSGID = 'F2'.
SY-MSGNO = '077'. " Failure
SY-MSGV1 = CUST-NAME.
SY-MSGV2 = ''.
SY-MSGV3 = ''.
SY-MSGV4 = ''.
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
TYPE = 'E'
CL = SY-MSGID
NUMBER = SY-MSGNO
PAR1 = SY-MSGV1
PAR2 = SY-MSGV2
PAR3 = SY-MSGV3
PAR4 = SY-MSGV4
* LOG_NO = ' '
* LOG_MSG_NO = ' '
IMPORTING
BAPIRETURN = RETURN.
ENDIF.
ENDFUNCTION. -
"Buffer table not upto date" while creating Service entry via BAPI
Hi All,
I am facing the same issue while creating and accepting a service entry sheet via BAPI_ENTRYSHEET_CREATE in a report . I get a pop up message S001 (Buffer table not upto date) in ML81N. Though, it is not an error message it delays the further processing. I have checked the relevant threads for this message but since there is no SRM involved, I couldn't track the exact solution.
Regards,
GarimaHi ,
Please close all the applications and re-check your rquirement.
Also, check for any information from SM21 logs.
Some times, it can be due to program /report not correctly maintained.
Finally, Basis people need to validate & may re-start (cautios of Production system) system.
Regards
Nagaraju -
Error while creating BOM using BAPI 'BAPI_BOM_UPLOAD_SAVE'
Hi All,
We are getting an error as 'Data is incomplete' while trying to create BoM using the bapi 'BAPI_BOM_UPLOAD_SAVE', if the item contains Item category as 'T'. But for other item category like 'L' or 'N', the bapi is sucessfull.
The values that we pass to fill the item category 'T' are operation, item_cat, bom_itm_no, COMPON_QTY, FIXED_QTY as 'X', UNMEAS as 'ST', ITEM_TEXT1 and ITEM_TEXT2.
Anyone who has faced same problem or has a solution to the problem, kindly provide a solution.
Regards,
VijayThe error you receive is because of different config for different Item Categories. Find out from the functional team what fields have they kept mandatory for the item category 'T'. You may not be passing one of those fields in the BAPI.
Try creating a BOM manually for item category 'T' and you may figure our which field you are missing. -
Create Purchase Order via Upload.
Hi,
Our company have lost 4 months data due to some hardware problem. After hardware issue resolved we have to post all lost data. Therefore in MM module can it is possible that I can create PO order via BAPI program? We have four type of PO (Inventory, Assets, Changed off and IO). I got a BAPI function "BAPI_PO_CREATE1" can any body tell me how can I you this BAPI to create PO or Upload it?
Thanks
Syed Tayab ShahHi
[Sample Code|Re: BAPI-PO;
[Explanation About BAPI|http://abap.wikiprog.com/wiki/BAPI_PO_CREATE1]
Re: BAPI_PO_CREATE1-Runtime error
BAPI_PO_CREATE1
Regards
Pavan -
SD-PP integration: BOM alternative
hello, friends. i wish to ask you about transfer of requirements from SD to PP.
when processing the sales order, the user can manually select the BOM alternative via a dialog box. in standard, BOM with usage 3 (universal) and 5 (SD) are supported.
i notice that after we run MRP, in the planned order the BOM usage is 1 and alternative is defaulted to the first in the order sequence. this is true if the BOM selection method in the material master MRP 4 view is either for production version or blank.
if the selection method is by key date, then the BOM in the planned order will be the first in sequence for alternatives by key date.
in variant configuration, the specific requirements are transferred. but for a simple BOM, in neither situation is the alternative selected in the sales order transferred. why is this so? are there missing settings?
hoping for your valued inputs.
many thanks.Hi
In case of Variant configuration(VC) , the BOM Selection will be based on Dependencies assigned to the Components. In VC there is no alternative BOM Concept. There will be one Simple BOM called Super BOM which contain all the components which is required to make all the variants of K-mat.
In the sales order , the user will configure the requirements and based on the requirements selected in SO , the system will pick respective Components from Super BOM during MRP
Regards
Brahmaji -
FM/BAPI to create BOM where alternative can be passed as input
Hi
My requirement is to create BOM of a material where I need to input 'Alternative BOM' also like ijn CS01 t-code.
I got one FM CSAP_MAT_BOM_CREATE which is creating BOM , but it does not take 'Alternative BOM' as input parameter, rather it creates default alternative BOM. But I need a FM which will take alternative BOM as input.
Please help.Dear Avishek,
In my understanding the system creates the first alternative BOM 01 for a BOM usage,whenever you
create through CS01 or by a functional module,no need of any input for this field.
come back with your queries,if you are facing some problem on this.
Regards
Mangalraj.S -
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_bapiHi 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
Maybe you are looking for
-
Fields required for report creation
Hi Experts, In My report(Invoice distribution report for company wise) I need to add fields invoice number, invoice status, invoice type, invoice date, invoice period, customer number account document number, company code,amount in local, g/l amount
-
App.openDoc error in browser
I have created a javascript that I use to add links to a pdf that opens another pdf file. The script works fine in Acrobat and Reader, but not when the pdf is displayed through a web site using Internet Explorer. I set the disclosed attribute and hav
-
Edge 2013 does not discover all Exchange servers in the org
We have the following co-existence setup: Edge 2013 sitting on the DMZ. 1 CAS 2013 1 MBX 2013 1 CAS/HUB 2010 1 MBX 2010 After creating a new edge subscription on the edge server and successfully completing it on the 2013 mbx server, when I run get-ex
-
Hi, I am a starter in JMS, quite stuck at first program its been a hard time loading InitialContext with attributes. I need to know what are the context attributes that are mandatory and their values. I am listing two of them i use in my program as w
-
Starting applications of specific desktops
I've been looking for awhile to start certain applications on the same desktop but have not had much success finding information about it, so I decided to post. What I want to do is, should be , simple: When I start say Firefox it should open it in