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:
Field 'DISTRIB' needs to be populated in case of Multiple account assignment along with 'PART_INV'. For more details check the data element documentation for both.
After that populate the table 'REQUISITION_ACCOUNT_ASSIGNMENT'. In this table two fields needs to be populated carefully, they are 'SERIAL_NO' & 'PREQ_ITEM'. This can be done as:
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
* item.
call function 'CONVERSION_EXIT_CUNIT_INPUT'
exporting
input = i_in2-unit
language = sy-langu
importing
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)
append requisition_services.
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.
Code:
* 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'.
append requisition_srv_accass_values.
If we have the requirement to populate long text for each service line item, we can do it as:
Code:
* 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'
exporting
i_string = i_in2-ser_ltext
i_tabline_length = 132
tables
et_table = it_outlines.
"Now all the required tables are populated properly, we just need to call the BAPI.
Code:
at end of preqitem.
at end of preqno.
call function 'BAPI_REQUISITION_CREATE'
importing
number = prno
tables
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'
exporting
wait = 'X'.
else.
call function 'BAPI_TRANSACTION_ROLLBACK'.
endif.
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.