‎2007 Feb 06 12:46 PM
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
‎2007 Feb 06 1:07 PM
This isn't a bapi, but it does create a material BOM(Simple) CSAP_MAT_BOM_CREATE.
Regards,
Ravi
‎2007 Feb 06 1:00 PM
rafal
you are right with ur steps. u need to call a z bapi to create a BOM. check if any f/n mod is available for that. by debuggin u can trace this out. i remember that when i debugged while creating a bom.
regds
Prabhu
‎2007 Feb 06 1:01 PM
Hi Rafal,
Check out BAPI_MATERIAL_BOM_GROUP_CREAT.
Regards,
John.
‎2007 Feb 06 1:07 PM
I heard about this BAPI_MATERIAL_BOM_GROUP_CREAT, but I cannot find it in documentation. Do u know where to look for it?
‎2007 Feb 06 1:40 PM
Use transaction SE37 and check the documentation of the BAPI. First part of the docu:
Functionality
This method enables you to create a material BOM with all its assigned objects.
In extreme case, the entire BOM group can be transferred, that means
All variants of a variant BOM or alternatives of a multiple BOM
The entire history
All material assignments
All items
All subitems
This enables the the data to be transferred from the non-SAP system in one step.
Regards,
john.
‎2007 Feb 06 1:56 PM
I'm extremely grateful for ur answer.
Perhaps it seems to be ridiculous for you, but since I'm completely new with SAP, "transaction SE37" doesn't tell me anything. Could you write a little bit more, please?
In which group in the hierarchy in Bapi Browser did u find BAPI_MATERIAL_BOM_GROUP_CREATE?
Ur answer will be warmly appreciated.
Thanks in advance
Br,
Rafal
‎2007 Feb 06 2:07 PM
If you use the BAPI browser don't use the hierarchy but the Alphabetical tab. You will the find the BAPI with object MaterialBOM.
Regards,
John.
‎2007 Feb 06 2:18 PM
Thanks a lot for an answer.
It seems that I have some old or strange version of Sap Easy Access, because the is no MaterialBOM in my documentation. Perhaps that was the reason why I cannot find anything and I was forced to ask.
Any suggestion will be appreciated.
Br,
Rafal
‎2007 Feb 06 2:30 PM
This BAPI has been released in SAP R/3 4.6C which is quiet an old release. Perhaps you are using a system before 4.6.C?
Regards,
John.
‎2007 Feb 06 2:46 PM
The server which I use is not in my company, but at University, so I'm not sure about version. I checked attributes of my connection and I show it below:
PARTNER_REL: 46B
PARTNER_TYPE: 3
KERNEL_REL: 46D
TRACE:
RFC_ROLE: C
OWN_TYPE: E
CPIC_CONVID: 72696078
It seems that the version is either 46B or 46D. I am not sure which number describes version of the system. I've tried to create BAPI_MATERIAL_BOM_GROUP_CREATE in my Java application, but it cannot. So i guess that the version is 46B, am I right?
BR,
Rafal
‎2007 Feb 06 2:56 PM
Yes, you are... 46B is quiet an old version; the BAPI I have mentioned is not available in this system.
Regards,
John.
‎2007 Feb 06 3:00 PM
I am very grateful for ur answer. In this case I will try to solve it by using CSAP_MAT_BOM_CREATE....hope it is possible
‎2007 Feb 06 1:05 PM
Hi,
<b>BAPI_MATERIAL_BOM_GROUP_CREATE</b> Creation of a material BOM group
Regards
Sudheer
‎2007 Feb 06 1:07 PM
This isn't a bapi, but it does create a material BOM(Simple) CSAP_MAT_BOM_CREATE.
Regards,
Ravi
‎2007 Feb 06 1:17 PM
I am developing an application in Java, so every operation is handled by JCO. I've got to check whether it is possible to use it in my case. Perhaps u may tell me where to find documentation? Do you know what is the difference between CSAP_MAT_BOM_CREATE and BAPI_MATERIAL_BOM_GROUP_CREATE, except that the first one is not Bapi
‎2007 Feb 06 2:37 PM
Hi
Both the function modules are BAPIs.
Incase you read the Documentation of both the function modules, you will get the difference.
Read this documenation in my next response.
Regards
- Atul
‎2007 Feb 06 2:38 PM
Hi
<b>This is the documentation for Function module -</b>
-
BAPI_MATERIAL_BOM_GROUP_CREATE
____________________________________________________
Short Text
Creation of a material BOM group
Functionality
This method enables you to create a material BOM with all its assigned objects.
In extreme case, the entire BOM group can be transferred, that means
All variants of a variant BOM or alternatives of a multiple BOM
The entire history
All material assignments
All items
All subitems
This enables the the data to be transferred from the non-SAP system in one step.
Caution:
Make sure that a BOM can not be transferred several times. That also means that you can not first transfer a part of the BOM group, such as part of the variants or items (particularly with regard to history) and then in a second run, transfer the rest (additional variants, assignments, other historical statuses and so on).
A prerequisite for the successful transfer of a BOM, is that all business objects, to which a BOM refer have first been transferred into the SAP System. These are
Material masters
Document info records, provided document items exist in the BOM
Classes, provided class items are to be transferred
Change numbers tha control the change status of the BOMs
Standard texts, provided they are to be included in the long text of the BOM group, variants or items
Example
You want to transfer several (entire) BOM groups with complete history.
In other words, the variants (in the case of variant BOMs) or alternatives (in the case of multiple BOMs) with their history and assigned long texts.
The assignment of assembly materials - possibly from different plants - to BOMs.
The corresponding items with their historical statuses and their long texts.
The sub items of these items
For this you generate entries in the following tables, which are organized into three categories.
Tables that define objects
BOMGROUP - Basic data for the entire BOM group
VARIANTS - Variant or alternative data
ITEMS - Items
SUBITEMS - Subitems
Tables that define the relationship between objects
MATERIALRELATIONS - Assignment of the header materials to the BOM groups, with the relevant requirements
ITEMASSIGNMENTS - Assignment requirements of the components to the variants or alternatives
SUBITEMASSIGNMENTS - Assignments of subitems to items
Tables with other assigned attributes
TEXTS - Long texts for individual objects
The BOM groups are cumulated within the running transfer with a unique group definition of up to 32 characters (BOM_GROUP_IDENTIFICATION). This is entered in all table entries. Provided an external (unique) BOM group is to be placed in the SAP System, this can be used for identification.
Each object can be uniquely identified within a BOM group in the field OBJECT_ID. In order to be able to easily recognize the object in the data stream of the import, the field OBJECT_TYPE is also filled with the value:
BOM in the table VARIANTS
BGR in the table BOMGROUP
ITM in the table ITEMS
SUI in the table SUBITEMS
In addition to this general data, the tables are individually created as follows
BOMGROUP
Contains the essential basic characteristics of a BOM group such as
BOM usage (BOM_USAGE)
Authorization group (AUTH_GROUP)
Description (BOM_TEXT)
and so on.
VARIANTS
Contain the variant specific data such as
Laboratory (LAB_DESIGN)
Base quantity to which the component quantities refer (BASE_QTY)
Validity entries such as change number (CHANGE_NO) and/or key date (VALID_FROM_DATE)
In the field FUNCTION you place the value
NEW if the variant runs in on a specified key date
DEL if the variant runs out on a specified key date
ITEMS
Contains the component attributes. Competing attributes that refer to primary objects, such as component material (COMPONENT), document number (DOCUMENT_NUMBER), class number (CLASS_NUM) are determined by the item category (ITEM_CAT). Read the information in SAP Customizing about the relevant item types and about the other attributes related to the specified primary objects.
SUBITEMS
Contains the sub item data
Quantity (SUBITEM_QTY)
Installation location (INSTALLATION_POINT)
and so on.
MATERIAL RELATIONS
Contains - by entering the variant BOM number - the assignments of the assembly materials to the BOM with the requirements
Plant
Lot size area for multiple BOMs (LOT_SIZE_FROM, LOT_SIZE_TO)
ITEMASSIGNMENTS
Assigns the components of the individual variants/alternatives to BOM groups.
In the fields SUB_OBJECT_TYPE, SUB_OBJECT_ID you enter the BOM components and in the fields SUPER_OBJECT_TYPE, SUPER_OBJECT_ID you enter the variants/alternatives. This means, you deposit the values from the fields OBJECT_TYPE and OBJECT_ID from the table ITEMS in the field SUB_OBJECT_TYPE, SUB_OBJECT_ID and the values from the fields OBJECT_TYPE and OBJECT_ID from the table VARIANTS in the fields SUPER_OBJECT_TYPE, SUPER_OBJECT_ID .
The validity of the assignments is determined by the valid-from date (VALID_FROM_DATE) or change number (CHANGE_NO)
The field FUNCTION has to be scheduled with a value
NEW component created with this validity
DEL component deleted with this validity.
SUBITEM ASSIGNMENTS
Assigns the sub items to the components
You enter the subitem in the fields SUB_OBJECT_TYPE, SUB_OBJECT_ID the components in the fields SUPER_OBJECT_TYPE, SUPER_OBJECT_ID. That means, you deposit the values from the fields OBJECT_TYPE and OBJECT_ID of table SUBITEMS into the fields SUB_OBJECT_TYPE, SUB_OBJECT_ID and the values from the fields OBJECT_TYPE and OBJECT_ID from table ITEMS into the fields SUPER_OBJECT_TYPE, SUPER_OBJECT_ID .
TEXTS
The table TEXTS contains the individual long text lines for all the objects whose long texts can be assigned. The assignment to the relevant objects is produced in the fields OBJECT_TYP and OBJECT_ID.
Notes
To secure the data in the database, you have to carry out a COMMIT WORK for each BOM group.
All errors that occur are logged in the export parameter RETURN. In the case of inconsistencies, the entire BOM group to be generated is rejected.
The messages specified in the export parameter RETURN, are arranged as follows:
Messages with the message Id BAPI provide information about the general results when processing the input.
000 Processing was successful
001 Processing failed
Messages with the message Id BAPI1080 provide detailed information about the processing.
The detail messages fall into two groups:
Message 028 highlights errors or warnings that result from the analysis of the structure of the transferred BOM data. In the case that only warnings are given then the processing has been continued and finished successfully provided no other error messages occur. Still, in this case, the warning should be followed.
Message 029 highlights errors in the data of the individual imported objects (variants, items and so on). The process is cancelled.
In addition to messages 028 and 029, other (error) messages are given, which better describe the affected sub-objects (variants, items and so on) or their relationship with each other. The identification of the object takes place using the message variable BOM_GROUP_IDENTIFICATION to identify the addected BOM group, and OBJECT_TYP and OBJECT_ID to identify the objects (variants, items and so on) within a group.
Also (if available) the application log and/or the relevant internal message last set in the API are given in the export parameter RETURN.
Parameters
TESTRUN
ALL_ERROR
BOMGROUP
VARIANTS
ITEMS
SUBITEMS
MATERIALRELATIONS
ITEMASSIGNMENTS
SUBITEMASSIGNMENTS
TEXTS
RETURN
Exceptions
Function Group
CPCC_BUS1080
-
Regards
- Atul
‎2007 Feb 06 2:39 PM
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
‎2007 Feb 06 3:03 PM
Thanks for ur help.
I can't use BAPI_MATERIAL_BOM_GROUP_CREATE since the version of my sap is 46B. I hope i can use Using CSAP_MAT_BOM_CREATE. Can I?
‎2007 Feb 06 3:06 PM
Hi
Yes.. Pls go ahead.
Just for your reference, Any of the BAPIs can be used.
Since they have the ability to support both up-ward and down-ward versions.
Hope this will help.
Pls reward suitable points.
Regards
- Atul
‎2007 Feb 06 4:10 PM
Hi,
Both of you (I mean You and John) are already rewarded. Hopefully I can still get ur help if necessary.
I tried to use BAPI_MATERIAL_BOM_GROUP_CREATE, but it doesn't work. pls explain how it can work in both directions? in my case it doesn't want
Br,
Rafal
‎2007 Feb 07 9:00 AM
Hi
Jus for your reference, There is a function module, which in turn calls this BAPI..
The function module name is IDOC_INPUT_MAT_BOMGROUP_CREATE.
Please refer this function module, to see, how you need to go ahead.
Hope this will help.
Please reward suitable points.
Regards
- Atul
‎2007 Feb 07 9:24 AM
Thank you very much.
Now I am during GUI implementation. I will try to use infomation which you provide tomorow during appropriate method implementation and let you know how helpful it is for me or even ask you sth more.
U r already rewarded with 6 points. When I solve my problem completely I will decide who is going to get 10 (first of all I need to be sure that I don't make a mistake during the evaluation - I want to be fair).
Thanks again.
BR,
Rafal
‎2007 Feb 12 8:57 AM
Hi,
I am starting to read ur materials. I just wonder where did u find it? Could u write me about ur source, pls? It will be easier to read for me (i guess) and find additional information, when I know the source.
Thanks in advance.
BR,
Rafal
‎2007 Feb 12 9:12 AM
Hi
This is the standard documentation which is available with nearly all the objects like functio modules, BADIs etc.
Incase you want to know the standard documetation of say, a function module, - BAPI_MATERIAL_BOM_GROUP_CREATE
Then, go the standard transaction - SE37 and then put the name there in the inputbox and then click F9 Key to get the SAP standard documentation avaialable with the same.
Hope this will help.
Please reward suitable points.
Regards
- Atul
‎2007 Feb 20 12:27 PM
Hi,
I am trying to use CSAP_MAT_BOM_CREATE in my Java application. First of all I used CALO_INIT_API... and it seems to be called without error, but when my application calls CSAP_MAT_BOM_CREATE following exception occurs:
com.sap.mw.jco.JCO$AbapException: (126) ERROR: Terminate processing
Do you know how to get more detailed information about errors caused by API? I see that there is no RETURN structure.
I think I didn't pass sufficient data.
!!! The most important (I would say crucial) problem is how to prepare the structure (like Headdata, items data) in Java and pass it to CSAP_MAT_BOM_CREATE.
I see in your example (copied from documentation) that a special table is created and its members are itialized and then everything passed to API (solution is shown in script). But how to do it in my case? Anybody knows?
Looking forward an answer.
Any help will be warmly appreciated
BR,
Rafal
‎2007 Feb 20 12:44 PM
Hi
Have you read the documenation of this Function module carefully.
Here is the sample code as well.
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
CSAPHope this will help.
Please reward suitable points.
Regards
- Atul
‎2007 Feb 20 2:10 PM
Hi,
Yes....I've read carefully earlier. I've solved my problems.
First one was my mistake. Sorry that I bothered you.
In case of second one I wondered (for instance) how to initialize base_quan or bom_text in headdata. I saw how it is done in documentation which you attached to your post. I've tried to initialize it directly, but it was impossible. Finally I've found out that firstly I've got to get structure (in case of headdata is I_STKO) and then initialize it. It works Hopefully I am not going to have a problem with initializing Items. We will see.
But if somebody needs the help with passing data to CSAP_MAT_BOM_CREATE in Java, don't hesitate to ask me. I'll try to help you. Hopefully I'll get more information about this issue in future.
Thanks for all Atul. I'll reward you with 10 points.
BR,
Rafal