Purpose: This BAPI is used to create Purchase Requisitions (PRs).There are different scenarios to create the PRs depends on the requirements. I will be focusing here to create different service item because problems occur when you create PRs with services using this BAPI.
Purchase Requisitions for services can be of two types:
With and without master - Single account assignment.
With and without master- Multiple account assignment
There is one more type of PRs for services i.e. WITH LIMIT. But here I will be focusing on above two types.
Technical Information: This BAPI is having two importing parameters, they are:
SKIP_ITEMS_WITH_ERROR & AUTOMATIC_SOURCE.
Do not consider any of them while calling the BAPI in your code. we can skip both of them as they are not mandatory.
Scenario: To upload Mass PRs for services from legacy systems to 6.0. The data was to be uploaded through a spread sheet having all the required fields to create Service Purchase Requisition. This is also helpful for creation of individual Service PR also.
Some of the fields (from different structures used in BAPI) whose sequencing and value initialization is to be done very logically otherwise the service line item will not get created. They are 'SERIAL_NO', 'LINE_NO', 'EXT_LINE', and 'PCKG_NO'. For every new PR number initialize 'SERIAL_NO' to '01', 'LINE_NO' to '1', 'EXT_LINE' to '10', 'ITEM_NO' = '00001' and 'PCKG_NO' to '0000000001'. This can be done by declaring different variables for those fields and then initializing the values like:
While populating the table 'REQUISITION_SERVICES' we will have to take a look on under given logic.
Each line item of the PR will link with a logical header in 'REQUISITION_SERVICES', which we can not see but until and unless we will provide the proper header there will not be any creation of a single SERVICE line item.
This can be done as:
* To Populate the header data for Requisition Services. Every unique PR line item
* should have different header data which internally links to multiple service line
call function 'CONVERSION_EXIT_CUNIT_INPUT'
input = i_in2-unit
language = sy-langu
output = i_in2-unit.
requisition_services-base_uom = i_in2-unit.
v_packno = v_packno + requisition_services-pckg_no.
"(Above line is very important, else there will be improper output)
After doing all the above work properly we need to populate the table 'REQUISITION_SRV_ACCASS_VALUES' which acts as a Value/Link to Service Account Assignment.
* Populate the requisition service access value table.
requisition_srv_accass_values-pckg_no = requisition_services-pckg_no.
requisition_srv_accass_values-line_no = requisition_services-line_no.
requisition_srv_accass_values-serno_line = requisition_account_assignment-serial_no.
requisition_srv_accass_values-serial_no = requisition_srv_accass_values-serno_line.
requisition_srv_accass_values-percentage = '100'.
If we have the requirement to populate long text for each service line item, we can do it as:
* Populate the service long text.
requisition_services_text-pckg_no = requisition_services-pckg_no.
requisition_services_text-line_no = requisition_srv_accass_values-line_no.
requisition_services_text-text_id = 'LLTX'.
requisition_services_text-format_col = '*'.
"(This is done if the long text is more than 132 chars, as the BAPI has limitation of 132 chars.)
call function 'CONVERT_STRING_TO_TABLE'
i_string = i_in2-ser_ltext
i_tabline_length = 132
et_table = it_outlines.
"Now all the required tables are populated properly, we just need to call the BAPI.
at end of preqitem.
at end of preqno.
call function 'BAPI_REQUISITION_CREATE'
number = prno
requisition_items = requisition_items
requisition_account_assignment = requisition_account_assignment
requisition_services = requisition_services
requisition_srv_accass_values = requisition_srv_accass_values
requisition_services_text = requisition_services_text
return = i_return.
read table i_return with key type = 'E'.
if sy-subrc <> 0 .
*Function called for commit
call function 'BAPI_TRANSACTION_COMMIT'
wait = 'X'.
call function 'BAPI_TRANSACTION_ROLLBACK'.
We can cross check the created PR by TCODE: ME53N.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.