USE BAPI BAPI_ROUTING_CREATE
HI ,
THIS IS FIRST TIME I AM USING BAPI FOR CREATING ROUTING .
I NEED HELP REGARDING DATA DECLERATION THAT I NEED TO TRANSFER TO THE FUNCTION MODULE,
A HELP IS NEEDED SO THAT I CAN START.PLEASE TELL ME HOW TO PROCEDE TO UPLOAD DATA USING BAPI.
PLEASE HELP ME.
HI
vijay here
******DECLARATION*******
DATA : path TYPE string.
DATA : flag type c.
data: count(2) TYPE n.
DATA : intern TYPE TABLE OF alsmex_tabline,
wa_intern TYPE alsmex_tabline.
DATA :
testrun TYPE bapiflag,
profile TYPE PROFID_STD, "bapi1012_control_data-profile,
bomusage TYPE STLAN , "bapi1012_control_data-bom_usage,
application TYPE CAPID. " bapi1012_control_data-application.
internal tables declaration.
DATA :
it_task TYPE TABLE OF bapi1012_tsk_c,
it_materialtaskallocation TYPE TABLE OF bapi1012_mtk_c,
it_operation TYPE TABLE OF bapi1012_opr_c,
it_COMPONENTALLOCATION TYPE TABLE OF BAPI1012_COM_C,
*text TYPE TABLE OF bapi1012_txt_c,
return TYPE TABLE OF bapiret2,
it_return TYPE TABLE OF bapiret2.
Work area declaration.
DATA :
wa_items_task TYPE bapi1012_tsk_c ,
wa_item_materailtask TYPE bapi1012_mtk_c,
wa_item_operation TYPE bapi1012_opr_c,
wa_item_componentallocation TYPE BAPI1012_COM_C,
wa_item_text TYPE bapi1012_txt_c,
wa_return TYPE return.
DATA : v_group TYPE bapi1012_tsk_c-task_list_group,
v_groupcounter TYPE bapi1012_tsk_c-group_counter.
DATA : filename TYPE string.
*************INTERNAL TABLE DECLARATION***************
TYPES: BEGIN OF routing,
valid_from1 TYPE datuv, "TASK(HEADER)
valid_todate1 TYPE datub,
usage TYPE pln_verwe ,
werkstask(6),
status TYPE plnst,
task_measure_unit(3) TYPE c,
lot_size_from(010),
lot_size_to(020),
matnr(010), " MATERIAL ALLOCATION(INITIAL SCREEN)
werks2(006),
valid_from2 TYPE datuv,
valid_todate2 TYPE datub,
valid_from3 TYPE datuv,
valid_todate3 TYPE datub,
optno TYPE VORNR,
controlkey(004),
work_cntr(006),
werks3(006),
description(20),
denominator,
quant(20),
setup TYPE vgwrt,
machine TYPE vgwrt,
labor TYPE vgwrt,
reqsplit TYPE splittung,
noofsplits TYPE dec03,
unitmax TYPE vgwrteh,
maxwaittime TYPE dzlmax,
unitstd TYPE vgwrteh,
stdqtime TYPE dzwnor,
unitmin TYPE vgwrteh,
minqtime TYPE dzwmin,
unitstdmove TYPE vgwrteh,
stdmovetime TYPE dztnor,
unitminmove TYPE vgwrteh,
minmovetime TYPE dztmin,
palnnedel TYPE dec03, " IF CONTROL KEY PP02
netprice(20) TYPE c,
priceunit TYPE pack3,
COSTELEMENT TYPE KSTAR,
currency TYPE waers,
purchorg(4) TYPE c,
purchgrp(3) TYPE c,
matgrp(9) TYPE c ,
subcontracting(1) TYPE c,
valid_from4 TYPE datuv, " COMPONENT ALLOCATION
valid_todate4 TYPE datub,
optno1(5),
itemno(5),
TEXT TYPE TDLINE,
END OF routing.
DATA: it_record TYPE STANDARD TABLE OF record1.
DATA: record TYPE record1.
PARAMETERS : fname TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
CHANGING
file_name = fname
EXCEPTIONS
mask_too_long = 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.
START OF SLECTION*************
START-OF-SELECTION.
filename = fname.
UPLOADING DATA***************
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
read_by_line = 'X'
TABLES
data_tab = it_record
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
SORT it_record BY matnr.
LOOP AT it_record INTO record.
at new matnr.
flag = 'X'.
endat.
if flag = 'X'.
count = 1.
bomusage = '1'.
application = 'PP01'.
REFRESH: task , materialtaskallocation , operation , COMPONENTALLOCATION .
*********HEADER DATA**********************
wa_items_task-valid_from = record-valid_from1.
wa_items_task-valid_to_date = record-valid_todate1.
wa_items_task-task_list_usage = record-usage.
wa_items_task-plant = record-werkstask.
wa_items_task-task_list_status = record-status.
wa_items_task-task_measure_unit = record-task_measure_unit.
wa_items_task-lot_size_from = record-lot_size_from.
wa_items_task-lot_size_to = record-lot_size_to.
APPEND wa_items_task TO task.
*************INITIAL SCREEN DATA*************
wa_item_materailtask-material = record-matnr.
wa_item_materailtask-plant = record-werks2.
wa_item_materailtask-valid_from = record-valid_from2.
wa_item_materailtask-valid_to_date = record-valid_todate2.
APPEND wa_item_materailtask TO materialtaskallocation.
flag = ' '.
endif.
IF count = 20.
count = 1.
ENDIF.
**************OPERATION DATA*******************
wa_item_operation-valid_from = record-valid_from3.
wa_item_operation-valid_to_date = record-valid_todate3.
wa_item_operation-activity = record-optno.
wa_item_operation-control_key = record-controlkey.
wa_item_operation-work_cntr = record-work_cntr.
wa_item_operation-plant = record-werks3.
wa_item_operation-description = record-description.
wa_item_operation-denominator = record-denominator.
wa_item_operation-base_quantity = record-quant.
wa_item_operation-std_value_01 = record-setup.
wa_item_operation-std_value_02 = record-machine.
wa_item_operation-std_value_03 = record-labor.
wa_item_operation-ind_splitting_reqrd = record-reqsplit .
wa_item_operation-max_no_of_splits = record-noofsplits.
wa_item_operation-max_wait_time_unit = record-unitmax.
wa_item_operation-max_wait_time = record-maxwaittime.
wa_item_operation-standard_queue_time_unit = record-unitstd.
wa_item_operation-standard_queue_time = record-stdqtime.
wa_item_operation-min_queue_time_unit = record-unitmin.
wa_item_operation-min_queue_time = record-minqtime.
wa_item_operation-standard_move_time_unit = record-unitstdmove.
wa_item_operation-standard_move_time = record-stdmovetime.
wa_item_operation-min_move_time_unit = record-unitminmove.
wa_item_operation-min_move_time = record-minmovetime.
************SUBCONTRACTING DATA********************
wa_item_operation-plnd_delry = record-palnnedel.
wa_item_operation-info_rec_net_price = record-netprice.
wa_item_operation-price_unit = record-priceunit.
wa_item_operation-COST_ELEM = RECORD-COSTELEMENT.
wa_item_operation-currency = record-currency.
wa_item_operation-purch_org = record-purchorg.
wa_item_operation-purch_group = record-purchgrp.
wa_item_operation-matl_group = record-matgrp.
wa_item_operation-ext_proc_with_subcontract_ind = record-subcontracting.
APPEND wa_item_operation TO operation.
*****************COMPONENT ALLOCATION****************
wa_item_componentallocation-valid_from = record-valid_from4.
wa_item_componentallocation-valid_to_date = record-valid_todate4.
wa_item_componentallocation-activity = record-optno1.
wa_item_componentallocation-item_no = record-itemno.
APPEND wa_item_componentallocation TO componentallocation.
TEXT************************************
wa_item_text-TEXT_LINE = RECORD-TEXT.
APPEND wa_item_text TO TEXT.
count = count + 1.
AT END OF MATNR.
****************CALLING FUNCTION MODULE**************
CALL FUNCTION 'BAPI_ROUTING_CREATE'
EXPORTING
bomusage = bomusage
application = application
IMPORTING
group = group
groupcounter = groupcounter
TABLES
task = task
materialtaskallocation = materialtaskallocation
SEQUENCE =
operation = operation
SUBOPERATION =
REFERENCEOPERATION =
WORKCENTERREFERENCE =
componentallocation = componentallocation
PRODUCTIONRESOURCE =
INSPCHARACTERISTIC =
TEXTALLOCATION =
text = text
return = return.
loop at return into wa_return.
write: / 'message type:' ,wa_return.
endloop.
COMMIT WORK.
WRITE:/ 'GROUP:', group.
WRITE:/ 'GROUPCOUNTER:', groupcounter.
ENDAT.
ENDLOOP.
this will help u
@vijji
Similar Messages
-
Problem while creation of Routing using BAPI "BAPI_ROUTING_CREATE"
Hi.
I am trying to create routing using the BAPI "BAPI_ROUTING_CREATE", when I execute I get the group number and the group counter number in the Export parameters. But it is not saved in the database, when we look at CA03 using the group number system says routing not found.
I am passing "Space" to Bapiflag and i am passing input to tables TASK, MATERIAL ALLOCATON and OPERATION as follows:-
MATERIALTASKALLOCATION-MATERIAL
MATERIALTASKALLOCATION-PLANT
TASK-TASK_LIST_USAGE
TASK-PLANT
TASK-TASK_LIST_STATUS
TASK-TASK_MEASURE_UNIT
OPERATION-ACTIVITY
OPERATION-CONTROL_KEY
OPERATION-WORK_CNTR
OPERATION-PLANT
OPERATION-DESCRIPTION
OPERATION-NUMERATOR
OPERATION-DENOMENATOR
OPERATION-BASE_QUANTITY
OPERATION-STD_UNIT_01
OPERATION-STD_VALUE_01
OPERATION-STD_UNIT_02
OPERATION-STD_VALUE_02
OPERATION-STD_UNIT_03
OPERATION-STD_VALUE_03
OPERATION-STD_UNIT_04
OPERATION-STD_VALUE_04
OPERATION-STD_UNIT_05
OPERATION-STD_VALUE_05
OPERATION-STD_UNIT_06
OPERATION-STD_VALUE_06
Appreciate your replies.
Regards.
Anand Ghawade.Use BAPI_TRANSACTION_COMMIT after you call the BAPI_ROUTING_CREATE
-
BAPI : BAPI_ROUTING_CREATE
Hi, I want to upload data operation and Inspection Char using BAPI : BAPI_ROUTING_CREATE.
Can anybody explain me with coding.
thanks
nareshDear gurus,
we must see in the atp available chek (MDPV) only storage location but the system see all the stock present in the mrp .
Infact the stock is for example in the storage location :
storage location 1 = 100 pz
storage location 2 = 20 pz
Is possible see only the stock in the storage location 2 = 20 pz.
I insert in the details item BOM for the component the storage location (storage location2) but the avalaible check confirmed the quantity 120 , i vould like quantity 20 only.
There are the method or customizing impostation for my problem?
Thanks a lot for help.
Daniele Pistilli
PP TEAM -
Create a new routing with BAPI BAPI_ROUTING_CREATE via JCo
I try to create a new routing with BAPI BAPI_ROUTING_CREATE via JCo.
I filled all necessary parameters. I also realized a commit_work. I get in the RETURN parameter of the BAPI the Message "S 000 Routing N/50001641/01". But the routing isn't in the database. Other JCo programs I wrote (create material master or costumer order) are working very well.
Have anyone an idea?
Thanks Jörg
Here's my coding:
public void createArbeitsplan() {
doLogin();
// connectionAttributes();
Plan plan = new Plan();
for (int i = 0; i < planList.size(); i++)
plan = (Plan) planList.get(i);
//Ein Function-Objekt erzeugen
String bapi = "BAPI_ROUTING_CREATE";
JCO.Function savePlan = null;
try { savePlan = this.createFunction(bapi); }
catch(Exception ex) { ex.printStackTrace(); System.exit(1); }
if(savePlan == null) { System.err.println(bapi + " not found in SAP"); System.exit(1); }
//Import und Tabellen füllen
// Plankopf
JCO.Table headData = savePlan.getTableParameterList().getTable("TASK");
headData.appendRow();
headData.setValue(plan.kurztext,"DESCRIPTION");
headData.setValue("1","TASK_LIST_USAGE");
headData.setValue(werks,"PLANT");
headData.setValue("4","TASK_LIST_STATUS");
headData.setValue("ST","TASK_MEASURE_UNIT");
headData.setValue("001","RESP_PLANNER_GROUP");
headData.setValue("20070101","VALID_FROM");
headData.setValue("20991231","VALID_TO_DATE");
headData.setValue("1","LOT_SIZE_FROM");
headData.setValue("99999999","LOT_SIZE_TO");
// Materialzuordnung
JCO.Table materialAlloc = savePlan.getTableParameterList().getTable("MATERIALTASKALLOCATION");
materialAlloc.appendRow();
materialAlloc.setValue(plan.material,"MATERIAL");
materialAlloc.setValue(werks,"PLANT");
materialAlloc.setValue("20070101","VALID_FROM");
materialAlloc.setValue("20991231","VALID_TO_DATE");
materialAlloc.setValue("1","GROUP_COUNTER");
// Vorgänge
JCO.Table operationData = savePlan.getTableParameterList().getTable("OPERATION");
for (int j = 0; j < plan.getAnzahl(); j++) {
operationData.appendRow();
operationData.setValue(plan.getVorgang(j).vorgang,"ACTIVITY");
operationData.setValue(plan.getVorgang(j).steuschl,"CONTROL_KEY");
operationData.setValue(plan.getVorgang(j).arbplatz,"WORK_CNTR");
operationData.setValue("1111","WORK_CNTR");
operationData.setValue(plan.getVorgang(j).text,"DESCRIPTION");
operationData.setValue(plan.getVorgang(j).basismenge,"BASE_QUANTITY");
operationData.setValue(plan.getVorgang(j).vw1,"STD_VALUE_01");
operationData.setValue(plan.getVorgang(j).vw2,"STD_VALUE_02");
operationData.setValue(plan.getVorgang(j).vw3,"STD_VALUE_03");
operationData.setValue(plan.getVorgang(j).ze1,"STD_UNIT_01");
operationData.setValue(plan.getVorgang(j).ze2,"STD_UNIT_02");
operationData.setValue(plan.getVorgang(j).ze3,"STD_UNIT_03");
operationData.setValue("1","DENOMINATOR");
operationData.setValue("1","NOMINATOR");
operationData.setValue("20070101","VALID_FROM");
operationData.setValue("20991231","VALID_TO_DATE");
operationData.setValue("ST","OPERATION_MEASURE_UNIT");
// Testflag
JCO.Structure test = savePlan.getImportParameterList().getStructure("TESTRUN");
test.setValue(" ","BAPIFLAG");
//BAPI ausführen (incl. Commit)
mConnection.execute(savePlan);
JCO.Function commit = null;
try {commit = this.createFunction("BAPI_TRANSACTION_COMMIT"); }
catch (Exception ex) { ex.printStackTrace();System.exit(1); }
JCO.ParameterList input = commit.getImportParameterList();
input.setValue("X","WAIT");
mConnection.execute(commit);
//Messages vom SAP-System holen
JCO.Table jcoReturn = savePlan.getTableParameterList().getTable("RETURN");
for (int k = 0; k < jcoReturn.getNumRows(); k++)
jcoReturn.setRow(i);
// System.out.println(jcoReturn.getField("MESSAGE").getValue());
System.out.println(jcoReturn.getField("TYPE").getValue());
System.out.println(jcoReturn.getField("NUMBER").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V1").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V2").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V3").getValue());
System.out.println(jcoReturn.getField("MESSAGE_V4").getValue());
JCO.Structure output = commit.getExportParameterList().getStructure("RETURN");;
System.out.println(output.getString("MESSAGE"));
System.out.println(output.getString("TYPE"));
System.out.println(output.getString("NUMBER"));
System.out.println(output.getString("MESSAGE_V1"));
closeConnectionToSAP();
System.exit(1);Hi,
perhaps you could use
BAPI_HRMASTER_SAVE_REPL_MULT
Regards
Bernd -
Deletion of Scheduling Agreement and Delivery Schedule using BAPI
Hi SAP MM Gurus,
Please assist in inquiry below:
My scenario is that I am trying to delete delivery schedules and scheduling lines using BAPIs. I have no issues when there is no GR made yet for the delivery schedules. The error arises when there are already existing Goods Receipts and Invoices for the schedule line that I wish to delete
When using the BAPIs (either BAPI_SAG_CHANGE or BAPI_SCHEDULE_MAINTAIN), I set the deletion indicator to "L" and set to X all change relevant fields (i.e. DELETION_INDX). However, whenever I execute it, I get the error message 06088. The funny thing is both the Quantities and the delivered quantities that are normally populated are left blank.
For example:
Normal error for 06088:
Quantity 100.0 smaller than quantity delivered 179.0
Error using BAPI with deletion indicator:
Quantity smaller than quantity delivered
Is this a bug of the BAPI? or am I just missing some settings?
Your immediate response is appreciated
Regards,
DeLoHi,
Please find the below link check the setting are correct or not
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a02cb00a-bfb4-2c10-98aa-e33e7f64ba28?quicklink=index&overridelayout=true
Reagrds,
Pramod -
Issue in material master update from presentation server using BAPI....
Hi Guru's...
i am trying to change the material master from presentation server (desktop flat file)
using BAPI(BAPI_MATERIAL_SAVEDATA) ....
while executing my program i am getting the message like material had changed...
but while in mm02 i am un able to fine the updates...
please find below program logic and correct me if any mistakes....
thanks in advance...
*& Report ZAREPAS36
REPORT zarepas36.
DATA : gs_bapimathead TYPE bapimathead,
gs_clientdata TYPE bapi_mara,
gs_clientdatax TYPE bapi_marax.
TYPES : BEGIN OF gty_itab1,
matnr(18),
matkl(9),
spart(2),
ntgew(13),
gewei(3),
meins(3),
END OF gty_itab1.
DATA : gt_itab1 TYPE STANDARD TABLE OF gty_itab1,
gwa_itab1 TYPE gty_itab1.
TYPES: BEGIN OF gty_itab2,
abc(132),
END OF gty_itab2.
DATA: gt_itab2 TYPE STANDARD TABLE OF gty_itab2,
gwa_itab2 TYPE gty_itab2.
flat file at selection screen
PARAMETERS: p_files TYPE string.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_files
filetype = 'ASC'
CHANGING
data_tab = gt_itab2
EXCEPTIONS
OTHERS = 8.
LOOP AT gt_itab2 INTO gwa_itab2.
IF gwa_itab2-abc(1) = 'S'.
gwa_itab1 = gwa_itab2-abc(132).
APPEND gwa_itab1 TO gt_itab1.
ENDIF.
ENDLOOP.
loop at gt_itab1 into gwa_itab1.
*Material
gs_bapimathead-material = gwa_itab1-matnr.
*Material details at client data
*material group.
gs_clientdata-matl_group = gwa_itab1-matkl.
gs_clientdatax-matl_group = 'X'.
*Division
gs_clientdata-division = gwa_itab1-spart.
gs_clientdatax-division = 'X'.
*Net Weight
gs_clientdata-net_weight = gwa_itab1-ntgew.
gs_clientdatax-net_weight = 'X'.
*Unit of Weight
gs_clientdata-unit_of_wt = gwa_itab1-gewei.
gs_clientdatax-unit_of_wt = 'X'.
*Base Unit of Measure
gs_clientdata-base_uom = gwa_itab1-meins.
gs_clientdatax-base_uom = 'X'.
endloop.
*calling BAPI for making changes in material and saving thru BAPI.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_bapimathead
clientdata = gs_clientdata
clientdatax = gs_clientdatax.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
WRITE: / 'Error occured while changing material'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'material',gs_bapimathead-material,'changed'.
ENDIF.hi hello Guru's
i resolved the issuee..
pleaso go thru the below proram logic for your reference..........
*& Report ZAREPAS36
REPORT zarepas36.
DATA : gs_bapimathead TYPE bapimathead,
gs_clientdata TYPE bapi_mara,
gs_clientdatax TYPE bapi_marax.
TYPES : BEGIN OF gty_itab1,
matnr(18),
matkl(9),
spart(2),
ntgew(13),
gewei(3),
meins(3),
END OF gty_itab1.
DATA : gt_itab1 TYPE STANDARD TABLE OF gty_itab1,
gwa_itab1 TYPE gty_itab1.
TYPES: BEGIN OF gty_itab2,
abc(132),
END OF gty_itab2.
DATA: gt_itab2 TYPE STANDARD TABLE OF gty_itab2,
gwa_itab2 TYPE gty_itab2.
DATA:ls_return TYPE bapiret2,
lt_bapiret2 TYPE standard table of bapiret2.
flat file at selection screen
PARAMETERS: p_files TYPE string.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_files
filetype = 'ASC'
CHANGING
data_tab = gt_itab2
EXCEPTIONS
OTHERS = 8.
LOOP AT gt_itab2 INTO gwa_itab2.
IF gwa_itab2-abc(1) = 'S'.
gwa_itab1 = gwa_itab2-abc(132).
APPEND gwa_itab1 TO gt_itab1.
ENDIF.
ENDLOOP.
LOOP AT gt_itab1 INTO gwa_itab1.
*Material
gs_bapimathead-material = gwa_itab1-matnr.
*Material details at client data
*material group.
gs_clientdata-matl_group = gwa_itab1-matkl.
gs_clientdatax-matl_group = 'X'.
*Division
gs_clientdata-division = gwa_itab1-spart.
gs_clientdatax-division = 'X'.
*Net Weight
gs_clientdata-net_weight = gwa_itab1-ntgew.
gs_clientdatax-net_weight = 'X'.
*Unit of Weight
gs_clientdata-unit_of_wt = gwa_itab1-gewei.
gs_clientdatax-unit_of_wt = 'X'.
*Base Unit of Measure
gs_clientdata-base_uom = gwa_itab1-meins.
gs_clientdatax-base_uom = 'X'.
ENDLOOP.
*calling BAPI for making changes in material and saving thru BAPI.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = gs_bapimathead
clientdata = gs_clientdata
clientdatax = gs_clientdatax
IMPORTING
return = ls_return.
LOOP AT lt_bapiret2 INTO ls_return.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
WRITE: / 'Error occured while changing material'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
WRITE: / 'material',gs_bapimathead-material,'changed'.
ENDIF. -
Service order creation using bapi with repair order number
Hi experts,
Pls suggest me a BAPI to create a service order for those repair orders where a PGR has been done(for return delivery type : LR).
The plant should be 0260 with storage location wh01 and item category ZRRE
Creation of a service order with repair order type SM03 is not allowed in iw31.
thanks and regards,
Vijayb.Hi prakash,
Thank u for the BAPI
But an error is being displayed saying that the REFURBISHMENT ORDERS CANNOT BE PROCESSED USING BAPI.
ERROR DURING PROCESSING OF BAPI METHODS.
This is while u pass the order type as either ZM03 or SM01or SM02 or SM03.
pls help me on that.
thanks and regards,
Vijayb. -
Unable to capture error message while creating an SO using bapi
Hi,
Can anybody suggest how to capture the error message while creating a SO using BAPI.
I have developed a customeized BAPI and using the BDC format to create the SO.
Note: i am using a call transaction method for the BDC.
I am sending the message into message1.
but i am unable to send the same into an internal table
shyam.Hi Shyam
If my understanding is correct, you are performing BDC process within the customized BAPI...
And you want to collect the messages from BDC to an internal table and pass to the output.
Proceed as below:
1. While calling BDC, use CALL TRANSACTION .... with addition: <b>MESSAGES INTO itab</b>. The structure of itab should be like <b>BDCMSGCOLL</b>.
2. Now the messages will be collected in ita.
3. Prepare the messages using FM: <b>FORMAT_MESSAGE</b>
4. Collect to the returning table.
Hope this helps...
Though i could not understand the reason of creating a BDC within BAPI, you can opt for loading orders via BAPI's like: BAPI_SALESORDER_CREATEFROMDAT1 or BAPI_SALESORDER_CREATEFROMDAT2.
Kind Regards
Eswar -
Please find herewith my below code. This program i have created for transferring goods with mvt type '657' to '555' using BAPI 'BAPI_GOODSMVT_CREATE' for TCODE MB1A.
*& Report Z_BAPI_FOR_MB1A
REPORT Z_BAPI_FOR_MB1A.
Tables : mkpf, mseg, WB2_V_MKPF_MSEG2.
DATA:
it_mb1a LIKE BAPI2017_GM_ITEM_CREATE OCCURS 0 WITH HEADER LINE,
it_return LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
it_ex_headret LIKE BAPI2017_GM_HEAD_RET OCCURS 0 WITH HEADER LINE,
it_im_header LIKE BAPI2017_GM_HEAD_01, " OCCURS 0, " WITH HEADER LINE,
it_im_gmcode LIKE BAPI2017_GM_CODE, " OCCURS 0, "WITH HEADER LINE,
mat_doc type bapi2017_gm_head_ret-mat_doc,
mat_docyear type bapi2017_gm_head_ret-doc_year.
*data : lv_intense(01).
data : it_mseg like WB2_V_MKPF_MSEG2 occurs 0 with header line,
it_cost like csks occurs 0 with header line.
selection-screen begin of block a with frame title text-001.
parameters: p_date type sy-datum default sy-datum.
select-options: so_budat for WB2_V_MKPF_MSEG2-budat,
so_werks for WB2_V_MKPF_MSEG2-werks_i,
so_matnr for WB2_V_MKPF_MSEG2-matnr_i,
so_lgort for WB2_V_MKPF_MSEG2-lgort_i.
selection-screen end of block a.
select * from WB2_V_MKPF_MSEG2 into
table it_mseg where
budat in so_budat and
werks_i in so_werks and
matnr_i in so_matnr and
lgort_i in so_lgort and
bwart_i = '657'.
select * from csks into table it_cost
for all entries in it_mseg where
gsber = it_mseg-werks_i.
*Filling BAPI Header Tables
it_im_header-pstng_date = sy-datum.
it_im_header-doc_date = sy-datum.
it_im_gmcode-gm_code = '03'.
*Filling BAPI Item Tables
loop at it_mseg.
read table it_cost with key gsber = it_mseg-werks_i.
it_mb1a-material = it_mseg-matnr_i.
it_mb1a-plant = it_mseg-werks_i.
it_mb1a-stge_loc = it_mseg-lgort_i.
it_mb1a-batch = it_mseg-charg_i.
it_mb1a-move_type = 555. " '103'.
it_mb1a-entry_qnt = it_mseg-menge_i.
it_mb1a-costcenter = it_cost-KOSTL.
it_mb1a-gl_account = '530089'.
append it_mb1a.
clear it_mb1a.
clear it_cost.
endloop.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = it_im_header
goodsmvt_code = it_im_gmcode
* TESTRUN = ' '
* GOODSMVT_REF_EWM =
IMPORTING
GOODSMVT_HEADRET = it_ex_headret
MATERIALDOCUMENT = mat_doc
MATDOCUMENTYEAR = mat_docyear
tables
goodsmvt_item = it_mseg
* GOODSMVT_SERIALNUMBER =
return = it_return
* GOODSMVT_SERV_PART_DATA =
* EXTENSIONIN =
if sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
endif.
But when i execute the above i am getting the following error.
Runtime Errors CALL_FUNCTION_UC_STRUCT
Except. CX_SY_DYN_CALL_ILLEGAL_TYPE
Date and Time 27.01.2009 14:43:06
Short text
Type conflict during structure parameter transfer at CALL FUNCTION.
What happened?
Error in the ABAP Application Program
The current ABAP program "Z_BAPI_FOR_MB1A" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
not caught and
therefore caused a runtime error.
The reason for the exception is:
In the function "BAPI_GOODSMVT_CREATE", the STRUCTURE parameter "GOODSMVT_ITEM"
is typed in such a way
that only actual parameters are allowed, which are compatible in Unicode
with respect to the fragment view. However, the specified actual
parameter "IT_MSEG" has an incompatible fragment view.
Missing Handling of System Exception
Program Z_BAPI_FOR_MB1A
Trigger Location of Exception
Program Z_BAPI_FOR_MB1A
Include Z_BAPI_FOR_MB1A
Row 72
Module Name START-OF-SELECTION
Source Code Extract
Line SourceCde
42 lgort_i in so_lgort and
43 bwart_i = '657'.
44
45 select * from csks into table it_cost
46 for all entries in it_mseg where
47 gsber = it_mseg-werks_i.
48 *Filling BAPI Header Tables
49 it_im_header-pstng_date = sy-datum.
50 it_im_header-doc_date = sy-datum.
51 it_im_gmcode-gm_code = '03'.
52
53 *Filling BAPI Item Tables
54 loop at it_mseg.
55
56 read table it_cost with key gsber = it_mseg-werks_i.
57
58 it_mb1a-material = it_mseg-matnr_i.
59 it_mb1a-plant = it_mseg-werks_i.
60 it_mb1a-stge_loc = it_mseg-lgort_i.
61 it_mb1a-batch = it_mseg-charg_i.
62 it_mb1a-move_type = 555. " '103'.
64 it_mb1a-costcenter = it_cost-KOSTL.
65 it_mb1a-gl_account = '530089'.
66
67 append it_mb1a.
68 clear it_mb1a.
69 clear it_cost.
70 endloop.
71
72*>>>> CALL FUNCTION 'BAPI_GOODSMVT_CREATE'* 73 EXPORTING
74 goodsmvt_header = it_im_header
75 goodsmvt_code = it_im_gmcode
76 * TESTRUN = ' '
77 * GOODSMVT_REF_EWM =
78 IMPORTING
79 GOODSMVT_HEADRET = it_ex_headret
80 MATERIALDOCUMENT = mat_doc
81 MATDOCUMENTYEAR = mat_docyear
82 tables
83 goodsmvt_item = it_mseg
84 * GOODSMVT_SERIALNUMBER =
85 return = it_return
86 * GOODSMVT_SERV_PART_DATA =
87 * EXTENSIONIN =
88 .
89 if sy-subrc = 0.
90 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
91 EXPORTING
Can u explain why this is coming. Your valuable suggestions are required.
Thanks,
Jitesh M NairHi,
Try this Code.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = WF_HEADER
GOODSMVT_CODE = WF_CODE
TESTRUN = WL_space
IMPORTING
MATERIALDOCUMENT = FS_MATERIAL_DOC
TABLES
GOODSMVT_ITEM = INT_ITEM
GOODSMVT_SERIALNUMBER = INT_SERIALNO
RETURN = INT_RETURN1.
*VARIABLES for goods movement creation bapi
DATA : WF_HEADER TYPE BAPI2017_GM_HEAD_01,
WF_CODE TYPE BAPI2017_GM_CODE.
DATA : FS_MATERIAL_DOC TYPE BAPI2017_GM_HEAD_RET-MAT_DOC,
FS_SERIALNO TYPE BAPI2017_GM_SERIALNUMBER,
FS_ITEM TYPE BAPI2017_GM_ITEM_CREATE,
FS_RETURN1 TYPE BAPIRET2,
data declaration for goods movement creation bapi
DATA : INT_ITEM TYPE TABLE OF BAPI2017_GM_ITEM_CREATE,
INT_SERIALNO TYPE TABLE OF BAPI2017_GM_SERIALNUMBER,
INT_RETURN1 TYPE TABLE OF BAPIRET2.
Hope this will help.
Regards,
Rohan. -
Send mail to non-sap using bapi's
hi friends,
Can any one please help me how to send mail from sap to non-sap systems using bapi's.plesae help me .i want the procedure and code
regards
srikanth.vHi,
Use this sample Code...
REPORT ZSENDMAIL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Send External Mail'.
Mail Contents
OBJTXT = 'Minimum bid : $250000'.
APPEND OBJTXT.
OBJTXT = 'A representation of the pictures up for auction'.
APPEND OBJTXT.
OBJTXT = 'was included as attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
*OBJBIN = ' \O/ '. APPEND OBJBIN.
*OBJBIN = ' | '. APPEND OBJBIN.
*OBJBIN = ' / \ '. APPEND OBJBIN.
*DESCRIBE TABLE OBJBIN LINES TAB_LINES.
*OBJHEAD = 'PICTURE.BMP'.
*APPEND OBJHEAD.
Creation of the entry for the compressed attachment
*OBJPACK-TRANSF_BIN = 'X'.
*OBJPACK-HEAD_START = 1.
*OBJPACK-HEAD_NUM = 1.
*OBJPACK-BODY_START = 1.
*OBJPACK-BODY_NUM = TAB_LINES.
*OBJPACK-DOC_TYPE = 'BMP'.
*OBJPACK-OBJ_NAME = 'PICTURE'.
*OBJPACK-OBJ_DESCR = 'Representation of object 138'.
*OBJPACK-DOC_SIZE = TAB_LINES * 255.
*APPEND OBJPACK.
Completing the recipient list
RECLIST-RECEIVER = '[email protected]'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
*RECLIST-RECEIVER = 'SAPUSERNAME'.
*RECLIST-REC_TYPE = 'P'.
*APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'The document was sent'.
ELSE.
WRITE 'The document could not be sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'No authorization for sending to the specified number',
'of recipients'.
WHEN 2.
WRITE: / 'Document could not be sent to any recipient'.
WHEN 4.
WRITE: / 'No send authorization'.
WHEN OTHERS.
WRITE: / 'Error occurred while sending'.
ENDCASE.
in this code....Internal table IF RECLIST-RETRN_CODE is not 0,then the mail is not send to the recipient, so if you want the undeliverable mail for a perticular recipient then call the same function module SO_NEW_DOCUMENT_ATT_SEND_API1 with undeliverd message to whom want to receive the undeliverd message.
hope this solves your problem -
Hi experts, Upload purchase order using BAPI
hi
Could you please help me how to do PURCHASE ORDER CREATION using BAPI.
Thank you.Satyendra,
The forum that you have posted your question in is for questions related to the SAP Business One Integration for SAP NetWeaver. Your question is or seems to be related to R/3 and should be posted in that forum.
Eddy -
Hi bapi Guru's,
I am asked to use bapi's(Instead of BDC's) for data upload .I am not getting good documentation on 'USING BAPI's IN ABAP',Like Defining structures, and what are the FM's to be called like bapi_commit.
Any Info is Appriciated.
Regards
satishSorry Satish,
Maybe this is going off topic a little, bit perhaps also its relevant as you have been asked to move from BDC's to BAPIs.
Juan,
When I talk about debugging, there are two levels to this:
<b>1. Debugging by the programmer</b>
In this case, how can it be easier to debug an error from a BAPI than from the screen? For a sales order, for example, when you enter a delivery date of 01.01.2000 for an item, via BDC you will get an error message as the item is entered (something along the lines of delivery date is in the past), and you will see exactly the date you have entered, and if you don't understand the error, you can click on F1 and it will give you the long description of the error. Via a BAPI, you would get the error message, and you MIGHT get the item number and the date in question. But if you don't understand the error what do you do then? Debug the BAPI itself? You could, but isn't this a rather lengthy way to get to the root of the problem? In general, any errors you get calling BAPIs/BDCs are errors with your master data, or breaking business rules, you shouldn't have to debug standard code to tell you whats going wrong, the application can tell you.
<b>2. Debugging by the end user</b>
When you implement a BAPI/BDC this will be related to an interface/automated transaction etc. When its in production you will occassionally get errors (due to bad master data, not fully capturing all the business logic in your custom coding [it happens], technical issues etc.) What do you do then? In the case of BDC you can do nothing. The error is recorded, and you can get end users to process the errors by stepping through the screens (which they already know how to use) and make corrections as required. In the case of BAPIs, you have to record the error in a table or a file, then develop some kind of interface to display the errors, then develop some kind of process for re-processing the errors. If the data used to call the BAPI is not correct then you also need to provide a facility for changing the data before reprocessing. Normally you do none of this because its too much work and you end up having all errors coming back to the SAP team who have to debug and change table entries etc. to get it all to work. I would not say that this makes BAPIs easier to debug.
Oops, just realised my pasta is burning!!!
Anyway, think I got my point across. Not personal but feel quite strongly about this topic. To me BDC's are still a relevant tool despite the push for Idocs/BAPIs.
Cheers,
Brad -
Changing Payment terms using Bapi
Hi Gurus,
I want to change the Payment terms in Purchase order / Scheduling agreement Using Bapi.
I used BAPI_PO_CHANGE.but Payment terms are not updating.
Useful Answers will be rewarded with Points.Did you use BAPI_TRANSACTION_COMMIT after BAPI_PO_CHANGE.
Look also at this <a href="http://www.sap-img.com/abap/sample-abap-code-on-bapi-po-change.htm">Sample Abap code on BAPI_PO_CHANGE</a>
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
PURCHASEORDER = T_POHEADER-PO
POHEADER = T_BAPI_POHEADER
POHEADERX = T_BAPI_POHEADERX
TABLES
RETURN = T_BAPIRETURN
POITEM = T_BAPI_POITEM
POITEMX = T_BAPI_POITEMX.
READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
ENDIF.
Regards -
Problem in Sales order create using BAPI with reference to quotation
Hi,
I am creating a sales order from Quotation using BAPI /AFS/BAPI_SALESORD_CREATEFDATA.
The Sale order is getting created and the document flow is updated. When i check the status of quotation it is "OPEN".
Ideally when a sale order is created in VA01 with reference to a quotation and if all items are added in the order from quotation, then the status of the quotation must be "Complete".
When i use the BAPI, the status of the quotation is sill "Open". Has anyone faced this issue?
Even if anyone has faced this issue with BAPI_SALESORDER_CREATEFROMDAT2, please let me know...
RegardsHi RV,
I am using BAPI to create order reference to contracts. I am facing same issue. Its not updating document flow (vbfa-plmin field). After creating orders I am forcing to update plmin field in vbfa. This worked fine. But now status in reference document not updating properly. I saw your thread. It looks like similar issue. I saw your comments "Customization was not maintained properly for the Order types ". Please can you explain little bit more about your solution. It will helps us lot.
Thanks,
srini -
Creating sale order by using BAPI
Hi,
My requirement is to create a inquiry(VA11), By using the Inquiry no as a input in report, i should create a salesorder using BAPI in which the datas should be flowed from inquiry to sale order. i did almost everything except the Pricing Condition.
I am fetching the pricing condition values from table KONV-KSCHL and passing the value via BAPI_SALESORDER_CREATEFROMDAT2 it creates saleorder. In the created salesorder, there are two same pricing conditions but different rate 1.) the price of the MATNR which is maintained 2.) the changed MATNR price in inquiry level,
i need the value which is changed in inquiry level that is 2nd value.
can anyone help me in this...REPORT ZSALESORDER.
<< Cut and paste without attribution from
create sales order using BAPI
removed >>
Edited by: Rob Burbank on Feb 24, 2009 10:43 AM
Maybe you are looking for
-
Editable shared elements in a template?
I want to make use of DW Templates to maintain the appearance of the site, but I tend to use templates purely for control of the basic framework of the web pages and then keep all of the shared elements inside include files (I find it easier to updat
-
I know this is a very simple thing, but I have no clue how to do this. I have an unordered listing that indents itself from the table border. I would like to get rid of this indent so it is right against the border. I turned the borders on and you ca
-
Since upgrade, how do I select a new game in Freecell?
Since iPad upgrade Why can't I select a new game in Freecell?
-
Table for Normal Duration of the activity
Hi all, In which table ( not structure), is the normal duration of the activity is stored ?. How do we really understand this information from looking at the structure AFVGD? Warm regards, Srinivas Potluri
-
How do I get Mozilla Fireefox to open.
I have been using Firefox for several months now and like it. but for some reason it will not open now. I don't want to lose my favorites. Right now I can only get on the internet using Internet Explorer. I can even go into the File and try opening i