09-17-2020 5:03 AM
I create program that using BAPI_REQUISITION_CREATE, but it's not work. when i click CONVERTPR button nothing happend.
anyone help me, thanks.
MODULE user_command_0110 INPUT.
CASE sy-ucomm.
WHEN 'CONVERTPR'.
CALL METHOD g_grid_cart2->check_changed_data.
PERFORM fm_convert_doc.
ENDCASE.
ENDMODULE.
FORM fm_convert_doc .
DATA : lv_type_pr TYPE bapiebanc-doc_type.
IF lv_plant = 'BM01'.
lv_type_pr = 'ZBMT'.
ELSEIF lv_plant = 'CA01'.
lv_type_pr = 'ZCAT'.
ELSEIF lv_plant = 'DB01'.
lv_type_pr = 'ZDBT'.
ELSEIF lv_plant = 'ES01'.
lv_type_pr = 'ZEST'.
ELSEIF lv_plant = 'GB01'.
lv_type_pr = 'ZGBT'.
ELSEIF lv_plant = 'IF01'.
lv_type_pr = 'ZIFT'.
ELSEIF lv_plant = 'IM01'.
lv_type_pr = 'ZIMT'.
ELSEIF lv_plant = 'MP01'.
lv_type_pr = 'ZMPT'.
ELSEIF lv_plant = 'OI01'.
lv_type_pr = 'ZOIT'.
ELSEIF lv_plant = 'PF01'.
lv_type_pr = 'ZPFT'.
ELSEIF lv_plant = 'PP01'.
lv_type_pr = 'ZPPT'.
ELSEIF lv_plant = 'QT01'.
lv_type_pr = 'ZQTT'.
ELSEIF lv_plant = 'WR01'.
lv_type_pr = 'ZWRT'.
ENDIF.
SELECT * FROM ztblzmrp_item INTO CORRESPONDING FIELDS OF TABLE it_mrp2_convert
WHERE mrpno = lv_mrpno.
LOOP AT it_mrp2_convert INTO wa_mrp2_convert.
wa_requisition_items-trackingno = wa_mrp2_convert-mrpno.
wa_requisition_items-doc_type = lv_type_pr.
wa_requisition_items-pur_group = 'TR1'.
wa_requisition_items-preq_name = wa_mrp2_convert-requisitioner.
wa_requisition_items-material = wa_mrp2_convert-matnr.
wa_requisition_items-plant = lv_plant.
wa_requisition_items-quantity = wa_mrp2_convert-orderqty.
wa_requisition_items-unit = wa_mrp2_convert-meins.
wa_requisition_items-deliv_date = wa_mrp2_convert-req_del_date.
wa_requisition_items-c_amt_bapi = wa_mrp2_convert-price.
wa_requisition_items-gr_ind = wa_mrp2_convert-requisitioner.
wa_requisition_items-ir_ind = 'X'.
wa_requisition_items-purch_org = 'X'.
wa_requisition_items-currency = wa_mrp2_convert-curr.
APPEND wa_requisition_items TO it_requisition_items.
CLEAR wa_requisition_items.
ENDLOOP.
CALL FUNCTION 'BAPI_REQUISITION_CREATE'
EXPORTING
skip_items_with_error = 'X'
automatic_source = 'X'
* IMPORTING
* NUMBER = ld_number
TABLES
requisition_items = it_requisition_items
requisition_account_assignment = it_requisition_account_assign
requisition_item_text = it_requisition_item_text
requisition_limits = it_requisition_limits
requisition_contract_limits = it_requisition_contract_limits
requisition_services = it_requisition_services
requisition_srv_accass_values = it_requisition_srv_accass_val
return = it_return
requisition_services_text = it_requisition_services_text
requisition_addrdelivery = it_requisition_addrdelivery
extensionin = it_extensionin.
ENDFORM.
09-17-2020 7:08 AM
BAPI_REQUISITION_CREATE does not require a separate commit (also mentioned in 394058 - BAPI_REQUISITION and COMMIT WORK).
Anyways, it is unclear if the creation was successful or not (no information from the OP about any debugging analysis).
It is unclear what is understood by nothing happens - no PR was created, some message is expected to be shown (this is probably only a part of the code).
If I had to troubleshoot this, I would probably start not from the BAPI creation, but by placing a breakpoint at
PERFORM fm_convert_doc.
If the debugger stops there, at least it will mean that it makes sense to start troubleshooting this part of the code before looking into other parts of the program.
Then it would be a good idea to check what is the content of it_return, based on which it may be needed to check what is passed to the BAPI, what is in ztblzmrp_item, and so on.
09-17-2020 6:04 AM
09-17-2020 6:33 AM
Hello saddam.id,
You have to add below snippet post the BAPI is called, ensure the BAPI call was successful before using the below code.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
You can refer the LINK for more details on the implementation part.
Regards!
09-17-2020 7:29 AM
09-17-2020 7:08 AM
BAPI_REQUISITION_CREATE does not require a separate commit (also mentioned in 394058 - BAPI_REQUISITION and COMMIT WORK).
Anyways, it is unclear if the creation was successful or not (no information from the OP about any debugging analysis).
It is unclear what is understood by nothing happens - no PR was created, some message is expected to be shown (this is probably only a part of the code).
If I had to troubleshoot this, I would probably start not from the BAPI creation, but by placing a breakpoint at
PERFORM fm_convert_doc.
If the debugger stops there, at least it will mean that it makes sense to start troubleshooting this part of the code before looking into other parts of the program.
Then it would be a good idea to check what is the content of it_return, based on which it may be needed to check what is passed to the BAPI, what is in ztblzmrp_item, and so on.
09-17-2020 7:28 AM
thanks veselina.peykova, I have checked, it_return and then i know what the problem and message. and I can solve it. The error because the input of purchasing organization is wrong.